Commit a8cc2f6f authored by con's avatar con
Browse files

Need the settings also in form of non-QSettings.

parent 4a18ac34
......@@ -142,20 +142,41 @@ void FancyMainWindow::handleVisibilityChanged(bool visible)
void FancyMainWindow::saveSettings(QSettings *settings) const
{
settings->setValue("State", saveState());
settings->setValue("Locked", m_locked);
for (int i = 0; i < m_dockWidgetActiveState.count(); ++i) {
settings->setValue(m_dockWidgets.at(i)->objectName(),
m_dockWidgetActiveState.at(i));
QHash<QString, QVariant> hash = saveSettings();
QHashIterator<QString, QVariant> it(hash);
while (it.hasNext()) {
it.next();
settings->setValue(it.key(), it.value());
}
}
void FancyMainWindow::restoreSettings(QSettings *settings)
{
QByteArray ba = settings->value("State", QByteArray()).toByteArray();
QHash<QString, QVariant> hash;
foreach (const QString &key, settings->childKeys()) {
hash.insert(key, settings->value(key));
}
restoreSettings(hash);
}
QHash<QString, QVariant> FancyMainWindow::saveSettings() const
{
QHash<QString, QVariant> settings;
settings["State"] = saveState();
settings["Locked"] = m_locked;
for (int i = 0; i < m_dockWidgetActiveState.count(); ++i) {
settings[m_dockWidgets.at(i)->objectName()] =
m_dockWidgetActiveState.at(i);
}
return settings;
}
void FancyMainWindow::restoreSettings(const QHash<QString, QVariant> &settings)
{
QByteArray ba = settings.value("State", QByteArray()).toByteArray();
restoreState(ba);
m_locked = settings->value("Locked", true).toBool();
m_locked = settings.value("Locked", true).toBool();
for (int i = 0; i < m_dockWidgetActiveState.count(); ++i) {
m_dockWidgetActiveState[i] = settings->value(m_dockWidgets.at(i)->objectName(), false).toBool();
m_dockWidgetActiveState[i] = settings.value(m_dockWidgets.at(i)->objectName(), false).toBool();
}
}
......@@ -33,6 +33,7 @@
#include "utils_global.h"
#include <QtCore/QList>
#include <QtCore/QHash>
#include <QtCore/QSettings>
#include <QtGui/QMainWindow>
#include <QtGui/QDockWidget>
......@@ -56,6 +57,8 @@ public:
void saveSettings(QSettings *settings) const;
void restoreSettings(QSettings *settings);
QHash<QString, QVariant> saveSettings() const;
void restoreSettings(const QHash<QString, QVariant> &settings);
public slots:
void setLocked(bool locked);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment