From ced8d3d4954d8d3a951e0eded62ae69e1724815b Mon Sep 17 00:00:00 2001 From: Richard Maudsley Date: Mon, 20 Jan 2014 14:24:11 +0000 Subject: Changed to UI layout. Change-Id: Ia215c3c4ddf13be5b5f31c02ae7624d39ccea12d 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 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 senders = rule.getSenders(); if (senders.empty()) { @@ -414,11 +436,11 @@ void QtHighlightEditor::ruleToDialog(const HighlightRule& rule) std::vector 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 @@ 0 0 - 800 - 715 + 845 + 801 @@ -21,12 +21,6 @@ - - - - - - @@ -158,48 +152,53 @@ p, li { white-space: pre-wrap; } - Rule Conditions + Apply Rule To - + - - - - - Apply to: - - - - - - - Chats - - - - - - - Rooms - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - + + + Chats + + + + + + + Rooms + + + + + + + Chats and Rooms + + + + + Qt::Horizontal + + + + 100 + 20 + + + + + + + + + + + Rule Conditions + + + @@ -214,41 +213,75 @@ p, li { white-space: pre-wrap; } - - - - - Keyword: - - - - - - - + + + All messages + + + + + + + Messages mentioning me + + + + + + + Messages mentioning a keyword + + - + - - - Messages that mention my nickname + + + Qt::Horizontal - - - - - - Match keyword within longer words + + QSizePolicy::Preferred - + + + 15 + 20 + + + - - - Keyword is case sensitive - - + + + + + + + Keyword: + + + + + + + + + + + + Match keyword within longer words + + + + + + + Keyword is case sensitive + + + + @@ -435,6 +468,19 @@ p, li { white-space: pre-wrap; } + + + + Qt::Vertical + + + + 20 + 40 + + + + @@ -473,6 +519,9 @@ p, li { white-space: pre-wrap; } line_2 line_3 + groupBox_6 + verticalSpacer_2 + horizontalSpacer_7 -- cgit v0.10.2-6-g49f6