00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #ifndef QCTSETTINGS_P_H
00026 #define QCTSETTINGS_P_H
00027
00028 #include <QCoreApplication>
00029 #include <QSettings>
00030 #include <QStringList>
00031 #include <QFileSystemWatcher>
00032
00043 class QctSettingsSingleton : public QObject
00044 {
00045 Q_OBJECT
00046
00047 public:
00048 QctSettingsSingleton();
00049
00050 public:
00051 void registerSetting(const QString& key, const QVariant &defaultValue);
00052 void setValue(const QString &key, const QVariant &value);
00053 QVariant value(const QString &key) const;
00054 void sync();
00055
00056 signals:
00057 void valuesChanged(const QHash<QString,QVariant> &changedSettings);
00058
00059 private slots:
00060 void onStoredSettingsChanged();
00061
00062 private:
00064 QSettings m_storedSettings;
00066 QHash<QString,QVariant> m_localSettings;
00067 };
00068
00069
00070 inline void
00071 QctSettingsSingleton::setValue(const QString &key, const QVariant &value)
00072 {
00073
00074 m_localSettings[key] = value;
00075
00076 m_storedSettings.setValue(key, value);
00077
00078
00079 QHash<QString,QVariant> changedSettings;
00080 changedSettings.insert(key, value);
00081 emit valuesChanged(changedSettings);
00082 }
00083
00084 inline QVariant
00085 QctSettingsSingleton::value(const QString &key) const
00086 {
00087 return m_localSettings.value(key);
00088 }
00089
00090 #endif // QCTSETTINGS_P_H