|
KanoopCommonQt 2.1.1
Kanoop foundational Qt utility library
|
|
Persistent application settings storage backed by QSettings. More...
#include <appsettings.h>
Inheritance diagram for AppSettings:
Collaboration diagram for AppSettings:Signals | |
| void | settingsChanged () |
| Emitted when any setting value changes. | |
Public Member Functions | |
| AppSettings () | |
| Construct an AppSettings object backed by the default QSettings store. | |
| void | setStringValue (const QString &key, const QString &value) |
| Persist an arbitrary string value. | |
| QString | getStringValue (const QString &key) const |
| Retrieve an arbitrary string value. | |
| void | setVariantValue (const QString &key, const QVariant &value) |
| Persist an arbitrary QVariant value. | |
| QVariant | getVariantValue (const QString &key) const |
| Retrieve an arbitrary QVariant value. | |
| void | setByteArrayValue (const QString &key, const QByteArray &value) |
| Persist an arbitrary byte array value. | |
| QByteArray | getByteArrayValue (const QString &key) const |
| Retrieve an arbitrary byte array value. | |
| int | maxRecentFiles () const |
| Return the maximum number of recent files to track. | |
| void | setMaxRecentFiles (int value) |
| Set the maximum number of recent files to track. | |
| QString | lastDirectory (const QString &extension) const |
| Return the last directory used for a given file extension. | |
| QString | lastDirectory (int fileType) const |
| Return the last directory used for a given file-type integer. | |
| virtual void | saveLastDirectory (const QString &extension, const QString &value) |
| Save the last directory used for a given file extension. | |
| virtual void | saveLastDirectory (int fileType, const QString &value) |
| Save the last directory used for a given file-type integer. | |
| void | sync () |
| Synchronize settings file to disk and reload any changed values. | |
Static Public Member Functions | |
| static AppSettings * | globalInstance () |
| Return the process-wide AppSettings singleton. | |
| static void | setGlobalInstance (AppSettings *value) |
| Set the process-wide AppSettings singleton. | |
Protected Member Functions | |
| virtual void | ensureValidDefaults () |
| Override to ensure sane default values on first run. | |
Static Protected Member Functions | |
| static QString | makeStandardKey (const QString &key) |
| Build a settings key prefixed with the application key. | |
| static QString | makeKey (const QString &key, const QString &subKey) |
| Build a compound settings key from two parts. | |
| static QString | makeObjectKey (const QObject *object) |
| Build a settings key based on a QObject's identity. | |
| static QString | makeFileTypeKey (const QString &key, const QString &extension) |
| Build a settings key based on a file extension. | |
| static QString | makeFileTypeKey (const QString &key, int fileType) |
| Build a settings key based on a file-type integer. | |
| static QString | makeCompoundObjectKey (const QString &key, const QObject *object) |
| Build a compound settings key from a base key and a QObject. | |
Protected Attributes | |
| QSettings | _settings |
| Underlying QSettings storage. | |
Static Protected Attributes | |
| static const QString | KEY_APP |
| Settings key for the application group. | |
| static const QString | KEY_LAST_DIRECTORY |
| Settings key for the last-used directory. | |
Persistent application settings storage backed by QSettings.
AppSettings provides typed, named accessors for arbitrary key/value persistence and last-used-directory tracking. It has no Qt GUI dependencies and is suitable as a base class for non-GUI applications. Subclass to add application-specific settings; for GUI applications, subclass GuiSettings (in KanoopGuiQt) instead.
A process-wide singleton can be registered with setGlobalInstance() and retrieved with globalInstance().
Definition at line 30 of file appsettings.h.
|
inlineprotectedvirtual |
Override to ensure sane default values on first run.
Definition at line 156 of file appsettings.h.
|
inline |
Retrieve an arbitrary byte array value.
| key | Settings key |
Definition at line 78 of file appsettings.h.
|
inline |
Retrieve an arbitrary string value.
| key | Settings key |
Definition at line 50 of file appsettings.h.
|
inline |
Retrieve an arbitrary QVariant value.
| key | Settings key |
Definition at line 64 of file appsettings.h.
|
inlinestatic |
Return the process-wide AppSettings singleton.
Definition at line 129 of file appsettings.h.
|
inline |
Return the last directory used for a given file extension.
| extension | File extension (without leading dot) |
Definition at line 97 of file appsettings.h.
|
inline |
Return the last directory used for a given file-type integer.
| fileType | Application-defined file type integer |
Definition at line 104 of file appsettings.h.
|
inlinestaticprotected |
Build a compound settings key from two parts.
Definition at line 145 of file appsettings.h.
|
inlinestaticprotected |
Build a settings key prefixed with the application key.
Definition at line 143 of file appsettings.h.
|
inline |
Return the maximum number of recent files to track.
Definition at line 84 of file appsettings.h.
|
inlinevirtual |
Save the last directory used for a given file extension.
| extension | File extension (without leading dot) |
| value | Directory path to save |
Definition at line 111 of file appsettings.h.
|
inlinevirtual |
Save the last directory used for a given file-type integer.
| fileType | Application-defined file type integer |
| value | Directory path to save |
Definition at line 118 of file appsettings.h.
|
inline |
Persist an arbitrary byte array value.
| key | Settings key |
| value | Byte array to save |
Definition at line 71 of file appsettings.h.
|
inlinestatic |
Set the process-wide AppSettings singleton.
| value | Instance to register as global |
Definition at line 135 of file appsettings.h.
|
inline |
Set the maximum number of recent files to track.
| value | Maximum recent file count |
Definition at line 90 of file appsettings.h.
|
inline |
Persist an arbitrary string value.
| key | Settings key |
| value | String to save |
Definition at line 43 of file appsettings.h.
|
inline |
Persist an arbitrary QVariant value.
| key | Settings key |
| value | Variant to save |
Definition at line 57 of file appsettings.h.
|
protected |
Underlying QSettings storage.
Definition at line 159 of file appsettings.h.
|
staticprotected |
Settings key for the application group.
Definition at line 162 of file appsettings.h.
|
staticprotected |
Settings key for the last-used directory.
Definition at line 164 of file appsettings.h.