diff options
Diffstat (limited to 'client/widgets/widget.cc')
-rw-r--r-- | client/widgets/widget.cc | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/client/widgets/widget.cc b/client/widgets/widget.cc index b128a53..d17754e 100644 --- a/client/widgets/widget.cc +++ b/client/widgets/widget.cc @@ -38,7 +38,7 @@ Widget::Widget(QDomNode &node) } if(elem.hasAttribute("lua_validator")) { - // lua_validator = elem.attribute("lua_validator"); + lua_validator = elem.attribute("lua_validator"); hasluavalidator = true; } else { hasluavalidator = false; @@ -75,5 +75,17 @@ bool Widget::regexpValidator() bool Widget::luaValidator() { - return !hasluavalidator || true; + 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()); + + return result == "true"; } |