From db2fdbe872cc6c1b224a1c4c735fac4369b3802e Mon Sep 17 00:00:00 2001 From: deva Date: Fri, 13 Aug 2010 08:24:46 +0000 Subject: Add missing children widgets to actual layouts. --- client/macrowindow.cc | 7 +------ client/widgets/altcombobox.cc | 8 +++++++- client/widgets/frame.cc | 2 +- client/widgets/groupbox.cc | 2 +- client/widgets/metawidget.cc | 5 ++++- client/widgets/multilist.cc | 2 +- client/widgets/widget.cc | 14 ++++++-------- client/widgets/widget.h | 5 +++-- client/widgets/window.cc | 2 +- 9 files changed, 25 insertions(+), 22 deletions(-) diff --git a/client/macrowindow.cc b/client/macrowindow.cc index 38e466d..c439497 100644 --- a/client/macrowindow.cc +++ b/client/macrowindow.cc @@ -101,13 +101,8 @@ void MacroWindow::initMacro(QDomNode &node) ((ResumeWidget*)collapsedWidget())->setText(resume, state); } else if(xml_elem.tagName() == "script") { - if(xml_elem.hasAttribute("language") && - xml_elem.attribute("language") == "lua") { - // luaprograms.push_back(xml_elem.text()); + if(xml_elem.attribute("language", "lua") == "lua") { this->lua->runScript(xml_elem.text(), NULL, "preload"); - } else { - printf("Unknown script type %s\n", - xml_elem.attribute("language").toStdString().c_str()); } } else if(xml_elem.tagName() == "widgets") { diff --git a/client/widgets/altcombobox.cc b/client/widgets/altcombobox.cc index 66eb444..a4f5e76 100644 --- a/client/widgets/altcombobox.cc +++ b/client/widgets/altcombobox.cc @@ -97,7 +97,7 @@ AltComboBox::AltComboBox(QDomNode &node, MacroWindow *macrowindow) altframe->setLayout(layout); } - addChildren(item); + addChildren(item, altframe->layout()); } @@ -177,7 +177,13 @@ void AltComboBox::setValue(QString value, QString source) void AltComboBox::onValueChange(int index) { + QComboBox *cmb = (QComboBox*)combobox->qwidget(); + + printf("Value changed: %s altvalue: %s\n", + cmb->itemData(index).toString().toStdString().c_str(), + altvalue.toStdString().c_str()); + if(cmb->itemData(index).toString() == altvalue) { // altframe->setEnabled(true); altframerepl->setVisible(false); diff --git a/client/widgets/frame.cc b/client/widgets/frame.cc index e117467..d6f8187 100644 --- a/client/widgets/frame.cc +++ b/client/widgets/frame.cc @@ -43,7 +43,7 @@ Frame::Frame(QDomNode &node, MacroWindow *macrowindow) frame->layout()->setContentsMargins(0,0,0,0); - addChildren(node); + addChildren(node, frame->layout()); } Frame::~Frame() diff --git a/client/widgets/groupbox.cc b/client/widgets/groupbox.cc index 085a876..3c00fa4 100644 --- a/client/widgets/groupbox.cc +++ b/client/widgets/groupbox.cc @@ -49,7 +49,7 @@ GroupBox::GroupBox(QDomNode &node, MacroWindow *macrowindow) groupbox->setTitle(elem.attribute("caption")); } - addChildren(node); + addChildren(node, groupbox->layout()); } GroupBox::~GroupBox() diff --git a/client/widgets/metawidget.cc b/client/widgets/metawidget.cc index 9634c76..ff359f4 100644 --- a/client/widgets/metawidget.cc +++ b/client/widgets/metawidget.cc @@ -50,12 +50,15 @@ MetaWidget::MetaWidget(QDomNode &node, MacroWindow *macrowindow) QDomElement elem = node.toElement(); storechildren = elem.attribute("storechildren", "false") == "true"; + /* // Create children QDomNodeList children = node.childNodes(); for (int i=0; ilayout()); // Connect all children wasChanged signal, to catch changes. QVector< Widget* >::iterator i = widgets.begin(); diff --git a/client/widgets/multilist.cc b/client/widgets/multilist.cc index 2c4438f..cccad5a 100644 --- a/client/widgets/multilist.cc +++ b/client/widgets/multilist.cc @@ -95,7 +95,7 @@ MultiList::MultiList(QDomNode &node, MacroWindow *macrowindow) inputbox->layout()->setContentsMargins(0,0,0,0); - addChildren(node); + addChildren(node, inputbox->layout()); innerwidget = NULL; if(elem.hasAttribute("innerwidget")) { diff --git a/client/widgets/widget.cc b/client/widgets/widget.cc index 2205beb..93deb31 100644 --- a/client/widgets/widget.cc +++ b/client/widgets/widget.cc @@ -90,12 +90,12 @@ Widget::~Widget() } } -void Widget::addChildren(QDomNode &node) +void Widget::addChildren(QDomNode &node, QLayout *layout) { QDomNodeList children = node.childNodes(); for (int i=0; ilayout()) { - ((QBoxLayout*)qwidget()->layout())->addStretch(); - } + if(layout) ((QBoxLayout*)layout)->addStretch(); + return; // This is not a real widget. } else if(xml_elem.tagName() == "frame") { @@ -333,8 +332,7 @@ void Widget::widgetBuilder(QDomNode &xml_node) addChild(widget); - if(qwidget() && qwidget()->layout()) - qwidget()->layout()->addWidget(widget->qwidget()); + if(layout) layout->addWidget(widget->qwidget()); if(widget && widget->qwidget()) widget->qwidget()->show(); } diff --git a/client/widgets/widget.h b/client/widgets/widget.h index 9e493d0..960dca9 100644 --- a/client/widgets/widget.h +++ b/client/widgets/widget.h @@ -35,6 +35,7 @@ #include "lua.h" +class QLayout; class MacroWindow; class LUA; class Widget; @@ -95,8 +96,8 @@ protected: QWidget *widget; bool hideChildren; - void widgetBuilder(QDomNode &xml_node); - void addChildren(QDomNode &xml_node); + void widgetBuilder(QDomNode &xml_node, QLayout *layout); + void addChildren(QDomNode &xml_node, QLayout *layout); private: QVector< Widget* > children; diff --git a/client/widgets/window.cc b/client/widgets/window.cc index f51cfd9..4d9253d 100644 --- a/client/widgets/window.cc +++ b/client/widgets/window.cc @@ -55,7 +55,7 @@ Window::Window(QDomNode &node, MacroWindow *macrowindow) widget->setWindowTitle(elem.attribute("caption")); } - addChildren(node); + addChildren(node, widget->layout()); } Window::~Window() -- cgit v1.2.3