summaryrefslogtreecommitdiff
path: root/client/widgets
diff options
context:
space:
mode:
Diffstat (limited to 'client/widgets')
-rw-r--r--client/widgets/checkbox.cc4
-rw-r--r--client/widgets/checkbox.h2
-rw-r--r--client/widgets/combobox.cc4
-rw-r--r--client/widgets/combobox.h2
-rw-r--r--client/widgets/frame.cc4
-rw-r--r--client/widgets/frame.h2
-rw-r--r--client/widgets/groupbox.cc4
-rw-r--r--client/widgets/groupbox.h2
-rw-r--r--client/widgets/label.cc4
-rw-r--r--client/widgets/label.h2
-rw-r--r--client/widgets/lineedit.cc9
-rw-r--r--client/widgets/lineedit.h3
-rw-r--r--client/widgets/listbox.cc4
-rw-r--r--client/widgets/listbox.h2
-rw-r--r--client/widgets/pushbutton.cc4
-rw-r--r--client/widgets/pushbutton.h2
-rw-r--r--client/widgets/radiobuttons.cc4
-rw-r--r--client/widgets/radiobuttons.h2
-rw-r--r--client/widgets/textedit.cc4
-rw-r--r--client/widgets/textedit.h2
-rw-r--r--client/widgets/widget.cc30
-rw-r--r--client/widgets/widget.h10
-rw-r--r--client/widgets/window.cc4
-rw-r--r--client/widgets/window.h2
24 files changed, 59 insertions, 53 deletions
diff --git a/client/widgets/checkbox.cc b/client/widgets/checkbox.cc
index 2ce3802..6b6f0e8 100644
--- a/client/widgets/checkbox.cc
+++ b/client/widgets/checkbox.cc
@@ -26,8 +26,8 @@
*/
#include "checkbox.h"
-CheckBox::CheckBox(QDomNode &node)
- : QCheckBox(), Widget(node)
+CheckBox::CheckBox(QDomNode &node, MacroWindow *macrowindow)
+ : QCheckBox(), Widget(node, macrowindow)
{
QDomElement elem = node.toElement();
diff --git a/client/widgets/checkbox.h b/client/widgets/checkbox.h
index 228723e..e24792c 100644
--- a/client/widgets/checkbox.h
+++ b/client/widgets/checkbox.h
@@ -34,7 +34,7 @@
class CheckBox : public QCheckBox, public Widget
{
public:
- CheckBox(QDomNode &node);
+ CheckBox(QDomNode &node, MacroWindow *macrowindow);
bool isValid();
diff --git a/client/widgets/combobox.cc b/client/widgets/combobox.cc
index 480cada..aa2d78b 100644
--- a/client/widgets/combobox.cc
+++ b/client/widgets/combobox.cc
@@ -27,8 +27,8 @@
#include "combobox.h"
#include <QDomNodeList>
-ComboBox::ComboBox(QDomNode &node)
- : QComboBox(), Widget(node)
+ComboBox::ComboBox(QDomNode &node, MacroWindow *macrowindow)
+ : QComboBox(), Widget(node, macrowindow)
{
QDomElement elem = node.toElement();
diff --git a/client/widgets/combobox.h b/client/widgets/combobox.h
index ab92e64..a79b2aa 100644
--- a/client/widgets/combobox.h
+++ b/client/widgets/combobox.h
@@ -34,7 +34,7 @@
class ComboBox : public QComboBox, public Widget
{
public:
- ComboBox(QDomNode &node);
+ ComboBox(QDomNode &node, MacroWindow *macrowindow);
public slots:
bool isValid();
diff --git a/client/widgets/frame.cc b/client/widgets/frame.cc
index e2227cc..2560994 100644
--- a/client/widgets/frame.cc
+++ b/client/widgets/frame.cc
@@ -28,8 +28,8 @@
#include <QVBoxLayout>
#include <QHBoxLayout>
-Frame::Frame(QDomNode &node)
- : QFrame(), Widget(node)
+Frame::Frame(QDomNode &node, MacroWindow *macrowindow)
+ : QFrame(), Widget(node, macrowindow)
{
QDomElement elem = node.toElement();
diff --git a/client/widgets/frame.h b/client/widgets/frame.h
index 80aeded..1daf3d4 100644
--- a/client/widgets/frame.h
+++ b/client/widgets/frame.h
@@ -34,7 +34,7 @@
class Frame : public QFrame, public Widget
{
public:
- Frame(QDomNode &node);
+ Frame(QDomNode &node, MacroWindow *macrowindow);
public slots:
QString getValue();
diff --git a/client/widgets/groupbox.cc b/client/widgets/groupbox.cc
index dba97cd..8461a1b 100644
--- a/client/widgets/groupbox.cc
+++ b/client/widgets/groupbox.cc
@@ -28,8 +28,8 @@
#include <QVBoxLayout>
#include <QHBoxLayout>
-GroupBox::GroupBox(QDomNode &node)
- : QGroupBox(), Widget(node)
+GroupBox::GroupBox(QDomNode &node, MacroWindow *macrowindow)
+ : QGroupBox(), Widget(node, macrowindow)
{
QDomElement elem = node.toElement();
diff --git a/client/widgets/groupbox.h b/client/widgets/groupbox.h
index 0cc1890..567fa3f 100644
--- a/client/widgets/groupbox.h
+++ b/client/widgets/groupbox.h
@@ -34,7 +34,7 @@
class GroupBox : public QGroupBox, public Widget
{
public:
- GroupBox(QDomNode &node);
+ GroupBox(QDomNode &node, MacroWindow *macrowindow);
public slots:
QString getValue();
diff --git a/client/widgets/label.cc b/client/widgets/label.cc
index 95d53ac..c495c12 100644
--- a/client/widgets/label.cc
+++ b/client/widgets/label.cc
@@ -27,8 +27,8 @@
#include "label.h"
#include <stdio.h>
-Label::Label(QDomNode &node)
- : QLabel(), Widget(node)
+Label::Label(QDomNode &node, MacroWindow *macrowindow)
+ : QLabel(), Widget(node, macrowindow)
{
QDomElement elem = node.toElement();
diff --git a/client/widgets/label.h b/client/widgets/label.h
index 9c539e7..c1ede43 100644
--- a/client/widgets/label.h
+++ b/client/widgets/label.h
@@ -36,7 +36,7 @@ class Label : public QLabel, public Widget
{
Q_OBJECT
public:
- Label(QDomNode &node);
+ Label(QDomNode &node, MacroWindow *macrowindow);
public slots:
QString getValue();
diff --git a/client/widgets/lineedit.cc b/client/widgets/lineedit.cc
index a6f2e83..7f270e9 100644
--- a/client/widgets/lineedit.cc
+++ b/client/widgets/lineedit.cc
@@ -27,8 +27,8 @@
#include "lineedit.h"
#include <stdio.h>
-LineEdit::LineEdit(QDomNode &node)
- : QLineEdit(), Widget(node)
+LineEdit::LineEdit(QDomNode &node, MacroWindow *macrowindow)
+ : QLineEdit(), Widget(node, macrowindow)
{
QDomElement elem = node.toElement();
@@ -75,3 +75,8 @@ QString LineEdit::getValue()
{
return text();
}
+
+void LineEdit::setValue(QString value)
+{
+ setText(value);
+}
diff --git a/client/widgets/lineedit.h b/client/widgets/lineedit.h
index faea440..41296a9 100644
--- a/client/widgets/lineedit.h
+++ b/client/widgets/lineedit.h
@@ -36,11 +36,12 @@ class LineEdit : public QLineEdit, public Widget
{
Q_OBJECT
public:
- LineEdit(QDomNode &node);
+ LineEdit(QDomNode &node, MacroWindow *macrowindow);
public slots:
void changed();
QString getValue();
+ void setValue(QString value);
private:
bool valid;
diff --git a/client/widgets/listbox.cc b/client/widgets/listbox.cc
index c7151cc..3021bd9 100644
--- a/client/widgets/listbox.cc
+++ b/client/widgets/listbox.cc
@@ -27,8 +27,8 @@
#include "listbox.h"
#include <QListWidgetItem>
-ListBox::ListBox(QDomNode &node)
- : QListWidget(), Widget(node)
+ListBox::ListBox(QDomNode &node, MacroWindow *macrowindow)
+ : QListWidget(), Widget(node, macrowindow)
{
QDomElement elem = node.toElement();
diff --git a/client/widgets/listbox.h b/client/widgets/listbox.h
index e41838b..b283bcc 100644
--- a/client/widgets/listbox.h
+++ b/client/widgets/listbox.h
@@ -34,7 +34,7 @@
class ListBox : public QListWidget, public Widget
{
public:
- ListBox(QDomNode &node);
+ ListBox(QDomNode &node, MacroWindow *macrowindow);
public slots:
bool isValid();
diff --git a/client/widgets/pushbutton.cc b/client/widgets/pushbutton.cc
index d674162..a0540f3 100644
--- a/client/widgets/pushbutton.cc
+++ b/client/widgets/pushbutton.cc
@@ -27,8 +27,8 @@
#include "pushbutton.h"
#include <stdio.h>
-PushButton::PushButton(QDomNode &node)
- : QPushButton(), Widget(node)
+PushButton::PushButton(QDomNode &node, MacroWindow *macrowindow)
+ : QPushButton(), Widget(node, macrowindow)
{
QDomElement elem = node.toElement();
diff --git a/client/widgets/pushbutton.h b/client/widgets/pushbutton.h
index 42e3156..fe75fbf 100644
--- a/client/widgets/pushbutton.h
+++ b/client/widgets/pushbutton.h
@@ -36,7 +36,7 @@ class PushButton : public QPushButton, public Widget
{
Q_OBJECT
public:
- PushButton(QDomNode &node);
+ PushButton(QDomNode &node, MacroWindow *macrowindow);
QString field;
public slots:
diff --git a/client/widgets/radiobuttons.cc b/client/widgets/radiobuttons.cc
index 8c87a0c..7508974 100644
--- a/client/widgets/radiobuttons.cc
+++ b/client/widgets/radiobuttons.cc
@@ -30,8 +30,8 @@
#include <QHBoxLayout>
#include <QVBoxLayout>
-RadioButtons::RadioButtons(QDomNode &node)
- : QFrame(), Widget(node)
+RadioButtons::RadioButtons(QDomNode &node, MacroWindow *macrowindow)
+ : QFrame(), Widget(node, macrowindow)
{
QDomElement elem = node.toElement();
diff --git a/client/widgets/radiobuttons.h b/client/widgets/radiobuttons.h
index 454d159..67c1cd0 100644
--- a/client/widgets/radiobuttons.h
+++ b/client/widgets/radiobuttons.h
@@ -37,7 +37,7 @@
class RadioButtons : public QFrame, public Widget
{
public:
- RadioButtons(QDomNode &node);
+ RadioButtons(QDomNode &node, MacroWindow *macrowindow);
public slots:
bool isValid();
diff --git a/client/widgets/textedit.cc b/client/widgets/textedit.cc
index e217cc6..a284967 100644
--- a/client/widgets/textedit.cc
+++ b/client/widgets/textedit.cc
@@ -28,8 +28,8 @@
#include <stdio.h>
#include <QPalette>
-TextEdit::TextEdit(QDomNode &node)
- : QTextEdit(), Widget(node)
+TextEdit::TextEdit(QDomNode &node, MacroWindow *macrowindow)
+ : QTextEdit(), Widget(node, macrowindow)
{
//setAutoFillBackground(true); /* Default is false, which disables background
// color manipulation.*/
diff --git a/client/widgets/textedit.h b/client/widgets/textedit.h
index 466af0f..946e7b9 100644
--- a/client/widgets/textedit.h
+++ b/client/widgets/textedit.h
@@ -36,7 +36,7 @@ class TextEdit : public QTextEdit, public Widget
{
Q_OBJECT
public:
- TextEdit(QDomNode &node);
+ TextEdit(QDomNode &node, MacroWindow *macrowindow);
public slots:
void changed();
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());
}
diff --git a/client/widgets/widget.h b/client/widgets/widget.h
index 391f2e9..cba6be9 100644
--- a/client/widgets/widget.h
+++ b/client/widgets/widget.h
@@ -31,13 +31,15 @@
#include <QDomNode>
#include <QRegExp>
+#include "macrowindow.h"
#include "lua.h"
class Widget {
public:
- Widget(QDomNode &node);
+ Widget(QDomNode &node, MacroWindow *macrowindow);
virtual ~Widget(){}
virtual QString getValue();
+ virtual void setValue(QString value);
virtual bool isValid();
QString getName();
@@ -51,9 +53,11 @@ private:
QRegExp rx;
bool hasregexpvalidator;
- bool hasluavalidator;
+ bool hasluaprogram;
- QString lua_validator;
+ QString luaprogram;
+ LUA *lua;
+ MacroWindow *macrowindow;
};
#endif/*__PRACRO_WIDGET_H__*/
diff --git a/client/widgets/window.cc b/client/widgets/window.cc
index 5d15733..b2b4298 100644
--- a/client/widgets/window.cc
+++ b/client/widgets/window.cc
@@ -28,8 +28,8 @@
#include <QVBoxLayout>
#include <QHBoxLayout>
-Window::Window(QDomNode &node)
- : QWidget(NULL), Widget(node)
+Window::Window(QDomNode &node, MacroWindow *macrowindow)
+ : QWidget(NULL), Widget(node, macrowindow)
{
QDomElement elem = node.toElement();
diff --git a/client/widgets/window.h b/client/widgets/window.h
index 93c48ab..bd4c77b 100644
--- a/client/widgets/window.h
+++ b/client/widgets/window.h
@@ -34,7 +34,7 @@
class Window : public QWidget, public Widget
{
public:
- Window(QDomNode &node);
+ Window(QDomNode &node, MacroWindow *macrowindow);
public slots:
QString getValue();