58 lines
1.5 KiB
C++
58 lines
1.5 KiB
C++
#ifndef APPSETTINGS_H
|
|
#define APPSETTINGS_H
|
|
|
|
#include <QObject>
|
|
#include <QSettings>
|
|
#include <QStandardPaths>
|
|
#include "scstwremotesettings.h"
|
|
|
|
class ScStwAppSettings : public ScStwRemoteSettings
|
|
{
|
|
Q_OBJECT
|
|
public:
|
|
explicit ScStwAppSettings(QObject *parent = nullptr);
|
|
explicit ScStwAppSettings(ScStwClient * scStwClient, QObject *parent = nullptr);
|
|
|
|
enum AppInternalSetting {
|
|
InvalidSetting = -1,
|
|
AppThemeSetting,
|
|
BaseStationIpSetting
|
|
};
|
|
Q_ENUM(AppInternalSetting)
|
|
|
|
enum KeyLevelEnum {
|
|
KeyLevel = 1
|
|
};
|
|
Q_ENUM(KeyLevelEnum)
|
|
|
|
using ScStwSettings::readSetting;
|
|
Q_INVOKABLE QVariant readSetting(AppInternalSetting key);
|
|
using ScStwSettings::writeSetting;
|
|
Q_INVOKABLE bool writeSetting(AppInternalSetting key, QVariant value);
|
|
using ScStwSettings::setDefaultSetting;
|
|
Q_INVOKABLE bool setDefaultSetting(AppInternalSetting key, QVariant defaultValue);
|
|
|
|
static QString keyToString(int key) {
|
|
return QMetaEnum::fromType<AppInternalSetting>().valueToKey(key);
|
|
}
|
|
|
|
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;
|
|
}
|
|
|
|
signals:
|
|
|
|
public slots:
|
|
|
|
};
|
|
extern ScStwAppSettings * pGlobalAppSettings;
|
|
|
|
#endif // APPSETTINGS_H
|