summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swift/QtUI/QtHighlightEditor.cpp')
-rw-r--r--Swift/QtUI/QtHighlightEditor.cpp146
1 files changed, 103 insertions, 43 deletions
diff --git a/Swift/QtUI/QtHighlightEditor.cpp b/Swift/QtUI/QtHighlightEditor.cpp
index bd52e2d..8a27a09 100644
--- a/Swift/QtUI/QtHighlightEditor.cpp
+++ b/Swift/QtUI/QtHighlightEditor.cpp
@@ -60,17 +60,17 @@ QtHighlightEditor::QtHighlightEditor(QtSettingsProvider* settings, QWidget* pare
connect(ui_.buttonBox->button(QDialogButtonBox::Cancel), SIGNAL(clicked()), SLOT(onCancelButtonClick()));
connect(ui_.buttonBox->button(QDialogButtonBox::Ok), SIGNAL(clicked()), SLOT(onOkButtonClick()));
- connect(ui_.radioButton, SIGNAL(clicked()), SLOT(colorOtherSelect()));
- connect(ui_.radioButton_2, SIGNAL(clicked()), SLOT(colorOtherSelect()));
- connect(ui_.radioButton_7, SIGNAL(clicked()), SLOT(colorCustomSelect()));
+ connect(ui_.noColorRadio, SIGNAL(clicked()), SLOT(colorOtherSelect()));
+ connect(ui_.defaultColorRadio, SIGNAL(clicked()), SLOT(colorOtherSelect()));
+ connect(ui_.customColorRadio, SIGNAL(clicked()), SLOT(colorCustomSelect()));
- connect(ui_.radioButton_4, SIGNAL(clicked()), SLOT(soundOtherSelect()));
- connect(ui_.radioButton_5, SIGNAL(clicked()), SLOT(soundOtherSelect()));
- connect(ui_.radioButton_6, SIGNAL(clicked()), SLOT(soundCustomSelect()));
+ connect(ui_.noSoundRadio, SIGNAL(clicked()), SLOT(soundOtherSelect()));
+ connect(ui_.defaultSoundRadio, SIGNAL(clicked()), SLOT(soundOtherSelect()));
+ connect(ui_.customSoundRadio, SIGNAL(clicked()), SLOT(soundCustomSelect()));
- ui_.lineEdit->setVisible(false);
+ ui_.dummySenderName->setVisible(false);
jid_ = new QtSuggestingJIDInput(this, settings);
- ui_.horizontalLayout_2->addWidget(jid_);
+ ui_.senderName->addWidget(jid_);
setWindowTitle(tr("Highlight Rules"));
}
@@ -162,14 +162,14 @@ void QtHighlightEditor::setHighlightManager(HighlightManager* highlightManager)
void QtHighlightEditor::colorOtherSelect()
{
- ui_.foreground_2->setEnabled(false);
- ui_.background->setEnabled(false);
+ ui_.foregoundColor->setEnabled(false);
+ ui_.backgroundColor->setEnabled(false);
}
void QtHighlightEditor::colorCustomSelect()
{
- ui_.foreground_2->setEnabled(true);
- ui_.background->setEnabled(true);
+ ui_.foregoundColor->setEnabled(true);
+ ui_.backgroundColor->setEnabled(true);
}
void QtHighlightEditor::soundOtherSelect()
@@ -197,8 +197,10 @@ void QtHighlightEditor::onNewButtonClicked()
void QtHighlightEditor::onDeleteButtonClicked()
{
int selectedRow = getSelectedRow();
- delete ui_.listWidget->takeItem(selectedRow);
- highlightManager_->removeRule(selectedRow);
+ if (selectedRow == -1) {
+ delete ui_.listWidget->takeItem(selectedRow);
+ highlightManager_->removeRule(selectedRow);
+ }
}
void QtHighlightEditor::onMoveUpButtonClicked()
@@ -243,11 +245,14 @@ void QtHighlightEditor::onCurrentRowChanged(int currentRow)
if (currentRow != -1) {
ruleToDialog(highlightManager_->getRule(currentRow));
- } else {
- /* grey/disable entire dialog */
}
+ /* grey the dialog if we have nothing selected */
+ enableDialog(currentRow != -1);
+
previousRow_ = currentRow;
+
+ updateRuleDescription();
}
void QtHighlightEditor::onApplyButtonClick()
@@ -267,6 +272,51 @@ void QtHighlightEditor::onOkButtonClick()
close();
}
+void QtHighlightEditor::updateRuleDescription()
+{
+ ui_.ruleDescription->setText(P2QSTRING(formatNaturalDescription(ruleFromDialog())));
+}
+
+void QtHighlightEditor::enableDialog(bool state)
+{
+ if (!state) { /* also clear the value, if applicable */
+ ui_.chatCheck->setChecked(false);
+ ui_.roomCheck->setChecked(false);
+ ui_.senderCheck->setChecked(false);
+ jid_->setText("");
+ ui_.keywordCheck->setChecked(false);
+ ui_.keyword->setText("");
+ ui_.nickIsKeyword->setChecked(false);
+ ui_.matchWholeWords->setChecked(false);
+ ui_.matchCase->setChecked(false);
+ ui_.noColorRadio->setChecked(true);
+ //ui_.foregoundColor->setEnabled(state);
+ //ui_.backgroundColor->setEnabled(state);
+ ui_.noSoundRadio->setChecked(true);
+ ui_.soundFile->setText("");
+ }
+
+ ui_.chatCheck->setEnabled(state);
+ ui_.roomCheck->setEnabled(state);
+ ui_.senderCheck->setEnabled(state);
+ jid_->setEnabled(state);
+ ui_.keywordCheck->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_.foregoundColor->setEnabled(state);
+ ui_.backgroundColor->setEnabled(state);
+ ui_.noSoundRadio->setEnabled(state);
+ ui_.defaultSoundRadio->setEnabled(state);
+ ui_.customSoundRadio->setEnabled(state);
+ ui_.soundFile->setEnabled(state);
+ ui_.soundFileButton->setEnabled(state);
+}
+
void QtHighlightEditor::selectRow(int row)
{
for (int i = 0; i < ui_.listWidget->count(); ++i) {
@@ -293,10 +343,10 @@ HighlightRule QtHighlightEditor::ruleFromDialog()
{
HighlightRule rule;
- rule.setMatchChat(ui_.checkBox->isChecked());
- rule.setMatchMUC(ui_.checkBox_2->isChecked());
+ rule.setMatchChat(ui_.chatCheck->isChecked());
+ rule.setMatchMUC(ui_.roomCheck->isChecked());
- if (ui_.checkBox_3->isChecked()) {
+ if (ui_.senderCheck->isChecked()) {
QString senderName = jid_->text();
if (!senderName.isEmpty()) {
std::vector<std::string> senders;
@@ -305,8 +355,8 @@ HighlightRule QtHighlightEditor::ruleFromDialog()
}
}
- if (ui_.checkBox_4->isChecked()) {
- QString keywordString = ui_.lineEdit_2->text();
+ if (ui_.keywordCheck->isChecked()) {
+ QString keywordString = ui_.keyword->text();
if (!keywordString.isEmpty()) {
std::vector<std::string> keywords;
keywords.push_back(Q2PSTRING(keywordString));
@@ -315,14 +365,14 @@ HighlightRule QtHighlightEditor::ruleFromDialog()
}
rule.setNickIsKeyword(ui_.nickIsKeyword->isChecked());
- rule.setMatchWholeWords(ui_.matchWholeWords_2->isChecked());
- rule.setMatchCase(ui_.matchCase_2->isChecked());
+ rule.setMatchWholeWords(ui_.matchWholeWords->isChecked());
+ rule.setMatchCase(ui_.matchCase->isChecked());
HighlightAction& action = rule.getAction();
- if (ui_.radioButton->isChecked()) {
+ if (ui_.noColorRadio->isChecked()) {
action.setHighlightText(false);
- } else if (ui_.radioButton_2->isChecked()) {
+ } else if (ui_.defaultColorRadio->isChecked()) {
action.setHighlightText(true);
action.setTextColor("");
action.setTextBackground("");
@@ -332,60 +382,70 @@ HighlightRule QtHighlightEditor::ruleFromDialog()
action.setTextBackground("#ffffffff");
}
+ if (ui_.noSoundRadio->isChecked()) {
+ action.setPlaySound(false);
+ } else if (ui_.defaultSoundRadio->isChecked()) {
+ action.setPlaySound(true);
+ action.setSoundFile("");
+ } else {
+ action.setPlaySound(true);
+ action.setSoundFile(Q2PSTRING(ui_.soundFile->text()));
+ }
+
return rule;
}
void QtHighlightEditor::ruleToDialog(const HighlightRule& rule)
{
- ui_.checkBox->setChecked(rule.getMatchChat());
- ui_.checkBox_2->setChecked(rule.getMatchMUC());
+ ui_.chatCheck->setChecked(rule.getMatchChat());
+ ui_.roomCheck->setChecked(rule.getMatchMUC());
std::vector<std::string> senders = rule.getSenders();
if (senders.empty()) {
- ui_.checkBox_3->setChecked(false);
+ ui_.senderCheck->setChecked(false);
jid_->setEnabled(false);
jid_->setText("");
} else {
- ui_.checkBox_3->setChecked(true);
+ ui_.senderCheck->setChecked(true);
jid_->setEnabled(true);
jid_->setText(P2QSTRING(senders[0]));
}
std::vector<std::string> keywords = rule.getKeywords();
if (keywords.empty()) {
- ui_.checkBox_4->setChecked(false);
- ui_.lineEdit_2->setEnabled(false);
- ui_.lineEdit_2->setText("");
+ ui_.keywordCheck->setChecked(false);
+ ui_.keyword->setEnabled(false);
+ ui_.keyword->setText("");
} else {
- ui_.checkBox_4->setChecked(true);
- ui_.lineEdit_2->setEnabled(true);
- ui_.lineEdit_2->setText(P2QSTRING(keywords[0]));
+ ui_.keywordCheck->setChecked(true);
+ ui_.keyword->setEnabled(true);
+ ui_.keyword->setText(P2QSTRING(keywords[0]));
}
ui_.nickIsKeyword->setChecked(rule.getNickIsKeyword());
- ui_.matchWholeWords_2->setChecked(rule.getMatchWholeWords());
- ui_.matchCase_2->setChecked(rule.getMatchCase());
+ ui_.matchWholeWords->setChecked(rule.getMatchWholeWords());
+ ui_.matchCase->setChecked(rule.getMatchCase());
const HighlightAction& action = rule.getAction();
if (action.highlightText()) {
if (action.getTextColor().empty() && action.getTextBackground().empty()) {
- ui_.radioButton_2->setChecked(true);
+ ui_.defaultColorRadio->setChecked(true);
} else {
- ui_.radioButton_7->setChecked(true);
+ ui_.customColorRadio->setChecked(true);
}
} else {
- ui_.radioButton->setChecked(true);
+ ui_.noColorRadio->setChecked(true);
}
if (action.playSound()) {
if (action.getSoundFile().empty()) {
- ui_.radioButton_5->setChecked(true);
+ ui_.defaultSoundRadio->setChecked(true);
} else {
- ui_.radioButton_6->setChecked(true);
+ ui_.customSoundRadio->setChecked(true);
}
} else {
- ui_.radioButton_4->setChecked(true);
+ ui_.noSoundRadio->setChecked(true);
}
}