From 61dcc529651e05fd64586da6a2057d6129f345d7 Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Fri, 16 Jun 2017 17:05:35 +0300 Subject: [PATCH] Remember Formula Wizard dialog size. --HG-- branch : develop --- src/libs/vmisc/vcommonsettings.cpp | 13 ++++++++ src/libs/vmisc/vcommonsettings.h | 3 ++ .../support/dialogeditwrongformula.cpp | 30 +++++++++++++++++-- .../dialogs/support/dialogeditwrongformula.h | 1 + .../tools/piece/dialogseamallowance.cpp | 9 +++--- .../dialogs/tools/piece/dialogseamallowance.h | 1 - 6 files changed, 48 insertions(+), 9 deletions(-) diff --git a/src/libs/vmisc/vcommonsettings.cpp b/src/libs/vmisc/vcommonsettings.cpp index a21413934..faf22e74c 100644 --- a/src/libs/vmisc/vcommonsettings.cpp +++ b/src/libs/vmisc/vcommonsettings.cpp @@ -72,6 +72,7 @@ const QString settingGeneralWindowState = QStringLiteral("windowState") const QString settingGeneralToolbarsState = QStringLiteral("toolbarsState"); const QString settingPreferenceDialogSize = QStringLiteral("preferenceDialogSize"); const QString settingToolSeamAllowanceDialogSize = QStringLiteral("toolSeamAllowanceDialogSize"); +const QString settingFormulaWizardDialogSize = QStringLiteral("formulaWizardDialogSize"); const QString settingLatestSkippedVersion = QStringLiteral("lastestSkippedVersion"); const QString settingDateOfLastRemind = QStringLiteral("dateOfLastRemind"); const QString settingUserDefinedMaterials = QStringLiteral("configuration/userDefinedMaterials"); @@ -571,6 +572,18 @@ void VCommonSettings::SetToolSeamAllowanceDialogSize(const QSize &sz) setValue(settingToolSeamAllowanceDialogSize, sz); } +//--------------------------------------------------------------------------------------------------------------------- +QSize VCommonSettings::GetFormulaWizardDialogSize() const +{ + return value(settingFormulaWizardDialogSize, QSize(0, 0)).toSize(); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VCommonSettings::SetFormulaWizardDialogSize(const QSize &sz) +{ + setValue(settingFormulaWizardDialogSize, sz); +} + //--------------------------------------------------------------------------------------------------------------------- int VCommonSettings::GetLatestSkippedVersion() const { diff --git a/src/libs/vmisc/vcommonsettings.h b/src/libs/vmisc/vcommonsettings.h index f96879506..1770bebaa 100644 --- a/src/libs/vmisc/vcommonsettings.h +++ b/src/libs/vmisc/vcommonsettings.h @@ -123,6 +123,9 @@ public: QSize GetToolSeamAllowanceDialogSize() const; void SetToolSeamAllowanceDialogSize(const QSize& sz); + QSize GetFormulaWizardDialogSize() const; + void SetFormulaWizardDialogSize(const QSize& sz); + int GetLatestSkippedVersion() const; void SetLatestSkippedVersion(int value); diff --git a/src/libs/vtools/dialogs/support/dialogeditwrongformula.cpp b/src/libs/vtools/dialogs/support/dialogeditwrongformula.cpp index 1d691165f..b17fba173 100644 --- a/src/libs/vtools/dialogs/support/dialogeditwrongformula.cpp +++ b/src/libs/vtools/dialogs/support/dialogeditwrongformula.cpp @@ -350,14 +350,38 @@ void DialogEditWrongFormula::closeEvent(QCloseEvent *event) //--------------------------------------------------------------------------------------------------------------------- void DialogEditWrongFormula::showEvent(QShowEvent *event) { - DialogTool::showEvent( event ); + QDialog::showEvent( event ); if ( event->spontaneous() ) { return; } - setMaximumSize(QSize(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX)); - setMinimumSize(QSize(0, 0)); + if (isInitialized) + { + return; + } + // do your init stuff here + + const QSize sz = qApp->Settings()->GetFormulaWizardDialogSize(); + if (not sz.isEmpty()) + { + resize(sz); + } + + isInitialized = true;//first show windows are held +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogEditWrongFormula::resizeEvent(QResizeEvent *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) + { + qApp->Settings()->SetFormulaWizardDialogSize(size()); + } + DialogTool::resizeEvent(event); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vtools/dialogs/support/dialogeditwrongformula.h b/src/libs/vtools/dialogs/support/dialogeditwrongformula.h index 93e76cb7f..63b6e6455 100644 --- a/src/libs/vtools/dialogs/support/dialogeditwrongformula.h +++ b/src/libs/vtools/dialogs/support/dialogeditwrongformula.h @@ -91,6 +91,7 @@ protected: virtual void CheckState() Q_DECL_FINAL; virtual void closeEvent(QCloseEvent *event) Q_DECL_OVERRIDE; virtual void showEvent( QShowEvent *event ) Q_DECL_OVERRIDE; + virtual void resizeEvent(QResizeEvent *event) Q_DECL_OVERRIDE; private slots: void FilterVariablesEdited(const QString &filter); private: diff --git a/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.cpp b/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.cpp index bd3642f95..b34516a45 100644 --- a/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.cpp +++ b/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.cpp @@ -89,7 +89,6 @@ DialogSeamAllowance::DialogSeamAllowance(const VContainer *data, const quint32 & m_tabPins(new QWidget), m_tabPassmarks(new QWidget), m_ftb(new FancyTabBar(FancyTabBar::Left, this)), - m_isInitialized(false), applyAllowed(false),// By default disabled flagGPin(true), flagDPin(true), @@ -432,7 +431,7 @@ void DialogSeamAllowance::showEvent(QShowEvent *event) return; } - if (m_isInitialized) + if (isInitialized) { return; } @@ -444,20 +443,20 @@ void DialogSeamAllowance::showEvent(QShowEvent *event) resize(sz); } - m_isInitialized = true;//first show windows are held + isInitialized = true;//first show windows are held } //--------------------------------------------------------------------------------------------------------------------- void DialogSeamAllowance::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 (m_isInitialized) + if (isInitialized) { qApp->Settings()->SetToolSeamAllowanceDialogSize(size()); } + DialogTool::resizeEvent(event); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.h b/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.h index 6856c3c0e..570511782 100644 --- a/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.h +++ b/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.h @@ -174,7 +174,6 @@ private: FancyTabBar* m_ftb; - bool m_isInitialized; bool applyAllowed; bool flagGPin; bool flagDPin;