2021-04-08 10:29:21 +08:00
|
|
|
#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
|
|
|
|
2021-04-08 10:29:21 +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-08 10:29:21 +08:00
|
|
|
|
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);
|
|
|
|
};
|
2021-04-08 10:29:21 +08:00
|
|
|
|
|
|
|
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();
|
2021-04-08 10:29:21 +08:00
|
|
|
private:
|
|
|
|
QSettings mSettings;
|
2021-04-13 11:23:37 +08:00
|
|
|
Dirs mDirs;
|
|
|
|
Editor mEditor;
|
2021-04-08 10:29:21 +08:00
|
|
|
};
|
|
|
|
|
2021-04-13 11:23:37 +08:00
|
|
|
|
2021-04-08 10:29:21 +08:00
|
|
|
extern Settings* pSettings;
|
|
|
|
|
|
|
|
#endif // SETTINGS_H
|