diff options
Diffstat (limited to 'Swift/QtUI/QtHighlightEditor.cpp')
-rw-r--r-- | Swift/QtUI/QtHighlightEditor.cpp | 45 |
1 files changed, 17 insertions, 28 deletions
diff --git a/Swift/QtUI/QtHighlightEditor.cpp b/Swift/QtUI/QtHighlightEditor.cpp index ce07003..8488d7d 100644 --- a/Swift/QtUI/QtHighlightEditor.cpp +++ b/Swift/QtUI/QtHighlightEditor.cpp @@ -34,19 +34,18 @@ QtHighlightEditor::QtHighlightEditor(QtSettingsProvider* settings, QWidget* pare connect(ui_.newButton, SIGNAL(clicked()), SLOT(onNewButtonClicked())); connect(ui_.deleteButton, SIGNAL(clicked()), SLOT(onDeleteButtonClicked())); connect(ui_.buttonBox->button(QDialogButtonBox::Apply), SIGNAL(clicked()), SLOT(onApplyButtonClick())); connect(ui_.buttonBox->button(QDialogButtonBox::Cancel), SIGNAL(clicked()), SLOT(onCancelButtonClick())); connect(ui_.buttonBox->button(QDialogButtonBox::Ok), SIGNAL(clicked()), SLOT(onOkButtonClick())); connect(ui_.noColorRadio, SIGNAL(clicked()), SLOT(colorOtherSelect())); - connect(ui_.defaultColorRadio, SIGNAL(clicked()), SLOT(colorOtherSelect())); connect(ui_.customColorRadio, SIGNAL(clicked()), SLOT(colorCustomSelect())); connect(ui_.noSoundRadio, SIGNAL(clicked()), SLOT(soundOtherSelect())); connect(ui_.defaultSoundRadio, SIGNAL(clicked()), SLOT(soundOtherSelect())); connect(ui_.customSoundRadio, SIGNAL(clicked()), SLOT(soundCustomSelect())); /* replace the static line-edit control with the roster autocompleter */ ui_.dummySenderName->setVisible(false); jid_ = new QtSuggestingJIDInput(this, settings); @@ -62,19 +61,18 @@ QtHighlightEditor::QtHighlightEditor(QtSettingsProvider* settings, QWidget* pare connect(ui_.nickIsKeyword, SIGNAL(clicked()), SLOT(widgetClick())); connect(ui_.allMsgRadio, SIGNAL(clicked()), SLOT(widgetClick())); connect(ui_.senderRadio, SIGNAL(clicked()), SLOT(widgetClick())); connect(jid_, SIGNAL(textChanged(const QString&)), SLOT(widgetClick())); connect(ui_.keywordRadio, SIGNAL(clicked()), SLOT(widgetClick())); connect(ui_.keyword, SIGNAL(textChanged(const QString&)), SLOT(widgetClick())); connect(ui_.matchPartialWords, SIGNAL(clicked()), SLOT(widgetClick())); connect(ui_.matchCase, SIGNAL(clicked()), SLOT(widgetClick())); connect(ui_.noColorRadio, SIGNAL(clicked()), SLOT(widgetClick())); - connect(ui_.defaultColorRadio, SIGNAL(clicked()), SLOT(widgetClick())); connect(ui_.customColorRadio, SIGNAL(clicked()), SLOT(widgetClick())); connect(ui_.noSoundRadio, SIGNAL(clicked()), SLOT(widgetClick())); connect(ui_.defaultSoundRadio, SIGNAL(clicked()), SLOT(widgetClick())); connect(ui_.customSoundRadio, SIGNAL(clicked()), SLOT(widgetClick())); /* allow selection of a custom sound file */ connect(ui_.soundFileButton, SIGNAL(clicked()), SLOT(selectSoundFile())); /* if these are not needed, then they should be removed */ @@ -299,19 +297,18 @@ void QtHighlightEditor::disableDialog() ui_.allMsgRadio->setEnabled(false); ui_.nickIsKeyword->setEnabled(false); ui_.senderRadio->setEnabled(false); ui_.dummySenderName->setEnabled(false); ui_.keywordRadio->setEnabled(false); ui_.keyword->setEnabled(false); ui_.matchPartialWords->setEnabled(false); ui_.matchCase->setEnabled(false); ui_.noColorRadio->setEnabled(false); - ui_.defaultColorRadio->setEnabled(false); ui_.customColorRadio->setEnabled(false); ui_.foregroundColor->setEnabled(false); ui_.backgroundColor->setEnabled(false); ui_.noSoundRadio->setEnabled(false); ui_.defaultSoundRadio->setEnabled(false); ui_.customSoundRadio->setEnabled(false); ui_.soundFile->setEnabled(false); ui_.soundFileButton->setEnabled(false); } @@ -393,34 +390,33 @@ HighlightRule QtHighlightEditor::ruleFromDialog() if (ui_.keywordRadio->isChecked()) { QString keywordString = ui_.keyword->text(); if (!keywordString.isEmpty()) { std::vector<std::string> keywords; keywords.push_back(Q2PSTRING(keywordString)); rule.setKeywords(keywords); } } - rule.setNickIsKeyword(ui_.nickIsKeyword->isChecked()); - rule.setMatchWholeWords(!ui_.matchPartialWords->isChecked()); - rule.setMatchCase(ui_.matchCase->isChecked()); + if (ui_.nickIsKeyword->isChecked()) { + rule.setNickIsKeyword(true); + rule.setMatchWholeWords(true); + rule.setMatchCase(true); + } else { + rule.setMatchWholeWords(!ui_.matchPartialWords->isChecked()); + rule.setMatchCase(ui_.matchCase->isChecked()); + } HighlightAction& action = rule.getAction(); if (ui_.noColorRadio->isChecked()) { - action.setHighlightText(false); - action.setTextColor(""); - action.setTextBackground(""); - } else if (ui_.defaultColorRadio->isChecked()) { - action.setHighlightText(true); action.setTextColor(""); action.setTextBackground(""); } else { - action.setHighlightText(true); action.setTextColor(Q2PSTRING(ui_.foregroundColor->getColor().name())); action.setTextBackground(Q2PSTRING(ui_.backgroundColor->getColor().name())); } if (ui_.noSoundRadio->isChecked()) { action.setPlaySound(false); } else if (ui_.defaultSoundRadio->isChecked()) { action.setPlaySound(true); action.setSoundFile(""); @@ -470,38 +466,31 @@ void QtHighlightEditor::ruleToDialog(const HighlightRule& rule) ui_.keywordRadio->setChecked(true); ui_.keyword->setText(P2QSTRING(keywords[0])); ui_.matchPartialWords->setChecked(!rule.getMatchWholeWords()); ui_.matchCase->setChecked(rule.getMatchCase()); } const HighlightAction& action = rule.getAction(); ui_.noColorRadio->setEnabled(true); - ui_.defaultColorRadio->setEnabled(true); ui_.customColorRadio->setEnabled(true); - if (action.highlightText()) { - if (action.getTextColor().empty() && action.getTextBackground().empty()) { - ui_.defaultColorRadio->setChecked(true); - ui_.foregroundColor->setEnabled(false); - ui_.backgroundColor->setEnabled(false); - } else { - ui_.foregroundColor->setEnabled(true); - ui_.backgroundColor->setEnabled(true); - QColor foregroundColor(P2QSTRING(action.getTextColor())); - ui_.foregroundColor->setColor(foregroundColor); - QColor backgroundColor(P2QSTRING(action.getTextBackground())); - ui_.backgroundColor->setColor(backgroundColor); - ui_.customColorRadio->setChecked(true); - } - } else { + if (action.getTextColor().empty() && action.getTextBackground().empty()) { ui_.noColorRadio->setChecked(true); ui_.foregroundColor->setEnabled(false); ui_.backgroundColor->setEnabled(false); + } else { + ui_.foregroundColor->setEnabled(true); + ui_.backgroundColor->setEnabled(true); + QColor foregroundColor(P2QSTRING(action.getTextColor())); + ui_.foregroundColor->setColor(foregroundColor); + QColor backgroundColor(P2QSTRING(action.getTextBackground())); + ui_.backgroundColor->setColor(backgroundColor); + ui_.customColorRadio->setChecked(true); } ui_.noSoundRadio->setEnabled(true); ui_.defaultSoundRadio->setEnabled(true); ui_.customSoundRadio->setEnabled(true); ui_.soundFile->setText(""); ui_.soundFile->setEnabled(false); ui_.soundFileButton->setEnabled(false); if (action.playSound()) { |