From 355772289f57522157759b6150ebfd2cc849c0ae Mon Sep 17 00:00:00 2001 From: deva Date: Mon, 22 Sep 2008 12:21:14 +0000 Subject: Made the client use the static attribute to set a macro always visible, non-collapsable. Made the macro widgetlist clear itself when loading a new macro. --- client/macrowindow.cc | 13 ++++++++++--- client/macrowindow.h | 2 +- client/mainwindow.cc | 26 ++++++++++++++++---------- 3 files changed, 27 insertions(+), 14 deletions(-) (limited to 'client') diff --git a/client/macrowindow.cc b/client/macrowindow.cc index 6a20632..3161ce6 100644 --- a/client/macrowindow.cc +++ b/client/macrowindow.cc @@ -44,16 +44,18 @@ extern QString user; extern QString host; extern quint16 port; -MacroWindow::MacroWindow(NetCom &n, QDomNode &xml_doc, QString course) +MacroWindow::MacroWindow(NetCom &n, QDomNode &xml_doc, QString course, bool collapsed) : Collapser(), netcom(n) { this->course = course; - mainwidget = NULL; - setCollapsedWidget(new QLabel("Empty")); + + setCollapsedWidget(new QLabel("")); this->lua = new LUA(this); update(xml_doc); + + setCollapsed(collapsed); } MacroWindow::~MacroWindow() @@ -69,6 +71,11 @@ void MacroWindow::update(QDomNode &node) // mainwidget = new QLabel("Expanded"); // resumewidget = new QLabel("Collapsed"); + mainwidget = NULL; + + widgets.clear(); + auxwidgets.clear(); + initMacro(node); if(mainwidget) setExpandedWidget(mainwidget); diff --git a/client/macrowindow.h b/client/macrowindow.h index 4e040da..3100a5d 100644 --- a/client/macrowindow.h +++ b/client/macrowindow.h @@ -46,7 +46,7 @@ class MacroWindow : public Collapser { Q_OBJECT public: - MacroWindow(NetCom &netcom, QDomNode &xml_doc, QString course); + MacroWindow(NetCom &netcom, QDomNode &xml_doc, QString course, bool collapsed = true); ~MacroWindow(); bool isClosed(); diff --git a/client/mainwindow.cc b/client/mainwindow.cc index 50ca8a9..efd4c31 100644 --- a/client/mainwindow.cc +++ b/client/mainwindow.cc @@ -80,20 +80,24 @@ void MainWindow::update() if(xml_elem.hasAttribute("name")) macroname = xml_elem.attribute("name"); if(macros.find(macroname) == macros.end()) { - macros[macroname] = new MacroWindow(netcom, macronode, course); - + bool isstatic = false; + if(xml_elem.attribute("static", "false") == "true") isstatic = true; + macros[macroname] = new MacroWindow(netcom, macronode, course, !isstatic); + QGroupBox *g = new QGroupBox(" " + xml_elem.attribute("caption", macroname)); g->setCheckable(false); g->setChecked(false); + ((QBoxLayout*)w->layout())->addWidget(g); - QPushButton *b = new QPushButton(">>", g); - b->setFixedSize(16,16); - b->show(); - b->move(0,0); + if(!isstatic) { + QPushButton *b = new QPushButton(">>", g); + b->setFixedSize(16,16); + b->show(); + b->move(0,0); - connect(b, SIGNAL(clicked()), this, SLOT(closeAll())); - connect(b, SIGNAL(clicked()), macros[macroname], SLOT(toggleMacro())); - ((QBoxLayout*)w->layout())->addWidget(g); + connect(b, SIGNAL(clicked()), this, SLOT(closeAll())); + connect(b, SIGNAL(clicked()), macros[macroname], SLOT(toggleMacro())); + } QHBoxLayout *l = new QHBoxLayout(); l->setContentsMargins(10,0,10,0); @@ -105,7 +109,9 @@ void MainWindow::update() } else { macros[macroname]->update(macronode); - macros[macroname]->setCollapsed(true); + if(xml_elem.attribute("static", "false") == "false") { + macros[macroname]->setCollapsed(true); + } } } -- cgit v1.2.3