RedPanda-CPP/RedPandaIDE/settings.h

61 lines
1.4 KiB
C
Raw Normal View History

#ifndef SETTINGS_H
#define SETTINGS_H
#include <QSettings>
2021-04-13 11:23:37 +08:00
#define SETTING_DIRS "dirs"
#define SETTING_EDITOR "editor"
#define SETTING_EDITOR_DEFAULT_ENCODING "default_encoding"
#define SETTING_EDITOR_AUTO_INDENT "default_auto_indent"
2021-04-09 17:48:25 +08:00
class Settings
{
2021-04-13 11:23:37 +08:00
private:
class _Base {
public:
explicit _Base(Settings* settings, const QString& groupName);
void setDefault(const QString &key, const QVariant &value);
void setValue(const QString &key, const QVariant &value);
QVariant value(const QString &key);
protected:
Settings* mSettings;
QString mGroup;
};
2021-04-13 11:23:37 +08:00
public:
class Dirs: public _Base {
public:
explicit Dirs(Settings * settings);
const QString app() const;
};
class Editor: public _Base {
public:
explicit Editor(Settings * settings);
QByteArray defaultEncoding();
void setDefaultEncoding(const QByteArray& encoding);
bool autoIndent();
void setAutoIndent(bool indent);
};
public:
Settings();
2021-04-13 11:23:37 +08:00
void setDefault(const QString& group, const QString &key, const QVariant &value);
void setValue(const QString& group, const QString &key, const QVariant &value);
QVariant value(const QString& group, const QString &key);
Dirs& dirs();
Editor& editor();
private:
QSettings mSettings;
2021-04-13 11:23:37 +08:00
Dirs mDirs;
Editor mEditor;
};
2021-04-13 11:23:37 +08:00
extern Settings* pSettings;
#endif // SETTINGS_H