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[]);
|
2023-10-17 22:18:12 +08:00
|
|
|
Q_INVOKABLE void saveRender(const QVariant& render){save("render",render);}
|
|
|
|
Q_INVOKABLE QVariant getRender(){return get("render");}
|
2023-09-17 20:36:33 +08:00
|
|
|
Q_INVOKABLE void saveDarkMode(int darkModel){save("darkMode",darkModel);}
|
2023-10-17 22:18:12 +08:00
|
|
|
Q_INVOKABLE QVariant getDarkMode(){return get("darkMode",QVariant(0));}
|
2023-10-15 17:24:33 +08:00
|
|
|
Q_INVOKABLE void saveVsync(bool vsync){save("vsync",vsync);}
|
2023-10-17 22:18:12 +08:00
|
|
|
Q_INVOKABLE QVariant getVsync(){return get("vsync",QVariant(true));}
|
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
|