0001-allow-usage-of-.ini-config-files-with-compile-time-s.patch
CMakeLists.txt | ||
---|---|---|
32 | 32 |
option(WANT_QTCLIENT "Build the Qt4 GUI client binary" ON) |
33 | 33 |
option(WANT_MONO "Build the monolithic (all-in-one) binary" OFF) |
34 | 34 | |
35 |
option(ENABLE_INI "Use .ini files for settings. Useful on windows" OFF) |
|
36 | ||
35 | 37 |
option(WITH_OPENSSL "Enable OpenSSL support if present on the system" ON) |
36 | 38 |
option(WITH_DBUS "Enable D-Bus support if present on the system" ON) |
37 | 39 |
option(WITH_WEBKIT "Enable WebKit support if present on the system" ON) |
... | ... | |
205 | 207 |
endif(OXYGEN_ICONS MATCHES "External") |
206 | 208 |
endif(WANT_QTCLIENT OR WANT_MONO) |
207 | 209 | |
210 |
if(ENABLE_INI) |
|
211 |
add_definitions(-DCFG_INI) |
|
212 |
endif(ENABLE_INI) |
|
213 | ||
208 | 214 |
# These variables will be added to the main targets (CORE, QTCLIENT, MONO) |
209 | 215 | |
210 | 216 |
set(COMMON_DEPS ${RC_WIN32}) |
src/common/settings.cpp | ||
---|---|---|
62 | 62 |
} |
63 | 63 | |
64 | 64 |
QStringList Settings::allLocalKeys() { |
65 |
QSettings s(org(), appName); |
|
65 |
QSettings s(cfgformat, QSettings::UserScope, org(), appName);
|
|
66 | 66 |
s.beginGroup(group); |
67 | 67 |
QStringList res = s.allKeys(); |
68 | 68 |
s.endGroup(); |
... | ... | |
76 | 76 |
else |
77 | 77 |
g = QString("%1/%2").arg(group, rootkey); |
78 | 78 | |
79 |
QSettings s(org(), appName); |
|
79 |
QSettings s(cfgformat, QSettings::UserScope, org(), appName);
|
|
80 | 80 |
s.beginGroup(g); |
81 | 81 |
QStringList res = s.childKeys(); |
82 | 82 |
s.endGroup(); |
... | ... | |
90 | 90 |
else |
91 | 91 |
g = QString("%1/%2").arg(group, rootkey); |
92 | 92 | |
93 |
QSettings s(org(), appName); |
|
93 |
QSettings s(cfgformat, QSettings::UserScope, org(), appName);
|
|
94 | 94 |
s.beginGroup(g); |
95 | 95 |
QStringList res = s.childGroups(); |
96 | 96 |
s.endGroup(); |
... | ... | |
98 | 98 |
} |
99 | 99 | |
100 | 100 |
void Settings::setLocalValue(const QString &key, const QVariant &data) { |
101 |
QSettings s(org(), appName); |
|
101 |
QSettings s(cfgformat, QSettings::UserScope, org(), appName);
|
|
102 | 102 |
s.beginGroup(group); |
103 | 103 |
s.setValue(key, data); |
104 | 104 |
s.endGroup(); |
... | ... | |
110 | 110 | |
111 | 111 |
const QVariant &Settings::localValue(const QString &key, const QVariant &def) { |
112 | 112 |
if(!isCached(group, key)) { |
113 |
QSettings s(org(), appName); |
|
113 |
QSettings s(cfgformat, QSettings::UserScope, org(), appName);
|
|
114 | 114 |
s.beginGroup(group); |
115 | 115 |
setCacheValue(group, key, s.value(key, def)); |
116 | 116 |
s.endGroup(); |
... | ... | |
119 | 119 |
} |
120 | 120 | |
121 | 121 |
void Settings::removeLocalKey(const QString &key) { |
122 |
QSettings s(org(), appName); |
|
122 |
QSettings s(cfgformat, QSettings::UserScope, org(), appName);
|
|
123 | 123 |
s.beginGroup(group); |
124 | 124 |
s.remove(key); |
125 | 125 |
s.endGroup(); |
src/common/settings.h | ||
---|---|---|
25 | 25 |
#include <QHash> |
26 | 26 |
#include <QString> |
27 | 27 |
#include <QVariant> |
28 |
#include <QSettings> |
|
28 | 29 | |
29 | 30 |
class SettingsChangeNotifier : public QObject { |
30 | 31 |
Q_OBJECT |
... | ... | |
61 | 62 |
QString group; |
62 | 63 |
QString appName; |
63 | 64 | |
65 | ||
64 | 66 |
private: |
65 | 67 |
inline QString org() { |
66 | 68 |
#ifdef Q_WS_MAC |
... | ... | |
70 | 72 |
#endif |
71 | 73 |
} |
72 | 74 | |
75 |
#ifdef CFG_INI |
|
76 |
static const QSettings::Format cfgformat = QSettings::IniFormat; |
|
77 |
#else |
|
78 |
static const QSettings::Format cfgformat = QSettings::NativeFormat; |
|
79 |
#endif |
|
80 | ||
73 | 81 |
static QHash<QString, QHash<QString, QVariant> > settingsCache; |
74 | 82 |
static QHash<QString, QHash<QString, SettingsChangeNotifier *> > settingsChangeNotifier; |
75 | 83 | |
76 |
- |