forked from qt-creator/qt-creator
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:
@@ -38,6 +38,8 @@ public:
|
||||
|
||||
template<typename T>
|
||||
void setValueWithDefault(const QString &key, const T &val, const T &defaultValue);
|
||||
template<typename T>
|
||||
void setValueWithDefault(const QString &key, const T &val);
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
@@ -49,4 +51,13 @@ void QtcSettings::setValueWithDefault(const QString &key, const T &val, const T
|
||||
setValue(key, QVariant::fromValue(val));
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void QtcSettings::setValueWithDefault(const QString &key, const T &val)
|
||||
{
|
||||
if (val == T())
|
||||
remove(key);
|
||||
else
|
||||
setValue(key, QVariant::fromValue(val));
|
||||
}
|
||||
|
||||
} // namespace Utils
|
||||
|
@@ -295,7 +295,8 @@ void CorePlugin::setEnvironmentChanges(const EnvironmentItems &changes)
|
||||
Environment systemEnv = m_instance->m_startupSystemEnvironment;
|
||||
systemEnv.modify(changes);
|
||||
Environment::setSystemEnvironment(systemEnv);
|
||||
ICore::settings()->setValue(kEnvironmentChanges, EnvironmentItem::toStringList(changes));
|
||||
ICore::settings()->setValueWithDefault(kEnvironmentChanges,
|
||||
EnvironmentItem::toStringList(changes));
|
||||
if (ICore::instance())
|
||||
emit ICore::instance()->systemEnvironmentChanged();
|
||||
}
|
||||
|
@@ -484,9 +484,9 @@ void NewDialog::saveState()
|
||||
const QModelIndex idx = m_filterProxyModel->mapToSource(filterIdx);
|
||||
QStandardItem *currentItem = m_model->itemFromIndex(idx);
|
||||
if (currentItem)
|
||||
ICore::settings()->setValue(QLatin1String(LAST_CATEGORY_KEY),
|
||||
currentItem->data(Qt::UserRole));
|
||||
ICore::settings()->setValue(QLatin1String(LAST_PLATFORM_KEY), m_ui->comboBox->currentData());
|
||||
ICore::settings()->setValue(LAST_CATEGORY_KEY, currentItem->data(Qt::UserRole));
|
||||
ICore::settings()->setValueWithDefault(LAST_PLATFORM_KEY,
|
||||
m_ui->comboBox->currentData().toString());
|
||||
}
|
||||
|
||||
static void runWizard(IWizardFactory *wizard, const QString &defaultLocation, Id platform,
|
||||
|
@@ -755,7 +755,9 @@ bool SettingsDialog::execDialog()
|
||||
exec();
|
||||
m_running = false;
|
||||
m_instance = nullptr;
|
||||
ICore::settings()->setValue(kPreferenceDialogSize, size());
|
||||
ICore::settings()->setValueWithDefault(kPreferenceDialogSize,
|
||||
size(),
|
||||
QSize(kInitialWidth, kInitialHeight));
|
||||
// make sure that the current "single" instance is deleted
|
||||
// we can't delete right away, since we still access the m_applied member
|
||||
deleteLater();
|
||||
|
@@ -70,6 +70,7 @@
|
||||
#include <QMenu>
|
||||
#include <QMessageBox>
|
||||
|
||||
static const bool kUseProjectsDirectoryDefault = true;
|
||||
static Q_LOGGING_CATEGORY(log, "qtc.core.documentmanager", QtWarningMsg)
|
||||
|
||||
/*!
|
||||
@@ -182,7 +183,7 @@ public:
|
||||
bool m_postponeAutoReload = false;
|
||||
bool m_blockActivated = false;
|
||||
bool m_checkOnFocusChange = false;
|
||||
bool m_useProjectsDirectory = true;
|
||||
bool m_useProjectsDirectory = kUseProjectsDirectoryDefault;
|
||||
|
||||
QFileSystemWatcher *m_fileWatcher = nullptr; // Delayed creation.
|
||||
QFileSystemWatcher *m_linkWatcher = nullptr; // Delayed creation (only UNIX/if a link is seen).
|
||||
@@ -1366,14 +1367,16 @@ void DocumentManager::saveSettings()
|
||||
recentEditorIds.append(file.second.toString());
|
||||
}
|
||||
|
||||
QSettings *s = ICore::settings();
|
||||
s->beginGroup(QLatin1String(settingsGroupC));
|
||||
s->setValue(QLatin1String(filesKeyC), recentFiles);
|
||||
s->setValue(QLatin1String(editorsKeyC), recentEditorIds);
|
||||
QtcSettings *s = ICore::settings();
|
||||
s->beginGroup(settingsGroupC);
|
||||
s->setValueWithDefault(filesKeyC, recentFiles);
|
||||
s->setValueWithDefault(editorsKeyC, recentEditorIds);
|
||||
s->endGroup();
|
||||
s->beginGroup(QLatin1String(directoryGroupC));
|
||||
s->setValue(QLatin1String(projectDirectoryKeyC), d->m_projectsDirectory.toString());
|
||||
s->setValue(QLatin1String(useProjectDirectoryKeyC), d->m_useProjectsDirectory);
|
||||
s->beginGroup(directoryGroupC);
|
||||
s->setValueWithDefault(projectDirectoryKeyC, d->m_projectsDirectory.toString());
|
||||
s->setValueWithDefault(useProjectDirectoryKeyC,
|
||||
d->m_useProjectsDirectory,
|
||||
kUseProjectsDirectoryDefault);
|
||||
s->endGroup();
|
||||
}
|
||||
|
||||
@@ -1403,8 +1406,8 @@ void readSettings()
|
||||
d->m_projectsDirectory = settingsProjectDir;
|
||||
else
|
||||
d->m_projectsDirectory = FilePath::fromString(PathChooser::homePath());
|
||||
d->m_useProjectsDirectory = s->value(QLatin1String(useProjectDirectoryKeyC),
|
||||
d->m_useProjectsDirectory).toBool();
|
||||
d->m_useProjectsDirectory
|
||||
= s->value(QLatin1String(useProjectDirectoryKeyC), kUseProjectsDirectoryDefault).toBool();
|
||||
|
||||
s->endGroup();
|
||||
}
|
||||
|
@@ -130,6 +130,9 @@ static inline QString completionSettingsFlagsKey() { return QStringLiteral("Flag
|
||||
|
||||
void CompletionModel::writeSettings(QSettings *settings) const
|
||||
{
|
||||
if (m_entries.isEmpty()) {
|
||||
settings->remove(completionSettingsArrayPrefix());
|
||||
} else {
|
||||
const int size = m_entries.size();
|
||||
settings->beginWriteArray(completionSettingsArrayPrefix(), size);
|
||||
for (int i = 0; i < size; ++i) {
|
||||
@@ -139,6 +142,7 @@ void CompletionModel::writeSettings(QSettings *settings) const
|
||||
}
|
||||
settings->endArray();
|
||||
}
|
||||
}
|
||||
|
||||
void CompletionModel::readSettings(QSettings *settings)
|
||||
{
|
||||
@@ -380,15 +384,17 @@ bool Find::hasFindFlag(FindFlag flag)
|
||||
|
||||
void FindPrivate::writeSettings()
|
||||
{
|
||||
QSettings *settings = ICore::settings();
|
||||
QtcSettings *settings = ICore::settings();
|
||||
settings->beginGroup(QLatin1String("Find"));
|
||||
settings->setValue(QLatin1String("Backward"), bool(m_findFlags & FindBackward));
|
||||
settings->setValue(QLatin1String("CaseSensitively"), bool(m_findFlags & FindCaseSensitively));
|
||||
settings->setValue(QLatin1String("WholeWords"), bool(m_findFlags & FindWholeWords));
|
||||
settings->setValue(QLatin1String("RegularExpression"), bool(m_findFlags & FindRegularExpression));
|
||||
settings->setValue(QLatin1String("PreserveCase"), bool(m_findFlags & FindPreserveCase));
|
||||
settings->setValueWithDefault("Backward", bool(m_findFlags & FindBackward), false);
|
||||
settings->setValueWithDefault("CaseSensitively", bool(m_findFlags & FindCaseSensitively), false);
|
||||
settings->setValueWithDefault("WholeWords", bool(m_findFlags & FindWholeWords), false);
|
||||
settings->setValueWithDefault("RegularExpression",
|
||||
bool(m_findFlags & FindRegularExpression),
|
||||
false);
|
||||
settings->setValueWithDefault("PreserveCase", bool(m_findFlags & FindPreserveCase), false);
|
||||
m_findCompletionModel.writeSettings(settings);
|
||||
settings->setValue(QLatin1String("ReplaceStrings"), m_replaceCompletions);
|
||||
settings->setValueWithDefault("ReplaceStrings", m_replaceCompletions);
|
||||
settings->endGroup();
|
||||
m_findToolBar->writeSettings();
|
||||
m_findDialog->writeSettings();
|
||||
|
@@ -894,14 +894,20 @@ void FindToolBar::resizeEvent(QResizeEvent *event)
|
||||
|
||||
void FindToolBar::writeSettings()
|
||||
{
|
||||
QSettings *settings = ICore::settings();
|
||||
settings->beginGroup(QLatin1String("Find"));
|
||||
settings->beginGroup(QLatin1String("FindToolBar"));
|
||||
settings->setValue(QLatin1String("Backward"), QVariant((m_findFlags & FindBackward) != 0));
|
||||
settings->setValue(QLatin1String("CaseSensitively"), QVariant((m_findFlags & FindCaseSensitively) != 0));
|
||||
settings->setValue(QLatin1String("WholeWords"), QVariant((m_findFlags & FindWholeWords) != 0));
|
||||
settings->setValue(QLatin1String("RegularExpression"), QVariant((m_findFlags & FindRegularExpression) != 0));
|
||||
settings->setValue(QLatin1String("PreserveCase"), QVariant((m_findFlags & FindPreserveCase) != 0));
|
||||
Utils::QtcSettings *settings = ICore::settings();
|
||||
settings->beginGroup("Find");
|
||||
settings->beginGroup("FindToolBar");
|
||||
settings->setValueWithDefault("Backward", bool((m_findFlags & FindBackward) != 0), false);
|
||||
settings->setValueWithDefault("CaseSensitively",
|
||||
bool((m_findFlags & FindCaseSensitively) != 0),
|
||||
false);
|
||||
settings->setValueWithDefault("WholeWords", bool((m_findFlags & FindWholeWords) != 0), false);
|
||||
settings->setValueWithDefault("RegularExpression",
|
||||
bool((m_findFlags & FindRegularExpression) != 0),
|
||||
false);
|
||||
settings->setValueWithDefault("PreserveCase",
|
||||
bool((m_findFlags & FindPreserveCase) != 0),
|
||||
false);
|
||||
settings->endGroup();
|
||||
settings->endGroup();
|
||||
}
|
||||
|
@@ -299,9 +299,10 @@ void FindToolWindow::replace()
|
||||
|
||||
void FindToolWindow::writeSettings()
|
||||
{
|
||||
QSettings *settings = ICore::settings();
|
||||
settings->beginGroup(QLatin1String("Find"));
|
||||
settings->setValue(QLatin1String("CurrentFilter"), m_currentFilter ? m_currentFilter->id() : QString());
|
||||
Utils::QtcSettings *settings = ICore::settings();
|
||||
settings->beginGroup("Find");
|
||||
settings->setValueWithDefault("CurrentFilter",
|
||||
m_currentFilter ? m_currentFilter->id() : QString());
|
||||
foreach (IFindFilter *filter, m_filters)
|
||||
filter->writeSettings(settings);
|
||||
settings->endGroup();
|
||||
|
@@ -116,7 +116,7 @@ namespace Internal {
|
||||
QToolButton *m_expandCollapseButton;
|
||||
QToolButton *m_newSearchButton;
|
||||
QAction *m_expandCollapseAction;
|
||||
static const bool m_initiallyExpand = false;
|
||||
static const bool m_initiallyExpand;
|
||||
QWidget *m_spacer;
|
||||
QLabel *m_historyLabel;
|
||||
QWidget *m_spacer2;
|
||||
@@ -130,6 +130,8 @@ namespace Internal {
|
||||
|
||||
};
|
||||
|
||||
const bool SearchResultWindowPrivate::m_initiallyExpand = false;
|
||||
|
||||
SearchResultWindowPrivate::SearchResultWindowPrivate(SearchResultWindow *window, QWidget *nsp) :
|
||||
q(window),
|
||||
m_expandCollapseButton(nullptr),
|
||||
@@ -630,9 +632,11 @@ void SearchResultWindow::readSettings()
|
||||
*/
|
||||
void SearchResultWindow::writeSettings()
|
||||
{
|
||||
QSettings *s = ICore::settings();
|
||||
s->beginGroup(QLatin1String(SETTINGSKEYSECTIONNAME));
|
||||
s->setValue(QLatin1String(SETTINGSKEYEXPANDRESULTS), d->m_expandCollapseAction->isChecked());
|
||||
Utils::QtcSettings *s = ICore::settings();
|
||||
s->beginGroup(SETTINGSKEYSECTIONNAME);
|
||||
s->setValueWithDefault(SETTINGSKEYEXPANDRESULTS,
|
||||
d->m_expandCollapseAction->isChecked(),
|
||||
SearchResultWindowPrivate::m_initiallyExpand);
|
||||
s->endGroup();
|
||||
}
|
||||
|
||||
|
@@ -96,8 +96,8 @@ GeneralSettingsWidget::GeneralSettingsWidget(GeneralSettings *q)
|
||||
} else {
|
||||
const bool defaultValue = Utils::HostOsInfo::isWindowsHost();
|
||||
m_ui.dpiCheckbox->setChecked(ICore::settings()->value(settingsKeyDPI, defaultValue).toBool());
|
||||
connect(m_ui.dpiCheckbox, &QCheckBox::toggled, this, [](bool checked) {
|
||||
ICore::settings()->setValue(settingsKeyDPI, checked);
|
||||
connect(m_ui.dpiCheckbox, &QCheckBox::toggled, this, [defaultValue](bool checked) {
|
||||
ICore::settings()->setValueWithDefault(settingsKeyDPI, checked, defaultValue);
|
||||
QMessageBox::information(ICore::dialogParent(),
|
||||
tr("Restart Required"),
|
||||
tr("The high DPI settings will take effect after restart."));
|
||||
|
@@ -1027,6 +1027,8 @@ static const char windowGeometryKey[] = "WindowGeometry";
|
||||
static const char windowStateKey[] = "WindowState";
|
||||
static const char modeSelectorLayoutKey[] = "ModeSelectorLayout";
|
||||
|
||||
static const bool askBeforeExitDefault = false;
|
||||
|
||||
void MainWindow::readSettings()
|
||||
{
|
||||
QSettings *settings = PluginManager::settings();
|
||||
@@ -1041,7 +1043,7 @@ void MainWindow::readSettings()
|
||||
QColor(StyleHelper::DEFAULT_BASE_COLOR)).value<QColor>());
|
||||
}
|
||||
|
||||
m_askConfirmationBeforeExit = settings->value(askBeforeExitKey, false).toBool();
|
||||
m_askConfirmationBeforeExit = settings->value(askBeforeExitKey, askBeforeExitDefault).toBool();
|
||||
|
||||
{
|
||||
ModeManager::Style modeStyle =
|
||||
@@ -1068,13 +1070,17 @@ void MainWindow::readSettings()
|
||||
|
||||
void MainWindow::saveSettings()
|
||||
{
|
||||
QSettings *settings = PluginManager::settings();
|
||||
QtcSettings *settings = PluginManager::settings();
|
||||
settings->beginGroup(QLatin1String(settingsGroup));
|
||||
|
||||
if (!(m_overrideColor.isValid() && StyleHelper::baseColor() == m_overrideColor))
|
||||
settings->setValue(QLatin1String(colorKey), StyleHelper::requestedBaseColor());
|
||||
settings->setValueWithDefault(colorKey,
|
||||
StyleHelper::requestedBaseColor(),
|
||||
QColor(StyleHelper::DEFAULT_BASE_COLOR));
|
||||
|
||||
settings->setValue(askBeforeExitKey, m_askConfirmationBeforeExit);
|
||||
settings->setValueWithDefault(askBeforeExitKey,
|
||||
m_askConfirmationBeforeExit,
|
||||
askBeforeExitDefault);
|
||||
|
||||
settings->endGroup();
|
||||
|
||||
|
@@ -401,15 +401,25 @@ void NavigationWidget::closeSubWidget()
|
||||
}
|
||||
}
|
||||
|
||||
void NavigationWidget::saveSettings(QSettings *settings)
|
||||
static QString defaultFirstView(Side side)
|
||||
{
|
||||
return side == Side::Left ? QString("Projects") : QString("Outline");
|
||||
}
|
||||
|
||||
static bool defaultVisible(Side side)
|
||||
{
|
||||
return side == Side::Left;
|
||||
}
|
||||
|
||||
void NavigationWidget::saveSettings(QtcSettings *settings)
|
||||
{
|
||||
QStringList viewIds;
|
||||
for (int i=0; i<d->m_subWidgets.count(); ++i) {
|
||||
d->m_subWidgets.at(i)->saveSettings();
|
||||
viewIds.append(d->m_subWidgets.at(i)->factory()->id().toString());
|
||||
}
|
||||
settings->setValue(settingsKey("Views"), viewIds);
|
||||
settings->setValue(settingsKey("Visible"), isShown());
|
||||
settings->setValueWithDefault(settingsKey("Views"), viewIds, {defaultFirstView(d->m_side)});
|
||||
settings->setValueWithDefault(settingsKey("Visible"), isShown(), defaultVisible(d->m_side));
|
||||
settings->setValue(settingsKey("VerticalPosition"), saveState());
|
||||
settings->setValue(settingsKey("Width"), d->m_width);
|
||||
|
||||
@@ -431,8 +441,9 @@ void NavigationWidget::restoreSettings(QSettings *settings)
|
||||
}
|
||||
|
||||
const bool isLeftSide = d->m_side == Side::Left;
|
||||
QLatin1String defaultFirstView = isLeftSide ? QLatin1String("Projects") : QLatin1String("Outline");
|
||||
QStringList viewIds = settings->value(settingsKey("Views"), QStringList(defaultFirstView)).toStringList();
|
||||
QStringList viewIds = settings
|
||||
->value(settingsKey("Views"), QStringList(defaultFirstView(d->m_side)))
|
||||
.toStringList();
|
||||
|
||||
bool restoreSplitterState = true;
|
||||
int version = settings->value(settingsKey("Version"), 1).toInt();
|
||||
@@ -459,9 +470,9 @@ void NavigationWidget::restoreSettings(QSettings *settings)
|
||||
|
||||
if (d->m_subWidgets.isEmpty())
|
||||
// Make sure we have at least the projects widget or outline widget
|
||||
insertSubItem(0, qMax(0, factoryIndex(defaultFirstView.data())));
|
||||
insertSubItem(0, qMax(0, factoryIndex(Id::fromString(defaultFirstView(d->m_side)))));
|
||||
|
||||
setShown(settings->value(settingsKey("Visible"), isLeftSide).toBool());
|
||||
setShown(settings->value(settingsKey("Visible"), defaultVisible(d->m_side)).toBool());
|
||||
|
||||
if (restoreSplitterState && settings->contains(settingsKey("VerticalPosition"))) {
|
||||
restoreState(settings->value(settingsKey("VerticalPosition")).toByteArray());
|
||||
|
@@ -36,6 +36,10 @@ class QSettings;
|
||||
class QAbstractItemModel;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
namespace Utils {
|
||||
class QtcSettings;
|
||||
}
|
||||
|
||||
namespace Core {
|
||||
class INavigationWidgetFactory;
|
||||
class Command;
|
||||
@@ -87,7 +91,7 @@ public:
|
||||
void setFactories(const QList<INavigationWidgetFactory*> &factories);
|
||||
|
||||
QString settingsGroup() const;
|
||||
void saveSettings(QSettings *settings);
|
||||
void saveSettings(Utils::QtcSettings *settings);
|
||||
void restoreSettings(QSettings *settings);
|
||||
|
||||
QWidget *activateSubWidget(Utils::Id factoryId, int preferredPosition);
|
||||
|
@@ -145,7 +145,7 @@ OutputWindow::OutputWindow(Context context, const QString &settingsKey, QWidget
|
||||
connect(this, &QPlainTextEdit::copyAvailable, copyAction, &QAction::setEnabled);
|
||||
connect(Core::ICore::instance(), &Core::ICore::saveSettingsRequested, this, [this] {
|
||||
if (!d->settingsKey.isEmpty())
|
||||
Core::ICore::settings()->setValue(d->settingsKey, fontZoom());
|
||||
Core::ICore::settings()->setValueWithDefault(d->settingsKey, fontZoom(), 0.f);
|
||||
});
|
||||
|
||||
connect(outputFormatter(), &OutputFormatter::openInEditorRequested, this,
|
||||
|
@@ -53,9 +53,9 @@ QString PatchTool::patchCommand()
|
||||
|
||||
void PatchTool::setPatchCommand(const QString &newCommand)
|
||||
{
|
||||
QSettings *s = ICore::settings();
|
||||
Utils::QtcSettings *s = ICore::settings();
|
||||
s->beginGroup(QLatin1String(settingsGroupC));
|
||||
s->setValue(QLatin1String(patchCommandKeyC), newCommand);
|
||||
s->setValueWithDefault(QLatin1String(patchCommandKeyC), newCommand, QString(patchCommandKeyC));
|
||||
s->endGroup();
|
||||
}
|
||||
|
||||
|
@@ -56,6 +56,7 @@
|
||||
|
||||
static const char kSettingsGroup[] = "Progress";
|
||||
static const char kDetailsPinned[] = "DetailsPinned";
|
||||
static const bool kDetailsPinnedDefault = true;
|
||||
static const int TimerInterval = 100; // 100 ms
|
||||
|
||||
using namespace Core;
|
||||
@@ -250,8 +251,8 @@ ProgressManagerPrivate::~ProgressManagerPrivate()
|
||||
void ProgressManagerPrivate::readSettings()
|
||||
{
|
||||
QSettings *settings = ICore::settings();
|
||||
settings->beginGroup(QLatin1String(kSettingsGroup));
|
||||
m_progressViewPinned = settings->value(QLatin1String(kDetailsPinned), true).toBool();
|
||||
settings->beginGroup(kSettingsGroup);
|
||||
m_progressViewPinned = settings->value(kDetailsPinned, kDetailsPinnedDefault).toBool();
|
||||
settings->endGroup();
|
||||
}
|
||||
|
||||
@@ -661,9 +662,9 @@ void ProgressManagerPrivate::progressDetailsToggled(bool checked)
|
||||
m_progressViewPinned = checked;
|
||||
updateVisibility();
|
||||
|
||||
QSettings *settings = ICore::settings();
|
||||
settings->beginGroup(QLatin1String(kSettingsGroup));
|
||||
settings->setValue(QLatin1String(kDetailsPinned), m_progressViewPinned);
|
||||
QtcSettings *settings = ICore::settings();
|
||||
settings->beginGroup(kSettingsGroup);
|
||||
settings->setValueWithDefault(kDetailsPinned, m_progressViewPinned, kDetailsPinnedDefault);
|
||||
settings->endGroup();
|
||||
}
|
||||
|
||||
|
@@ -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);
|
||||
|
@@ -36,6 +36,10 @@ QT_BEGIN_NAMESPACE
|
||||
class QSettings;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
namespace Utils {
|
||||
class QtcSettings;
|
||||
}
|
||||
|
||||
namespace Core {
|
||||
|
||||
class RightPaneWidget;
|
||||
@@ -65,7 +69,7 @@ public:
|
||||
RightPaneWidget();
|
||||
~RightPaneWidget() override;
|
||||
|
||||
void saveSettings(QSettings *settings);
|
||||
void saveSettings(Utils::QtcSettings *settings);
|
||||
void readSettings(QSettings *settings);
|
||||
|
||||
bool isShown();
|
||||
|
@@ -177,11 +177,13 @@ void ThemeChooser::apply()
|
||||
if (index == -1)
|
||||
return;
|
||||
const QString themeId = d->m_themeListModel->themeAt(index).id().toString();
|
||||
QSettings *settings = ICore::settings();
|
||||
QtcSettings *settings = ICore::settings();
|
||||
const QString currentThemeId = ThemeEntry::themeSetting().toString();
|
||||
if (currentThemeId != themeId) {
|
||||
// save filename of selected theme in global config
|
||||
settings->setValue(QLatin1String(Constants::SETTINGS_THEME), themeId);
|
||||
settings->setValueWithDefault(Constants::SETTINGS_THEME,
|
||||
themeId,
|
||||
QString(Constants::DEFAULT_THEME));
|
||||
RestartDialog restartDialog(ICore::dialogParent(),
|
||||
tr("The theme change will take effect after restart."));
|
||||
restartDialog.exec();
|
||||
|
Reference in New Issue
Block a user