16#include <Kanoop/gui/libkanoopgui.h>
47 void setLastWindowPosition(
const QWidget* widget,
const QPoint& pos) { _settings.setValue(makeKey(KEY_LAST_WIDGET_POS, widget->objectName()), pos); }
62 void setLastWindowSize(
const QWidget* widget,
const QSize& size) { _settings.setValue(makeKey(KEY_LAST_WIDGET_SIZE, widget->objectName()), size); }
134 void setStringValue(
const QString& key,
const QString& value) { _settings.setValue(key, value); }
141 QString
getStringValue(
const QString& key)
const {
return _settings.value(key).toString(); }
148 void setVariantValue(
const QString& key,
const QVariant& value) { _settings.setValue(key, value); }
162 void setByteArrayValue(
const QString& key,
const QByteArray& value) { _settings.setValue(key, value); }
169 QByteArray
getByteArrayValue(
const QString& key)
const {
return _settings.value(key).toByteArray(); }
188 QString
lastDirectory(
const QString& extension)
const {
return _settings.value(makeFileTypeKey(KEY_LAST_DIRECTORY, extension)).toString(); }
195 QString
lastDirectory(
int fileType)
const {
return _settings.value(makeFileTypeKey(KEY_LAST_DIRECTORY, fileType)).toString(); }
202 virtual void saveLastDirectory(
const QString& extension,
const QString& value) { _settings.setValue(makeFileTypeKey(KEY_LAST_DIRECTORY, extension), value); }
209 virtual void saveLastDirectory(
int fileType,
const QString& value) { _settings.setValue(makeFileTypeKey(KEY_LAST_DIRECTORY, fileType), value); }
220 int fontSize()
const {
return _settings.value(makeStandardKey(KEY_FONT_SIZE)).toInt(); }
226 void setFontSize(
int value) { _settings.setValue(makeStandardKey(KEY_FONT_SIZE), value); }
246 static QString
makeStandardKey(
const QString& key) {
return QString(
"%1/%2").arg(KEY_APP).arg(key); }
248 static QString
makeKey(
const QString& key,
const QString& subKey) {
return QString(
"%1/%2").arg(key).arg(subKey); }
291 static QStringList uuidListToStringList(
const QList<QUuid>& uuids);
293 static QList<QUuid> stringListToUuidList(
const QStringList& values);
Extended QAbstractItemModel providing EntityMetadata-based item lookup and header management.
Persistent GUI settings storage for widget geometry, header states, and directories.
static void setGlobalInstance(GuiSettings *value)
Set the process-wide GuiSettings singleton.
QSize getLastWindowSize(const QWidget *widget, const QSize &defaultSize=QSize())
Retrieve the last saved size of a widget.
void setStringValue(const QString &key, const QString &value)
Persist an arbitrary string value.
static const QString KEY_HEADER_STATE_HORIZ
Settings key for the horizontal header state.
static QString makeFileTypeKey(const QString &key, const QString &extension)
Build a settings key based on a file extension.
static QString makeObjectKey(const QObject *object)
Build a settings key based on a QObject's identity.
QByteArray getByteArrayValue(const QString &key) const
Retrieve an arbitrary byte array value.
static const QString KEY_SPLITTER_STATE_HORIZ
Settings key for the horizontal splitter state.
QSettings _settings
Underlying QSettings storage.
void setMaxRecentFiles(int value)
Set the maximum number of recent files to track.
virtual void saveLastDirectory(const QString &extension, const QString &value)
Save the last directory used for a given file extension.
void saveLastHeaderState(QHeaderView *header)
Save the current state of a QHeaderView.
virtual void saveLastDirectory(int fileType, const QString &value)
Save the last directory used for a given file-type integer.
static const QString KEY_LAST_WIDGET_SIZE
Settings key for the last widget size.
static QString makeFileTypeKey(const QString &key, int fileType)
Build a settings key based on a file-type integer.
QString getStringValue(const QString &key) const
Retrieve an arbitrary string value.
void saveTreeViewState(TreeViewBase *treeView)
Save the expansion/selection state of a TreeViewBase.
bool widgetHasPersistentGeometry(const QWidget *widget) const
Return whether any geometry has been saved for a widget.
void restoreLastHeaderState(QHeaderView *header)
Restore a previously saved QHeaderView state.
void restoreLastSplitterState(QSplitter *splitter)
Restore a previously saved QSplitter state.
void restoreTreeViewState(TreeViewBase *treeView)
Restore the expansion/selection state of a TreeViewBase.
static const QString KEY_LAST_WIDGET_POS
Settings key for the last widget position.
void restoreLastHeaderState(QHeaderView *header, AbstractItemModel *model)
Restore header state using the model's column definitions as keys.
static const QString KEY_LAST_DIRECTORY
Settings key for the last-used directory.
int maxRecentFiles() const
Return the maximum number of recent files to track.
static GuiSettings * globalInstance()
Return the process-wide GuiSettings singleton.
int fontSize() const
Return the persisted font size.
QVariant getVariantValue(const QString &key) const
Retrieve an arbitrary QVariant value.
void setVariantValue(const QString &key, const QVariant &value)
Persist an arbitrary QVariant value.
static QString makeCompoundObjectKey(const QString &key, const QObject *object)
Build a compound settings key from a base key and a QObject.
static QString makeStandardKey(const QString &key)
Build a settings key prefixed with the application key.
static const QString KEY_MODEL_HEADER_STATE_VERT
Settings key for the vertical model header state.
virtual void ensureValidDefaults()
Override to ensure sane default values on first run.
static const QString KEY_APP
Settings key for the application group.
void saveLastSplitterState(QSplitter *splitter)
Save the current state of a QSplitter.
void sync()
Synchronize settings file to disk and reload any changed values.
static const QString KEY_SPLITTER_STATE_VERT
Settings key for the vertical splitter state.
static const QString KEY_FONT_SIZE
Settings key for the saved font size.
void saveLastHeaderState(QHeaderView *header, AbstractItemModel *model)
Save header state using the model's column definitions as keys.
QString lastDirectory(const QString &extension) const
Return the last directory used for a given file extension.
QPoint getLastWindowPosition(QWidget *widget, const QSize &defaultSize=QSize()) const
Retrieve the last saved position of a widget.
void setByteArrayValue(const QString &key, const QByteArray &value)
Persist an arbitrary byte array value.
void setLastWindowSize(const QWidget *widget, const QSize &size)
Persist the last size of a widget.
void setFontSize(int value)
Persist the font size.
static const QString KEY_HEADER_STATE_VERT
Settings key for the vertical header state.
GuiSettings()
Construct a GuiSettings object backed by the default QSettings store.
QString lastDirectory(int fileType) const
Return the last directory used for a given file-type integer.
static const QString KEY_MODEL_HEADER_STATE_HORIZ
Settings key for the horizontal model header state.
void settingsChanged()
Emitted when any setting value changes.
static const QString KEY_TREEVIEW_STATE
Settings key for the tree view expansion state.
void setLastWindowPosition(const QWidget *widget, const QPoint &pos)
Persist the last position of a widget.
static QString makeKey(const QString &key, const QString &subKey)
Build a compound settings key from two parts.
QTreeView subclass integrating AbstractItemModel with rich navigation helpers.