Changeset View
Changeset View
Standalone View
Standalone View
shell/scripting/applet.cpp
Show First 20 Lines • Show All 96 Lines • ▼ Show 20 Line(s) | |||||
97 | { | 97 | { | ||
98 | if (d->configGroup.isValid()) { | 98 | if (d->configGroup.isValid()) { | ||
99 | return d->configGroup.groupList(); | 99 | return d->configGroup.groupList(); | ||
100 | } | 100 | } | ||
101 | 101 | | |||
102 | return QStringList(); | 102 | return QStringList(); | ||
103 | } | 103 | } | ||
104 | 104 | | |||
105 | QVariant Applet::readConfig(const QString &key, const QVariant &def) const | 105 | QVariant Applet::readConfig(const QString &key, const QJSValue &def) const | ||
106 | { | 106 | { | ||
107 | if (d->configGroup.isValid()) { | 107 | if (d->configGroup.isValid()) { | ||
108 | return d->configGroup.readEntry(key, def); | 108 | return d->configGroup.readEntry(key, def.toVariant()); | ||
109 | } else { | 109 | } else { | ||
110 | return QVariant(); | 110 | return QVariant(); | ||
111 | } | 111 | } | ||
112 | } | 112 | } | ||
113 | 113 | | |||
114 | void Applet::writeConfig(const QString &key, const QVariant &value) | 114 | void Applet::writeConfig(const QString &key, const QJSValue &value) | ||
115 | { | 115 | { | ||
116 | if (d->configGroup.isValid()) { | 116 | if (d->configGroup.isValid()) { | ||
117 | if (d->inWallpaperConfig) { | 117 | if (d->inWallpaperConfig) { | ||
118 | //hacky, but only way to make the wallpaper react immediately | 118 | //hacky, but only way to make the wallpaper react immediately | ||
119 | QObject *wallpaperGraphicsObject = applet()->property("wallpaperGraphicsObject").value<QObject *>(); | 119 | QObject *wallpaperGraphicsObject = applet()->property("wallpaperGraphicsObject").value<QObject *>(); | ||
120 | if (wallpaperGraphicsObject) { | 120 | if (wallpaperGraphicsObject) { | ||
121 | KDeclarative::ConfigPropertyMap *config = static_cast<KDeclarative::ConfigPropertyMap *>(wallpaperGraphicsObject->property("configuration").value<QObject *>()); | 121 | KDeclarative::ConfigPropertyMap *config = static_cast<KDeclarative::ConfigPropertyMap *>(wallpaperGraphicsObject->property("configuration").value<QObject *>()); | ||
122 | config->setProperty(key.toLatin1(), value); | 122 | config->setProperty(key.toLatin1(), value.toVariant()); | ||
123 | } | 123 | } | ||
124 | } else if (applet()->configScheme()) { | 124 | } else if (applet()->configScheme()) { | ||
125 | //check if it can be written in the applets' configScheme | 125 | //check if it can be written in the applets' configScheme | ||
126 | KConfigSkeletonItem *item = applet()->configScheme()->findItemByName(key); | 126 | KConfigSkeletonItem *item = applet()->configScheme()->findItemByName(key); | ||
127 | if (item) { | 127 | if (item) { | ||
128 | item->setProperty(value); | 128 | item->setProperty(value.toVariant()); | ||
129 | applet()->configScheme()->blockSignals(true); | 129 | applet()->configScheme()->blockSignals(true); | ||
130 | applet()->configScheme()->save(); | 130 | applet()->configScheme()->save(); | ||
131 | //why read? read will update KConfigSkeletonItem::mLoadedValue, | 131 | //why read? read will update KConfigSkeletonItem::mLoadedValue, | ||
132 | //allowing a write operation to be performed next time | 132 | //allowing a write operation to be performed next time | ||
133 | applet()->configScheme()->read(); | 133 | applet()->configScheme()->read(); | ||
134 | applet()->configScheme()->blockSignals(false); | 134 | applet()->configScheme()->blockSignals(false); | ||
135 | emit applet()->configScheme()->configChanged(); | 135 | emit applet()->configScheme()->configChanged(); | ||
136 | } | 136 | } | ||
137 | } | 137 | } | ||
138 | 138 | | |||
139 | d->configGroup.writeEntry(key, value); | 139 | d->configGroup.writeEntry(key, value.toVariant()); | ||
anthonyfieroni: So writeEntry gets QJSValue& now why you call again toVariant(), here everywhere else. | |||||
KConfigGroup != ConfigGroup. d->configGroup is from kconfig and does not take QJSValue. That's the core of the bugfix. fvogt: KConfigGroup != ConfigGroup. d->configGroup is from kconfig and does not take QJSValue. That's… | |||||
140 | d->configDirty = true; | 140 | d->configDirty = true; | ||
141 | } | 141 | } | ||
142 | } | 142 | } | ||
143 | 143 | | |||
144 | void Applet::setCurrentGlobalConfigGroup(const QStringList &groupNames) | 144 | void Applet::setCurrentGlobalConfigGroup(const QStringList &groupNames) | ||
145 | { | 145 | { | ||
146 | Plasma::Applet *app = applet(); | 146 | Plasma::Applet *app = applet(); | ||
147 | if (!app) { | 147 | if (!app) { | ||
Show All 28 Lines | |||||
176 | { | 176 | { | ||
177 | if (d->globalConfigGroup.isValid()) { | 177 | if (d->globalConfigGroup.isValid()) { | ||
178 | return d->globalConfigGroup.groupList(); | 178 | return d->globalConfigGroup.groupList(); | ||
179 | } | 179 | } | ||
180 | 180 | | |||
181 | return QStringList(); | 181 | return QStringList(); | ||
182 | } | 182 | } | ||
183 | 183 | | |||
184 | QVariant Applet::readGlobalConfig(const QString &key, const QVariant &def) const | 184 | QVariant Applet::readGlobalConfig(const QString &key, const QJSValue &def) const | ||
185 | { | 185 | { | ||
186 | if (d->globalConfigGroup.isValid()) { | 186 | if (d->globalConfigGroup.isValid()) { | ||
187 | return d->globalConfigGroup.readEntry(key, def); | 187 | return d->globalConfigGroup.readEntry(key, def.toVariant()); | ||
188 | } else { | 188 | } else { | ||
189 | return QVariant(); | 189 | return QVariant(); | ||
190 | } | 190 | } | ||
191 | } | 191 | } | ||
192 | 192 | | |||
193 | void Applet::writeGlobalConfig(const QString &key, const QVariant &value) | 193 | void Applet::writeGlobalConfig(const QString &key, const QJSValue &value) | ||
194 | { | 194 | { | ||
195 | if (d->globalConfigGroup.isValid()) { | 195 | if (d->globalConfigGroup.isValid()) { | ||
196 | d->globalConfigGroup.writeEntry(key, value); | 196 | d->globalConfigGroup.writeEntry(key, value.toVariant()); | ||
197 | d->configDirty = true; | 197 | d->configDirty = true; | ||
198 | } | 198 | } | ||
199 | } | 199 | } | ||
200 | 200 | | |||
201 | void Applet::reloadConfigIfNeeded() | 201 | void Applet::reloadConfigIfNeeded() | ||
202 | { | 202 | { | ||
203 | if (d->configDirty) { | 203 | if (d->configDirty) { | ||
204 | reloadConfig(); | 204 | reloadConfig(); | ||
▲ Show 20 Lines • Show All 70 Lines • Show Last 20 Lines |
So writeEntry gets QJSValue& now why you call again toVariant(), here everywhere else.