ORE Studio 0.0.4
Loading...
Searching...
No Matches
Static Public Member Functions | List of all members
UiPersistence Class Reference

Static utility for persisting UI widget state via QSettings. More...

#include <UiPersistence.hpp>

Collaboration diagram for UiPersistence:
Collaboration graph

Static Public Member Functions

static void saveSize (const QString &group, const QWidget *w)
 Save widget size to settings.
 
static QSize restoreSize (const QString &group, const QSize &defaultSize={900, 400})
 Restore saved widget size, or return defaultSize if none saved.
 
static void saveSplitter (const QString &group, const QSplitter *s)
 Save splitter position to settings.
 
static void restoreSplitter (const QString &group, QSplitter *s)
 Restore saved splitter position. No-op if no state is saved.
 
static void saveHeader (const QString &group, const QHeaderView *h, int version=1)
 Save table header state (column widths, order, visibility) to settings.
 
static bool restoreHeader (const QString &group, QHeaderView *h, int version=1)
 Restore saved table header state.
 

Detailed Description

Static utility for persisting UI widget state via QSettings.

All methods use QSettings("OreStudio", "OreStudio") and store values under the given group name. Methods are composable — callers may save and restore only the subset of state they need.

Typical usage:

// In closeEvent():
UiPersistence::saveSize("MyWindow", this);
UiPersistence::saveSplitter("MyWindow", splitter_);
// In constructor/setup (after widgets are created):
savedSize_ = UiPersistence::restoreSize("MyWindow", {800, 500});
UiPersistence::restoreSplitter("MyWindow", splitter_);
static void saveSplitter(const QString &group, const QSplitter *s)
Save splitter position to settings.
Definition UiPersistence.cpp:52
static void saveSize(const QString &group, const QWidget *w)
Save widget size to settings.
Definition UiPersistence.cpp:37
static QSize restoreSize(const QString &group, const QSize &defaultSize={900, 400})
Restore saved widget size, or return defaultSize if none saved.
Definition UiPersistence.cpp:44
static void restoreSplitter(const QString &group, QSplitter *s)
Restore saved splitter position. No-op if no state is saved.
Definition UiPersistence.cpp:59

Member Function Documentation

◆ saveHeader()

void saveHeader ( const QString &  group,
const QHeaderView *  h,
int  version = 1 
)
static

Save table header state (column widths, order, visibility) to settings.

Parameters
versionBump this when the column layout changes to invalidate old state.

◆ restoreHeader()

bool restoreHeader ( const QString &  group,
QHeaderView *  h,
int  version = 1 
)
static

Restore saved table header state.

Returns
true if state was restored successfully. false if no saved state or version mismatch — the caller should apply their default hidden columns.