summaryrefslogtreecommitdiff
path: root/client/widgets/widget.cc
diff options
context:
space:
mode:
Diffstat (limited to 'client/widgets/widget.cc')
-rw-r--r--client/widgets/widget.cc24
1 files changed, 24 insertions, 0 deletions
diff --git a/client/widgets/widget.cc b/client/widgets/widget.cc
index 1fefae8..085ac21 100644
--- a/client/widgets/widget.cc
+++ b/client/widgets/widget.cc
@@ -62,11 +62,17 @@ Widget::Widget(QDomNode &node, MacroWindow *macrowindow)
hasOnChangeEvent = elem.hasAttribute("onChange");
onChangeEventScript = elem.attribute("onChange", "");
+ hasOnInitEvent = elem.hasAttribute("onInit");
+ onInitEventScript = elem.attribute("onInit", "");
+
is_valid = true;
connect(this, SIGNAL(eventOnChange()),
this, SLOT(runEventOnChange()), Qt::QueuedConnection);
+ connect(this, SIGNAL(eventOnInit()),
+ this, SLOT(runEventOnInit()), Qt::QueuedConnection);
+
DEBUG(widget, "Create Widget '%s' of type '%s'\n",
name().toStdString().c_str(),
type().toStdString().c_str());
@@ -160,6 +166,24 @@ void Widget::runEventOnChange(bool deep)
}
}
+void Widget::runEventOnInit(bool deep)
+{
+ if(enabled()) {
+ //if(preValid() == false) setWdgValid(false);
+ setWdgValid(valid());
+ if(hasOnInitEvent)
+ lua->runScript(onInitEventScript, this, "onInit");
+ }
+
+ if(!deep) return;
+
+ QVector< Widget* >::iterator i = children.begin();
+ while(i != children.end()) {
+ if(*i) (*i)->runEventOnInit(deep);
+ i++;
+ }
+}
+
void Widget::setWdgValidRecursive(bool forcevalid)
{
if(forcevalid) setWdgValid(true);