13 #ifndef hifi_SettingManager_h
14 #define hifi_SettingManager_h
16 #include <QtCore/QPointer>
17 #include <QtCore/QSettings>
18 #include <QtCore/QTimer>
19 #include <QtCore/QUuid>
23 #include <QLoggingCategory>
25 #include "DependencyManager.h"
26 #include "shared/ReadWriteLockable.h"
28 Q_DECLARE_LOGGING_CATEGORY(settings_manager)
29 Q_DECLARE_LOGGING_CATEGORY(settings_writer)
33 class SettingsTestsWorker;
69 void setValue(
const QString key,
const QVariant value);
106 _qSettings =
new QSettings();
110 QSettings* _qSettings =
nullptr;
126 class Manager :
public QObject,
public ReadWriteLockable,
public Dependency {
130 Manager(QObject *parent =
nullptr);
132 void customDeleter()
override;
146 void remove(
const QString &key);
162 bool contains(
const QString &key)
const;
179 QVariant
value(
const QString &key,
const QVariant &defaultValue = QVariant())
const;
198 void registerHandle(Interface* handle);
199 void removeHandle(
const QString& key);
201 void loadSetting(Interface* handle);
202 void saveSetting(Interface* handle);
256 QHash<QString, Interface*> _handles;
258 friend class Interface;
259 friend class ::SettingsTests;
260 friend class ::SettingsTestsWorker;
262 friend void cleanupSettingsSaveThread();
263 friend void setupSettingsSaveThread();
266 QHash<QString, QVariant> _settings;
268 QThread _workerThread;
Settings manager.
Definition: SettingManager.h:126
void valueChanged(const QString key, QVariant value)
The value of a setting was changed.
void setValue(const QString &key, const QVariant &value)
Set a setting to a value.
Definition: SettingManager.cpp:206
void remove(const QString &key)
Remove a configuration key.
Definition: SettingManager.cpp:186
void forceSave()
Force saving the config to disk.
Definition: SettingManager.cpp:166
void clearAllSettings()
Clear all the settings.
Definition: SettingManager.cpp:220
void syncRequested()
A request to synchronize the settings to permanent storage was made.
QVariant value(const QString &key, const QVariant &defaultValue=QVariant()) const
Returns the value of a setting.
Definition: SettingManager.cpp:214
bool contains(const QString &key) const
Returns whether a key is part of the configuration.
Definition: SettingManager.cpp:200
const int THREAD_TERMINATION_TIMEOUT
How long to wait for writer thread termination.
Definition: SettingManager.h:195
void terminateThread()
Write config to disk and terminate the writer thread.
Definition: SettingManager.cpp:170
QString fileName() const
Returns the filename where the config file will be written.
Definition: SettingManager.cpp:180
void keyRemoved(const QString key)
A setting was removed.
QStringList allKeys() const
Lists all keys in the configuration.
Definition: SettingManager.cpp:194
void terminationRequested()
The termination of the settings system was requested.
void clearAllSettingsRequested()
A request to clear all the settings was made.
Settings write worker.
Definition: SettingManager.h:52
void threadFinished()
Called when the thread is terminating.
Definition: SettingManager.cpp:60
void clearAllSettings()
Remove all values from the configuration.
Definition: SettingManager.cpp:48
void start()
Initialize anything that needs initializing, called on thread start.
Definition: SettingManager.cpp:27
void setValue(const QString key, const QVariant value)
Sets a configuration value.
Definition: SettingManager.cpp:33
void removeKey(const QString key)
Remove a value from the configuration.
Definition: SettingManager.cpp:43
void sync()
Force writing the config to disk.
Definition: SettingManager.cpp:54
void terminate()
Thread is being asked to finish work and quit.
Definition: SettingManager.cpp:66