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.cc30
1 files changed, 13 insertions, 17 deletions
diff --git a/client/widgets/widget.cc b/client/widgets/widget.cc
index d17754e..61e2a53 100644
--- a/client/widgets/widget.cc
+++ b/client/widgets/widget.cc
@@ -26,10 +26,12 @@
*/
#include "widget.h"
-Widget::Widget(QDomNode &node)
+Widget::Widget(QDomNode &node, MacroWindow *macrowindow)
{
QDomElement elem = node.toElement();
+ this->macrowindow = macrowindow;
+
if(elem.hasAttribute("name")) {
widget_name = elem.attribute("name");
} else {
@@ -37,11 +39,11 @@ Widget::Widget(QDomNode &node)
elem.tagName().toStdString().c_str());
}
- if(elem.hasAttribute("lua_validator")) {
- lua_validator = elem.attribute("lua_validator");
- hasluavalidator = true;
+ if(elem.hasAttribute("lua")) {
+ luaprogram = elem.attribute("lua");
+ hasluaprogram = true;
} else {
- hasluavalidator = false;
+ hasluaprogram = false;
}
if(elem.hasAttribute("regexp")) {
@@ -63,6 +65,10 @@ QString Widget::getValue()
return "";
}
+void Widget::setValue(QString)
+{
+}
+
bool Widget::isValid()
{
return regexpValidator() && luaValidator();
@@ -75,17 +81,7 @@ bool Widget::regexpValidator()
bool Widget::luaValidator()
{
- if(!hasluavalidator) return true;
-
- Variables v;
- v["value"] = getValue().toStdString();
- LUA lua(v);
-
- std::string program = lua_validator.toStdString();
-
- std::string result = lua.run(program);
-
- // printf("Running [%s] => [%s]\n", program.c_str(), result.c_str());
+ if(!hasluaprogram) return true;
- return result == "true";
+ return macrowindow->lua->run(luaprogram, getValue());
}