This repository has been archived on 2024-06-03. You can view files and clone it, but cannot push or open issues or pull requests.
app/headers/scstwappsettings.h

59 lines
1.5 KiB
C
Raw Normal View History

2020-07-06 15:04:02 +02:00
#ifndef APPSETTINGS_H
#define APPSETTINGS_H
#include <QObject>
#include <QSettings>
#include <QStandardPaths>
2020-07-10 15:20:41 +02:00
#include "scstwremotesettings.h"
2020-07-06 15:04:02 +02:00
2020-07-10 15:20:41 +02:00
class ScStwAppSettings : public ScStwRemoteSettings
2020-07-06 15:04:02 +02:00
{
Q_OBJECT
public:
explicit ScStwAppSettings(QObject *parent = nullptr);
2020-07-10 15:20:41 +02:00
explicit ScStwAppSettings(ScStwClient * scStwClient, QObject *parent = nullptr);
2020-07-06 15:04:02 +02:00
enum AppInternalSetting {
InvalidSetting = -1,
AppThemeSetting,
BaseStationIpSetting
};
Q_ENUM(AppInternalSetting)
2020-07-10 15:20:41 +02:00
enum KeyLevelEnum {
KeyLevel = 1
};
Q_ENUM(KeyLevelEnum)
2020-07-06 15:04:02 +02:00
using ScStwSettings::readSetting;
2020-07-10 15:20:41 +02:00
Q_INVOKABLE QVariant readSetting(AppInternalSetting key);
2020-07-06 15:04:02 +02:00
using ScStwSettings::writeSetting;
2020-07-10 15:20:41 +02:00
Q_INVOKABLE bool writeSetting(AppInternalSetting key, QVariant value);
2020-07-06 15:04:02 +02:00
using ScStwSettings::setDefaultSetting;
Q_INVOKABLE bool setDefaultSetting(AppInternalSetting key, QVariant defaultValue);
static QString keyToString(int key) {
return QMetaEnum::fromType<AppInternalSetting>().valueToKey(key);
}
2020-07-06 15:04:02 +02:00
2020-07-30 11:29:11 +02:00
static QVariant::Type keyToType(int key) {
QMap<AppInternalSetting, QVariant::Type> types = {
{AppThemeSetting, QVariant::String},
{BaseStationIpSetting, QVariant::String}
};
if(types.contains(AppInternalSetting(key)))
return types[AppInternalSetting(key)];
return QVariant::Invalid;
}
2020-07-06 15:04:02 +02:00
signals:
public slots:
};
extern ScStwAppSettings * pGlobalAppSettings;
#endif // APPSETTINGS_H