summaryrefslogtreecommitdiff
path: root/client/widgets
diff options
context:
space:
mode:
Diffstat (limited to 'client/widgets')
-rw-r--r--client/widgets/widget.cc24
-rw-r--r--client/widgets/widget.h5
2 files changed, 29 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);
diff --git a/client/widgets/widget.h b/client/widgets/widget.h
index d964974..37a365f 100644
--- a/client/widgets/widget.h
+++ b/client/widgets/widget.h
@@ -85,10 +85,12 @@ signals:
* LUA scripting events:
*/
void eventOnChange(bool deep = false);
+ void eventOnInit(bool deep = false);
public slots:
void childWasChanged();
void runEventOnChange(bool deep = false);
+ void runEventOnInit(bool deep = false);
protected:
QWidget *widget;
@@ -118,6 +120,9 @@ private:
bool hasOnChangeEvent;
QString onChangeEventScript;
+
+ bool hasOnInitEvent;
+ QString onInitEventScript;
};
#endif/*__PRACRO_WIDGET_H__*/