FluentUI/example/src/helper/SettingsHelper.h

34 lines
1015 B
C
Raw Normal View History

2023-09-17 20:36:33 +08:00
#ifndef SETTINGSHELPER_H
#define SETTINGSHELPER_H
#include <QtCore/qobject.h>
#include <QtQml/qqml.h>
#include <QSettings>
#include <QScopedPointer>
#include <QFileInfo>
#include <QCoreApplication>
#include <QDir>
#include "src/singleton.h"
class SettingsHelper : public QObject
{
Q_OBJECT
private:
explicit SettingsHelper(QObject* parent = nullptr);
public:
SINGLETONG(SettingsHelper)
~SettingsHelper() override;
void init(char *argv[]);
Q_INVOKABLE void saveDarkMode(int darkModel){save("darkMode",darkModel);}
2023-12-08 17:30:50 +08:00
Q_INVOKABLE int getDarkMode(){return get("darkMode",QVariant(0)).toInt();}
2023-11-23 19:58:54 +08:00
Q_INVOKABLE void saveUseSystemAppBar(bool useSystemAppBar){save("useSystemAppBar",useSystemAppBar);}
2023-12-08 17:30:50 +08:00
Q_INVOKABLE bool getUseSystemAppBar(){return get("useSystemAppBar",QVariant(false)).toBool();}
2023-09-17 20:36:33 +08:00
private:
void save(const QString& key,QVariant val);
2023-10-17 22:18:12 +08:00
QVariant get(const QString& key,QVariant def={});
2023-09-17 20:36:33 +08:00
private:
QScopedPointer<QSettings> m_settings;
};
#endif // SETTINGSHELPER_H