diff options
-rw-r--r-- | Swift/Controllers/HighlightAction.h | 9 | ||||
-rw-r--r-- | Swift/Controllers/HighlightManager.cpp | 7 | ||||
-rw-r--r-- | Swift/QtUI/QtHighlightEditor.cpp | 67 | ||||
-rw-r--r-- | Swift/QtUI/QtHighlightEditor.h | 3 | ||||
-rw-r--r-- | Swift/QtUI/QtHighlightEditor.ui | 38 |
5 files changed, 109 insertions, 15 deletions
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<HighlightRule> 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 <boost/lexical_cast.hpp> +#include <Swift/QtUI/UserSearch/QtSuggestingJIDInput.h> #include <Swift/Controllers/HighlightManager.cpp> #include <Swift/QtUI/QtHighlightEditor.h> #include <Swift/QtUI/QtSwiftUtil.h> +#include <Swift/QtUI/QtSettingsProvider.h> #include <QTreeWidgetItem> @@ -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<std::string> 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<std::string> 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 <Swift/Controllers/HighlightRule.h> #include <Swift/Controllers/UIInterfaces/HighlightEditorWindow.h> #include <Swift/QtUI/ui_QtHighlightEditor.h> @@ -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 @@ </property> <property name="icon"> <iconset theme="list-add"> - <normaloff/> - </iconset> + <normaloff>../../../../../home/rm/.designer/backup</normaloff>../../../../../home/rm/.designer/backup</iconset> </property> </widget> </item> @@ -64,8 +63,7 @@ </property> <property name="icon"> <iconset theme="list-remove"> - <normaloff/> - </iconset> + <normaloff>../../../../../home/rm/.designer/backup</normaloff>../../../../../home/rm/.designer/backup</iconset> </property> </widget> </item> @@ -76,8 +74,7 @@ </property> <property name="icon"> <iconset theme="up"> - <normaloff/> - </iconset> + <normaloff>../../../../../home/rm/.designer/backup</normaloff>../../../../../home/rm/.designer/backup</iconset> </property> </widget> </item> @@ -88,8 +85,7 @@ </property> <property name="icon"> <iconset theme="down"> - <normaloff/> - </iconset> + <normaloff>../../../../../home/rm/.designer/backup</normaloff>../../../../../home/rm/.designer/backup</iconset> </property> </widget> </item> @@ -291,6 +287,19 @@ p, li { white-space: pre-wrap; } </property> </widget> </item> + <item> + <spacer name="horizontalSpacer_5"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>40</width> + <height>20</height> + </size> + </property> + </spacer> + </item> </layout> </item> <item> @@ -371,6 +380,19 @@ p, li { white-space: pre-wrap; } </property> </widget> </item> + <item> + <spacer name="horizontalSpacer_6"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>40</width> + <height>20</height> + </size> + </property> + </spacer> + </item> </layout> </item> <item> |