summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordeva <deva>2009-04-02 10:05:14 +0000
committerdeva <deva>2009-04-02 10:05:14 +0000
commit035e52b780036762799174dd2630d3780d540f1f (patch)
tree245c508b5ce3f2405e0a1fdfc4d78247cafe7f65
parentdc61dff1aa28c9463d4ff0adeb5b3a21163a9c11 (diff)
Validation and coloring of radiobuttons.
-rw-r--r--client/widgets/radiobuttons.cc48
-rw-r--r--client/widgets/radiobuttons.h1
2 files changed, 28 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();
}
diff --git a/client/widgets/radiobuttons.h b/client/widgets/radiobuttons.h
index b0f6cd3..a32147b 100644
--- a/client/widgets/radiobuttons.h
+++ b/client/widgets/radiobuttons.h
@@ -66,6 +66,7 @@ signals:
private:
QVector < RadioButton* > radiobutton_list;
+ bool setBGColor(bool valid);
};
#endif/*__PRACRO_RADIOBUTTONS_H__*/