summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swift/QtUI/QtHighlightEditor.cpp')
-rw-r--r--Swift/QtUI/QtHighlightEditor.cpp80
1 files changed, 51 insertions, 29 deletions
diff --git a/Swift/QtUI/QtHighlightEditor.cpp b/Swift/QtUI/QtHighlightEditor.cpp
index 65ddd4d..e59c747 100644
--- a/Swift/QtUI/QtHighlightEditor.cpp
+++ b/Swift/QtUI/QtHighlightEditor.cpp
@@ -55,21 +55,22 @@ QtHighlightEditor::QtHighlightEditor(QtSettingsProvider* settings, QWidget* pare
connect(jid_, SIGNAL(textEdited(QString)), SLOT(handleContactSuggestionRequested(QString)));
/* we need to be notified if any of the state changes so that we can update our textual rule description */
- connect(ui_.chatCheck, SIGNAL(clicked()), SLOT(updateRuleDescription()));
- connect(ui_.roomCheck, SIGNAL(clicked()), SLOT(updateRuleDescription()));
- connect(ui_.senderCheck, SIGNAL(clicked()), SLOT(updateRuleDescription()));
- connect(jid_, SIGNAL(textChanged(const QString&)), SLOT(updateRuleDescription()));
- connect(ui_.keywordCheck, SIGNAL(clicked()), SLOT(updateRuleDescription()));
- connect(ui_.keyword, SIGNAL(textChanged(const QString&)), SLOT(updateRuleDescription()));
- connect(ui_.nickIsKeyword, SIGNAL(clicked()), SLOT(updateRuleDescription()));
- connect(ui_.matchWholeWords, SIGNAL(clicked()), SLOT(updateRuleDescription()));
- connect(ui_.matchCase, SIGNAL(clicked()), SLOT(updateRuleDescription()));
- connect(ui_.noColorRadio, SIGNAL(clicked()), SLOT(updateRuleDescription()));
- connect(ui_.defaultColorRadio, SIGNAL(clicked()), SLOT(updateRuleDescription()));
- connect(ui_.customColorRadio, SIGNAL(clicked()), SLOT(updateRuleDescription()));
- connect(ui_.noSoundRadio, SIGNAL(clicked()), SLOT(updateRuleDescription()));
- connect(ui_.defaultSoundRadio, SIGNAL(clicked()), SLOT(updateRuleDescription()));
- connect(ui_.customSoundRadio, SIGNAL(clicked()), SLOT(updateRuleDescription()));
+ connect(ui_.chatRadio, SIGNAL(clicked()), SLOT(widgetClick()));
+ connect(ui_.roomRadio, SIGNAL(clicked()), SLOT(widgetClick()));
+ connect(ui_.chatAndRoomRadio, SIGNAL(clicked()), SLOT(widgetClick()));
+ connect(ui_.senderCheck, 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_.nickIsKeyword, SIGNAL(clicked()), SLOT(widgetClick()));
+ connect(ui_.matchWholeWords, 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()));
/* if these are not needed, then they should be removed */
ui_.moveUpButton->setVisible(false);
@@ -257,7 +258,7 @@ void QtHighlightEditor::onOkButtonClick()
close();
}
-void QtHighlightEditor::updateRuleDescription()
+void QtHighlightEditor::widgetClick()
{
HighlightRule rule = ruleFromDialog();
const std::string description = formatNaturalDescription(rule);
@@ -266,16 +267,27 @@ void QtHighlightEditor::updateRuleDescription()
if (ui_.listWidget->currentItem()) {
ui_.listWidget->currentItem()->setText(P2QSTRING(description));
}
+
+ if (ui_.chatRadio->isChecked()) {
+ if (ui_.nickIsKeyword->isChecked()) {
+ /* switch to another choice before we disable this button */
+ ui_.allMsgRadio->setChecked(true);
+ }
+ ui_.nickIsKeyword->setEnabled(false);
+ } else if (ui_.roomRadio->isChecked()) {
+ ui_.nickIsKeyword->setEnabled(true);
+ } else { /* chats and rooms */
+ ui_.nickIsKeyword->setEnabled(true);
+ }
}
void QtHighlightEditor::enableDialog(bool state)
{
if (!state) { /* also clear the value, if applicable */
- ui_.chatCheck->setChecked(false);
- ui_.roomCheck->setChecked(false);
+ ui_.chatRadio->setChecked(true);
ui_.senderCheck->setChecked(false);
jid_->setText("");
- ui_.keywordCheck->setChecked(false);
+ ui_.keywordRadio->setChecked(false);
ui_.keyword->setText("");
ui_.nickIsKeyword->setChecked(false);
ui_.matchWholeWords->setChecked(false);
@@ -293,11 +305,11 @@ void QtHighlightEditor::enableDialog(bool state)
ui_.soundFileButton->setEnabled(false);
}
- ui_.chatCheck->setEnabled(state);
- ui_.roomCheck->setEnabled(state);
+ //ui_.chatCheck->setEnabled(state);
+ //ui_.roomCheck->setEnabled(state);
ui_.senderCheck->setEnabled(state);
jid_->setEnabled(state);
- ui_.keywordCheck->setEnabled(state);
+ ui_.nickIsKeyword->setEnabled(state);
ui_.keyword->setEnabled(state);
ui_.nickIsKeyword->setEnabled(state);
ui_.matchWholeWords->setEnabled(state);
@@ -342,8 +354,18 @@ HighlightRule QtHighlightEditor::ruleFromDialog()
{
HighlightRule rule;
- rule.setMatchChat(ui_.chatCheck->isChecked());
- rule.setMatchMUC(ui_.roomCheck->isChecked());
+ if (ui_.chatRadio->isChecked()) {
+ if (ui_.roomRadio->isChecked()) {
+ rule.setMatchChat(true);
+ rule.setMatchMUC(true);
+ } else {
+ rule.setMatchChat(true);
+ rule.setMatchMUC(false);
+ }
+ } else {
+ rule.setMatchChat(false);
+ rule.setMatchMUC(true);
+ }
if (ui_.senderCheck->isChecked()) {
QString senderName = jid_->text();
@@ -354,7 +376,7 @@ HighlightRule QtHighlightEditor::ruleFromDialog()
}
}
- if (ui_.keywordCheck->isChecked()) {
+ if (ui_.nickIsKeyword->isChecked()) {
QString keywordString = ui_.keyword->text();
if (!keywordString.isEmpty()) {
std::vector<std::string> keywords;
@@ -398,8 +420,8 @@ HighlightRule QtHighlightEditor::ruleFromDialog()
void QtHighlightEditor::ruleToDialog(const HighlightRule& rule)
{
- ui_.chatCheck->setChecked(rule.getMatchChat());
- ui_.roomCheck->setChecked(rule.getMatchMUC());
+ //ui_.chatCheck->setChecked(rule.getMatchChat());
+ //ui_.roomCheck->setChecked(rule.getMatchMUC());
std::vector<std::string> senders = rule.getSenders();
if (senders.empty()) {
@@ -414,11 +436,11 @@ void QtHighlightEditor::ruleToDialog(const HighlightRule& rule)
std::vector<std::string> keywords = rule.getKeywords();
if (keywords.empty()) {
- ui_.keywordCheck->setChecked(false);
+ ui_.nickIsKeyword->setChecked(false);
ui_.keyword->setEnabled(false);
ui_.keyword->setText("");
} else {
- ui_.keywordCheck->setChecked(true);
+ ui_.nickIsKeyword->setChecked(true);
ui_.keyword->setEnabled(true);
ui_.keyword->setText(P2QSTRING(keywords[0]));
}