47 lines
1.3 KiB
C++
47 lines
1.3 KiB
C++
#ifndef SETTINGSSERVICE_H
|
|
#define SETTINGSSERVICE_H
|
|
|
|
#include <QObject>
|
|
#include <QSettings>
|
|
|
|
class SettingsService : public QObject
|
|
{
|
|
Q_OBJECT
|
|
|
|
Q_PROPERTY(QString serverAddress READ serverAddress WRITE setServerAddress NOTIFY serverAddressChanged)
|
|
Q_PROPERTY(QString selectedUserId READ selectedUserId WRITE setSelectedUserId NOTIFY selectedUserIdChanged)
|
|
Q_PROPERTY(QString selectedStoreId READ selectedStoreId WRITE setSelectedStoreId NOTIFY selectedStoreIdChanged)
|
|
|
|
public:
|
|
static SettingsService *instance()
|
|
{
|
|
static SettingsService i;
|
|
return &i;
|
|
}
|
|
|
|
QString serverAddress() const;
|
|
void setServerAddress(const QString &address);
|
|
|
|
QString selectedUserId() const;
|
|
void setSelectedUserId(const QString &userId);
|
|
|
|
QString selectedStoreId() const;
|
|
void setSelectedStoreId(const QString &storeId);
|
|
|
|
signals:
|
|
void serverAddressChanged();
|
|
void selectedUserIdChanged();
|
|
void selectedStoreIdChanged();
|
|
|
|
private:
|
|
QVariant value(const QString &key, const QVariant &defaultValue = QVariant{}) const;
|
|
void setValue(const QString &key, const QVariant &value);
|
|
|
|
SettingsService() = default;
|
|
~SettingsService() = default;
|
|
|
|
QSettings m_settings = QSettings("DedSoft", "BeerLog");
|
|
};
|
|
|
|
#endif // SETTINGSSERVICE_H
|