diff options
author | deva <deva> | 2008-07-02 07:49:31 +0000 |
---|---|---|
committer | deva <deva> | 2008-07-02 07:49:31 +0000 |
commit | 4d7617cbf20985b7cf2231675d8aadd01f77c3d2 (patch) | |
tree | 673a098723c6f6cef90719e0ffa65b2cb31c37b6 /client/widgets | |
parent | ef408f5639958ce51170978433a0e483240a3ff2 (diff) |
Added disable/enable methods on widgets and exposed them to lua.
Diffstat (limited to 'client/widgets')
-rw-r--r-- | client/widgets/checkbox.cc | 25 | ||||
-rw-r--r-- | client/widgets/checkbox.h | 4 | ||||
-rw-r--r-- | client/widgets/combobox.cc | 10 | ||||
-rw-r--r-- | client/widgets/combobox.h | 7 | ||||
-rw-r--r-- | client/widgets/frame.cc | 3 | ||||
-rw-r--r-- | client/widgets/groupbox.cc | 7 | ||||
-rw-r--r-- | client/widgets/lineedit.cc | 10 | ||||
-rw-r--r-- | client/widgets/lineedit.h | 2 | ||||
-rw-r--r-- | client/widgets/widget.cc | 8 | ||||
-rw-r--r-- | client/widgets/widget.h | 2 | ||||
-rw-r--r-- | client/widgets/window.cc | 2 |
11 files changed, 74 insertions, 6 deletions
diff --git a/client/widgets/checkbox.cc b/client/widgets/checkbox.cc index 0585abf..8474e58 100644 --- a/client/widgets/checkbox.cc +++ b/client/widgets/checkbox.cc @@ -42,13 +42,15 @@ CheckBox::CheckBox(QDomNode &node, MacroWindow *macrowindow) if(elem.hasAttribute("caption")) { setText(elem.attribute("caption")); } else { - setText(elem.attribute("")); + setText(""); } + connect(this, SIGNAL(stateChanged(int)), this, SLOT(state_change())); + if(elem.hasAttribute("value")) { setValue(elem.attribute("value")); } else { - setChecked(false); + setValue("false"); } } @@ -60,11 +62,26 @@ QString CheckBox::getValue() void CheckBox::setValue(QString value) { - if(value == "true") setChecked(true); - else setChecked(false); + bool old = isChecked(); + + if(value == "true") { + setChecked(true); + } else { + setChecked(false); + } + + // If set operation did not change the value we must invocate the code manually. + if(old == isChecked()) state_change(); } bool CheckBox::isValid() { return true; } + +void CheckBox::state_change() +{ + printf("state_change\n"); + + luaValidator(); +} diff --git a/client/widgets/checkbox.h b/client/widgets/checkbox.h index 9db7bf2..65a0356 100644 --- a/client/widgets/checkbox.h +++ b/client/widgets/checkbox.h @@ -33,15 +33,17 @@ class CheckBox : public QCheckBox, public Widget { +Q_OBJECT public: CheckBox(QDomNode &node, MacroWindow *macrowindow); bool isValid(); -public slots: QString getValue(); void setValue(QString value); +public slots: + void state_change(); }; #endif/*__PRACRO_CHECKBOX_H__*/ diff --git a/client/widgets/combobox.cc b/client/widgets/combobox.cc index a60f1ed..3856bed 100644 --- a/client/widgets/combobox.cc +++ b/client/widgets/combobox.cc @@ -154,3 +154,13 @@ void ComboBox::changed() setPalette(palette); } + +void ComboBox::enable() +{ + setEnabled(true); +} + +void ComboBox::disable() +{ + setEnabled(false); +} diff --git a/client/widgets/combobox.h b/client/widgets/combobox.h index 9ad2323..0a5724f 100644 --- a/client/widgets/combobox.h +++ b/client/widgets/combobox.h @@ -38,10 +38,15 @@ Q_OBJECT public: ComboBox(QDomNode &node, MacroWindow *macrowindow); -public slots: bool isValid(); + QString getValue(); void setValue(QString value); + + void enable(); + void disable(); + +public slots: void changed(); private: diff --git a/client/widgets/frame.cc b/client/widgets/frame.cc index ecf0701..44571f5 100644 --- a/client/widgets/frame.cc +++ b/client/widgets/frame.cc @@ -42,5 +42,8 @@ Frame::Frame(QDomNode &node, MacroWindow *macrowindow) setLayout(layout); } } + setLineWidth(0); + setMidLineWidth(0); + setContentsMargins(0,0,0,0); } diff --git a/client/widgets/groupbox.cc b/client/widgets/groupbox.cc index 2edb344..9dc36ec 100644 --- a/client/widgets/groupbox.cc +++ b/client/widgets/groupbox.cc @@ -47,5 +47,12 @@ GroupBox::GroupBox(QDomNode &node, MacroWindow *macrowindow) QVBoxLayout *layout = new QVBoxLayout(); setLayout(layout); } + } else { + QHBoxLayout *layout = new QHBoxLayout(); + setLayout(layout); } + + // setLineWidth(0); + // setMidLineWidth(0); + setContentsMargins(0,10,0,0); } diff --git a/client/widgets/lineedit.cc b/client/widgets/lineedit.cc index 7f270e9..8694889 100644 --- a/client/widgets/lineedit.cc +++ b/client/widgets/lineedit.cc @@ -80,3 +80,13 @@ void LineEdit::setValue(QString value) { setText(value); } + +void LineEdit::enable() +{ + setEnabled(true); +} + +void LineEdit::disable() +{ + setEnabled(false); +} diff --git a/client/widgets/lineedit.h b/client/widgets/lineedit.h index 3deb3d1..3f0bb17 100644 --- a/client/widgets/lineedit.h +++ b/client/widgets/lineedit.h @@ -40,6 +40,8 @@ public: QString getValue(); void setValue(QString value); + void enable(); + void disable(); public slots: void changed(); diff --git a/client/widgets/widget.cc b/client/widgets/widget.cc index dafe4b7..efba31c 100644 --- a/client/widgets/widget.cc +++ b/client/widgets/widget.cc @@ -84,3 +84,11 @@ bool Widget::luaValidator() return macrowindow->lua->run(luaprogram, getName(), getValue()); } + +void Widget::disable() +{ +} + +void Widget::enable() +{ +} diff --git a/client/widgets/widget.h b/client/widgets/widget.h index cba6be9..9b6a996 100644 --- a/client/widgets/widget.h +++ b/client/widgets/widget.h @@ -41,6 +41,8 @@ public: virtual QString getValue(); virtual void setValue(QString value); virtual bool isValid(); + virtual void disable(); + virtual void enable(); QString getName(); protected: diff --git a/client/widgets/window.cc b/client/widgets/window.cc index b2b4298..c4d8d14 100644 --- a/client/widgets/window.cc +++ b/client/widgets/window.cc @@ -64,6 +64,8 @@ Window::Window(QDomNode &node, MacroWindow *macrowindow) setLayout(layout); } } + + setContentsMargins(0,0,0,0); } QString Window::getValue() |