From 4e92968f36e283979401a32719e1710b0d85314e Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Wed, 22 Apr 2015 17:22:47 +0300 Subject: [PATCH] Saves/restores the current state of mainwindow's toolbars and dockwidgets. --HG-- branch : develop --- src/app/core/vsettings.cpp | 13 +++++++++++++ src/app/core/vsettings.h | 4 ++++ src/app/dialogs/app/dialogaboutapp.cpp | 2 +- src/app/main.cpp | 4 ++-- src/app/mainwindow.cpp | 2 ++ src/app/mainwindow.h | 2 ++ src/app/version.cpp | 2 +- src/app/version.h | 7 ++++++- 8 files changed, 31 insertions(+), 5 deletions(-) diff --git a/src/app/core/vsettings.cpp b/src/app/core/vsettings.cpp index 311fc5111..66410ca57 100644 --- a/src/app/core/vsettings.cpp +++ b/src/app/core/vsettings.cpp @@ -57,6 +57,7 @@ const QString VSettings::SettingGeneralRecentFileList = QStringLitera const QString VSettings::SettingGeneralRestoreFileList = QStringLiteral("restoreFileList"); const QString VSettings::SettingGeneralGeometry = QStringLiteral("geometry"); const QString VSettings::SettingGeneralWindowState = QStringLiteral("windowState"); +const QString VSettings::SettingGeneralToolbarsState = QStringLiteral("toolbarsState"); const QString VSettings::SettingCommunityServer = QStringLiteral("community/server"); const QString VSettings::SettingCommunityServerSecure = QStringLiteral("community/serverSecure"); @@ -337,6 +338,18 @@ void VSettings::SetWindowState(const QByteArray &value) setValue(SettingGeneralWindowState, value); } +//--------------------------------------------------------------------------------------------------------------------- +QByteArray VSettings::GetToolbarsState() const +{ + return value(SettingGeneralToolbarsState).toByteArray(); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VSettings::SetToolbarsState(const QByteArray &value) +{ + setValue(SettingGeneralToolbarsState, value); +} + //--------------------------------------------------------------------------------------------------------------------- QString VSettings::GetServer() const { diff --git a/src/app/core/vsettings.h b/src/app/core/vsettings.h index 9957b0262..3f88dfb3e 100644 --- a/src/app/core/vsettings.h +++ b/src/app/core/vsettings.h @@ -100,6 +100,9 @@ public: QByteArray GetWindowState() const; void SetWindowState(const QByteArray &value); + QByteArray GetToolbarsState() const; + void SetToolbarsState(const QByteArray &value); + QString GetServer() const; void SetServer(const QString &value); @@ -155,6 +158,7 @@ private: static const QString SettingGeneralRestoreFileList; static const QString SettingGeneralGeometry; static const QString SettingGeneralWindowState; + static const QString SettingGeneralToolbarsState; static const QString SettingCommunityServer; static const QString SettingCommunityServerSecure; diff --git a/src/app/dialogs/app/dialogaboutapp.cpp b/src/app/dialogs/app/dialogaboutapp.cpp index 1598bf34d..17dce5b12 100644 --- a/src/app/dialogs/app/dialogaboutapp.cpp +++ b/src/app/dialogs/app/dialogaboutapp.cpp @@ -44,7 +44,7 @@ DialogAboutApp::DialogAboutApp(QWidget *parent) : qApp->getSettings()->GetOsSeparator() ? setLocale(QLocale::system()) : setLocale(QLocale(QLocale::C)); - ui->label_Valentina_Version->setText(QString("Valentina %1").arg(APP_VERSION)); + ui->label_Valentina_Version->setText(QString("Valentina %1").arg(APP_VERSION_STR)); ui->labelBuildRevision->setText(QString("Build revision: %1").arg(BUILD_REVISION)); ui->label_QT_Version->setText(buildCompatibilityString()); diff --git a/src/app/main.cpp b/src/app/main.cpp index d5f8dcaa5..e1dd4ded1 100644 --- a/src/app/main.cpp +++ b/src/app/main.cpp @@ -62,7 +62,7 @@ int main(int argc, char *argv[]) app.setOrganizationName(VER_COMPANYNAME_STR); app.setOrganizationDomain(VER_COMPANYDOMAIN_STR); // Setting the Application version - app.setApplicationVersion(APP_VERSION); + app.setApplicationVersion(APP_VERSION_STR); app.OpenSettings(); @@ -75,7 +75,7 @@ int main(int argc, char *argv[]) // Run creation log after sending crash report app.StartLogging(); - qDebug()<<"Version:"<getSettings()->GetGeometry()); restoreState(qApp->getSettings()->GetWindowState()); + restoreState(qApp->getSettings()->GetToolbarsState(), APP_VERSION); // Scene antialiasing const bool graphOutputValue = qApp->getSettings()->GetGraphicalOutput(); @@ -2125,6 +2126,7 @@ void MainWindow::WriteSettings() { qApp->getSettings()->SetGeometry(saveGeometry()); qApp->getSettings()->SetWindowState(saveState()); + qApp->getSettings()->SetToolbarsState(saveState(APP_VERSION)); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/app/mainwindow.h b/src/app/mainwindow.h index 079415182..689bb4783 100644 --- a/src/app/mainwindow.h +++ b/src/app/mainwindow.h @@ -246,8 +246,10 @@ private: void AutoSavePattern(); void setCurrentFile(const QString &fileName); QString strippedName(const QString &fullFileName); + void ReadSettings(); void WriteSettings(); + bool MaybeSave(); void UpdateRecentFileActions(); void CreateMenus(); diff --git a/src/app/version.cpp b/src/app/version.cpp index 4f109497b..d428be86b 100644 --- a/src/app/version.cpp +++ b/src/app/version.cpp @@ -35,7 +35,7 @@ extern const int MAJOR_VERSION = 0; extern const int MINOR_VERSION = 3; extern const int DEBUG_VERSION = 0; -extern const QString APP_VERSION(QStringLiteral("%1.%2.%3.%4").arg(MAJOR_VERSION).arg(MINOR_VERSION) +extern const QString APP_VERSION_STR(QStringLiteral("%1.%2.%3.%4").arg(MAJOR_VERSION).arg(MINOR_VERSION) .arg(DEBUG_VERSION).arg(LATEST_TAG_DISTANCE)); //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/app/version.h b/src/app/version.h index 9ab41de8b..d4b70aece 100644 --- a/src/app/version.h +++ b/src/app/version.h @@ -35,7 +35,12 @@ extern const int MAJOR_VERSION; extern const int MINOR_VERSION; extern const int DEBUG_VERSION; -extern const QString APP_VERSION; +extern const QString APP_VERSION_STR; + +/* + APP_VERSION is (major << 16) + (minor << 8) + patch. +*/ +#define APP_VERSION 0x000300 // Change version number in version.cpp too.