Chat highlighting when mentioned
When being mentioned in a post with '@username' you will now see the entry highlighted. This helps to see when someone is talking to you. It work across the main chat, in game and in private chat.
This commit is contained in:
parent
7476667b69
commit
5452d0ceae
5 changed files with 37 additions and 3 deletions
|
@ -8,6 +8,8 @@
|
||||||
#include "user_context_menu.h"
|
#include "user_context_menu.h"
|
||||||
#include "tab_supervisor.h"
|
#include "tab_supervisor.h"
|
||||||
#include "pixmapgenerator.h"
|
#include "pixmapgenerator.h"
|
||||||
|
#include "settingscache.h"
|
||||||
|
#include "main.h"
|
||||||
|
|
||||||
ChatView::ChatView(const TabSupervisor *_tabSupervisor, TabGame *_game, bool _showTimestamps, QWidget *parent)
|
ChatView::ChatView(const TabSupervisor *_tabSupervisor, TabGame *_game, bool _showTimestamps, QWidget *parent)
|
||||||
: QTextBrowser(parent), tabSupervisor(_tabSupervisor), game(_game), evenNumber(true), showTimestamps(_showTimestamps), hoveredItemType(HoveredNothing)
|
: QTextBrowser(parent), tabSupervisor(_tabSupervisor), game(_game), evenNumber(true), showTimestamps(_showTimestamps), hoveredItemType(HoveredNothing)
|
||||||
|
@ -102,7 +104,7 @@ 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.setFontWeight(QFont::Bold);
|
senderFormat.setFontWeight(QFont::Bold);
|
||||||
senderFormat.setForeground(Qt::red);
|
senderFormat.setForeground(QBrush(QColor(113, 43, 43)));
|
||||||
} else {
|
} else {
|
||||||
senderFormat.setForeground(Qt::blue);
|
senderFormat.setForeground(Qt::blue);
|
||||||
if (playerBold)
|
if (playerBold)
|
||||||
|
@ -168,8 +170,17 @@ void ChatView::appendMessage(QString message, QString sender, UserLevelFlags use
|
||||||
} else
|
} else
|
||||||
from = 1;
|
from = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QTextCharFormat charFormat;
|
||||||
|
if (settingsCache->getChatMention()) {
|
||||||
|
if (message.toLower().contains("@" + QString::fromStdString(tabSupervisor->getUserInfo()->name()).toLower())) {
|
||||||
|
charFormat.setFontWeight(QFont::Bold);
|
||||||
|
charFormat.setForeground(QBrush(QColor(113, 43, 43)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!message.isEmpty())
|
if (!message.isEmpty())
|
||||||
cursor.insertText(message);
|
cursor.insertText(message, charFormat);
|
||||||
|
|
||||||
if (atBottom)
|
if (atBottom)
|
||||||
verticalScrollBar()->setValue(verticalScrollBar()->maximum());
|
verticalScrollBar()->setValue(verticalScrollBar()->maximum());
|
||||||
|
|
|
@ -494,6 +494,10 @@ UserInterfaceSettingsPage::UserInterfaceSettingsPage()
|
||||||
tapAnimationCheckBox->setChecked(settingsCache->getTapAnimation());
|
tapAnimationCheckBox->setChecked(settingsCache->getTapAnimation());
|
||||||
connect(tapAnimationCheckBox, SIGNAL(stateChanged(int)), settingsCache, SLOT(setTapAnimation(int)));
|
connect(tapAnimationCheckBox, SIGNAL(stateChanged(int)), settingsCache, SLOT(setTapAnimation(int)));
|
||||||
|
|
||||||
|
chatMentionCheckBox = new QCheckBox;
|
||||||
|
chatMentionCheckBox->setChecked(settingsCache->getChatMention());
|
||||||
|
connect(chatMentionCheckBox, SIGNAL(stateChanged(int)), settingsCache, SLOT(setChatMention(int)));
|
||||||
|
|
||||||
soundEnabledCheckBox = new QCheckBox;
|
soundEnabledCheckBox = new QCheckBox;
|
||||||
soundEnabledCheckBox->setChecked(settingsCache->getSoundEnabled());
|
soundEnabledCheckBox->setChecked(settingsCache->getSoundEnabled());
|
||||||
connect(soundEnabledCheckBox, SIGNAL(stateChanged(int)), settingsCache, SLOT(setSoundEnabled(int)));
|
connect(soundEnabledCheckBox, SIGNAL(stateChanged(int)), settingsCache, SLOT(setSoundEnabled(int)));
|
||||||
|
@ -525,9 +529,16 @@ UserInterfaceSettingsPage::UserInterfaceSettingsPage()
|
||||||
animationGroupBox = new QGroupBox;
|
animationGroupBox = new QGroupBox;
|
||||||
animationGroupBox->setLayout(animationGrid);
|
animationGroupBox->setLayout(animationGrid);
|
||||||
|
|
||||||
|
QGridLayout *chatGrid = new QGridLayout;
|
||||||
|
chatGrid->addWidget(chatMentionCheckBox, 0, 0);
|
||||||
|
|
||||||
|
chatGroupBox = new QGroupBox;
|
||||||
|
chatGroupBox->setLayout(chatGrid);
|
||||||
|
|
||||||
QVBoxLayout *mainLayout = new QVBoxLayout;
|
QVBoxLayout *mainLayout = new QVBoxLayout;
|
||||||
mainLayout->addWidget(generalGroupBox);
|
mainLayout->addWidget(generalGroupBox);
|
||||||
mainLayout->addWidget(animationGroupBox);
|
mainLayout->addWidget(animationGroupBox);
|
||||||
|
mainLayout->addWidget(chatGroupBox);
|
||||||
mainLayout->addWidget(soundGroupBox);
|
mainLayout->addWidget(soundGroupBox);
|
||||||
|
|
||||||
setLayout(mainLayout);
|
setLayout(mainLayout);
|
||||||
|
@ -540,7 +551,9 @@ void UserInterfaceSettingsPage::retranslateUi()
|
||||||
doubleClickToPlayCheckBox->setText(tr("&Double-click cards to play them (instead of single-click)"));
|
doubleClickToPlayCheckBox->setText(tr("&Double-click cards to play them (instead of single-click)"));
|
||||||
playToStackCheckBox->setText(tr("&Play all nonlands onto the stack (not the battlefield) by default"));
|
playToStackCheckBox->setText(tr("&Play all nonlands onto the stack (not the battlefield) by default"));
|
||||||
animationGroupBox->setTitle(tr("Animation settings"));
|
animationGroupBox->setTitle(tr("Animation settings"));
|
||||||
|
chatGroupBox->setTitle(tr("Chat settings"));
|
||||||
tapAnimationCheckBox->setText(tr("&Tap/untap animation"));
|
tapAnimationCheckBox->setText(tr("&Tap/untap animation"));
|
||||||
|
chatMentionCheckBox->setText(tr("Enable chat mentions ('@yourusername' in chat log will be highlighted)"));
|
||||||
soundEnabledCheckBox->setText(tr("Enable &sounds"));
|
soundEnabledCheckBox->setText(tr("Enable &sounds"));
|
||||||
soundPathLabel->setText(tr("Path to sounds directory:"));
|
soundPathLabel->setText(tr("Path to sounds directory:"));
|
||||||
soundTestButton->setText(tr("Test system sound engine"));
|
soundTestButton->setText(tr("Test system sound engine"));
|
||||||
|
|
|
@ -89,10 +89,11 @@ private:
|
||||||
QCheckBox *doubleClickToPlayCheckBox;
|
QCheckBox *doubleClickToPlayCheckBox;
|
||||||
QCheckBox *playToStackCheckBox;
|
QCheckBox *playToStackCheckBox;
|
||||||
QCheckBox *tapAnimationCheckBox;
|
QCheckBox *tapAnimationCheckBox;
|
||||||
|
QCheckBox *chatMentionCheckBox;
|
||||||
QCheckBox *soundEnabledCheckBox;
|
QCheckBox *soundEnabledCheckBox;
|
||||||
QLabel *soundPathLabel;
|
QLabel *soundPathLabel;
|
||||||
QLineEdit *soundPathEdit;
|
QLineEdit *soundPathEdit;
|
||||||
QGroupBox *generalGroupBox, *animationGroupBox, *soundGroupBox;
|
QGroupBox *generalGroupBox, *animationGroupBox, *soundGroupBox, *chatGroupBox;
|
||||||
QPushButton *soundTestButton;
|
QPushButton *soundTestButton;
|
||||||
public:
|
public:
|
||||||
UserInterfaceSettingsPage();
|
UserInterfaceSettingsPage();
|
||||||
|
|
|
@ -39,6 +39,7 @@ SettingsCache::SettingsCache()
|
||||||
invertVerticalCoordinate = settings->value("table/invert_vertical", false).toBool();
|
invertVerticalCoordinate = settings->value("table/invert_vertical", false).toBool();
|
||||||
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();
|
||||||
|
|
||||||
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();
|
||||||
|
@ -231,6 +232,11 @@ void SettingsCache::setTapAnimation(int _tapAnimation)
|
||||||
settings->setValue("cards/tapanimation", tapAnimation);
|
settings->setValue("cards/tapanimation", tapAnimation);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SettingsCache::setChatMention(int _chatMention) {
|
||||||
|
chatMention = _chatMention;
|
||||||
|
settings->setValue("chat/mention", chatMention);
|
||||||
|
}
|
||||||
|
|
||||||
void SettingsCache::setZoneViewSortByName(int _zoneViewSortByName)
|
void SettingsCache::setZoneViewSortByName(int _zoneViewSortByName)
|
||||||
{
|
{
|
||||||
zoneViewSortByName = _zoneViewSortByName;
|
zoneViewSortByName = _zoneViewSortByName;
|
||||||
|
|
|
@ -51,6 +51,7 @@ private:
|
||||||
bool invertVerticalCoordinate;
|
bool invertVerticalCoordinate;
|
||||||
int minPlayersForMultiColumnLayout;
|
int minPlayersForMultiColumnLayout;
|
||||||
bool tapAnimation;
|
bool tapAnimation;
|
||||||
|
bool chatMention;
|
||||||
bool zoneViewSortByName, zoneViewSortByType;
|
bool zoneViewSortByName, zoneViewSortByType;
|
||||||
bool soundEnabled;
|
bool soundEnabled;
|
||||||
QString soundPath;
|
QString soundPath;
|
||||||
|
@ -88,6 +89,7 @@ public:
|
||||||
bool getInvertVerticalCoordinate() const { return invertVerticalCoordinate; }
|
bool getInvertVerticalCoordinate() const { return invertVerticalCoordinate; }
|
||||||
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 getZoneViewSortByName() const { return zoneViewSortByName; }
|
bool getZoneViewSortByName() const { return zoneViewSortByName; }
|
||||||
bool getZoneViewSortByType() const { return zoneViewSortByType; }
|
bool getZoneViewSortByType() const { return zoneViewSortByType; }
|
||||||
bool getSoundEnabled() const { return soundEnabled; }
|
bool getSoundEnabled() const { return soundEnabled; }
|
||||||
|
@ -126,6 +128,7 @@ public slots:
|
||||||
void setInvertVerticalCoordinate(int _invertVerticalCoordinate);
|
void setInvertVerticalCoordinate(int _invertVerticalCoordinate);
|
||||||
void setMinPlayersForMultiColumnLayout(int _minPlayersForMultiColumnLayout);
|
void setMinPlayersForMultiColumnLayout(int _minPlayersForMultiColumnLayout);
|
||||||
void setTapAnimation(int _tapAnimation);
|
void setTapAnimation(int _tapAnimation);
|
||||||
|
void setChatMention(int _chatMention);
|
||||||
void setZoneViewSortByName(int _zoneViewSortByName);
|
void setZoneViewSortByName(int _zoneViewSortByName);
|
||||||
void setZoneViewSortByType(int _zoneViewSortByType);
|
void setZoneViewSortByType(int _zoneViewSortByType);
|
||||||
void setSoundEnabled(int _soundEnabled);
|
void setSoundEnabled(int _soundEnabled);
|
||||||
|
|
Loading…
Reference in a new issue