config.h 990 Bytes
Newer Older
Philipp Erhardt's avatar
Philipp Erhardt committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
#ifndef CONFIG_H
#define CONFIG_H

#include <QSettings>
#include <QHash>
#include <QString>
#include <QVariant>
#include <QStringList>


class CFG {
private:
	CFG();
	CFG(const CFG &other);
15
	CFG(const char *file);
Philipp Erhardt's avatar
Philipp Erhardt committed
16
17
18
	CFG &operator=(const CFG &other);
	~CFG();

19
	void init_defaults();
Philipp Erhardt's avatar
Philipp Erhardt committed
20
21
22
23
	void set_defaults();

	QSettings settings;
	QHash<QString,QVariant> defaults;
24
	QHash<QString,QVariant> tmp_values; // not persistent
Philipp Erhardt's avatar
Philipp Erhardt committed
25
26
27
28
	QHash<QString,QStringList> keys;

public:
	static CFG *get_instance();
29
	static void write_defaults(const char *file); // write defaults to file
Philipp Erhardt's avatar
Philipp Erhardt committed
30
31
32
33

	QVariant get_value(const char *key) const;
	void set_value(const char *key, QVariant value);

34
35
	QVariant get_tmp_value(const char *key) const;
	void set_tmp_value(const char *key, QVariant value);
36
	bool has_tmp_value(const char *key) const;
37

38
39
40
	/** Return tmp_value (if set) but fall back to normal settings */
	QVariant get_most_current_value(const char *key) const;

Philipp Erhardt's avatar
Philipp Erhardt committed
41
42
43
44
45
	QStringList get_keys(const char *action) const;
};

#endif