commit
72d1b211c4
6 changed files with 69 additions and 6 deletions
|
@ -12,7 +12,7 @@
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
#include "tab_userlists.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
|
const QColor OTHER_USER_COLOR = QColor(0, 65, 255); // dark blue
|
||||||
|
|
||||||
ChatView::ChatView(const TabSupervisor *_tabSupervisor, TabGame *_game, bool _showTimestamps, QWidget *parent)
|
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();
|
mention = "@" + userName.toLower();
|
||||||
|
|
||||||
mentionFormat.setFontWeight(QFont::Bold);
|
mentionFormat.setFontWeight(QFont::Bold);
|
||||||
mentionFormat.setForeground(QBrush(Qt::white));
|
|
||||||
mentionFormat.setBackground(QBrush(MENTION_COLOR));
|
|
||||||
|
|
||||||
mentionFormatOtherUser.setFontWeight(QFont::Bold);
|
mentionFormatOtherUser.setFontWeight(QFont::Bold);
|
||||||
mentionFormatOtherUser.setForeground(Qt::blue);
|
mentionFormatOtherUser.setForeground(Qt::blue);
|
||||||
|
@ -118,8 +116,8 @@ void ChatView::appendMessage(QString message, QString sender, UserLevelFlags use
|
||||||
|
|
||||||
QTextCharFormat senderFormat;
|
QTextCharFormat senderFormat;
|
||||||
if (tabSupervisor && tabSupervisor->getUserInfo() && (sender == QString::fromStdString(tabSupervisor->getUserInfo()->name()))) {
|
if (tabSupervisor && tabSupervisor->getUserInfo() && (sender == QString::fromStdString(tabSupervisor->getUserInfo()->name()))) {
|
||||||
|
senderFormat.setForeground(QBrush(getCustomMentionColor()));
|
||||||
senderFormat.setFontWeight(QFont::Bold);
|
senderFormat.setFontWeight(QFont::Bold);
|
||||||
senderFormat.setForeground(QBrush(MENTION_COLOR));
|
|
||||||
} else {
|
} else {
|
||||||
senderFormat.setForeground(QBrush(OTHER_USER_COLOR));
|
senderFormat.setForeground(QBrush(OTHER_USER_COLOR));
|
||||||
if (playerBold)
|
if (playerBold)
|
||||||
|
@ -195,6 +193,8 @@ void ChatView::appendMessage(QString message, QString sender, UserLevelFlags use
|
||||||
break;
|
break;
|
||||||
// you have been mentioned
|
// you have been mentioned
|
||||||
if (message.toLower().startsWith(mention)) {
|
if (message.toLower().startsWith(mention)) {
|
||||||
|
mentionFormat.setBackground(QBrush(getCustomMentionColor()));
|
||||||
|
mentionFormat.setForeground(settingsCache->getChatMentionForeground() ? QBrush(Qt::white):QBrush(Qt::black));
|
||||||
cursor.insertText("@" + userName, mentionFormat);
|
cursor.insertText("@" + userName, mentionFormat);
|
||||||
message = message.mid(mention.size());
|
message = message.mid(mention.size());
|
||||||
QApplication::alert(this);
|
QApplication::alert(this);
|
||||||
|
@ -227,6 +227,12 @@ void ChatView::appendMessage(QString message, QString sender, UserLevelFlags use
|
||||||
verticalScrollBar()->setValue(verticalScrollBar()->maximum());
|
verticalScrollBar()->setValue(verticalScrollBar()->maximum());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QColor ChatView::getCustomMentionColor() {
|
||||||
|
QColor customColor;
|
||||||
|
customColor.setNamedColor("#" + settingsCache->getChatMentionColor());
|
||||||
|
return customColor.isValid() ? customColor : DEFAULT_MENTION_COLOR;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Returns the correct case version of the provided username, if no correct casing version
|
Returns the correct case version of the provided username, if no correct casing version
|
||||||
was found then the provided name is not available and will return an empty QString.
|
was found then the provided name is not available and will return an empty QString.
|
||||||
|
|
|
@ -37,6 +37,7 @@ private:
|
||||||
void appendCardTag(QTextCursor &cursor, const QString &cardName);
|
void appendCardTag(QTextCursor &cursor, const QString &cardName);
|
||||||
void appendUrlTag(QTextCursor &cursor, QString url);
|
void appendUrlTag(QTextCursor &cursor, QString url);
|
||||||
QString getNameFromUserList(QMap<QString, UserListTWI *> &userList, QString &userName);
|
QString getNameFromUserList(QMap<QString, UserListTWI *> &userList, QString &userName);
|
||||||
|
QColor getCustomMentionColor();
|
||||||
private slots:
|
private slots:
|
||||||
void openLink(const QUrl &link);
|
void openLink(const QUrl &link);
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -566,7 +566,6 @@ void DeckEditorSettingsPage::radioPriceTagSourceClicked(bool checked)
|
||||||
|
|
||||||
MessagesSettingsPage::MessagesSettingsPage()
|
MessagesSettingsPage::MessagesSettingsPage()
|
||||||
{
|
{
|
||||||
|
|
||||||
chatMentionCheckBox.setChecked(settingsCache->getChatMention());
|
chatMentionCheckBox.setChecked(settingsCache->getChatMention());
|
||||||
connect(&chatMentionCheckBox, SIGNAL(stateChanged(int)), settingsCache, SLOT(setChatMention(int)));
|
connect(&chatMentionCheckBox, SIGNAL(stateChanged(int)), settingsCache, SLOT(setChatMention(int)));
|
||||||
|
|
||||||
|
@ -575,9 +574,20 @@ MessagesSettingsPage::MessagesSettingsPage()
|
||||||
connect(&ignoreUnregUsersMainChat, SIGNAL(stateChanged(int)), settingsCache, SLOT(setIgnoreUnregisteredUsers(int)));
|
connect(&ignoreUnregUsersMainChat, SIGNAL(stateChanged(int)), settingsCache, SLOT(setIgnoreUnregisteredUsers(int)));
|
||||||
connect(&ignoreUnregUserMessages, SIGNAL(stateChanged(int)), settingsCache, SLOT(setIgnoreUnregisteredUserMessages(int)));
|
connect(&ignoreUnregUserMessages, SIGNAL(stateChanged(int)), settingsCache, SLOT(setIgnoreUnregisteredUserMessages(int)));
|
||||||
|
|
||||||
|
invertMentionForeground.setChecked(settingsCache->getChatMentionForeground());
|
||||||
|
connect(&invertMentionForeground, SIGNAL(stateChanged(int)), this, SLOT(updateTextColor(int)));
|
||||||
|
|
||||||
|
mentionColor = new QLineEdit();
|
||||||
|
mentionColor->setText(settingsCache->getChatMentionColor());
|
||||||
|
updateMentionPreview();
|
||||||
|
connect(mentionColor, SIGNAL(textChanged(QString)), this, SLOT(updateColor(QString)));
|
||||||
|
|
||||||
QGridLayout *chatGrid = new QGridLayout;
|
QGridLayout *chatGrid = new QGridLayout;
|
||||||
chatGrid->addWidget(&chatMentionCheckBox, 0, 0);
|
chatGrid->addWidget(&chatMentionCheckBox, 0, 0);
|
||||||
|
chatGrid->addWidget(&invertMentionForeground, 0, 1);
|
||||||
|
chatGrid->addWidget(mentionColor, 0, 2);
|
||||||
chatGrid->addWidget(&ignoreUnregUsersMainChat, 1, 0);
|
chatGrid->addWidget(&ignoreUnregUsersMainChat, 1, 0);
|
||||||
|
chatGrid->addWidget(&hexLabel, 1, 2);
|
||||||
chatGrid->addWidget(&ignoreUnregUserMessages, 2, 0);
|
chatGrid->addWidget(&ignoreUnregUserMessages, 2, 0);
|
||||||
chatGroupBox = new QGroupBox;
|
chatGroupBox = new QGroupBox;
|
||||||
chatGroupBox->setLayout(chatGrid);
|
chatGroupBox->setLayout(chatGrid);
|
||||||
|
@ -616,6 +626,25 @@ MessagesSettingsPage::MessagesSettingsPage()
|
||||||
retranslateUi();
|
retranslateUi();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MessagesSettingsPage::updateColor(const QString &value) {
|
||||||
|
QColor colorToSet;
|
||||||
|
colorToSet.setNamedColor("#" + value);
|
||||||
|
if (colorToSet.isValid()) {
|
||||||
|
settingsCache->setChatMentionColor(value);
|
||||||
|
updateMentionPreview();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void MessagesSettingsPage::updateTextColor(int value) {
|
||||||
|
settingsCache->setChatMentionForeground(value);
|
||||||
|
updateMentionPreview();
|
||||||
|
}
|
||||||
|
|
||||||
|
void MessagesSettingsPage::updateMentionPreview() {
|
||||||
|
mentionColor->setStyleSheet("QLineEdit{background:#" + settingsCache->getChatMentionColor() +
|
||||||
|
";color: " + (settingsCache->getChatMentionForeground() ? "white" : "black") + ";}");
|
||||||
|
}
|
||||||
|
|
||||||
void MessagesSettingsPage::storeSettings()
|
void MessagesSettingsPage::storeSettings()
|
||||||
{
|
{
|
||||||
QSettings settings;
|
QSettings settings;
|
||||||
|
@ -648,10 +677,13 @@ void MessagesSettingsPage::retranslateUi()
|
||||||
aAdd->setText(tr("&Add"));
|
aAdd->setText(tr("&Add"));
|
||||||
aRemove->setText(tr("&Remove"));
|
aRemove->setText(tr("&Remove"));
|
||||||
chatGroupBox->setTitle(tr("Chat settings"));
|
chatGroupBox->setTitle(tr("Chat settings"));
|
||||||
chatMentionCheckBox.setText(tr("Enable chat mentions ('@yourusername' in chat log will be highlighted)"));
|
chatMentionCheckBox.setText(tr("Enable chat mentions"));
|
||||||
messageShortcuts->setTitle(tr("In-game message macros"));
|
messageShortcuts->setTitle(tr("In-game message macros"));
|
||||||
|
ignoreUnregUsersMainChat.setText(tr("Ignore unregistered users in main chat"));
|
||||||
ignoreUnregUsersMainChat.setText(tr("Ignore chat room messages sent by unregistered users."));
|
ignoreUnregUsersMainChat.setText(tr("Ignore chat room messages sent by unregistered users."));
|
||||||
ignoreUnregUserMessages.setText(tr("Ignore private messages sent by unregistered users."));
|
ignoreUnregUserMessages.setText(tr("Ignore private messages sent by unregistered users."));
|
||||||
|
invertMentionForeground.setText(tr("Invert text color"));
|
||||||
|
hexLabel.setText(tr("(Color is hexadecimal)"));
|
||||||
}
|
}
|
||||||
|
|
||||||
DlgSettings::DlgSettings(QWidget *parent)
|
DlgSettings::DlgSettings(QWidget *parent)
|
||||||
|
|
|
@ -156,17 +156,23 @@ public:
|
||||||
private slots:
|
private slots:
|
||||||
void actAdd();
|
void actAdd();
|
||||||
void actRemove();
|
void actRemove();
|
||||||
|
void updateColor(const QString &value);
|
||||||
|
void updateTextColor(int value);
|
||||||
private:
|
private:
|
||||||
QListWidget *messageList;
|
QListWidget *messageList;
|
||||||
QAction *aAdd;
|
QAction *aAdd;
|
||||||
QAction *aRemove;
|
QAction *aRemove;
|
||||||
QCheckBox chatMentionCheckBox;
|
QCheckBox chatMentionCheckBox;
|
||||||
|
QCheckBox invertMentionForeground;
|
||||||
QCheckBox ignoreUnregUsersMainChat;
|
QCheckBox ignoreUnregUsersMainChat;
|
||||||
QCheckBox ignoreUnregUserMessages;
|
QCheckBox ignoreUnregUserMessages;
|
||||||
QGroupBox *chatGroupBox;
|
QGroupBox *chatGroupBox;
|
||||||
QGroupBox *messageShortcuts;
|
QGroupBox *messageShortcuts;
|
||||||
|
QLineEdit *mentionColor;
|
||||||
|
QLabel hexLabel;
|
||||||
|
|
||||||
void storeSettings();
|
void storeSettings();
|
||||||
|
void updateMentionPreview();
|
||||||
};
|
};
|
||||||
|
|
||||||
class DlgSettings : public QDialog {
|
class DlgSettings : public QDialog {
|
||||||
|
|
|
@ -45,6 +45,8 @@ SettingsCache::SettingsCache()
|
||||||
minPlayersForMultiColumnLayout = settings->value("interface/min_players_multicolumn", 5).toInt();
|
minPlayersForMultiColumnLayout = settings->value("interface/min_players_multicolumn", 5).toInt();
|
||||||
tapAnimation = settings->value("cards/tapanimation", true).toBool();
|
tapAnimation = settings->value("cards/tapanimation", true).toBool();
|
||||||
chatMention = settings->value("chat/mention", true).toBool();
|
chatMention = settings->value("chat/mention", true).toBool();
|
||||||
|
chatMentionForeground = settings->value("chat/mentionforeground", true).toBool();
|
||||||
|
chatMentionColor = settings->value("chat/mentioncolor", "C21F2F").toString();
|
||||||
|
|
||||||
zoneViewSortByName = settings->value("zoneview/sortbyname", true).toBool();
|
zoneViewSortByName = settings->value("zoneview/sortbyname", true).toBool();
|
||||||
zoneViewSortByType = settings->value("zoneview/sortbytype", true).toBool();
|
zoneViewSortByType = settings->value("zoneview/sortbytype", true).toBool();
|
||||||
|
@ -244,6 +246,16 @@ void SettingsCache::setChatMention(int _chatMention) {
|
||||||
settings->setValue("chat/mention", chatMention);
|
settings->setValue("chat/mention", chatMention);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SettingsCache::setChatMentionForeground(int _chatMentionForeground) {
|
||||||
|
chatMentionForeground = _chatMentionForeground;
|
||||||
|
settings->setValue("chat/mentionforeground", chatMentionForeground);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SettingsCache::setChatMentionColor(const QString &_chatMentionColor) {
|
||||||
|
chatMentionColor = _chatMentionColor;
|
||||||
|
settings->setValue("chat/mentioncolor", chatMentionColor);
|
||||||
|
}
|
||||||
|
|
||||||
void SettingsCache::setZoneViewSortByName(int _zoneViewSortByName)
|
void SettingsCache::setZoneViewSortByName(int _zoneViewSortByName)
|
||||||
{
|
{
|
||||||
zoneViewSortByName = _zoneViewSortByName;
|
zoneViewSortByName = _zoneViewSortByName;
|
||||||
|
|
|
@ -58,6 +58,8 @@ private:
|
||||||
int minPlayersForMultiColumnLayout;
|
int minPlayersForMultiColumnLayout;
|
||||||
bool tapAnimation;
|
bool tapAnimation;
|
||||||
bool chatMention;
|
bool chatMention;
|
||||||
|
QString chatMentionColor;
|
||||||
|
bool chatMentionForeground;
|
||||||
bool zoneViewSortByName, zoneViewSortByType, zoneViewPileView;
|
bool zoneViewSortByName, zoneViewSortByType, zoneViewPileView;
|
||||||
bool soundEnabled;
|
bool soundEnabled;
|
||||||
QString soundPath;
|
QString soundPath;
|
||||||
|
@ -85,6 +87,7 @@ public:
|
||||||
QString getTableBgPath() const { return tableBgPath; }
|
QString getTableBgPath() const { return tableBgPath; }
|
||||||
QString getPlayerBgPath() const { return playerBgPath; }
|
QString getPlayerBgPath() const { return playerBgPath; }
|
||||||
QString getCardBackPicturePath() const { return cardBackPicturePath; }
|
QString getCardBackPicturePath() const { return cardBackPicturePath; }
|
||||||
|
QString getChatMentionColor() const { return chatMentionColor; }
|
||||||
bool getPicDownload() const { return picDownload; }
|
bool getPicDownload() const { return picDownload; }
|
||||||
bool getPicDownloadHq() const { return picDownloadHq; }
|
bool getPicDownloadHq() const { return picDownloadHq; }
|
||||||
bool getNotificationsEnabled() const { return notificationsEnabled; }
|
bool getNotificationsEnabled() const { return notificationsEnabled; }
|
||||||
|
@ -98,6 +101,7 @@ public:
|
||||||
int getMinPlayersForMultiColumnLayout() const { return minPlayersForMultiColumnLayout; }
|
int getMinPlayersForMultiColumnLayout() const { return minPlayersForMultiColumnLayout; }
|
||||||
bool getTapAnimation() const { return tapAnimation; }
|
bool getTapAnimation() const { return tapAnimation; }
|
||||||
bool getChatMention() const { return chatMention; }
|
bool getChatMention() const { return chatMention; }
|
||||||
|
bool getChatMentionForeground() const { return chatMentionForeground; }
|
||||||
bool getZoneViewSortByName() const { return zoneViewSortByName; }
|
bool getZoneViewSortByName() const { return zoneViewSortByName; }
|
||||||
bool getZoneViewSortByType() const { return zoneViewSortByType; }
|
bool getZoneViewSortByType() const { return zoneViewSortByType; }
|
||||||
/**
|
/**
|
||||||
|
@ -131,6 +135,7 @@ public slots:
|
||||||
void setTableBgPath(const QString &_tableBgPath);
|
void setTableBgPath(const QString &_tableBgPath);
|
||||||
void setPlayerBgPath(const QString &_playerBgPath);
|
void setPlayerBgPath(const QString &_playerBgPath);
|
||||||
void setCardBackPicturePath(const QString &_cardBackPicturePath);
|
void setCardBackPicturePath(const QString &_cardBackPicturePath);
|
||||||
|
void setChatMentionColor(const QString &_chatMentionColor);
|
||||||
void setPicDownload(int _picDownload);
|
void setPicDownload(int _picDownload);
|
||||||
void setPicDownloadHq(int _picDownloadHq);
|
void setPicDownloadHq(int _picDownloadHq);
|
||||||
void setNotificationsEnabled(int _notificationsEnabled);
|
void setNotificationsEnabled(int _notificationsEnabled);
|
||||||
|
@ -144,6 +149,7 @@ public slots:
|
||||||
void setMinPlayersForMultiColumnLayout(int _minPlayersForMultiColumnLayout);
|
void setMinPlayersForMultiColumnLayout(int _minPlayersForMultiColumnLayout);
|
||||||
void setTapAnimation(int _tapAnimation);
|
void setTapAnimation(int _tapAnimation);
|
||||||
void setChatMention(int _chatMention);
|
void setChatMention(int _chatMention);
|
||||||
|
void setChatMentionForeground(int _chatMentionForeground);
|
||||||
void setZoneViewSortByName(int _zoneViewSortByName);
|
void setZoneViewSortByName(int _zoneViewSortByName);
|
||||||
void setZoneViewSortByType(int _zoneViewSortByType);
|
void setZoneViewSortByType(int _zoneViewSortByType);
|
||||||
void setZoneViewPileView(int _zoneViewPileView);
|
void setZoneViewPileView(int _zoneViewPileView);
|
||||||
|
|
Loading…
Reference in a new issue