Fixed issue #479. Improve feature: The Preferences dialog box in Valentina and Tape should be expandable.

--HG--
branch : feature
This commit is contained in:
BojanKverh 2016-06-10 21:34:21 +02:00
parent 1738972c85
commit 96b2d28604
7 changed files with 54 additions and 35 deletions

View File

@ -1,5 +1,5 @@
# Version 0.5.0
- [#479] Preferences dialog is now extendable and when it is opened again, it will be resized to its previous size
- [#479] Preferences dialog is now extendable and when it is opened again, it will be resized to its previous size.
- [#193] Undeletable zombie arc objects.
- New feature. Groups.
- Tool "Curve intersect axis" store data about subpaths.

View File

@ -147,12 +147,30 @@ void TapeConfigDialog::showEvent(QShowEvent *event)
}
// do your init stuff here
setMaximumSize(size());
setMinimumSize(size());
QSize sz = qApp->Settings()->GetPreferenceDialogSize();
if (sz.isEmpty() == false)
{
resize(sz);
}
isInitialized = true;//first show windows are held
}
//---------------------------------------------------------------------------------------------------------------------
void TapeConfigDialog::resizeEvent(QResizeEvent *event)
{
Q_UNUSED(event);
// remember the size for the next time this dialog is opened, but only
// if widget was already initialized, which rules out the resize at
// dialog creating, which would
if (isInitialized == true)
{
qApp->Settings()->SetPreferenceDialogSize(size());
}
}
//---------------------------------------------------------------------------------------------------------------------
void TapeConfigDialog::createIcons()
{

View File

@ -50,6 +50,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 *event) Q_DECL_OVERRIDE;
private:
Q_DISABLE_COPY(TapeConfigDialog)
QListWidget *contentsWidget;

View File

@ -87,8 +87,7 @@ ConfigDialog::ConfigDialog(QWidget *parent) :
QVBoxLayout *mainLayout = new QVBoxLayout;
mainLayout->addLayout(horizontalLayout);
//mainLayout->addStretch(1);
//mainLayout->addSpacing(12);
mainLayout->addSpacing(12);
mainLayout->addLayout(buttonsLayout);
mainLayout->setStretch(0, 1);
setLayout(mainLayout);
@ -96,11 +95,6 @@ ConfigDialog::ConfigDialog(QWidget *parent) :
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);
}
}
//---------------------------------------------------------------------------------------------------------------------
@ -151,27 +145,28 @@ void ConfigDialog::showEvent(QShowEvent *event)
}
// do your init stuff here
//setMaximumSize(size());
if (s_iMinWidth > 0 && s_iMinHeight > 0)
{
setMinimumSize(s_iMinWidth, s_iMinHeight);
}
else
{
setMinimumSize(size());
s_iMinWidth = width();
s_iMinHeight = height();
QSize sz = qApp->Settings()->GetPreferenceDialogSize();
if (sz.isEmpty() == false)
{
resize(sz);
}
isInitialized = true;//first show windows are held
}
//---------------------------------------------------------------------------------------------------------------------
void ConfigDialog::resizeEvent(QResizeEvent *)
void ConfigDialog::resizeEvent(QResizeEvent *event)
{
// remember the size for the next time this dialog is opened
s_iLastWidth = width();
s_iLastHeight = height();
Q_UNUSED(event);
// remember the size for the next time this dialog is opened, but only
// if widget was already initialized, which rules out the resize at
// dialog creating, which would
if (isInitialized == true)
{
qApp->Settings()->SetPreferenceDialogSize(size());
}
}
//---------------------------------------------------------------------------------------------------------------------
@ -240,8 +235,3 @@ 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,7 +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;
virtual void resizeEvent(QResizeEvent *event) Q_DECL_OVERRIDE;
private:
Q_DISABLE_COPY(ConfigDialog)
QListWidget *contentsWidget;
@ -62,13 +62,6 @@ 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();

View File

@ -64,6 +64,7 @@ const QString VCommonSettings::SettingGeneralRestoreFileList = QString
const QString VCommonSettings::SettingGeneralGeometry = QStringLiteral("geometry");
const QString VCommonSettings::SettingGeneralWindowState = QStringLiteral("windowState");
const QString VCommonSettings::SettingGeneralToolbarsState = QStringLiteral("toolbarsState");
const QString VCommonSettings::SettingPreferenceDialogSize = QStringLiteral("preferenceDialogSize");
//---------------------------------------------------------------------------------------------------------------------
VCommonSettings::VCommonSettings(Format format, Scope scope, const QString &organization,
@ -414,3 +415,15 @@ void VCommonSettings::SetToolbarsState(const QByteArray &value)
{
setValue(SettingGeneralToolbarsState, value);
}
//---------------------------------------------------------------------------------------------------------------------
QSize VCommonSettings::GetPreferenceDialogSize() const
{
return value(SettingPreferenceDialogSize, QSize(0, 0)).toSize();
}
//---------------------------------------------------------------------------------------------------------------------
void VCommonSettings::SetPreferenceDialogSize(const QSize& sz)
{
setValue(SettingPreferenceDialogSize, sz);
}

View File

@ -99,6 +99,9 @@ public:
QByteArray GetToolbarsState() const;
void SetToolbarsState(const QByteArray &value);
QSize GetPreferenceDialogSize() const;
void SetPreferenceDialogSize(const QSize& sz);
private:
Q_DISABLE_COPY(VCommonSettings)
@ -124,6 +127,7 @@ private:
static const QString SettingGeneralGeometry;
static const QString SettingGeneralWindowState;
static const QString SettingGeneralToolbarsState;
static const QString SettingPreferenceDialogSize;
};
#endif // VCOMMONSETTINGS_H