diff options
author | Olli Werwolff <qt-info@nokia.com> | 2011-04-28 13:28:47 +0200 |
---|---|---|
committer | Olli Werwolff <qt-info@nokia.com> | 2011-04-28 13:51:19 +0200 |
commit | 02d54472cb86424faaab4ddef27ef306037fc5e4 (patch) | |
tree | 0fc5d1bc72e047ba7680f28ebe83c5ae64572b53 | |
parent | fdaec3b650f3b2a89a43ba280731842bd4dd0ec5 (diff) |
Expand categories when according button is clicked
Reviewed-by: ckamm
-rw-r--r-- | library/remotecontrolwidget.cpp | 15 | ||||
-rw-r--r-- | library/remotecontrolwidget.h | 2 | ||||
-rw-r--r-- | library/toolbox.cpp | 20 | ||||
-rw-r--r-- | library/toolbox.h | 7 |
4 files changed, 23 insertions, 21 deletions
diff --git a/library/remotecontrolwidget.cpp b/library/remotecontrolwidget.cpp index fe5dabe..cd444b1 100644 --- a/library/remotecontrolwidget.cpp +++ b/library/remotecontrolwidget.cpp @@ -161,7 +161,6 @@ void RemoteControlWidget::addMenuOption(const QString &title, QWidget *target, P pageState->action = action; action->setText(title); action->setCheckable(true); - connect(action, SIGNAL(triggered(bool)), target, SLOT(setVisible(bool))); mMainMenu->addAction(action); // MasterButton Part @@ -173,15 +172,14 @@ void RemoteControlWidget::addMenuOption(const QString &title, QWidget *target, P toolButton->setText(title); toolButton->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Maximum); toolButton->setCheckable(true); - target->setVisible(false); connect(toolButton, SIGNAL(toggled(bool)), action, SLOT(setChecked(bool))); connect(action, SIGNAL(triggered(bool)), toolButton, SLOT(setChecked(bool))); - connect(toolButton, SIGNAL(toggled(bool)), target, SLOT(setVisible(bool))); + connect(toolButton, SIGNAL(toggled(bool)), target, SLOT(showAndOpen(bool))); count++; - connect(target, SIGNAL(hidden(bool)), action, SLOT(setChecked(bool))); - connect(target, SIGNAL(hidden(bool)), toolButton, SLOT(setChecked(bool))); - connect(target, SIGNAL(visible()), this, SLOT(pageGotVisible())); + connect(target, SIGNAL(visibilityChanged(bool)), action, SLOT(setChecked(bool))); + connect(target, SIGNAL(visibilityChanged(bool)), toolButton, SLOT(setChecked(bool))); + connect(target, SIGNAL(visibilityChanged(bool)), this, SLOT(showPage(bool))); } void RemoteControlWidget::addPage(ToolBoxPage *page) @@ -285,8 +283,11 @@ void RemoteControlWidget::initializeMenuArea() addPage(new MenuUi(mButtonBox, this)); } -void RemoteControlWidget::pageGotVisible() +void RemoteControlWidget::showPage(bool visible) { + if (!visible) + return; + QWidget *widget = qobject_cast<QWidget *>(sender()); if (!widget) return; diff --git a/library/remotecontrolwidget.h b/library/remotecontrolwidget.h index f27b0ef..62b8d9b 100644 --- a/library/remotecontrolwidget.h +++ b/library/remotecontrolwidget.h @@ -67,7 +67,7 @@ public: private slots: void changeFilters(); - void pageGotVisible(); + void showPage(bool visibile); private: struct PageState { diff --git a/library/toolbox.cpp b/library/toolbox.cpp index 98788a5..d5df1e9 100644 --- a/library/toolbox.cpp +++ b/library/toolbox.cpp @@ -101,7 +101,7 @@ ToolBoxPage::ToolBoxPage(QWidget *parent) mCloseButton = new QToolButton; mCloseButton->setText("x"); mCloseButton->setStyle(mManhattanStyle); - connect(mCloseButton, SIGNAL(clicked()), this, SLOT(wantClose())); + connect(mCloseButton, SIGNAL(clicked()), this, SLOT(closePage())); mHeaderLayout->addWidget(mCloseButton); mPage = new QWidget(this); @@ -111,8 +111,7 @@ ToolBoxPage::ToolBoxPage(QWidget *parent) mInnerLayout->setFieldGrowthPolicy(QFormLayout::AllNonFixedFieldsGrow); mInnerLayout->setLabelAlignment(Qt::AlignLeft); mPage->setLayout(mInnerLayout); - mPage->show(); - showContent(true); + vLayout->addWidget(mPage); } ToolBoxPage::~ToolBoxPage() @@ -366,10 +365,10 @@ void ToolBoxPage::toggleAdvanced(OptionsItem *item) } } -void ToolBoxPage::wantClose() +void ToolBoxPage::closePage() { hide(); - emit hidden(false); + emit visibilityChanged(false); } bool ToolBoxPage::isContentVisible() const @@ -411,9 +410,12 @@ void ToolBoxPage::writeSettings(QSettings &settings) const settings.endGroup(); } -void ToolBoxPage::setVisible(bool state) +void ToolBoxPage::showAndOpen(bool show) { - QFrame::setVisible(state); - if (state == true) - emit visible(); + if (show == isVisible()) + return; + + setVisible(show); + showContent(show); + emit visibilityChanged(show); } diff --git a/library/toolbox.h b/library/toolbox.h index 3f14805..a5e038f 100644 --- a/library/toolbox.h +++ b/library/toolbox.h @@ -73,7 +73,7 @@ public: virtual void writeSettings(QSettings &) const; public slots: - void setVisible(bool); + void showAndOpen(bool show); protected: bool isContentVisible() const; @@ -117,12 +117,11 @@ private slots: void toggleAdvanced(OptionsItem *item); void toggleOpenExplicitly(); void setAdvanced(bool advanced); - void wantClose(); + void closePage(); signals: void minimalInputWidthChanged(int newWidth); - void hidden(bool)const; - void visible()const; + void visibilityChanged(bool visible) const; }; #endif //TOOLBOX_H |