mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-04-27 07:48:01 -07:00
Chat mention color
+Chat mention / username color can now be set via hex in the settings + Users can invert the color of the mention text black/white + if an invalid color is provided, the default will be used
This commit is contained in:
parent
a31c15c752
commit
ec8a2de2eb
5 changed files with 43 additions and 5 deletions
|
|
@ -12,7 +12,7 @@
|
|||
#include "main.h"
|
||||
#include "tab_userlists.h"
|
||||
|
||||
const QColor MENTION_COLOR = QColor(190, 25, 85); // maroon
|
||||
const QColor DEFAULT_MENTION_COLOR = QColor(194, 31, 47);
|
||||
const QColor OTHER_USER_COLOR = QColor(0, 65, 255); // dark blue
|
||||
|
||||
ChatView::ChatView(const TabSupervisor *_tabSupervisor, TabGame *_game, bool _showTimestamps, QWidget *parent)
|
||||
|
|
@ -26,8 +26,6 @@ ChatView::ChatView(const TabSupervisor *_tabSupervisor, TabGame *_game, bool _sh
|
|||
mention = "@" + userName.toLower();
|
||||
|
||||
mentionFormat.setFontWeight(QFont::Bold);
|
||||
mentionFormat.setForeground(QBrush(Qt::white));
|
||||
mentionFormat.setBackground(QBrush(MENTION_COLOR));
|
||||
|
||||
mentionFormatOtherUser.setFontWeight(QFont::Bold);
|
||||
mentionFormatOtherUser.setForeground(Qt::blue);
|
||||
|
|
@ -118,8 +116,10 @@ void ChatView::appendMessage(QString message, QString sender, UserLevelFlags use
|
|||
|
||||
QTextCharFormat senderFormat;
|
||||
if (tabSupervisor && tabSupervisor->getUserInfo() && (sender == QString::fromStdString(tabSupervisor->getUserInfo()->name()))) {
|
||||
QColor customColor;
|
||||
customColor.setNamedColor("#" + settingsCache->getChatMentionColor());
|
||||
senderFormat.setForeground(customColor.isValid() ? QBrush(customColor) : QBrush(DEFAULT_MENTION_COLOR));
|
||||
senderFormat.setFontWeight(QFont::Bold);
|
||||
senderFormat.setForeground(QBrush(MENTION_COLOR));
|
||||
} else {
|
||||
senderFormat.setForeground(QBrush(OTHER_USER_COLOR));
|
||||
if (playerBold)
|
||||
|
|
@ -195,6 +195,10 @@ void ChatView::appendMessage(QString message, QString sender, UserLevelFlags use
|
|||
break;
|
||||
// you have been mentioned
|
||||
if (message.toLower().startsWith(mention)) {
|
||||
QColor customColor;
|
||||
customColor.setNamedColor("#" + settingsCache->getChatMentionColor());
|
||||
mentionFormat.setBackground(customColor.isValid() ? QBrush(customColor) : QBrush(DEFAULT_MENTION_COLOR));
|
||||
mentionFormat.setForeground(settingsCache->getChatMentionForeground() ? QBrush(Qt::white):QBrush(Qt::black));
|
||||
cursor.insertText("@" + userName, mentionFormat);
|
||||
message = message.mid(mention.size());
|
||||
QApplication::alert(this);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue