Phosphor
Qt6 / Wayland library suite for window-management tools
 
Loading...
Searching...
No Matches
PhosphorConfig::QSettingsBackend Class Reference

QSettings-backed configuration backend (INI format). More...

#include <phosphor-config/include/PhosphorConfig/QSettingsBackend.h>

Inheritance diagram for PhosphorConfig::QSettingsBackend:
[legend]

Public Member Functions

 QSettingsBackend (const QString &filePath)
 
 ~QSettingsBackend () override
 
std::unique_ptr< IGroupgroup (const QString &name) override
 Return a scoped view into the named group.
 
void reparseConfiguration () override
 Re-read configuration from disk, discarding any pending in-memory changes.
 
bool sync () override
 Flush pending writes to disk.
 
void deleteGroup (const QString &name) override
 Delete an entire group and everything inside it.
 
QString readRootString (const QString &key, const QString &defaultValue={}) const override
 Read/write ungrouped (root-level) keys.
 
void writeRootString (const QString &key, const QString &value) override
 
void removeRootKey (const QString &key) override
 
QStringList groupList () const override
 Enumerate every top-level group name.
 
- Public Member Functions inherited from PhosphorConfig::IBackend
virtual ~IBackend ()=default
 
virtual void setPathResolver (std::shared_ptr< IGroupPathResolver >)
 Install a group-path resolver.
 
virtual std::shared_ptr< IGroupPathResolverpathResolver () const
 Currently-installed resolver, or nullptr when none is set (also the default for backends that ignore setPathResolver).
 
virtual void setVersionStamp (const QString &, int)
 Install a "stamp on first sync" version annotation: if key is absent from the backend's root on the next flush, write key = version.
 
virtual std::pair< QString, int > versionStamp () const
 Currently-installed version stamp as {key, version}.
 
virtual bool applyMigration (const Schema &)
 Apply schema's migration chain against the backend's in-memory state and commit any resulting version bump.
 
 IBackend (const IBackend &)=delete
 
IBackendoperator= (const IBackend &)=delete
 

Static Public Member Functions

static QMap< QString, QVariant > readConfigFromDisk (const QString &filePath)
 Read an INI config from an arbitrary file path, bypassing Qt's QConfFile cache.
 

Additional Inherited Members

- Protected Member Functions inherited from PhosphorConfig::IBackend
 IBackend ()=default
 

Detailed Description

QSettings-backed configuration backend (INI format).

Primarily exists to read legacy INI files during a one-time migration to the JSON backend. New consumers should prefer JsonBackend.

Constructor & Destructor Documentation

◆ QSettingsBackend()

PhosphorConfig::QSettingsBackend::QSettingsBackend ( const QString &  filePath)
explicit

◆ ~QSettingsBackend()

PhosphorConfig::QSettingsBackend::~QSettingsBackend ( )
override

Member Function Documentation

◆ deleteGroup()

void PhosphorConfig::QSettingsBackend::deleteGroup ( const QString &  name)
overridevirtual

Delete an entire group and everything inside it.

Intermediate parents are pruned if they become empty (dot-path groups only).

Implements PhosphorConfig::IBackend.

◆ group()

std::unique_ptr< IGroup > PhosphorConfig::QSettingsBackend::group ( const QString &  name)
overridevirtual

Return a scoped view into the named group.

Caller owns the pointer; destroy it before asking for another group on this backend.

Implements PhosphorConfig::IBackend.

◆ groupList()

QStringList PhosphorConfig::QSettingsBackend::groupList ( ) const
overridevirtual

Enumerate every top-level group name.

Dot-path groups are returned with their full path ("Snapping", "Snapping.Behavior", ...). Groups produced by a plugged-in IGroupPathResolver appear in the resolver's preferred external form.

Implements PhosphorConfig::IBackend.

◆ readConfigFromDisk()

static QMap< QString, QVariant > PhosphorConfig::QSettingsBackend::readConfigFromDisk ( const QString &  filePath)
static

Read an INI config from an arbitrary file path, bypassing Qt's QConfFile cache.

Returns a flat QMap keyed by "Group/Key". Used by migration chains that want to consume a legacy INI without installing it as an active QSettings source.

◆ readRootString()

QString PhosphorConfig::QSettingsBackend::readRootString ( const QString &  key,
const QString &  defaultValue = {} 
) const
overridevirtual

Read/write ungrouped (root-level) keys.

Implements PhosphorConfig::IBackend.

◆ removeRootKey()

void PhosphorConfig::QSettingsBackend::removeRootKey ( const QString &  key)
overridevirtual

◆ reparseConfiguration()

void PhosphorConfig::QSettingsBackend::reparseConfiguration ( )
overridevirtual

Re-read configuration from disk, discarding any pending in-memory changes.

Must not be called while a group view is live.

Implements PhosphorConfig::IBackend.

◆ sync()

bool PhosphorConfig::QSettingsBackend::sync ( )
overridevirtual

Flush pending writes to disk.

No-op when nothing is dirty. Returns true on success (or when there was nothing to flush), false on an I/O error — backends log the reason before returning.

Implements PhosphorConfig::IBackend.

◆ writeRootString()

void PhosphorConfig::QSettingsBackend::writeRootString ( const QString &  key,
const QString &  value 
)
overridevirtual

The documentation for this class was generated from the following file: