Fix some dark mode colors. (#3596)
* Pick a link color that looks good in both light and dark mode * Fix up chat log colors
This commit is contained in:
parent
63839eb464
commit
a7f19f7848
4 changed files with 39 additions and 19 deletions
|
@ -13,8 +13,6 @@
|
|||
#include <QTextEdit>
|
||||
|
||||
const QColor DEFAULT_MENTION_COLOR = QColor(194, 31, 47);
|
||||
const QColor OTHER_USER_COLOR = QColor(0, 65, 255); // dark blue
|
||||
const QString SERVER_MESSAGE_COLOR = "#851515";
|
||||
|
||||
ChatView::ChatView(const TabSupervisor *_tabSupervisor,
|
||||
const UserlistProxy *_userlistProxy,
|
||||
|
@ -24,7 +22,20 @@ ChatView::ChatView(const TabSupervisor *_tabSupervisor,
|
|||
: QTextBrowser(parent), tabSupervisor(_tabSupervisor), game(_game), userlistProxy(_userlistProxy), evenNumber(true),
|
||||
showTimestamps(_showTimestamps), hoveredItemType(HoveredNothing)
|
||||
{
|
||||
document()->setDefaultStyleSheet("a { text-decoration: none; color: blue; }");
|
||||
if (palette().windowText().color().lightness() > 200) {
|
||||
document()->setDefaultStyleSheet(R"(
|
||||
a { text-decoration: none; color: rgb(71,158,252); }
|
||||
.blue { color: rgb(71,158,252); }
|
||||
)");
|
||||
serverMessageColor = QColor(0xFF, 0x73, 0x83);
|
||||
otherUserColor = otherUserColor.lighter(150);
|
||||
} else {
|
||||
document()->setDefaultStyleSheet(R"(
|
||||
a { text-decoration: none; color: blue; }
|
||||
.blue { color: blue }
|
||||
)");
|
||||
}
|
||||
|
||||
userContextMenu = new UserContextMenu(tabSupervisor, this, game);
|
||||
connect(userContextMenu, SIGNAL(openMessageDialog(QString, bool)), this, SIGNAL(openMessageDialog(QString, bool)));
|
||||
|
||||
|
@ -84,8 +95,9 @@ void ChatView::appendHtmlServerMessage(const QString &html, bool optionalIsBold,
|
|||
{
|
||||
bool atBottom = verticalScrollBar()->value() >= verticalScrollBar()->maximum();
|
||||
|
||||
QString htmlText = "<font color=" + ((optionalFontColor.size() > 0) ? optionalFontColor : SERVER_MESSAGE_COLOR) +
|
||||
">" + QDateTime::currentDateTime().toString("[hh:mm:ss] ") + html + "</font>";
|
||||
QString htmlText =
|
||||
"<font color=" + ((optionalFontColor.size() > 0) ? optionalFontColor : serverMessageColor.name()) + ">" +
|
||||
QDateTime::currentDateTime().toString("[hh:mm:ss] ") + html + "</font>";
|
||||
|
||||
if (optionalIsBold)
|
||||
htmlText = "<b>" + htmlText + "</b>";
|
||||
|
@ -142,7 +154,7 @@ void ChatView::appendMessage(QString message,
|
|||
// timestamp
|
||||
if (showTimestamps && (!sameSender || sender.toLower() == "servatrice") && !sender.isEmpty()) {
|
||||
QTextCharFormat timeFormat;
|
||||
timeFormat.setForeground(QColor(SERVER_MESSAGE_COLOR));
|
||||
timeFormat.setForeground(serverMessageColor);
|
||||
if (sender.isEmpty())
|
||||
timeFormat.setFontWeight(QFont::Bold);
|
||||
cursor.setCharFormat(timeFormat);
|
||||
|
@ -156,7 +168,7 @@ void ChatView::appendMessage(QString message,
|
|||
senderFormat.setForeground(QBrush(getCustomMentionColor()));
|
||||
senderFormat.setFontWeight(QFont::Bold);
|
||||
} else {
|
||||
senderFormat.setForeground(QBrush(OTHER_USER_COLOR));
|
||||
senderFormat.setForeground(QBrush(otherUserColor));
|
||||
if (playerBold)
|
||||
senderFormat.setFontWeight(QFont::Bold);
|
||||
}
|
||||
|
|
|
@ -59,6 +59,10 @@ private:
|
|||
void checkMention(QTextCursor &cursor, QString &message, QString &sender, UserLevelFlags userLevel);
|
||||
void checkWord(QTextCursor &cursor, QString &message);
|
||||
QString extractNextWord(QString &message, QString &rest);
|
||||
|
||||
QColor otherUserColor = QColor(0, 65, 255); // dark blue
|
||||
QColor serverMessageColor = QColor(0x85, 0x15, 0x15);
|
||||
|
||||
private slots:
|
||||
void openLink(const QUrl &link);
|
||||
void actMessageClicked();
|
||||
|
|
|
@ -263,7 +263,7 @@ void MessageLogWidget::logDeckSelect(Player *player, QString deckHash, int sideb
|
|||
else
|
||||
appendHtmlServerMessage(tr("%1 has loaded a deck with %2 sideboard cards (%3).")
|
||||
.arg(sanitizeHtml(player->getName()))
|
||||
.arg("<font color=\"blue\">" + QString::number(sideboardSize) + "</font>")
|
||||
.arg("<font class=\"blue\">" + QString::number(sideboardSize) + "</font>")
|
||||
.arg(deckHash));
|
||||
}
|
||||
|
||||
|
@ -357,7 +357,7 @@ void MessageLogWidget::logDrawCards(Player *player, int number)
|
|||
soundEngine->playSound("draw_card");
|
||||
appendHtmlServerMessage(tr("%1 draws %2 card(s).", "", number)
|
||||
.arg(sanitizeHtml(player->getName()))
|
||||
.arg("<font color=\"blue\">" + QString::number(number) + "</font>"));
|
||||
.arg("<font class=\"blue\">" + QString::number(number) + "</font>"));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -372,7 +372,7 @@ void MessageLogWidget::logDumpZone(Player *player, CardZone *zone, int numberCar
|
|||
tr("%1 is looking at the top %3 card(s) %2.", "top card for singular, top %3 cards for plural", numberCards)
|
||||
.arg(sanitizeHtml(player->getName()))
|
||||
.arg(zone->getTranslatedName(zone->getPlayer() == player, CaseTopCardsOfZone))
|
||||
.arg("<font color=\"blue\">" + QString::number(numberCards) + "</font>"));
|
||||
.arg("<font class=\"blue\">" + QString::number(numberCards) + "</font>"));
|
||||
}
|
||||
|
||||
void MessageLogWidget::logFlipCard(Player *player, QString cardName, bool faceDown)
|
||||
|
@ -491,7 +491,7 @@ void MessageLogWidget::logRevealCards(Player *player,
|
|||
cardStr = tr("cards", "an unknown amount of cards");
|
||||
} else {
|
||||
cardStr = tr("%1 card(s)", "a card for singular, %1 cards for plural", amount)
|
||||
.arg("<font color=\"blue\">" + QString::number(amount) + "</font>");
|
||||
.arg("<font class=\"blue\">" + QString::number(amount) + "</font>");
|
||||
}
|
||||
} else {
|
||||
cardStr = cardLink(cardName);
|
||||
|
@ -548,12 +548,12 @@ void MessageLogWidget::logRollDie(Player *player, int sides, int roll)
|
|||
QString coinOptions[2] = {tr("Heads") + " (1)", tr("Tails") + " (2)"};
|
||||
appendHtmlServerMessage(tr("%1 flipped a coin. It landed as %2.")
|
||||
.arg(sanitizeHtml(player->getName()))
|
||||
.arg("<font color=\"blue\">" + coinOptions[roll - 1] + "</font>"));
|
||||
.arg("<font class=\"blue\">" + coinOptions[roll - 1] + "</font>"));
|
||||
} else
|
||||
appendHtmlServerMessage(tr("%1 rolls a %2 with a %3-sided die.")
|
||||
.arg(sanitizeHtml(player->getName()))
|
||||
.arg("<font color=\"blue\">" + QString::number(roll) + "</font>")
|
||||
.arg("<font color=\"blue\">" + QString::number(sides) + "</font>"));
|
||||
.arg("<font class=\"blue\">" + QString::number(roll) + "</font>")
|
||||
.arg("<font class=\"blue\">" + QString::number(sides) + "</font>"));
|
||||
soundEngine->playSound("roll_dice");
|
||||
}
|
||||
|
||||
|
@ -644,7 +644,7 @@ void MessageLogWidget::logSetAnnotation(Player *player, CardItem *card, QString
|
|||
QString(tr("%1 sets annotation of %2 to %3."))
|
||||
.arg(sanitizeHtml(player->getName()))
|
||||
.arg(cardLink(card->getName()))
|
||||
.arg(QString(""<font color=\"blue\">%1</font>"").arg(sanitizeHtml(std::move(newAnnotation)))));
|
||||
.arg(QString(""<font class=\"blue\">%1</font>"").arg(sanitizeHtml(std::move(newAnnotation)))));
|
||||
}
|
||||
|
||||
void MessageLogWidget::logSetCardCounter(Player *player, QString cardName, int counterId, int value, int oldValue)
|
||||
|
@ -671,7 +671,7 @@ void MessageLogWidget::logSetCardCounter(Player *player, QString cardName, int c
|
|||
}
|
||||
|
||||
appendHtmlServerMessage(finalStr.arg(sanitizeHtml(player->getName()))
|
||||
.arg("<font color=\"blue\">" + QString::number(delta) + "</font>")
|
||||
.arg("<font class=\"blue\">" + QString::number(delta) + "</font>")
|
||||
.arg(colorStr)
|
||||
.arg(cardLink(std::move(cardName)))
|
||||
.arg(value));
|
||||
|
@ -684,8 +684,8 @@ void MessageLogWidget::logSetCounter(Player *player, QString counterName, int va
|
|||
|
||||
appendHtmlServerMessage(tr("%1 sets counter %2 to %3 (%4%5).")
|
||||
.arg(sanitizeHtml(player->getName()))
|
||||
.arg(QString("<font color=\"blue\">%1</font>").arg(sanitizeHtml(counterName)))
|
||||
.arg(QString("<font color=\"blue\">%1</font>").arg(value))
|
||||
.arg(QString("<font class=\"blue\">%1</font>").arg(sanitizeHtml(counterName)))
|
||||
.arg(QString("<font class=\"blue\">%1</font>").arg(value))
|
||||
.arg(value > oldValue ? "+" : "")
|
||||
.arg(value - oldValue));
|
||||
}
|
||||
|
@ -708,7 +708,7 @@ void MessageLogWidget::logSetPT(Player *player, CardItem *card, QString newPT)
|
|||
|
||||
QString name = card->getName();
|
||||
if (name.isEmpty()) {
|
||||
name = QString("<font color=\"blue\">card #%1</font>").arg(sanitizeHtml(QString::number(card->getId())));
|
||||
name = QString("<font class=\"blue\">card #%1</font>").arg(sanitizeHtml(QString::number(card->getId())));
|
||||
} else {
|
||||
name = cardLink(name);
|
||||
}
|
||||
|
|
|
@ -1244,6 +1244,10 @@ void TabDeckEditor::showSearchSyntaxHelp()
|
|||
browser->setWindowTitle("Search Help");
|
||||
browser->setReadOnly(true);
|
||||
browser->setMinimumSize({500, 600});
|
||||
|
||||
QString sheet = QString("a { text-decoration: underline; color: rgb(71,158,252) };");
|
||||
browser->document()->setDefaultStyleSheet(sheet);
|
||||
|
||||
browser->setHtml(text);
|
||||
connect(browser, &QTextBrowser::anchorClicked, [=](QUrl link) { searchEdit->setText(link.fragment()); });
|
||||
browser->show();
|
||||
|
|
Loading…
Reference in a new issue