diff options
author | ConfuSomu | 2023-08-15 20:16:44 -0400 |
---|---|---|
committer | ConfuSomu | 2023-08-15 20:16:44 -0400 |
commit | 5066f9908772d1838d73834eb5bcb6f8f7858fe1 (patch) | |
tree | a8abe11ccfb96033171985fcce6e6f86b8699dd9 /src/settings_interface.cpp | |
parent | def9f251739e9a0d6d0ff1c98dc4562dade3e9ef (diff) | |
download | ActorViewer-5066f9908772d1838d73834eb5bcb6f8f7858fe1.tar ActorViewer-5066f9908772d1838d73834eb5bcb6f8f7858fe1.tar.gz ActorViewer-5066f9908772d1838d73834eb5bcb6f8f7858fe1.zip |
Create convinence method for reading settings
This method avoids having to create a SettingsInterface object that will
be only used to read a small number of settings before being destroyed.
It creates a static object that persists between invocations. Through
the use of QSettings for reading a value, we are assured of always
reading the most up to date version of settings as this class guaranties
that changes done to one QSettings object will be immediately visible in
other QSettings objects.
Diffstat (limited to 'src/settings_interface.cpp')
-rw-r--r-- | src/settings_interface.cpp | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/src/settings_interface.cpp b/src/settings_interface.cpp index e14da92..17c5991 100644 --- a/src/settings_interface.cpp +++ b/src/settings_interface.cpp @@ -19,6 +19,11 @@ const QVariant SettingsInterface::read_setting(const QString &key) { return qt_settings.value(key, default_setting(key)); } +const QVariant SettingsInterface::quick_read_setting(const QString &key) { + static SettingsInterface settings; + return settings.read_setting(key); +} + // Write a new value for key. Isn't written to disk until you use SettingsInterface::commit(). void SettingsInterface::write_setting(const QString &key, const QVariant &value) { if (not modified) modified = new QHash<QString, QVariant>; |