forked from qt-creator/qt-creator
FancyMainWindow: Use "Store" type for settings instead of custom QHash
Change-Id: Id0735af2ee9b138c9a53525a236fde2a0310c695 Reviewed-by: hjk <hjk@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
This commit is contained in:
@@ -563,23 +563,23 @@ void FancyMainWindow::handleVisibilityChanged(bool visible)
|
|||||||
|
|
||||||
void FancyMainWindow::saveSettings(QtcSettings *settings) const
|
void FancyMainWindow::saveSettings(QtcSettings *settings) const
|
||||||
{
|
{
|
||||||
const QHash<Key, QVariant> hash = saveSettings();
|
const Store hash = saveSettings();
|
||||||
for (auto it = hash.cbegin(), end = hash.cend(); it != end; ++it)
|
for (auto it = hash.cbegin(), end = hash.cend(); it != end; ++it)
|
||||||
settings->setValue(it.key(), it.value());
|
settings->setValue(it.key(), it.value());
|
||||||
}
|
}
|
||||||
|
|
||||||
void FancyMainWindow::restoreSettings(const QtcSettings *settings)
|
void FancyMainWindow::restoreSettings(const QtcSettings *settings)
|
||||||
{
|
{
|
||||||
QHash<Key, QVariant> hash;
|
Store hash;
|
||||||
const KeyList childKeys = settings->childKeys();
|
const KeyList childKeys = settings->childKeys();
|
||||||
for (const Key &key : childKeys)
|
for (const Key &key : childKeys)
|
||||||
hash.insert(key, settings->value(key));
|
hash.insert(key, settings->value(key));
|
||||||
restoreSettings(hash);
|
restoreSettings(hash);
|
||||||
}
|
}
|
||||||
|
|
||||||
QHash<Key, QVariant> FancyMainWindow::saveSettings() const
|
Store FancyMainWindow::saveSettings() const
|
||||||
{
|
{
|
||||||
QHash<Key, QVariant> settings;
|
Store settings;
|
||||||
settings.insert(StateKey, saveState(settingsVersion));
|
settings.insert(StateKey, saveState(settingsVersion));
|
||||||
settings.insert(ShowCentralWidgetKey, d->m_showCentralWidget.isChecked());
|
settings.insert(ShowCentralWidgetKey, d->m_showCentralWidget.isChecked());
|
||||||
for (QDockWidget *dockWidget : dockWidgets()) {
|
for (QDockWidget *dockWidget : dockWidgets()) {
|
||||||
@@ -590,7 +590,7 @@ QHash<Key, QVariant> FancyMainWindow::saveSettings() const
|
|||||||
return settings;
|
return settings;
|
||||||
}
|
}
|
||||||
|
|
||||||
void FancyMainWindow::restoreSettings(const QHash<Key, QVariant> &settings)
|
void FancyMainWindow::restoreSettings(const Store &settings)
|
||||||
{
|
{
|
||||||
QByteArray ba = settings.value(StateKey, QByteArray()).toByteArray();
|
QByteArray ba = settings.value(StateKey, QByteArray()).toByteArray();
|
||||||
if (!ba.isEmpty()) {
|
if (!ba.isEmpty()) {
|
||||||
|
@@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
#include "utils_global.h"
|
#include "utils_global.h"
|
||||||
|
|
||||||
#include "storekey.h"
|
#include "store.h"
|
||||||
|
|
||||||
#include <QMainWindow>
|
#include <QMainWindow>
|
||||||
|
|
||||||
@@ -32,8 +32,8 @@ public:
|
|||||||
|
|
||||||
void saveSettings(QtcSettings *settings) const;
|
void saveSettings(QtcSettings *settings) const;
|
||||||
void restoreSettings(const QtcSettings *settings);
|
void restoreSettings(const QtcSettings *settings);
|
||||||
QHash<Key, QVariant> saveSettings() const;
|
Store saveSettings() const;
|
||||||
void restoreSettings(const QHash<Key, QVariant> &settings);
|
void restoreSettings(const Store &settings);
|
||||||
bool restoreFancyState(const QByteArray &state, int version = 0);
|
bool restoreFancyState(const QByteArray &state, int version = 0);
|
||||||
|
|
||||||
// Additional context menu actions
|
// Additional context menu actions
|
||||||
|
@@ -672,7 +672,7 @@ void EditorWidget::recreateEditors()
|
|||||||
Store windowState = m_document->settings()->windowState.value();
|
Store windowState = m_document->settings()->windowState.value();
|
||||||
|
|
||||||
if (!windowState.isEmpty()) {
|
if (!windowState.isEmpty()) {
|
||||||
QHash<Key, QVariant> hashMap;
|
Store hashMap;
|
||||||
for (const auto &key : windowState.keys()) {
|
for (const auto &key : windowState.keys()) {
|
||||||
if (key.view() != "State")
|
if (key.view() != "State")
|
||||||
hashMap.insert(key, windowState.value(key));
|
hashMap.insert(key, windowState.value(key));
|
||||||
|
Reference in New Issue
Block a user