From fb71563d8d77f34cef9a9f55832bd060e07be665 Mon Sep 17 00:00:00 2001 From: Richard Maudsley Date: Mon, 20 Jan 2014 16:33:11 +0000 Subject: Working on new dialog layout. Change-Id: Idfa797ed5e92f50bd7c492f26b23ac8e6fa87ca7 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 && selectedRowcount()); 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 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 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 senders = rule.getSenders(); + if (!senders.empty()) { + ui_.senderRadio->setChecked(true); jid_->setText(P2QSTRING(senders[0])); } + ui_.keywordRadio->setEnabled(true); std::vector 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 @@ 0 0 - 845 - 801 + 800 + 715 @@ -19,86 +19,62 @@ Form - + + + + + Incoming messages are checked against the following rules. First rule that matches will be executed. + + + true + + + - + + + + - + + + Qt::Horizontal + + + + 40 + 20 + + + + + + - Incoming messages are checked against the following rules. First rule that matches will be executed. + New Rule - - true + + + + + + Remove Rule - - - - - - - - - - - - - - ../../../../../home/rm/.designer/backup../../../../../home/rm/.designer/backup - - - - - - - - - - - ../../../../../home/rm/.designer/backup../../../../../home/rm/.designer/backup - - - - - - - - - - - ../../../../../home/rm/.designer/backup../../../../../home/rm/.designer/backup - - - - - - - - - - - ../../../../../home/rm/.designer/backup../../../../../home/rm/.designer/backup - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - + + + Move Up + + + + + + + Move Down + + @@ -148,7 +124,7 @@ p, li { white-space: pre-wrap; } - + @@ -160,6 +136,9 @@ p, li { white-space: pre-wrap; } Chats + + true + @@ -170,20 +149,13 @@ p, li { white-space: pre-wrap; } - - - Chats and Rooms - - - - Qt::Horizontal - 100 + 246 20 @@ -199,88 +171,104 @@ p, li { white-space: pre-wrap; } - - - - - Sender name: - - - - - - - - - - All messages + Apply to all messages + + + true - Messages mentioning me + Only messages mentioning me - - - Messages mentioning a keyword - - + + + + + Messages from this sender: + + + + + + + + + Qt::Horizontal + + + QSizePolicy::Preferred + + + + 18 + 20 + + + + + + + + + + - + - - - Qt::Horizontal - - - QSizePolicy::Preferred - - - - 15 - 20 - + + + Messages containing this keyword: - + - + - + + + Qt::Horizontal + + + QSizePolicy::Preferred + + + + 18 + 20 + + + + + + + + + - + - Keyword: + Match keyword within longer words - + + + Keyword is case sensitive + + - - - - Match keyword within longer words - - - - - - - Keyword is case sensitive - - - @@ -468,19 +456,6 @@ p, li { white-space: pre-wrap; } - - - - Qt::Vertical - - - - 20 - 40 - - - - @@ -522,6 +497,8 @@ p, li { white-space: pre-wrap; } groupBox_6 verticalSpacer_2 horizontalSpacer_7 + horizontalSpacer_8 + -- cgit v0.10.2-6-g49f6