-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathprefs.cpp
More file actions
92 lines (79 loc) · 2.36 KB
/
prefs.cpp
File metadata and controls
92 lines (79 loc) · 2.36 KB
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
/*
Ted, a simple text editor/IDE.
Copyright 2012, Blitz Research Ltd.
See LICENSE.TXT for licensing terms.
*/
#include "prefs.h"
Prefs::Prefs(){
_blockEmitPrefsChanged = false;
isValidMonkeyPath = false;
}
void Prefs::setValue( const QString &name,const QVariant &value ){
settings()->beginGroup( "userPrefs" );
settings()->setValue( name,value );
settings()->endGroup();
if(!_blockEmitPrefsChanged) {
emit prefsChanged( name );
}
}
QSettings* Prefs::settings() {
static QSettings *s = 0;
if (!s) {
//s = new QSettings(QApplication::applicationDirPath()+"/settings.ini",QSettings::IniFormat);
s = new QSettings();
int size = s->allKeys().size();
// if has no data then import from previous version
if (size == 0) {
QString dir = extractDir(s->fileName())+"/";
QString p = dir + "Jentos IDE.ini";
QFile f(p);
if (f.exists()) {
QString p2 = dir + "Jentos.Code.ini";
QFile f2(p2);
if (f2.exists())
f2.remove();
f.copy(p2);
}
}
delete s;
s = new QSettings();
prefs()->setDefaults();
}
return s;
}
void Prefs::setDefaults() {
Prefs *p = prefs();
if (!p->contains("charsForCompletion"))
p->setValue("charsForCompletion", 3);
if (!p->contains("addVoidForMethods"))
p->setValue("addVoidForMethods", true);
if (!p->contains("autoBracket"))
p->setValue("autoBracket", true);
if (!p->contains("showLineNumbers"))
p->setValue("showLineNumbers", true);
if (!p->contains("capitalizeKeywords"))
p->setValue("capitalizeKeywords", true);
if (!p->contains("updates")) {
p->setValue("updates",true);
p->setValue("tabSize",4);
p->setValue("fontSize",12);
p->setValue("highlightLine",true);
p->setValue("highlightWord",true);
p->setValue("style","Default");
p->setValue("showHelpInDock",false);
p->setValue("replaceDocsStyle",true);
}
}
Prefs *Prefs::prefs() {
static Prefs *_prefs;
if( !_prefs ) {
_prefs = new Prefs;
}
return _prefs;
}
void Prefs::blockEmitPrefsChanged(bool value, bool emitNow) {
_blockEmitPrefsChanged = value;
if(emitNow) {
emit prefsChanged( "" );
}
}