From 4d7617cbf20985b7cf2231675d8aadd01f77c3d2 Mon Sep 17 00:00:00 2001 From: deva Date: Wed, 2 Jul 2008 07:49:31 +0000 Subject: Added disable/enable methods on widgets and exposed them to lua. --- client/widgets/checkbox.cc | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) (limited to 'client/widgets/checkbox.cc') diff --git a/client/widgets/checkbox.cc b/client/widgets/checkbox.cc index 0585abf..8474e58 100644 --- a/client/widgets/checkbox.cc +++ b/client/widgets/checkbox.cc @@ -42,13 +42,15 @@ CheckBox::CheckBox(QDomNode &node, MacroWindow *macrowindow) if(elem.hasAttribute("caption")) { setText(elem.attribute("caption")); } else { - setText(elem.attribute("")); + setText(""); } + connect(this, SIGNAL(stateChanged(int)), this, SLOT(state_change())); + if(elem.hasAttribute("value")) { setValue(elem.attribute("value")); } else { - setChecked(false); + setValue("false"); } } @@ -60,11 +62,26 @@ QString CheckBox::getValue() void CheckBox::setValue(QString value) { - if(value == "true") setChecked(true); - else setChecked(false); + bool old = isChecked(); + + if(value == "true") { + setChecked(true); + } else { + setChecked(false); + } + + // If set operation did not change the value we must invocate the code manually. + if(old == isChecked()) state_change(); } bool CheckBox::isValid() { return true; } + +void CheckBox::state_change() +{ + printf("state_change\n"); + + luaValidator(); +} -- cgit v1.2.3