From cacd6f5cc3754872653311d5333145f2256079d9 Mon Sep 17 00:00:00 2001 From: Richard Maudsley Date: Thu, 16 Jan 2014 15:14:20 +0000 Subject: Updated highlight dialog. Change-Id: I9bf91fdbf542e01a9f2421315698846ca0bdb043 diff --git a/Swift/Controllers/HighlightAction.h b/Swift/Controllers/HighlightAction.h index a8da90a..8d8bafc 100644 --- a/Swift/Controllers/HighlightAction.h +++ b/Swift/Controllers/HighlightAction.h @@ -22,15 +22,24 @@ namespace Swift { bool highlightText() const { return highlightText_; } void setHighlightText(bool highlightText); + /** + * Gets the foreground highlight color. If the string is empty, assume a default color. + */ const std::string& getTextColor() const { return textColor_; } void setTextColor(const std::string& textColor) { textColor_ = textColor; } + /** + * Gets the background highlight color. If the string is empty, assume a default color. + */ const std::string& getTextBackground() const { return textBackground_; } void setTextBackground(const std::string& textBackground) { textBackground_ = textBackground; } bool playSound() const { return playSound_; } void setPlaySound(bool playSound); + /** + * Gets the sound filename. If the string is empty, assume a default sound file. + */ const std::string& getSoundFile() const { return soundFile_; } void setSoundFile(const std::string& soundFile) { soundFile_ = soundFile; } diff --git a/Swift/Controllers/HighlightManager.cpp b/Swift/Controllers/HighlightManager.cpp index 46af389..17ce776 100644 --- a/Swift/Controllers/HighlightManager.cpp +++ b/Swift/Controllers/HighlightManager.cpp @@ -125,12 +125,7 @@ void HighlightManager::storeSettings() void HighlightManager::loadSettings() { std::string highlightRules = settings_->getSetting(SettingConstants::HIGHLIGHT_RULES); - std::vector rules = rulesFromString(highlightRules); - if (rules.empty()) { - rules_ = getDefaultRules(); - } else { - rules_ = rules; - } + rules_ = rulesFromString(highlightRules); } Highlighter* HighlightManager::createHighlighter() diff --git a/Swift/QtUI/QtHighlightEditor.cpp b/Swift/QtUI/QtHighlightEditor.cpp index f4ec78f..bc07158 100644 --- a/Swift/QtUI/QtHighlightEditor.cpp +++ b/Swift/QtUI/QtHighlightEditor.cpp @@ -14,9 +14,11 @@ #include +#include #include #include #include +#include #include @@ -58,6 +60,9 @@ QtHighlightEditor::QtHighlightEditor(QtSettingsProvider* settings, QWidget* pare connect(ui_.buttonBox->button(QDialogButtonBox::Cancel), SIGNAL(clicked()), SLOT(onCancelButtonClick())); connect(ui_.buttonBox->button(QDialogButtonBox::Ok), SIGNAL(clicked()), SLOT(onOkButtonClick())); + ui_.lineEdit->setVisible(false); + ui_.horizontalLayout_2->addWidget(new QtSuggestingJIDInput(this, settings)); + setWindowTitle(tr("Highlight Rules")); } @@ -145,7 +150,6 @@ void QtHighlightEditor::onCurrentRowChanged(int currentRow) //ui_.ruleWidget->setEnabled(index.isValid()); ui_.deleteButton->setEnabled(currentRow != -1); - ui_.moveUpButton->setEnabled(currentRow != -1 && currentRow != 0); ui_.moveDownButton->setEnabled(currentRow != -1 && currentRow != (ui_.listWidget->count()-1)); } @@ -184,4 +188,65 @@ int QtHighlightEditor::getSelectedRow() const return -1; } +HighlightRule QtHighlightEditor::ruleFromDialog() +{ + HighlightRule rule; + + return rule; +} + +void QtHighlightEditor::ruleToDialog(const HighlightRule& rule) +{ + ui_.checkBox->setChecked(rule.getMatchChat()); + ui_.checkBox_2->setChecked(rule.getMatchMUC()); + + std::vector senders = rule.getSenders(); + if (senders.empty()) { + ui_.checkBox_3->setChecked(false); + ui_.lineEdit->setEnabled(false); + ui_.lineEdit->setText(""); + } else { + ui_.checkBox_3->setChecked(true); + ui_.lineEdit->setEnabled(true); + ui_.lineEdit->setText(P2QSTRING(senders[0])); + } + + std::vector keywords = rule.getKeywords(); + if (keywords.empty()) { + ui_.checkBox_4->setChecked(false); + ui_.lineEdit_2->setEnabled(false); + ui_.lineEdit_2->setText(""); + } else { + ui_.checkBox_4->setChecked(true); + ui_.lineEdit_2->setEnabled(true); + ui_.lineEdit_2->setText(P2QSTRING(keywords[0])); + } + + ui_.nickIsKeyword->setChecked(rule.getNickIsKeyword()); + ui_.matchWholeWords_2->setChecked(rule.getMatchWholeWords()); + ui_.matchCase_2->setChecked(rule.getMatchCase()); + + const HighlightAction &action = rule.getAction(); + + if (action.highlightText()) { + if (action.getTextColor().empty() && action.getTextBackground().empty()) { + ui_.radioButton_2->setChecked(true); + } else { + ui_.radioButton_7->setChecked(true); + } + } else { + ui_.radioButton->setChecked(true); + } + + if (action.playSound()) { + if (action.getSoundFile().empty()) { + ui_.radioButton_5->setChecked(true); + } else { + ui_.radioButton_6->setChecked(true); + } + } else { + ui_.radioButton_4->setChecked(true); + } +} + } diff --git a/Swift/QtUI/QtHighlightEditor.h b/Swift/QtUI/QtHighlightEditor.h index 4769ed9..3d52cd7 100644 --- a/Swift/QtUI/QtHighlightEditor.h +++ b/Swift/QtUI/QtHighlightEditor.h @@ -12,6 +12,7 @@ #pragma once +#include #include #include @@ -43,6 +44,8 @@ namespace Swift { void selectRow(int row); int getSelectedRow() const; + HighlightRule ruleFromDialog(); + void ruleToDialog(const HighlightRule& rule); Ui::QtHighlightEditor ui_; QtSettingsProvider* settings_; diff --git a/Swift/QtUI/QtHighlightEditor.ui b/Swift/QtUI/QtHighlightEditor.ui index 2b37e3c..8355381 100644 --- a/Swift/QtUI/QtHighlightEditor.ui +++ b/Swift/QtUI/QtHighlightEditor.ui @@ -52,8 +52,7 @@ - - + ../../../../../home/rm/.designer/backup../../../../../home/rm/.designer/backup @@ -64,8 +63,7 @@ - - + ../../../../../home/rm/.designer/backup../../../../../home/rm/.designer/backup @@ -76,8 +74,7 @@ - - + ../../../../../home/rm/.designer/backup../../../../../home/rm/.designer/backup @@ -88,8 +85,7 @@ - - + ../../../../../home/rm/.designer/backup../../../../../home/rm/.designer/backup @@ -291,6 +287,19 @@ p, li { white-space: pre-wrap; } + + + + Qt::Horizontal + + + + 40 + 20 + + + + @@ -371,6 +380,19 @@ p, li { white-space: pre-wrap; } + + + + Qt::Horizontal + + + + 40 + 20 + + + + -- cgit v0.10.2-6-g49f6