Fixed issue #479. Improve feature: The Preferences dialog box should be expandable.

--HG--
branch : feature
This commit is contained in:
BojanKverh 2016-06-09 13:16:04 +02:00
parent 15c99de75e
commit 98b232930f
2 changed files with 40 additions and 4 deletions

View file

@ -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;

View file

@ -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();