forked from engor/Jentos.Code
-
Notifications
You must be signed in to change notification settings - Fork 2
/
prefs.h
executable file
·74 lines (60 loc) · 1.88 KB
/
prefs.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
/*
Ted, a simple text editor/IDE.
Copyright 2012, Blitz Research Ltd.
See LICENSE.TXT for licensing terms.
*/
#ifndef PREFS_H
#define PREFS_H
#include "std.h"
class Prefs : public QObject{
Q_OBJECT
public:
void setValue( const QString &name,const QVariant &value );
bool contains(const QString &name) {
settings()->beginGroup( "userPrefs" );
bool v = settings()->contains(name);
settings()->endGroup();
return v;
}
bool getBool( const QString &name, bool def=false ) {
settings()->beginGroup( "userPrefs" );
bool v = (settings()->contains(name) ? settings()->value( name ).toBool() : def);
settings()->endGroup();
return v;
}
int getInt( const QString &name, int def=0 ) {
QSettings *s = settings();
s->beginGroup( "userPrefs" );
int v = (s->contains(name) ? s->value( name ).toInt() : def);
s->endGroup();
return v;
}
QString getString( const QString &name, QString def="") {
settings()->beginGroup( "userPrefs" );
QString v = (settings()->contains(name) ? settings()->value( name ).toString() : def);
settings()->endGroup();
return v;
}
QFont getFont( const QString &name ) {
settings()->beginGroup( "userPrefs" );
QFont v = settings()->value( name ).value<QFont>();
settings()->endGroup();
return v;
}
QColor getColor( const QString &name ) {
settings()->beginGroup( "userPrefs" );
QColor v = settings()->value( name ).value<QColor>();
settings()->endGroup();
return v;
}
void blockEmitPrefsChanged(bool value, bool emitNow=false);
static Prefs *prefs();
static QSettings *settings();
signals:
void prefsChanged( const QString &name );
private:
//QSettings _settings;
bool _blockEmitPrefsChanged;
Prefs();
};
#endif // PREFS_H