From cd6ab95ed849564a0aa8fceea3ae712355de37a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lukas=20Br=C3=BCbach?= Date: Sat, 8 Aug 2026 20:47:22 +0200 Subject: [PATCH] Highlight not found but attempted tag Took 6 minutes --- .../widgets/server/chat_view/chat_view.cpp | 20 ++++++++++++------- .../widgets/server/chat_view/chat_view.h | 1 + 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/cockatrice/src/interface/widgets/server/chat_view/chat_view.cpp b/cockatrice/src/interface/widgets/server/chat_view/chat_view.cpp index 7e5f6e277..72cb9a568 100644 --- a/cockatrice/src/interface/widgets/server/chat_view/chat_view.cpp +++ b/cockatrice/src/interface/widgets/server/chat_view/chat_view.cpp @@ -63,12 +63,14 @@ void ChatView::adjustColorsToPalette() serverMessageColor = QColor(0xFF, 0x73, 0x83); otherUserColor = otherUserColor.lighter(150); linkColor = QColor(71, 158, 252); + unresolvedCardTagColor = QColor(0xFF, 0x73, 0x83); } else { document()->setDefaultStyleSheet(R"( a { text-decoration: none; color: blue; } .blue { color: blue } )"); linkColor = palette().link().color(); + unresolvedCardTagColor = QColor(0x85, 0x15, 0x15); } QTimer::singleShot(0, this, &ChatView::refreshBlockColors); @@ -173,19 +175,23 @@ void ChatView::appendHtmlServerMessage(const QString &html, bool optionalIsBold, void ChatView::appendCardTag(QTextCursor &cursor, const QString &cardName) { + QTextCharFormat oldFormat = cursor.charFormat(); + QTextCharFormat cardFormat = oldFormat; + cardFormat.setFontItalic(true); + if (!CardDatabaseManager::query()->lookupCardByName(cardName)) { + cardFormat.setForeground(unresolvedCardTagColor); + cursor.setCharFormat(cardFormat); cursor.insertText(cardName); + cursor.setCharFormat(oldFormat); return; } - QTextCharFormat oldFormat = cursor.charFormat(); - QTextCharFormat anchorFormat = oldFormat; - anchorFormat.setForeground(linkColor); - anchorFormat.setAnchor(true); - anchorFormat.setAnchorHref("card://" + cardName); - anchorFormat.setFontItalic(true); + cardFormat.setForeground(linkColor); + cardFormat.setAnchor(true); + cardFormat.setAnchorHref("card://" + cardName); - cursor.setCharFormat(anchorFormat); + cursor.setCharFormat(cardFormat); cursor.insertText(cardName); cursor.setCharFormat(oldFormat); } diff --git a/cockatrice/src/interface/widgets/server/chat_view/chat_view.h b/cockatrice/src/interface/widgets/server/chat_view/chat_view.h index 506605d24..8d5894613 100644 --- a/cockatrice/src/interface/widgets/server/chat_view/chat_view.h +++ b/cockatrice/src/interface/widgets/server/chat_view/chat_view.h @@ -81,6 +81,7 @@ private: QColor otherUserColor = QColor(0, 65, 255); // dark blue QColor serverMessageColor = QColor(0x85, 0x15, 0x15); QColor linkColor; + QColor unresolvedCardTagColor; private slots: void openLink(const QUrl &link);