equal
deleted
inserted
replaced
38 QString value = ""; |
38 QString value = ""; |
39 if(settingList.contains(item)) |
39 if(settingList.contains(item)) |
40 { |
40 { |
41 value = settingList.value(item); |
41 value = settingList.value(item); |
42 } |
42 } |
|
43 else |
|
44 { |
|
45 value = getDefaultValue(item); |
|
46 settingList.insert(item, value); |
|
47 } |
43 return value; |
48 return value; |
44 } |
49 } |
45 |
50 |
46 |
51 |
47 void UiSetting::SetSetting(const QString& item, const QString& value) |
52 void UiSetting::SetSetting(const QString& item, const QString& value) |
56 |
61 |
57 |
62 |
58 void UiSetting::loadDefault() |
63 void UiSetting::loadDefault() |
59 { |
64 { |
60 settingList.clear(); |
65 settingList.clear(); |
61 settingList.insert("showoutput", "true"); |
66 settingList.insert(KShowOutput, getDefaultValue(KShowOutput)); |
|
67 settingList.insert(KStyleSheet, getDefaultValue(KStyleSheet)); |
62 //add mor default setting here. |
68 //add mor default setting here. |
63 } |
69 } |
64 |
70 |
|
71 QString UiSetting::getDefaultValue(const QString& item) |
|
72 { |
|
73 QString result = ""; |
|
74 if(item == KShowOutput) |
|
75 { |
|
76 result = "true"; |
|
77 } |
|
78 else if(item == KStyleSheet) |
|
79 { |
|
80 result = ":/qss/coffee.qss"; |
|
81 } |
|
82 return result; |
|
83 } |
65 |
84 |
66 bool UiSetting::load() |
85 bool UiSetting::load() |
67 { |
86 { |
68 QFile file(SETTINGFILE); |
87 QFile file(SETTINGFILE); |
69 if(!file.open(QIODevice::ReadOnly)) |
88 if(!file.open(QIODevice::ReadOnly)) |
73 QTextStream in(&file); |
92 QTextStream in(&file); |
74 QString line, item, value; |
93 QString line, item, value; |
75 int index; |
94 int index; |
76 while(!in.atEnd()) |
95 while(!in.atEnd()) |
77 { |
96 { |
78 line = in.readLine().trimmed().toLower(); |
97 line = in.readLine().trimmed(); |
79 if(!line.startsWith("//")) |
98 if(!line.startsWith("//")) |
80 { |
99 { |
81 index = line.indexOf("="); |
100 index = line.indexOf("="); |
82 if(index > 0 && index < line.length() - 1) |
101 if(index > 0 && index < line.length() - 1) |
83 { |
102 { |