ConfigDialog: allow changing page by QWidget*
authorPaulo Lieuthier <paulolieuthier@gmail.com>
Fri, 17 Apr 2015 19:50:48 +0000 (16:50 -0300)
committerPaulo Lieuthier <paulolieuthier@gmail.com>
Fri, 17 Apr 2015 19:52:47 +0000 (16:52 -0300)
configdialog/lxqtconfigdialog.cpp
configdialog/lxqtconfigdialog.h

index 53788bc..df443cf 100644 (file)
@@ -60,8 +60,10 @@ void ConfigDialog::addPage(QWidget* page, const QString& name, const QStringList
     {
         ui->moduleList->setVisible(true);
         ui->moduleList->setCurrentRow(0);
-        mMaxSize = QSize(qMax(page->geometry().width() + ui->moduleList->geometry().width(), mMaxSize.width()),
-                         qMax(page->geometry().height() + ui->buttons->geometry().height(), mMaxSize.height()));
+        mMaxSize = QSize(qMax(page->geometry().width() + ui->moduleList->geometry().width(),
+                              mMaxSize.width()),
+                         qMax(page->geometry().height() + ui->buttons->geometry().height(),
+                              mMaxSize.height()));
     }
     else
     {
@@ -70,6 +72,16 @@ void ConfigDialog::addPage(QWidget* page, const QString& name, const QStringList
     resize(mMaxSize);
 }
 
+void ConfigDialog::showPage(QWidget* page)
+{
+    int index = ui->stackedWidget->indexOf(page);
+    if (index < 0)
+        return;
+
+    ui->stackedWidget->setCurrentIndex(index);
+    ui->moduleList->setCurrentRow(index);
+}
+
 void ConfigDialog::closeEvent(QCloseEvent* event)
 {
     emit save();
index ab53972..8095ae1 100644 (file)
@@ -55,6 +55,11 @@ public:
      */
     void addPage(QWidget* page, const QString& name, const QStringList& iconNames);
 
+    /*!
+     * Show page containing the widget in parameter
+     */
+    void showPage(QWidget *page);
+
 signals:
     /*!
      * This signal is emitted when the user pressed the "Reset" button.