diff options
author | Richard Maudsley <richard.maudsley@isode.com> | 2014-01-20 16:33:11 (GMT) |
---|---|---|
committer | Richard Maudsley <richard.maudsley@isode.com> | 2014-01-20 16:33:11 (GMT) |
commit | fb71563d8d77f34cef9a9f55832bd060e07be665 (patch) | |
tree | 548d12763270651c61c58a924c00d3ccb3c15671 | |
parent | ced8d3d4954d8d3a951e0eded62ae69e1724815b (diff) | |
download | swift-fb71563d8d77f34cef9a9f55832bd060e07be665.zip swift-fb71563d8d77f34cef9a9f55832bd060e07be665.tar.bz2 |
Working on new dialog layout.
Change-Id: Idfa797ed5e92f50bd7c492f26b23ac8e6fa87ca7
-rw-r--r-- | Swift/QtUI/QtHighlightEditor.cpp | 170 | ||||
-rw-r--r-- | Swift/QtUI/QtHighlightEditor.h | 3 | ||||
-rw-r--r-- | Swift/QtUI/QtHighlightEditor.ui | 277 |
3 files changed, 223 insertions, 227 deletions
diff --git a/Swift/QtUI/QtHighlightEditor.cpp b/Swift/QtUI/QtHighlightEditor.cpp index e59c747..0fdec97 100644 --- a/Swift/QtUI/QtHighlightEditor.cpp +++ b/Swift/QtUI/QtHighlightEditor.cpp @@ -57,8 +57,7 @@ QtHighlightEditor::QtHighlightEditor(QtSettingsProvider* settings, QWidget* pare /* we need to be notified if any of the state changes so that we can update our textual rule description */ 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(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())); @@ -153,6 +152,9 @@ void QtHighlightEditor::show() selectRow(0); } + /* prepare default states */ + widgetClick(); + QWidget::show(); QWidget::activateWindow(); } @@ -212,7 +214,7 @@ void QtHighlightEditor::onNewButtonClicked() void QtHighlightEditor::onDeleteButtonClicked() { int selectedRow = getSelectedRow(); - assert(selectedRow > 0); + assert(selectedRow>=0 && selectedRow<ui_.listWidget->count()); delete ui_.listWidget->takeItem(selectedRow); highlightManager_->removeRule(selectedRow); } @@ -236,7 +238,9 @@ void QtHighlightEditor::onCurrentRowChanged(int currentRow) } /* grey the dialog if we have nothing selected */ - enableDialog(currentRow != -1); + if (currentRow == -1) { + disableDialog(); + } previousRow_ = currentRow; } @@ -258,15 +262,9 @@ void QtHighlightEditor::onOkButtonClick() close(); } -void QtHighlightEditor::widgetClick() +void QtHighlightEditor::setChildWidgetStates() { - HighlightRule rule = ruleFromDialog(); - const std::string description = formatNaturalDescription(rule); - ui_.ruleDescription->setText(P2QSTRING(description)); - - if (ui_.listWidget->currentItem()) { - ui_.listWidget->currentItem()->setText(P2QSTRING(description)); - } + /* disable appropriate radio button child widgets */ if (ui_.chatRadio->isChecked()) { if (ui_.nickIsKeyword->isChecked()) { @@ -279,47 +277,60 @@ void QtHighlightEditor::widgetClick() } else { /* chats and rooms */ ui_.nickIsKeyword->setEnabled(true); } + + if (ui_.senderRadio->isChecked()) { + jid_->setEnabled(true); + } else { + jid_->setEnabled(false); + } + + if (ui_.keywordRadio->isChecked()) { + ui_.keyword->setEnabled(true); + ui_.matchWholeWords->setEnabled(true); + ui_.matchCase->setEnabled(true); + } else { + ui_.keyword->setEnabled(false); + ui_.matchWholeWords->setEnabled(false); + ui_.matchCase->setEnabled(false); + } } -void QtHighlightEditor::enableDialog(bool state) +void QtHighlightEditor::widgetClick() { - if (!state) { /* also clear the value, if applicable */ - ui_.chatRadio->setChecked(true); - ui_.senderCheck->setChecked(false); - jid_->setText(""); - ui_.keywordRadio->setChecked(false); - ui_.keyword->setText(""); - ui_.nickIsKeyword->setChecked(false); - ui_.matchWholeWords->setChecked(false); - ui_.matchCase->setChecked(false); - ui_.noColorRadio->setChecked(true); - ui_.foregroundColor->setEnabled(state); - ui_.backgroundColor->setEnabled(state); - ui_.noSoundRadio->setChecked(true); - ui_.foregroundColor->setColor(QColor()); - ui_.backgroundColor->setColor(QColor()); - ui_.soundFile->setText(""); - ui_.foregroundColor->setEnabled(false); - ui_.backgroundColor->setEnabled(false); - ui_.soundFile->setEnabled(false); - ui_.soundFileButton->setEnabled(false); + HighlightRule rule = ruleFromDialog(); + const std::string description = formatNaturalDescription(rule); + ui_.ruleDescription->setText(P2QSTRING(description)); + + if (ui_.listWidget->currentItem()) { + ui_.listWidget->currentItem()->setText(P2QSTRING(description)); } - //ui_.chatCheck->setEnabled(state); - //ui_.roomCheck->setEnabled(state); - ui_.senderCheck->setEnabled(state); - jid_->setEnabled(state); - ui_.nickIsKeyword->setEnabled(state); - ui_.keyword->setEnabled(state); - ui_.nickIsKeyword->setEnabled(state); - ui_.matchWholeWords->setEnabled(state); - ui_.matchCase->setEnabled(state); - ui_.noColorRadio->setEnabled(state); - ui_.defaultColorRadio->setEnabled(state); - ui_.customColorRadio->setEnabled(state); - ui_.noSoundRadio->setEnabled(state); - ui_.defaultSoundRadio->setEnabled(state); - ui_.customSoundRadio->setEnabled(state); + setChildWidgetStates(); +} + +void QtHighlightEditor::disableDialog() +{ + /* TODO: check all of these */ + + ui_.chatRadio->setChecked(true); + ui_.senderRadio->setChecked(false); + jid_->setText(""); + ui_.keywordRadio->setChecked(false); + ui_.keyword->setText(""); + ui_.nickIsKeyword->setChecked(false); + ui_.matchWholeWords->setChecked(false); + ui_.matchCase->setChecked(false); + ui_.noColorRadio->setChecked(true); + ui_.foregroundColor->setEnabled(false); + ui_.backgroundColor->setEnabled(false); + ui_.noSoundRadio->setChecked(true); + ui_.foregroundColor->setColor(QColor()); + ui_.backgroundColor->setColor(QColor()); + ui_.soundFile->setText(""); + ui_.foregroundColor->setEnabled(false); + ui_.backgroundColor->setEnabled(false); + ui_.soundFile->setEnabled(false); + ui_.soundFileButton->setEnabled(false); } void QtHighlightEditor::handleContactSuggestionRequested(const QString& text) @@ -355,19 +366,14 @@ HighlightRule QtHighlightEditor::ruleFromDialog() HighlightRule rule; if (ui_.chatRadio->isChecked()) { - if (ui_.roomRadio->isChecked()) { - rule.setMatchChat(true); - rule.setMatchMUC(true); - } else { - rule.setMatchChat(true); - rule.setMatchMUC(false); - } + rule.setMatchChat(true); + rule.setMatchMUC(false); } else { rule.setMatchChat(false); rule.setMatchMUC(true); } - if (ui_.senderCheck->isChecked()) { + if (ui_.senderRadio->isChecked()) { QString senderName = jid_->text(); if (!senderName.isEmpty()) { std::vector<std::string> senders; @@ -420,35 +426,44 @@ HighlightRule QtHighlightEditor::ruleFromDialog() void QtHighlightEditor::ruleToDialog(const HighlightRule& rule) { - //ui_.chatCheck->setChecked(rule.getMatchChat()); - //ui_.roomCheck->setChecked(rule.getMatchMUC()); + ui_.chatRadio->setEnabled(true); + ui_.roomRadio->setEnabled(true); - std::vector<std::string> senders = rule.getSenders(); - if (senders.empty()) { - ui_.senderCheck->setChecked(false); - jid_->setEnabled(false); - jid_->setText(""); + if (rule.getMatchChat()) { + ui_.chatRadio->setChecked(true); + ui_.roomRadio->setChecked(false); } else { - ui_.senderCheck->setChecked(true); - jid_->setEnabled(true); + ui_.chatRadio->setChecked(false); + ui_.roomRadio->setChecked(true); + } + + ui_.allMsgRadio->setEnabled(true); + ui_.allMsgRadio->setChecked(true); /* this is the default radio button */ + jid_->setText(""); + ui_.matchWholeWords->setChecked(false); + ui_.matchCase->setChecked(false); + + ui_.nickIsKeyword->setEnabled(true); + if (rule.getNickIsKeyword()) { + ui_.nickIsKeyword->setChecked(true); + } + + ui_.senderRadio->setEnabled(true); + std::vector<std::string> senders = rule.getSenders(); + if (!senders.empty()) { + ui_.senderRadio->setChecked(true); jid_->setText(P2QSTRING(senders[0])); } + ui_.keywordRadio->setEnabled(true); std::vector<std::string> keywords = rule.getKeywords(); - if (keywords.empty()) { - ui_.nickIsKeyword->setChecked(false); - ui_.keyword->setEnabled(false); - ui_.keyword->setText(""); - } else { - ui_.nickIsKeyword->setChecked(true); - ui_.keyword->setEnabled(true); + if (!keywords.empty()) { + ui_.keywordRadio->setChecked(true); ui_.keyword->setText(P2QSTRING(keywords[0])); + ui_.matchWholeWords->setChecked(rule.getMatchWholeWords()); + ui_.matchCase->setChecked(rule.getMatchCase()); } - ui_.nickIsKeyword->setChecked(rule.getNickIsKeyword()); - ui_.matchWholeWords->setChecked(rule.getMatchWholeWords()); - ui_.matchCase->setChecked(rule.getMatchCase()); - const HighlightAction& action = rule.getAction(); if (action.highlightText()) { @@ -480,6 +495,9 @@ void QtHighlightEditor::ruleToDialog(const HighlightRule& rule) } else { ui_.noSoundRadio->setChecked(true); } + + /* set radio button child option states */ + setChildWidgetStates(); } } diff --git a/Swift/QtUI/QtHighlightEditor.h b/Swift/QtUI/QtHighlightEditor.h index b0f7bdd..634f637 100644 --- a/Swift/QtUI/QtHighlightEditor.h +++ b/Swift/QtUI/QtHighlightEditor.h @@ -43,8 +43,9 @@ namespace Swift { void onApplyButtonClick(); void onCancelButtonClick(); void onOkButtonClick(); + void setChildWidgetStates(); void widgetClick(); - void enableDialog(bool state); + void disableDialog(); void handleContactSuggestionRequested(const QString& text); private: diff --git a/Swift/QtUI/QtHighlightEditor.ui b/Swift/QtUI/QtHighlightEditor.ui index e9fb78f..5976331 100644 --- a/Swift/QtUI/QtHighlightEditor.ui +++ b/Swift/QtUI/QtHighlightEditor.ui @@ -6,8 +6,8 @@ <rect> <x>0</x> <y>0</y> - <width>845</width> - <height>801</height> + <width>800</width> + <height>715</height> </rect> </property> <property name="minimumSize"> @@ -19,86 +19,62 @@ <property name="windowTitle"> <string>Form</string> </property> - <layout class="QVBoxLayout" name="verticalLayout_11"> + <layout class="QVBoxLayout" name="verticalLayout_8"> + <item> + <widget class="QLabel" name="label_5"> + <property name="text"> + <string>Incoming messages are checked against the following rules. First rule that matches will be executed.</string> + </property> + <property name="wordWrap"> + <bool>true</bool> + </property> + </widget> + </item> <item> - <layout class="QVBoxLayout" name="verticalLayout_2"> + <widget class="QListWidget" name="listWidget"/> + </item> + <item> + <layout class="QHBoxLayout" name="horizontalLayout_3"> <item> - <widget class="QLabel" name="label_5"> + <spacer name="horizontalSpacer_8"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>40</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + <item> + <widget class="QPushButton" name="newButton"> <property name="text"> - <string>Incoming messages are checked against the following rules. First rule that matches will be executed.</string> + <string>New Rule</string> </property> - <property name="wordWrap"> - <bool>true</bool> + </widget> + </item> + <item> + <widget class="QPushButton" name="deleteButton"> + <property name="text"> + <string>Remove Rule</string> </property> </widget> </item> <item> - <layout class="QHBoxLayout" name="horizontalLayout_3"> - <item> - <widget class="QListWidget" name="listWidget"/> - </item> - <item> - <layout class="QVBoxLayout" name="verticalLayout_3"> - <item> - <widget class="QPushButton" name="newButton"> - <property name="text"> - <string/> - </property> - <property name="icon"> - <iconset theme="list-add"> - <normaloff>../../../../../home/rm/.designer/backup</normaloff>../../../../../home/rm/.designer/backup</iconset> - </property> - </widget> - </item> - <item> - <widget class="QPushButton" name="deleteButton"> - <property name="text"> - <string/> - </property> - <property name="icon"> - <iconset theme="list-remove"> - <normaloff>../../../../../home/rm/.designer/backup</normaloff>../../../../../home/rm/.designer/backup</iconset> - </property> - </widget> - </item> - <item> - <widget class="QPushButton" name="moveUpButton"> - <property name="text"> - <string/> - </property> - <property name="icon"> - <iconset theme="up"> - <normaloff>../../../../../home/rm/.designer/backup</normaloff>../../../../../home/rm/.designer/backup</iconset> - </property> - </widget> - </item> - <item> - <widget class="QPushButton" name="moveDownButton"> - <property name="text"> - <string/> - </property> - <property name="icon"> - <iconset theme="down"> - <normaloff>../../../../../home/rm/.designer/backup</normaloff>../../../../../home/rm/.designer/backup</iconset> - </property> - </widget> - </item> - <item> - <spacer name="verticalSpacer"> - <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> + <widget class="QPushButton" name="moveUpButton"> + <property name="text"> + <string>Move Up</string> + </property> + </widget> + </item> + <item> + <widget class="QPushButton" name="moveDownButton"> + <property name="text"> + <string>Move Down</string> + </property> + </widget> </item> </layout> </item> @@ -148,7 +124,7 @@ p, li { white-space: pre-wrap; } </layout> </item> <item> - <layout class="QVBoxLayout" name="verticalLayout_10"> + <layout class="QVBoxLayout" name="verticalLayout_7"> <item> <widget class="QGroupBox" name="groupBox"> <property name="title"> @@ -160,6 +136,9 @@ p, li { white-space: pre-wrap; } <property name="text"> <string>Chats</string> </property> + <property name="checked"> + <bool>true</bool> + </property> </widget> </item> <item> @@ -170,20 +149,13 @@ p, li { white-space: pre-wrap; } </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> + <width>246</width> <height>20</height> </size> </property> @@ -199,88 +171,104 @@ p, li { white-space: pre-wrap; } </property> <layout class="QVBoxLayout" name="verticalLayout_4"> <item> - <layout class="QHBoxLayout" name="senderName"> - <item> - <widget class="QCheckBox" name="senderCheck"> - <property name="text"> - <string>Sender name:</string> - </property> - </widget> - </item> - <item> - <widget class="QLineEdit" name="dummySenderName"/> - </item> - </layout> - </item> - <item> <widget class="QRadioButton" name="allMsgRadio"> <property name="text"> - <string>All messages</string> + <string>Apply to all messages</string> + </property> + <property name="checked"> + <bool>true</bool> </property> </widget> </item> <item> <widget class="QRadioButton" name="nickIsKeyword"> <property name="text"> - <string>Messages mentioning me</string> + <string>Only messages mentioning me</string> </property> </widget> </item> <item> - <widget class="QRadioButton" name="keywordRadio"> - <property name="text"> - <string>Messages mentioning a keyword</string> - </property> - </widget> + <layout class="QVBoxLayout" name="verticalLayout"> + <item> + <widget class="QRadioButton" name="senderRadio"> + <property name="text"> + <string>Messages from this sender:</string> + </property> + </widget> + </item> + <item> + <layout class="QHBoxLayout" name="senderName"> + <item> + <spacer name="horizontalSpacer_7"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeType"> + <enum>QSizePolicy::Preferred</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>18</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + <item> + <widget class="QLineEdit" name="dummySenderName"/> + </item> + </layout> + </item> + </layout> </item> <item> - <layout class="QHBoxLayout" name="horizontalLayout_2"> + <layout class="QVBoxLayout" name="verticalLayout_3"> <item> - <spacer name="horizontalSpacer_7"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeType"> - <enum>QSizePolicy::Preferred</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>15</width> - <height>20</height> - </size> + <widget class="QRadioButton" name="keywordRadio"> + <property name="text"> + <string>Messages containing this keyword:</string> </property> - </spacer> + </widget> </item> <item> - <layout class="QVBoxLayout" name="verticalLayout"> + <layout class="QHBoxLayout" name="horizontalLayout_4"> <item> - <layout class="QHBoxLayout" name="horizontalLayout_4"> + <spacer name="horizontalSpacer_9"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeType"> + <enum>QSizePolicy::Preferred</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>18</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + <item> + <layout class="QVBoxLayout" name="verticalLayout_2"> + <item> + <widget class="QLineEdit" name="keyword"/> + </item> <item> - <widget class="QLabel" name="label"> + <widget class="QCheckBox" name="matchWholeWords"> <property name="text"> - <string>Keyword:</string> + <string>Match keyword within longer words</string> </property> </widget> </item> <item> - <widget class="QLineEdit" name="keyword"/> + <widget class="QCheckBox" name="matchCase"> + <property name="text"> + <string>Keyword is case sensitive</string> + </property> + </widget> </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> @@ -468,19 +456,6 @@ 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> @@ -522,6 +497,8 @@ p, li { white-space: pre-wrap; } <zorder>groupBox_6</zorder> <zorder>verticalSpacer_2</zorder> <zorder>horizontalSpacer_7</zorder> + <zorder>horizontalSpacer_8</zorder> + <zorder></zorder> </widget> <customwidgets> <customwidget> |