Updated with latest changes from #1243

This commit is contained in:
Fabio Bas 2015-07-14 09:19:07 +02:00
parent 87c70466a4
commit 2e3e6c55ff
6 changed files with 116 additions and 29 deletions

View file

@ -580,6 +580,9 @@ MessagesSettingsPage::MessagesSettingsPage()
invertMentionForeground.setChecked(settingsCache->getChatMentionForeground());
connect(&invertMentionForeground, SIGNAL(stateChanged(int)), this, SLOT(updateTextColor(int)));
invertHighlightForeground.setChecked(settingsCache->getChatHighlightForeground());
connect(&invertHighlightForeground, SIGNAL(stateChanged(int)), this, SLOT(updateTextHighlightColor(int)));
mentionColor = new QLineEdit();
mentionColor->setText(settingsCache->getChatMentionColor());
updateMentionPreview();
@ -592,8 +595,8 @@ MessagesSettingsPage::MessagesSettingsPage()
connect(&mentionPopups, SIGNAL(stateChanged(int)), settingsCache, SLOT(setShowMentionPopups(int)));
customAlertString = new QLineEdit();
customAlertString->setPlaceholderText("Word1, Word2, Word3");
customAlertString->setText(settingsCache->getHighlightWords().join(", "));
customAlertString->setPlaceholderText("Word1 Word2 Word3");
customAlertString->setText(settingsCache->getHighlightWords());
connect(customAlertString, SIGNAL(textChanged(QString)), settingsCache, SLOT(setHighlightWords(QString)));
QGridLayout *chatGrid = new QGridLayout;
@ -608,9 +611,17 @@ MessagesSettingsPage::MessagesSettingsPage()
chatGroupBox = new QGroupBox;
chatGroupBox->setLayout(chatGrid);
highlightColor = new QLineEdit();
highlightColor->setText(settingsCache->getChatHighlightColor());
updateHighlightPreview();
connect(highlightColor, SIGNAL(textChanged(QString)), this, SLOT(updateHighlightColor(QString)));
QGridLayout *highlightNotice = new QGridLayout;
highlightNotice->addWidget(highlightColor, 0, 2);
highlightNotice->addWidget(&invertHighlightForeground, 0, 1);
highlightNotice->addWidget(&hexHighlightLabel, 1, 2);
highlightNotice->addWidget(customAlertString, 0, 0);
highlightNotice->addWidget(&customAlertStringLabel, 1, 0);
highlightNotice->addWidget(&customAlertStringLabel, 1, 0);
highlightGroupBox = new QGroupBox;
highlightGroupBox->setLayout(highlightNotice);
@ -660,16 +671,35 @@ void MessagesSettingsPage::updateColor(const QString &value) {
}
}
void MessagesSettingsPage::updateHighlightColor(const QString &value) {
QColor colorToSet;
colorToSet.setNamedColor("#" + value);
if (colorToSet.isValid()) {
settingsCache->setChatHighlightColor(value);
updateHighlightPreview();
}
}
void MessagesSettingsPage::updateTextColor(int value) {
settingsCache->setChatMentionForeground(value);
updateMentionPreview();
}
void MessagesSettingsPage::updateTextHighlightColor(int value) {
settingsCache->setChatHighlightForeground(value);
updateHighlightPreview();
}
void MessagesSettingsPage::updateMentionPreview() {
mentionColor->setStyleSheet("QLineEdit{background:#" + settingsCache->getChatMentionColor() +
";color: " + (settingsCache->getChatMentionForeground() ? "white" : "black") + ";}");
}
void MessagesSettingsPage::updateHighlightPreview() {
highlightColor->setStyleSheet("QLineEdit{background:#" + settingsCache->getChatHighlightColor() +
";color: " + (settingsCache->getChatHighlightForeground() ? "white" : "black") + ";}");
}
void MessagesSettingsPage::storeSettings()
{
QSettings settings;
@ -703,14 +733,15 @@ void MessagesSettingsPage::retranslateUi()
highlightGroupBox->setTitle(tr("Custom alert words"));
chatMentionCheckBox.setText(tr("Enable chat mentions"));
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."));
ignoreUnregUserMessages.setText(tr("Ignore private 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"));
invertMentionForeground.setText(tr("Invert text color"));
messagePopups.setText(tr("Enable desktop notifications for private messages."));
invertHighlightForeground.setText(tr("Invert text color"));
messagePopups.setText(tr("Enable desktop notifications for private messages"));
mentionPopups.setText(tr("Enable desktop notification for mentions."));
hexLabel.setText(tr("(Color is hexadecimal)"));
customAlertStringLabel.setText(tr("(Seperate each word with a comma, words are case insensitive)"));
hexHighlightLabel.setText(tr("(Color is hexadecimal)"));
customAlertStringLabel.setText(tr("(Seperate each word with a space, words are case insensitive)"));
}