From f1b511a3663c8057d066230a9c42af024878de61 Mon Sep 17 00:00:00 2001 From: Kimmo Varis Date: Tue, 23 Nov 2010 21:57:16 +0200 Subject: [PATCH] GUI: Remember main window splitter state. Save and restore the vertical splitter state (sizes of tree view and details panel). --- gui/common.h | 1 + gui/mainwindow.cpp | 2 +- gui/resultsview.cpp | 10 ++++++++-- gui/resultsview.h | 4 +++- 4 files changed, 13 insertions(+), 4 deletions(-) diff --git a/gui/common.h b/gui/common.h index e7e419d99..6c4a436ef 100644 --- a/gui/common.h +++ b/gui/common.h @@ -65,6 +65,7 @@ ShowTypes; #define SETTINGS_TOOLBARS_VIEW_SHOW "Toolbars/ShowView" #define SETTINGS_LOG_VIEW_WIDTH "Log/View width" #define SETTINGS_LOG_VIEW_HEIGHT "Log/View height" +#define SETTINGS_MAINWND_SPLITTER_STATE "Mainwindow/Vertical splitter state" /// @} #endif diff --git a/gui/mainwindow.cpp b/gui/mainwindow.cpp index 63be090a7..6e49a1123 100644 --- a/gui/mainwindow.cpp +++ b/gui/mainwindow.cpp @@ -206,7 +206,7 @@ void MainWindow::SaveSettings() mApplications->SaveSettings(mSettings); mSettings->setValue(SETTINGS_LANGUAGE, mTranslation->GetCurrentLanguage()); - mUI.mResults->SaveSettings(); + mUI.mResults->SaveSettings(mSettings); } void MainWindow::DoCheckFiles(const QStringList &files) diff --git a/gui/resultsview.cpp b/gui/resultsview.cpp index 494b1cb45..02f1514e6 100644 --- a/gui/resultsview.cpp +++ b/gui/resultsview.cpp @@ -24,6 +24,7 @@ #include #include #include +#include #include "erroritem.h" #include "resultsview.h" #include "resultstree.h" @@ -43,9 +44,11 @@ ResultsView::ResultsView(QWidget * parent) : void ResultsView::Initialize(QSettings *settings, ApplicationList *list) { - mUI.mProgress->setMinimum(0); mUI.mProgress->setVisible(false); + + QByteArray state = settings->value(SETTINGS_MAINWND_SPLITTER_STATE).toByteArray(); + mUI.mVerticalSplitter->restoreState(state); mShowNoErrorsMessage = settings->value(SETTINGS_SHOW_NO_ERRORS, true).toBool(); mUI.mTree->Initialize(settings, list); @@ -210,9 +213,12 @@ bool ResultsView::HasResults() const return mUI.mTree->HasResults(); } -void ResultsView::SaveSettings() +void ResultsView::SaveSettings(QSettings *settings) { mUI.mTree->SaveSettings(); + QByteArray state = mUI.mVerticalSplitter->saveState(); + settings->setValue(SETTINGS_MAINWND_SPLITTER_STATE, state); + mUI.mVerticalSplitter->restoreState(state); } void ResultsView::Translate() diff --git a/gui/resultsview.h b/gui/resultsview.h index d957cea9d..413a2b0df 100644 --- a/gui/resultsview.h +++ b/gui/resultsview.h @@ -30,6 +30,7 @@ class ErrorItem; class QModelIndex; +class QSettings; /// @addtogroup GUI /// @{ @@ -121,8 +122,9 @@ public: /** * @brief Save View's settings * + * @param settings program settings. */ - void SaveSettings(); + void SaveSettings(QSettings *settings); /** * @brief Translate this view