Settings.h header

#include <ew/app/Settings.h>

Namespace ew::app

Settings class

class ew::app::Settings

Key/value application settings (theme, recent projects, window state, ...). An interface so the UI depends on the abstraction and tests use an in-memory implementation (CODING_STANDARDS section 7: seams are interfaces).

Members

ew::app::settings::Settings::Settings()=default

Defaulted.

virtual ew::app::settings::Settings::~Settings()=default

Defaulted.

ew::app::settings::Settings::Settings(const Settings &)=delete

Interface type: non-copyable and non-movable (held via pointer/reference).

ew::app::settings::Settings::Settings(Settings &&)=delete

Not movable.

Settings & ew::app::settings::Settings::operator=(const Settings &)=delete

Not copyable.

Settings & ew::app::settings::Settings::operator=(Settings &&)=delete

Not movable.

virtual std::optional< QString > ew::app::settings::Settings::value(QStringView key) const =0

Returns the value stored for key, or std::nullopt if none is set.

virtual void ew::app::settings::Settings::setValue(QStringView key, const QString &value)=0

Stores value under key, replacing any existing value.

virtual bool ew::app::settings::Settings::contains(QStringView key) const =0

Returns true if a value is stored for key.

virtual void ew::app::settings::Settings::remove(QStringView key)=0

Removes the value stored for key, if any, AND every key beneath it.

Keys are hierarchical, separated by / ("shortcuts/save"), and removing a group removes its members – the semantics QSettings has and every implementation must match. It is stated here because it is the kind of difference a test double drifts on silently: a double that removed only the exact key would let remove("shortcuts") pass a test while the same call erased every shortcut the user had rebound.