QuasarAppLib 1.0.530.c9fba11
settings.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2021-2026 QuasarApp.
3 * Distributed under the lgplv3 software license, see the accompanying
4 * Everyone is permitted to copy and distribute verbatim copies
5 * of this license document, but changing it is not allowed.
6*/
7
8
9#ifndef SETTINGS_H
10#define SETTINGS_H
11
12#include "quasarapp_global.h"
13#include "isettings.h"
14#include <QSet>
15#include <QSettings>
16
17namespace QuasarAppUtils {
18
43{
44 Q_OBJECT
45public:
50 Settings(QSettings::Format format = QSettings::IniFormat);
51
52 // ISettings interface
59 const QSet<QString> &boolOptions() const;
60
67 void setBoolOptions(const QSet<QString> &newBoolOptions);
68
74 static bool initService();
75
82 static ISettings *autoInstance();
83
84
85protected:
86
91 void syncImplementation() override;
98 QVariant getValueImplementation(const QString &key, const QVariant &def) override;
104 void setValueImplementation(const QString key, const QVariant &value) override;
109 bool ignoreToRest(const QString &) const override;
115 QHash<QString, QVariant> defaultSettings() override;
116
127 virtual bool isBool(const QString& key) const;
133 void setGroup(const QString&);
134
135private:
137 QSettings *_settings = nullptr;
138
140 QSet<QString> _boolOptions;
141};
142
143}
144
145#endif // SETTINGS_H
ISettings(SettingsSaveMode mode=SettingsSaveMode::Auto)
Definition isettings.cpp:15
bool ignoreToRest(const QString &) const override
ignoreToRest This method checks if the key is a boolean option.
Definition settings.cpp:46
const QSet< QString > & boolOptions() const
boolOptions returns current map with keys that has a bool type.
Definition settings.cpp:58
Settings(QSettings::Format format=QSettings::IniFormat)
Settings This is the main constructor of the Settings object.
Definition settings.cpp:16
static bool initService()
initService This method initialize default object of the QuasarAppUtils::Settings type.
Definition settings.cpp:68
QVariant getValueImplementation(const QString &key, const QVariant &def) override
getValueImplementation This method returns the value of the key setting from the QSettings backend.
Definition settings.cpp:34
virtual bool isBool(const QString &key) const
isBool This method should be return true if the key's type is bool. This is needed because QVariant w...
Definition settings.cpp:54
QHash< QString, QVariant > defaultSettings() override
defaultSettings This method returns the default map of the settings and their values....
Definition settings.cpp:50
void setBoolOptions(const QSet< QString > &newBoolOptions)
setBoolOptions This method sets new map of the boolean options.
Definition settings.cpp:63
static ISettings * autoInstance()
autoInstance This method returns the default object of the QuasarAppUtils::Settings type and if it wa...
Definition settings.cpp:72
void setGroup(const QString &)
setGroup This method sets a new settings group in the QSettings backend. All values that will be read...
void setValueImplementation(const QString key, const QVariant &value) override
setValueImplementation This method sets a new value for the key setting in the QSettings backend.
Definition settings.cpp:42
void syncImplementation() override
syncImplementation This method saves all settings data to the hard disk. This is the QSettings based ...
Definition settings.cpp:30
The QuasarAppUtils namespace contains the base functions for all applications of the QuasarApp group....
#define QUASARAPPSHARED_EXPORT