|
KanoopGuiQt 1.3.0
Qt GUI utility library
|
|
Persistent GUI settings storage for widget geometry, header states, and directories. More...
#include <guisettings.h>
Inheritance diagram for GuiSettings:
Collaboration diagram for GuiSettings:Signals | |
| void | settingsChanged () |
| Emitted when any setting value changes. | |
Public Member Functions | |
| GuiSettings () | |
| Construct a GuiSettings object backed by the default QSettings store. | |
| void | setLastWindowPosition (const QWidget *widget, const QPoint &pos) |
| Persist the last position of a widget. | |
| QPoint | getLastWindowPosition (QWidget *widget, const QSize &defaultSize=QSize()) const |
| Retrieve the last saved position of a widget. | |
| void | setLastWindowSize (const QWidget *widget, const QSize &size) |
| Persist the last size of a widget. | |
| QSize | getLastWindowSize (const QWidget *widget, const QSize &defaultSize=QSize()) |
| Retrieve the last saved size of a widget. | |
| bool | widgetHasPersistentGeometry (const QWidget *widget) const |
| Return whether any geometry has been saved for a widget. | |
| void | saveLastSplitterState (QSplitter *splitter) |
| Save the current state of a QSplitter. | |
| void | restoreLastSplitterState (QSplitter *splitter) |
| Restore a previously saved QSplitter state. | |
| void | saveLastHeaderState (QHeaderView *header) |
| Save the current state of a QHeaderView. | |
| void | restoreLastHeaderState (QHeaderView *header) |
| Restore a previously saved QHeaderView state. | |
| void | saveLastHeaderState (QHeaderView *header, AbstractItemModel *model) |
| Save header state using the model's column definitions as keys. | |
| void | restoreLastHeaderState (QHeaderView *header, AbstractItemModel *model) |
| Restore header state using the model's column definitions as keys. | |
| void | saveTreeViewState (TreeViewBase *treeView) |
| Save the expansion/selection state of a TreeViewBase. | |
| void | restoreTreeViewState (TreeViewBase *treeView) |
| Restore the expansion/selection state of a TreeViewBase. | |
| 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. | |
| int | fontSize () const |
| Return the persisted font size. | |
| void | setFontSize (int value) |
| Persist the font size. | |
Static Public Member Functions | |
| static GuiSettings * | globalInstance () |
| Return the process-wide GuiSettings singleton. | |
| static void | setGlobalInstance (GuiSettings *value) |
| Set the process-wide GuiSettings 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_FONT_SIZE |
| Settings key for the saved font size. | |
| static const QString | KEY_HEADER_STATE_HORIZ |
| Settings key for the horizontal header state. | |
| static const QString | KEY_HEADER_STATE_VERT |
| Settings key for the vertical header state. | |
| static const QString | KEY_LAST_DIRECTORY |
| Settings key for the last-used directory. | |
| static const QString | KEY_LAST_WIDGET_POS |
| Settings key for the last widget position. | |
| static const QString | KEY_LAST_WIDGET_SIZE |
| Settings key for the last widget size. | |
| static const QString | KEY_MODEL_HEADER_STATE_HORIZ |
| Settings key for the horizontal model header state. | |
| static const QString | KEY_MODEL_HEADER_STATE_VERT |
| Settings key for the vertical model header state. | |
| static const QString | KEY_SPLITTER_STATE_HORIZ |
| Settings key for the horizontal splitter state. | |
| static const QString | KEY_SPLITTER_STATE_VERT |
| Settings key for the vertical splitter state. | |
| static const QString | KEY_TREEVIEW_STATE |
| Settings key for the tree view expansion state. | |
Persistent GUI settings storage for widget geometry, header states, and directories.
GuiSettings wraps QSettings to provide typed, named accessors for common GUI state such as window positions, sizes, splitter states, header view states, and last-used directories. Subclass to add application-specific settings.
A process-wide singleton can be registered with setGlobalInstance() and retrieved with globalInstance().
Definition at line 33 of file guisettings.h.
|
inline |
Return the persisted font size.
Definition at line 220 of file guisettings.h.
|
inline |
Retrieve an arbitrary byte array value.
| key | Settings key |
Definition at line 169 of file guisettings.h.
| QPoint GuiSettings::getLastWindowPosition | ( | QWidget * | widget, |
| const QSize & | defaultSize = QSize() |
||
| ) | const |
Retrieve the last saved position of a widget.
| widget | Widget to look up |
| defaultSize | Default size used to compute a centred position if no position is saved |
| QSize GuiSettings::getLastWindowSize | ( | const QWidget * | widget, |
| const QSize & | defaultSize = QSize() |
||
| ) |
Retrieve the last saved size of a widget.
| widget | Widget to look up |
| defaultSize | Size to return if nothing is saved |
|
inline |
Retrieve an arbitrary string value.
| key | Settings key |
Definition at line 141 of file guisettings.h.
|
inline |
Retrieve an arbitrary QVariant value.
| key | Settings key |
Definition at line 155 of file guisettings.h.
|
static |
Return the process-wide GuiSettings singleton.
|
inline |
Return the last directory used for a given file extension.
| extension | File extension (without leading dot) |
Definition at line 188 of file guisettings.h.
|
inline |
Return the last directory used for a given file-type integer.
| fileType | Application-defined file type integer |
Definition at line 195 of file guisettings.h.
|
inlinestaticprotected |
Build a compound settings key from two parts.
Definition at line 248 of file guisettings.h.
|
inlinestaticprotected |
Build a settings key prefixed with the application key.
Definition at line 246 of file guisettings.h.
|
inline |
Return the maximum number of recent files to track.
Definition at line 175 of file guisettings.h.
| void GuiSettings::restoreLastHeaderState | ( | QHeaderView * | header | ) |
Restore a previously saved QHeaderView state.
| header | Header view to restore |
| void GuiSettings::restoreLastHeaderState | ( | QHeaderView * | header, |
| AbstractItemModel * | model | ||
| ) |
Restore header state using the model's column definitions as keys.
| header | Header view to restore |
| model | Model providing column metadata for keying |
| void GuiSettings::restoreLastSplitterState | ( | QSplitter * | splitter | ) |
Restore a previously saved QSplitter state.
| splitter | Splitter to restore |
| void GuiSettings::restoreTreeViewState | ( | TreeViewBase * | treeView | ) |
Restore the expansion/selection state of a TreeViewBase.
| treeView | Tree view to restore |
|
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 202 of file guisettings.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 209 of file guisettings.h.
| void GuiSettings::saveLastHeaderState | ( | QHeaderView * | header | ) |
Save the current state of a QHeaderView.
| header | Header view whose state to save |
| void GuiSettings::saveLastHeaderState | ( | QHeaderView * | header, |
| AbstractItemModel * | model | ||
| ) |
Save header state using the model's column definitions as keys.
| header | Header view whose state to save |
| model | Model providing column metadata for keying |
| void GuiSettings::saveLastSplitterState | ( | QSplitter * | splitter | ) |
Save the current state of a QSplitter.
| splitter | Splitter whose state to save |
| void GuiSettings::saveTreeViewState | ( | TreeViewBase * | treeView | ) |
Save the expansion/selection state of a TreeViewBase.
| treeView | Tree view whose state to save |
|
inline |
Persist an arbitrary byte array value.
| key | Settings key |
| value | Byte array to save |
Definition at line 162 of file guisettings.h.
|
inline |
Persist the font size.
| value | Font point size |
Definition at line 226 of file guisettings.h.
|
inlinestatic |
Set the process-wide GuiSettings singleton.
| value | Instance to register as global |
Definition at line 238 of file guisettings.h.
|
inline |
Persist the last position of a widget.
| widget | Widget whose position to save (key is based on objectName) |
| pos | Position to save |
Definition at line 47 of file guisettings.h.
|
inline |
Persist the last size of a widget.
| widget | Widget whose size to save |
| size | Size to save |
Definition at line 62 of file guisettings.h.
|
inline |
Set the maximum number of recent files to track.
| value | Maximum recent file count |
Definition at line 181 of file guisettings.h.
|
inline |
Persist an arbitrary string value.
| key | Settings key |
| value | String to save |
Definition at line 134 of file guisettings.h.
|
inline |
Persist an arbitrary QVariant value.
| key | Settings key |
| value | Variant to save |
Definition at line 148 of file guisettings.h.
| bool GuiSettings::widgetHasPersistentGeometry | ( | const QWidget * | widget | ) | const |
Return whether any geometry has been saved for a widget.
| widget | Widget to check |
|
protected |
Underlying QSettings storage.
Definition at line 262 of file guisettings.h.
|
staticprotected |
Settings key for the application group.
Definition at line 265 of file guisettings.h.
|
staticprotected |
Settings key for the saved font size.
Definition at line 267 of file guisettings.h.
|
staticprotected |
Settings key for the horizontal header state.
Definition at line 269 of file guisettings.h.
|
staticprotected |
Settings key for the vertical header state.
Definition at line 271 of file guisettings.h.
|
staticprotected |
Settings key for the last-used directory.
Definition at line 273 of file guisettings.h.
|
staticprotected |
Settings key for the last widget position.
Definition at line 275 of file guisettings.h.
|
staticprotected |
Settings key for the last widget size.
Definition at line 277 of file guisettings.h.
|
staticprotected |
Settings key for the horizontal model header state.
Definition at line 279 of file guisettings.h.
|
staticprotected |
Settings key for the vertical model header state.
Definition at line 281 of file guisettings.h.
|
staticprotected |
Settings key for the horizontal splitter state.
Definition at line 283 of file guisettings.h.
|
staticprotected |
Settings key for the vertical splitter state.
Definition at line 285 of file guisettings.h.
|
staticprotected |
Settings key for the tree view expansion state.
Definition at line 287 of file guisettings.h.