From 97d03baffbf399c98238f9583c2718b5e7ab4b0e Mon Sep 17 00:00:00 2001 From: Richard Maudsley Date: Fri, 17 Jan 2014 17:14:46 +0000 Subject: Saving and restoring colour values. Change-Id: I36cf2a70958d7195dca264846962f28a1ec534b8 diff --git a/Swift/QtUI/QtHighlightEditor.cpp b/Swift/QtUI/QtHighlightEditor.cpp index 807b180..bd71c37 100644 --- a/Swift/QtUI/QtHighlightEditor.cpp +++ b/Swift/QtUI/QtHighlightEditor.cpp @@ -168,13 +168,13 @@ void QtHighlightEditor::setHighlightManager(HighlightManager* highlightManager) void QtHighlightEditor::colorOtherSelect() { - ui_.foregoundColor->setEnabled(false); + ui_.foregroundColor->setEnabled(false); ui_.backgroundColor->setEnabled(false); } void QtHighlightEditor::colorCustomSelect() { - ui_.foregoundColor->setEnabled(true); + ui_.foregroundColor->setEnabled(true); ui_.backgroundColor->setEnabled(true); } @@ -272,10 +272,16 @@ void QtHighlightEditor::enableDialog(bool state) ui_.matchWholeWords->setChecked(false); ui_.matchCase->setChecked(false); ui_.noColorRadio->setChecked(true); - //ui_.foregoundColor->setEnabled(state); - //ui_.backgroundColor->setEnabled(state); + 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); } ui_.chatCheck->setEnabled(state); @@ -290,13 +296,9 @@ void QtHighlightEditor::enableDialog(bool 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) @@ -354,17 +356,16 @@ HighlightRule QtHighlightEditor::ruleFromDialog() if (ui_.noColorRadio->isChecked()) { action.setHighlightText(false); + action.setTextColor(""); + action.setTextBackground(""); } else if (ui_.defaultColorRadio->isChecked()) { action.setHighlightText(true); action.setTextColor(""); action.setTextBackground(""); } else { action.setHighlightText(true); - QColor foregroundColor = ui_.foregoundColor.getColor(); - action.setTextColor("#ffffffff"); - - QColor backgroundColor = ui_.backgroundColor.getColor(); - action.setTextBackground("#ffffffff"); + action.setTextColor(Q2PSTRING(ui_.foregroundColor->getColor().name())); + action.setTextBackground(Q2PSTRING(ui_.backgroundColor->getColor().name())); } if (ui_.noSoundRadio->isChecked()) { @@ -416,11 +417,21 @@ void QtHighlightEditor::ruleToDialog(const HighlightRule& rule) if (action.highlightText()) { if (action.getTextColor().empty() && action.getTextBackground().empty()) { ui_.defaultColorRadio->setChecked(true); + ui_.foregroundColor->setEnabled(false); + ui_.backgroundColor->setEnabled(false); } else { + ui_.foregroundColor->setEnabled(true); + ui_.backgroundColor->setEnabled(true); + QColor foregroundColor(P2QSTRING(action.getTextColor())); + ui_.foregroundColor->setColor(foregroundColor); + QColor backgroundColor(P2QSTRING(action.getTextBackground())); + ui_.backgroundColor->setColor(backgroundColor); ui_.customColorRadio->setChecked(true); } } else { ui_.noColorRadio->setChecked(true); + ui_.foregroundColor->setEnabled(false); + ui_.backgroundColor->setEnabled(false); } if (action.playSound()) { diff --git a/Swift/QtUI/QtHighlightEditor.ui b/Swift/QtUI/QtHighlightEditor.ui index 76ccf05..cd07192 100644 --- a/Swift/QtUI/QtHighlightEditor.ui +++ b/Swift/QtUI/QtHighlightEditor.ui @@ -318,7 +318,7 @@ p, li { white-space: pre-wrap; } - + false -- cgit v0.10.2-6-g49f6