diff options
author | deva <deva> | 2009-04-02 10:05:14 +0000 |
---|---|---|
committer | deva <deva> | 2009-04-02 10:05:14 +0000 |
commit | 035e52b780036762799174dd2630d3780d540f1f (patch) | |
tree | 245c508b5ce3f2405e0a1fdfc4d78247cafe7f65 /client/widgets/radiobuttons.cc | |
parent | dc61dff1aa28c9463d4ff0adeb5b3a21163a9c11 (diff) |
Validation and coloring of radiobuttons.
Diffstat (limited to 'client/widgets/radiobuttons.cc')
-rw-r--r-- | client/widgets/radiobuttons.cc | 48 |
1 files changed, 27 insertions, 21 deletions
diff --git a/client/widgets/radiobuttons.cc b/client/widgets/radiobuttons.cc index 2385428..d11c3e5 100644 --- a/client/widgets/radiobuttons.cc +++ b/client/widgets/radiobuttons.cc @@ -56,21 +56,40 @@ RadioButtons::RadioButtons(QDomNode &node, MacroWindow *macrowindow) layout()->setContentsMargins(0,0,0,0); } -bool RadioButtons::isValid() +bool RadioButtons::setBGColor(bool valid) { - if(!regexpValidator()) return false; - if(!luaValidator()) return false; + QPalette palette; + + if(valid) { + palette.setBrush(QPalette::Base, QBrush(QColor(255, 255, 255))); + } else { + //palette.setBrush(QPalette::Base, QBrush(QColor(255, 255, 255))); + palette.setBrush(QPalette::Base, QBrush(QColor(230, 200, 200))); + } + + QVector< RadioButton* >::iterator i; + for (i = radiobutton_list.begin(); i != radiobutton_list.end(); ++i) { + RadioButton *widget = *i; + widget->setPalette(palette); + } + + return valid; +} +bool RadioButtons::isValid() +{ + if(!regexpValidator()) return setBGColor(false); + if(!luaValidator()) return setBGColor(false); QVector< RadioButton* >::iterator i; for (i = radiobutton_list.begin(); i != radiobutton_list.end(); ++i) { RadioButton *widget = *i; if(widget->isChecked()) { - return true; + return setBGColor(true); } } - return false; + return setBGColor(false); } QString RadioButtons::getValue() @@ -102,6 +121,8 @@ void RadioButtons::setValue(QString value, QString source) } setInitialValue(value); + + isValid(); } void RadioButtons::connectFrom(const char *signal, @@ -143,22 +164,7 @@ void RadioButtons::setVisibility(bool visible) void RadioButtons::childChanged() { - QPalette palette; - - if(regexpValidator()) { - if(luaValidator()) { - // valid string - palette.setBrush(QPalette::Base, QBrush(QColor(255, 255, 255))); - } else { - // invalid string - palette.setBrush(QPalette::Base, QBrush(QColor(200, 230, 200))); - } - } else { - // invalid string - palette.setBrush(QPalette::Base, QBrush(QColor(230, 200, 200))); - } - - setPalette(palette); + isValid(); emit wasChanged(); } |