summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swift/QtUI')
-rw-r--r--Swift/QtUI/QtHighlightEditor.cpp80
-rw-r--r--Swift/QtUI/QtHighlightEditor.h2
-rw-r--r--Swift/QtUI/QtHighlightEditor.ui197
3 files changed, 175 insertions, 104 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]));
}
diff --git a/Swift/QtUI/QtHighlightEditor.h b/Swift/QtUI/QtHighlightEditor.h
index 5c0d618..b0f7bdd 100644
--- a/Swift/QtUI/QtHighlightEditor.h
+++ b/Swift/QtUI/QtHighlightEditor.h
@@ -43,7 +43,7 @@ namespace Swift {
void onApplyButtonClick();
void onCancelButtonClick();
void onOkButtonClick();
- void updateRuleDescription();
+ void widgetClick();
void enableDialog(bool state);
void handleContactSuggestionRequested(const QString& text);
diff --git a/Swift/QtUI/QtHighlightEditor.ui b/Swift/QtUI/QtHighlightEditor.ui
index cd07192..e9fb78f 100644
--- a/Swift/QtUI/QtHighlightEditor.ui
+++ b/Swift/QtUI/QtHighlightEditor.ui
@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
- <width>800</width>
- <height>715</height>
+ <width>845</width>
+ <height>801</height>
</rect>
</property>
<property name="minimumSize">
@@ -21,12 +21,6 @@
</property>
<layout class="QVBoxLayout" name="verticalLayout_11">
<item>
- <layout class="QVBoxLayout" name="verticalLayout_8"/>
- </item>
- <item>
- <layout class="QVBoxLayout" name="verticalLayout_7"/>
- </item>
- <item>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QLabel" name="label_5">
@@ -158,48 +152,53 @@ p, li { white-space: pre-wrap; }
<item>
<widget class="QGroupBox" name="groupBox">
<property name="title">
- <string>Rule Conditions</string>
+ <string>Apply Rule To</string>
</property>
- <layout class="QVBoxLayout" name="verticalLayout_4">
+ <layout class="QHBoxLayout" name="horizontalLayout">
<item>
- <layout class="QHBoxLayout" name="horizontalLayout">
- <item>
- <widget class="QLabel" name="label_2">
- <property name="text">
- <string>Apply to:</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QCheckBox" name="chatCheck">
- <property name="text">
- <string>Chats</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QCheckBox" name="roomCheck">
- <property name="text">
- <string>Rooms</string>
- </property>
- </widget>
- </item>
- <item>
- <spacer name="horizontalSpacer">
- <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>
+ <widget class="QRadioButton" name="chatRadio">
+ <property name="text">
+ <string>Chats</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QRadioButton" name="roomRadio">
+ <property name="text">
+ <string>Rooms</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QRadioButton" name="chatAndRoomRadio">
+ <property name="text">
+ <string>Chats and Rooms</string>
+ </property>
+ </widget>
</item>
<item>
+ <spacer name="horizontalSpacer">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>100</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item>
+ <widget class="QGroupBox" name="groupBox_6">
+ <property name="title">
+ <string>Rule Conditions</string>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout_4">
+ <item>
<layout class="QHBoxLayout" name="senderName">
<item>
<widget class="QCheckBox" name="senderCheck">
@@ -214,41 +213,75 @@ p, li { white-space: pre-wrap; }
</layout>
</item>
<item>
- <layout class="QHBoxLayout" name="horizontalLayout_4">
- <item>
- <widget class="QCheckBox" name="keywordCheck">
- <property name="text">
- <string>Keyword:</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QLineEdit" name="keyword"/>
- </item>
- </layout>
+ <widget class="QRadioButton" name="allMsgRadio">
+ <property name="text">
+ <string>All messages</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QRadioButton" name="nickIsKeyword">
+ <property name="text">
+ <string>Messages mentioning me</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QRadioButton" name="keywordRadio">
+ <property name="text">
+ <string>Messages mentioning a keyword</string>
+ </property>
+ </widget>
</item>
<item>
- <layout class="QVBoxLayout" name="verticalLayout">
+ <layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
- <widget class="QCheckBox" name="nickIsKeyword">
- <property name="text">
- <string>Messages that mention my nickname</string>
+ <spacer name="horizontalSpacer_7">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
</property>
- </widget>
- </item>
- <item>
- <widget class="QCheckBox" name="matchWholeWords">
- <property name="text">
- <string>Match keyword within longer words</string>
+ <property name="sizeType">
+ <enum>QSizePolicy::Preferred</enum>
</property>
- </widget>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>15</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
</item>
<item>
- <widget class="QCheckBox" name="matchCase">
- <property name="text">
- <string>Keyword is case sensitive</string>
- </property>
- </widget>
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout_4">
+ <item>
+ <widget class="QLabel" name="label">
+ <property name="text">
+ <string>Keyword:</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLineEdit" name="keyword"/>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <widget class="QCheckBox" name="matchWholeWords">
+ <property name="text">
+ <string>Match keyword within longer words</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QCheckBox" name="matchCase">
+ <property name="text">
+ <string>Keyword is case sensitive</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
</item>
</layout>
</item>
@@ -435,6 +468,19 @@ p, li { white-space: pre-wrap; }
</layout>
</widget>
</item>
+ <item>
+ <spacer name="verticalSpacer_2">
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>20</width>
+ <height>40</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
</layout>
</item>
</layout>
@@ -473,6 +519,9 @@ p, li { white-space: pre-wrap; }
</layout>
<zorder>line_2</zorder>
<zorder>line_3</zorder>
+ <zorder>groupBox_6</zorder>
+ <zorder>verticalSpacer_2</zorder>
+ <zorder>horizontalSpacer_7</zorder>
</widget>
<customwidgets>
<customwidget>