summaryrefslogtreecommitdiff
path: root/client/widgets
diff options
context:
space:
mode:
Diffstat (limited to 'client/widgets')
-rw-r--r--client/widgets/altcombobox.cc7
-rw-r--r--client/widgets/combobox.cc12
-rw-r--r--client/widgets/widget.cc19
-rw-r--r--client/widgets/widget.h4
4 files changed, 30 insertions, 12 deletions
diff --git a/client/widgets/altcombobox.cc b/client/widgets/altcombobox.cc
index b5cdab0..fac2610 100644
--- a/client/widgets/altcombobox.cc
+++ b/client/widgets/altcombobox.cc
@@ -126,7 +126,7 @@ AltComboBox::AltComboBox(QDomNode &node, MacroWindow *macrowindow)
connect(innerwidget, SIGNAL(wasChanged()), this, SLOT(onChildChange()));
frame->layout()->setContentsMargins(0,0,0,0);
- //altframe->layout()->setContentsMargins(0,0,0,0);
+ altframe->layout()->setContentsMargins(0,0,0,0);
frame->show(); // Force altframe to get resized to its real size.
altframerepl->setFixedHeight(altframe->height());
@@ -181,7 +181,6 @@ void AltComboBox::setValue(QString value, QString source)
void AltComboBox::onValueChange(int index)
{
-
QComboBox *cmb = (QComboBox*)combobox->qwidget();
DEBUG(alcombobox, "Value changed: %s altvalue: %s\n",
@@ -203,6 +202,8 @@ void AltComboBox::onValueChange(int index)
frame->layout()->addWidget(altframerepl);
altframerepl->setVisible(true);
}
+
+ eventOnChange(true);
}
void AltComboBox::onValueChange(const QString &text)
@@ -214,7 +215,7 @@ void AltComboBox::onValueChange(const QString &text)
void AltComboBox::onChildChange()
{
emit wasChanged();
- eventOnChange();
+ eventOnChange(true);
}
bool AltComboBox::setKeyboardFocus()
diff --git a/client/widgets/combobox.cc b/client/widgets/combobox.cc
index ea8a239..de521ba 100644
--- a/client/widgets/combobox.cc
+++ b/client/widgets/combobox.cc
@@ -168,11 +168,13 @@ void ComboBox::setValue(QString value, QString source)
int idx = combobox->findData(value);
// printf("setValue(\"%s\") - %d\n", value.toStdString().c_str(), idx);
-
- ischangingbyuser = false;
- combobox->setCurrentIndex(idx);
- ischangingbyuser = true;
-
+ if(combobox->currentIndex() != idx) {
+ ischangingbyuser = false;
+ combobox->setCurrentIndex(idx);
+ ischangingbyuser = true;
+ } else {
+ eventOnChange(true);
+ }
// setInitialValue(value);
}
diff --git a/client/widgets/widget.cc b/client/widgets/widget.cc
index 9ebed55..cc74553 100644
--- a/client/widgets/widget.cc
+++ b/client/widgets/widget.cc
@@ -112,6 +112,7 @@ bool Widget::local()
bool Widget::valid(bool deep)
{
if(enabled() == false) return true;
+ if(visible() == false) return true;
if(preValid() == false) return false;
if(is_valid == false) return false;
@@ -139,10 +140,18 @@ void Widget::setValid(bool valid)
}
}
-void Widget::eventOnChange()
+void Widget::eventOnChange(bool deep)
{
if(enabled() && hasOnChangeEvent)
lua->runScript(onChangeEventScript, this, "onChange");
+
+ if(!deep) return;
+
+ QVector< Widget* >::iterator i = children.begin();
+ while(i != children.end()) {
+ if(*i) (*i)->eventOnChange(deep);
+ i++;
+ }
}
void Widget::setEnabled(bool enabled)
@@ -153,7 +162,7 @@ void Widget::setEnabled(bool enabled)
QVector< Widget* >::iterator i = children.begin();
while(i != children.end()) {
- if(*i) (*i)->setEnabled(enabled);
+ if(*i) (*i)->eventOnChange(true);
i++;
}
@@ -168,6 +177,12 @@ void Widget::setVisible(bool visible)
{
widget->setVisible(visible);
if(visible) eventOnChange();
+
+ QVector< Widget* >::iterator i = children.begin();
+ while(i != children.end()) {
+ if(*i) (*i)->eventOnChange(true);
+ i++;
+ }
}
bool Widget::visible()
diff --git a/client/widgets/widget.h b/client/widgets/widget.h
index d172543..99b9479 100644
--- a/client/widgets/widget.h
+++ b/client/widgets/widget.h
@@ -88,7 +88,7 @@ protected:
/*
* LUA scripting events:
*/
- void eventOnChange();
+ void eventOnChange(bool deep = false);
QWidget *widget;
bool hideChildren;
@@ -98,8 +98,8 @@ protected:
LUA *lua;
private:
- QVector< Widget* > children;
void createWidget(QDomNode &xml_node, QLayout *layout);
+ QVector< Widget* > children;
// Store value in constructor to be set later.
bool has_lazy;