Core: Save less settings

Try to not save settings that weren't changed from their default, and
make it possible for defaults to change in the future.

Task-number: QTCREATORBUG-24762
Change-Id: If469b72573791bc92ed535edf00271ef09b55386
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
This commit is contained in:
Eike Ziller
2020-12-10 11:24:27 +01:00
parent e2eab0e016
commit a40e5b5382
19 changed files with 140 additions and 84 deletions

View File

@@ -28,7 +28,7 @@
#include <coreplugin/imode.h>
#include <coreplugin/modemanager.h>
#include <QSettings>
#include <utils/qtcsettings.h>
#include <QVBoxLayout>
#include <QSplitter>
@@ -171,26 +171,20 @@ void RightPaneWidget::resizeEvent(QResizeEvent *re)
QWidget::resizeEvent(re);
}
void RightPaneWidget::saveSettings(QSettings *settings)
static const bool kVisibleDefault = false;
static const int kWidthDefault = 500;
void RightPaneWidget::saveSettings(Utils::QtcSettings *settings)
{
settings->setValue(QLatin1String("RightPane/Visible"), isShown());
settings->setValue(QLatin1String("RightPane/Width"), m_width);
settings->setValueWithDefault("RightPane/Visible", isShown(), kVisibleDefault);
settings->setValueWithDefault("RightPane/Width", m_width, kWidthDefault);
}
void RightPaneWidget::readSettings(QSettings *settings)
{
if (settings->contains(QLatin1String("RightPane/Visible")))
setShown(settings->value(QLatin1String("RightPane/Visible")).toBool());
else
setShown(false);
setShown(settings->value(QLatin1String("RightPane/Visible"), kVisibleDefault).toBool());
m_width = settings->value("RightPane/Width", kWidthDefault).toInt();
if (settings->contains(QLatin1String("RightPane/Width"))) {
m_width = settings->value(QLatin1String("RightPane/Width")).toInt();
if (!m_width)
m_width = 500;
} else {
m_width = 500; //pixel
}
// Apply
if (RightPanePlaceHolder::m_current)
RightPanePlaceHolder::m_current->applyStoredSize(m_width);