diff options
Diffstat (limited to 'client')
-rw-r--r-- | client/collapser.cc | 42 | ||||
-rw-r--r-- | client/collapser.h | 2 | ||||
-rw-r--r-- | client/macrowindow.cc | 51 | ||||
-rw-r--r-- | client/macrowindow.h | 1 |
4 files changed, 72 insertions, 24 deletions
diff --git a/client/collapser.cc b/client/collapser.cc index 6ae9d21..81c9b23 100644 --- a/client/collapser.cc +++ b/client/collapser.cc @@ -31,8 +31,8 @@ #include "debug.h" -#define ANIM_TIME 2000 -#define ANIM_INTERVAL 20 +#define ANIM_TIME 400 // ms +#define ANIM_INTERVAL 5 // ms Collapser::Collapser(QWidget *collapsed, QWidget *expanded, bool setcollapsed, QScrollArea *scrollarea) @@ -56,59 +56,71 @@ Collapser::Collapser(QWidget *collapsed, QWidget *expanded, bool setcollapsed, setCollapsed(setcollapsed); } +void Collapser::updateHeight() +{ + int c_height = 16; + int e_height = 16; + if(collapsed) { + QSize sz = collapsed->minimumSizeHint(); + c_height = sz.height(); + } + + if(expanded) { + QSize sz = expanded->minimumSizeHint(); + e_height = sz.height(); + } + + if(isCollapsed()) { + setFixedHeight(c_height); + } else { + setFixedHeight(e_height); + } +} + void Collapser::setWidgets(QWidget *collapsed, QWidget *expanded) { - DEBUG(collapser, "\n"); setCollapsedWidget(collapsed); setExpandedWidget(expanded); } void Collapser::setCollapsedWidget(QWidget *collapsed) { - DEBUG(collapser, "\n"); this->collapsed = collapsed; - /* + if(isCollapsed() == true && collapsed) { layout()->addWidget(collapsed); collapsed->setVisible(true); } - */ } void Collapser::setExpandedWidget(QWidget *expanded) { - DEBUG(collapser, "\n"); this->expanded = expanded; - /* + if(isCollapsed() == false && expanded) { layout()->addWidget(expanded); expanded->setVisible(true); } - */ } QWidget *Collapser::collapsedWidget() { - DEBUG(collapser, "\n"); return collapsed; } QWidget *Collapser::expandedWidget() { - DEBUG(collapser, "\n"); return expanded; } bool Collapser::isCollapsed() { - DEBUG(collapser, "\n"); return is_collapsed; } void Collapser::setCollapsed(bool setcollapsed) { - DEBUG(collapser, "\n"); if(this->is_collapsed == setcollapsed) return; if(setcollapsed) collapse(); @@ -117,7 +129,6 @@ void Collapser::setCollapsed(bool setcollapsed) void Collapser::collapse() { - DEBUG(collapser, "\n"); emit collapsing(); t_anim.start(); @@ -139,7 +150,6 @@ void Collapser::collapse() void Collapser::expand() { - DEBUG(collapser, "\n"); emit expanding(); t_anim.start(); @@ -164,14 +174,12 @@ void Collapser::expand() void Collapser::toggleCollapse() { - DEBUG(collapser, "\n"); if(!is_collapsed) collapse(); else expand(); } void Collapser::anim() { - DEBUG(collapser, "\n"); int c_height = 16; int e_height = 16; if(collapsed) { diff --git a/client/collapser.h b/client/collapser.h index 9702351..27d0810 100644 --- a/client/collapser.h +++ b/client/collapser.h @@ -51,6 +51,8 @@ public: void setCollapsedWidget(QWidget *collapsed); void setExpandedWidget(QWidget *expanded); + void updateHeight(); + public slots: void collapse(); void expand(); diff --git a/client/macrowindow.cc b/client/macrowindow.cc index 04cc2cb..16f86f9 100644 --- a/client/macrowindow.cc +++ b/client/macrowindow.cc @@ -79,13 +79,49 @@ MacroWindow::~MacroWindow() void MacroWindow::update(QDomNode &node) { - clear(); - lua->clear(); + if(is_static || mainwidget == NULL) { + clear(); + lua->clear(); - initMacro(node); + initMacro(node); + + if(mainwidget) setExpandedWidget(mainwidget->qwidget()); + else setExpandedWidget(NULL); + } + + updateResume(node); +} + +void MacroWindow::updateResume(QDomNode &node) +{ + QDomElement elem = node.toElement(); + + if(elem.tagName() == "resume") { + QString resume = elem.text(); + ResumeWidget::state_t state = ResumeWidget::OLD; + if(elem.hasAttribute("state")) { + if(elem.attribute("state") == "old") state = ResumeWidget::OLD; + if(elem.attribute("state") == "new") state = ResumeWidget::NEW; + if(elem.attribute("state") == "dirty") state = ResumeWidget::DIRTY; + } + /* + if(!mainwidget) { // Only call collapse if the macro is in resume state. + collapse(); + } + */ + ((ResumeWidget*)collapsedWidget())->setText(resume, state); + updateHeight(); + + return; + } + + QDomNodeList children = node.childNodes(); + + for (int i=0; i<children.count();i++) { + QDomNode child = children.at(i); + updateResume(child); + } - if(mainwidget) setExpandedWidget(mainwidget->qwidget()); - else setExpandedWidget(NULL); } void MacroWindow::initMacro(QDomNode &node) @@ -101,6 +137,7 @@ void MacroWindow::initMacro(QDomNode &node) } else if(elem.tagName() == "scripts") { // Nothing to do here } else if(elem.tagName() == "resume") { + /* // Handled in updateResume QString resume = elem.text(); ResumeWidget::state_t state = ResumeWidget::OLD; if(elem.hasAttribute("state")) { @@ -110,11 +147,11 @@ void MacroWindow::initMacro(QDomNode &node) } if(!mainwidget) { // Only call collapse if the macro is in resume state. - collapse(); + //collapse(); } ((ResumeWidget*)collapsedWidget())->setText(resume, state); - + */ } else if(elem.tagName() == "script") { lua->runScript(elem.text(), NULL, "preload"); diff --git a/client/macrowindow.h b/client/macrowindow.h index a41af01..28fc172 100644 --- a/client/macrowindow.h +++ b/client/macrowindow.h @@ -74,6 +74,7 @@ private slots: private: void initMacro(QDomNode &node); + void updateResume(QDomNode &node); bool doCommit(); |