Changeset View
Standalone View
decorations/decorationbridge.cpp
Show First 20 Lines • Show All 206 Lines • ▼ Show 20 Line(s) | 201 | } else { | |||
---|---|---|---|---|---|
207 | } | 207 | } | ||
208 | } | 208 | } | ||
209 | } | 209 | } | ||
210 | 210 | | |||
211 | void DecorationBridge::loadMetaData(const QJsonObject &object) | 211 | void DecorationBridge::loadMetaData(const QJsonObject &object) | ||
212 | { | 212 | { | ||
213 | // reset all settings | 213 | // reset all settings | ||
214 | m_blur = false; | 214 | m_blur = false; | ||
215 | m_recommendedBorderSize = QString(); | ||||
215 | m_theme = QString(); | 216 | m_theme = QString(); | ||
216 | m_defaultTheme = QString(); | 217 | m_defaultTheme = QString(); | ||
217 | 218 | | |||
218 | // load the settings | 219 | // load the settings | ||
219 | const QJsonValue decoSettings = object.value(s_pluginName); | 220 | const QJsonValue decoSettings = object.value(s_pluginName); | ||
220 | if (decoSettings.isUndefined()) { | 221 | if (decoSettings.isUndefined()) { | ||
221 | // no settings | 222 | // no settings | ||
222 | return; | 223 | return; | ||
223 | } | 224 | } | ||
224 | const QVariantMap decoSettingsMap = decoSettings.toObject().toVariantMap(); | 225 | const QVariantMap decoSettingsMap = decoSettings.toObject().toVariantMap(); | ||
225 | auto blurIt = decoSettingsMap.find(QStringLiteral("blur")); | 226 | auto blurIt = decoSettingsMap.find(QStringLiteral("blur")); | ||
226 | if (blurIt != decoSettingsMap.end()) { | 227 | if (blurIt != decoSettingsMap.end()) { | ||
227 | m_blur = blurIt.value().toBool(); | 228 | m_blur = blurIt.value().toBool(); | ||
228 | } | 229 | } | ||
230 | auto recBorderSizeIt = decoSettingsMap.find(QStringLiteral("recommendedBorderSize")); | ||||
zzag: IMHO, `recommendedBorderSize` sounds better. | |||||
It sounds better, but my rationale to have it the other way around is that this key is about the border size as an entity firstly and secondly it provides this entity with an attribute. I.e. if you have multiple values affecting the border size they can be grouped nicely as: borderSizeProp1, borderSizeProp2, borderSizeProp3 romangg: It sounds better, but my rationale to have it the other way around is that this key is about… | |||||
In that case, I think it would be better to have an object. E.g. "borderSize": { "recommended": "Normal", "prop1": "hypnotoad", "prop2": 42 } zzag: In that case, I think it would be better to have an object. E.g.
```
"borderSize": {… | |||||
Hmm, you are right. Since the metadata is a json struct, if there would be multiple properties in the future, we would extend it this way and deprecate the old top-level property. Ok, I will go with recommendedBorderSize. romangg: Hmm, you are right. Since the metadata is a json struct, if there would be multiple properties… | |||||
zzag: No short names. | |||||
231 | if (recBorderSizeIt != decoSettingsMap.end()) { | ||||
232 | m_recommendedBorderSize = recBorderSizeIt.value().toString(); | ||||
233 | } | ||||
229 | findTheme(decoSettingsMap); | 234 | findTheme(decoSettingsMap); | ||
235 | | ||||
236 | Q_EMIT metaDataLoaded(); | ||||
230 | } | 237 | } | ||
231 | 238 | | |||
232 | void DecorationBridge::findTheme(const QVariantMap &map) | 239 | void DecorationBridge::findTheme(const QVariantMap &map) | ||
233 | { | 240 | { | ||
234 | auto it = map.find(QStringLiteral("themes")); | 241 | auto it = map.find(QStringLiteral("themes")); | ||
235 | if (it == map.end()) { | 242 | if (it == map.end()) { | ||
236 | return; | 243 | return; | ||
237 | } | 244 | } | ||
▲ Show 20 Lines • Show All 63 Lines • ▼ Show 20 Line(s) | 294 | { | |||
301 | return variant.toString(); | 308 | return variant.toString(); | ||
302 | } | 309 | } | ||
303 | 310 | | |||
304 | QString DecorationBridge::supportInformation() const | 311 | QString DecorationBridge::supportInformation() const | ||
305 | { | 312 | { | ||
306 | QString b; | 313 | QString b; | ||
307 | b.append(QStringLiteral("Plugin: %1\n").arg(m_plugin)); | 314 | b.append(QStringLiteral("Plugin: %1\n").arg(m_plugin)); | ||
308 | b.append(QStringLiteral("Theme: %1\n").arg(m_theme)); | 315 | b.append(QStringLiteral("Theme: %1\n").arg(m_theme)); | ||
316 | b.append(QStringLiteral("Plugin recommends border size: %1\n").arg(m_recommendedBorderSize > 0 ? QString(m_recommendedBorderSize) : "No")); | ||||
how this line even works? m_recommendedBorderSize is a QString, so most probably the "> 0" is comparing it to a null char const*... pino: how this line even works? m_recommendedBorderSize is a QString, so most probably the "> 0" is… | |||||
zzag: QStringLiteral("No") | |||||
309 | b.append(QStringLiteral("Blur: %1\n").arg(m_blur)); | 317 | b.append(QStringLiteral("Blur: %1\n").arg(m_blur)); | ||
310 | const QMetaObject *metaOptions = m_settings->metaObject(); | 318 | const QMetaObject *metaOptions = m_settings->metaObject(); | ||
311 | for (int i=0; i<metaOptions->propertyCount(); ++i) { | 319 | for (int i=0; i<metaOptions->propertyCount(); ++i) { | ||
312 | const QMetaProperty property = metaOptions->property(i); | 320 | const QMetaProperty property = metaOptions->property(i); | ||
313 | if (QLatin1String(property.name()) == QLatin1String("objectName")) { | 321 | if (QLatin1String(property.name()) == QLatin1String("objectName")) { | ||
314 | continue; | 322 | continue; | ||
315 | } | 323 | } | ||
316 | b.append(QStringLiteral("%1: %2\n").arg(property.name()).arg(settingsProperty(m_settings->property(property.name())))); | 324 | b.append(QStringLiteral("%1: %2\n").arg(property.name()).arg(settingsProperty(m_settings->property(property.name())))); | ||
317 | } | 325 | } | ||
318 | return b; | 326 | return b; | ||
319 | } | 327 | } | ||
320 | 328 | | |||
321 | } // Decoration | 329 | } // Decoration | ||
322 | } // KWin | 330 | } // KWin |
IMHO, recommendedBorderSize sounds better.