From 98b232930fdfe991b4be461d1569b5f38c94f4cf Mon Sep 17 00:00:00 2001 From: BojanKverh Date: Thu, 9 Jun 2016 13:16:04 +0200 Subject: [PATCH] Fixed issue #479. Improve feature: The Preferences dialog box should be expandable. --HG-- branch : feature --- src/app/valentina/dialogs/configdialog.cpp | 36 +++++++++++++++++++--- src/app/valentina/dialogs/configdialog.h | 8 +++++ 2 files changed, 40 insertions(+), 4 deletions(-) diff --git a/src/app/valentina/dialogs/configdialog.cpp b/src/app/valentina/dialogs/configdialog.cpp index bc88e25d0..8d41f0a59 100644 --- a/src/app/valentina/dialogs/configdialog.cpp +++ b/src/app/valentina/dialogs/configdialog.cpp @@ -87,14 +87,20 @@ ConfigDialog::ConfigDialog(QWidget *parent) : QVBoxLayout *mainLayout = new QVBoxLayout; mainLayout->addLayout(horizontalLayout); - mainLayout->addStretch(1); - mainLayout->addSpacing(12); + //mainLayout->addStretch(1); + //mainLayout->addSpacing(12); mainLayout->addLayout(buttonsLayout); + mainLayout->setStretch(0, 1); setLayout(mainLayout); setWindowTitle(tr("Config Dialog")); qApp->Settings()->GetOsSeparator() ? setLocale(QLocale::system()) : setLocale(QLocale(QLocale::C)); + + if (s_iLastWidth > 0 && s_iLastHeight > 0) + { + resize(s_iLastWidth, s_iLastHeight); + } } //--------------------------------------------------------------------------------------------------------------------- @@ -145,12 +151,29 @@ void ConfigDialog::showEvent(QShowEvent *event) } // do your init stuff here - setMaximumSize(size()); - setMinimumSize(size()); + //setMaximumSize(size()); + if (s_iMinWidth > 0 && s_iMinHeight > 0) + { + setMinimumSize(s_iMinWidth, s_iMinHeight); + } + else + { + setMinimumSize(size()); + s_iMinWidth = width(); + s_iMinHeight = height(); + } isInitialized = true;//first show windows are held } +//--------------------------------------------------------------------------------------------------------------------- +void ConfigDialog::resizeEvent(QResizeEvent *) +{ + // remember the size for the next time this dialog is opened + s_iLastWidth = width(); + s_iLastHeight = height(); +} + //--------------------------------------------------------------------------------------------------------------------- void ConfigDialog::createIcons() { @@ -217,3 +240,8 @@ void ConfigDialog::RetranslateUi() contentsWidget->item(3)->setText(tr("Paths")); } +//--------------------------------------------------------------------------------------------------------------------- +int ConfigDialog::s_iLastWidth = 0; +int ConfigDialog::s_iLastHeight = 0; +int ConfigDialog::s_iMinWidth = 0; +int ConfigDialog::s_iMinHeight = 0; diff --git a/src/app/valentina/dialogs/configdialog.h b/src/app/valentina/dialogs/configdialog.h index bb1932032..f7d8b5e1f 100644 --- a/src/app/valentina/dialogs/configdialog.h +++ b/src/app/valentina/dialogs/configdialog.h @@ -49,6 +49,7 @@ protected: virtual void closeEvent(QCloseEvent *event) Q_DECL_OVERRIDE; virtual void changeEvent(QEvent* event) Q_DECL_OVERRIDE; virtual void showEvent(QShowEvent *event) Q_DECL_OVERRIDE; + virtual void resizeEvent(QResizeEvent *) Q_DECL_OVERRIDE; private: Q_DISABLE_COPY(ConfigDialog) QListWidget *contentsWidget; @@ -61,6 +62,13 @@ private: QPushButton *cancelButton; QPushButton *okButton; bool isInitialized; + // the following static variables are used to preserve the dialog size when it + // is opened again and to hold the minimum size (which will be determined when + // the dialog is opened for the first time) + static int s_iLastWidth; + static int s_iLastHeight; + static int s_iMinWidth; + static int s_iMinHeight; void createIcons(); void createIcon(const QString &icon, const QString &text); void Apply();