Changeset View
Changeset View
Standalone View
Standalone View
dataengines/statusnotifieritem/statusnotifieritemsource.cpp
Show First 20 Lines • Show All 81 Lines • ▼ Show 20 Line(s) | 73 | { | |||
---|---|---|---|---|---|
82 | //set the initial values for all the things | 82 | //set the initial values for all the things | ||
83 | //this is important as Plasma::DataModel has an unsolvable bug | 83 | //this is important as Plasma::DataModel has an unsolvable bug | ||
84 | //when it gets data with a new key it tries to update the QAIM roleNames | 84 | //when it gets data with a new key it tries to update the QAIM roleNames | ||
85 | //from QML this achieves absolutely nothing as there is no signal to tell QQmlDelegateModel to reload the roleNames in QQmlAdapatorModel | 85 | //from QML this achieves absolutely nothing as there is no signal to tell QQmlDelegateModel to reload the roleNames in QQmlAdapatorModel | ||
86 | //no matter if the row changes or the model refreshes | 86 | //no matter if the row changes or the model refreshes | ||
87 | //this means it does not re-evaluate what bindings exist (watchedRoleIds) - and we get properties that don't bind and thus system tray icons | 87 | //this means it does not re-evaluate what bindings exist (watchedRoleIds) - and we get properties that don't bind and thus system tray icons | ||
88 | 88 | | |||
89 | //by setting everything up-front so that we have all role names when we call the first checkForUpdate() | 89 | //by setting everything up-front so that we have all role names when we call the first checkForUpdate() | ||
90 | // TODO Plasma 6 remove combined "*Icon" properties and only expose the raw "*IconName" and "*IconPixmap" properties | ||||
kmaterka: I would suggest to extend removal to all *Changed roles. These are not used (were in KDE/Plasma… | |||||
90 | setData(QStringLiteral("AttentionIcon"), QIcon()); | 91 | setData(QStringLiteral("AttentionIcon"), QIcon()); | ||
91 | setData(QStringLiteral("AttentionIconName"), QString()); | 92 | setData(QStringLiteral("AttentionIconName"), QString()); | ||
93 | setData(QStringLiteral("AttentionIconPixmap"), QIcon()); | ||||
92 | setData(QStringLiteral("AttentionMovieName"), QString()); | 94 | setData(QStringLiteral("AttentionMovieName"), QString()); | ||
93 | setData(QStringLiteral("Category"), QString()); | 95 | setData(QStringLiteral("Category"), QString()); | ||
94 | setData(QStringLiteral("Icon"), QIcon()); | 96 | setData(QStringLiteral("Icon"), QIcon()); | ||
95 | setData(QStringLiteral("IconName"), QString()); | 97 | setData(QStringLiteral("IconName"), QString()); | ||
98 | setData(QStringLiteral("IconPixmap"), QIcon()); | ||||
96 | setData(QStringLiteral("IconsChanged"), false); | 99 | setData(QStringLiteral("IconsChanged"), false); | ||
97 | setData(QStringLiteral("IconThemePath"), QString()); | 100 | setData(QStringLiteral("IconThemePath"), QString()); | ||
98 | setData(QStringLiteral("Id"), QString()); | 101 | setData(QStringLiteral("Id"), QString()); | ||
99 | setData(QStringLiteral("ItemIsMenu"), false); | 102 | setData(QStringLiteral("ItemIsMenu"), false); | ||
100 | setData(QStringLiteral("OverlayIconName"), QString()); | 103 | setData(QStringLiteral("OverlayIconName"), QString()); | ||
104 | setData(QStringLiteral("OverlayIconPixmap"), QIcon()); | ||||
101 | setData(QStringLiteral("StatusChanged"), false); | 105 | setData(QStringLiteral("StatusChanged"), false); | ||
102 | setData(QStringLiteral("Status"), QString()); | 106 | setData(QStringLiteral("Status"), QString()); | ||
103 | setData(QStringLiteral("TitleChanged"), false); | 107 | setData(QStringLiteral("TitleChanged"), false); | ||
104 | setData(QStringLiteral("Title"), QString()); | 108 | setData(QStringLiteral("Title"), QString()); | ||
105 | setData(QStringLiteral("ToolTipChanged"), false); | 109 | setData(QStringLiteral("ToolTipChanged"), false); | ||
106 | setData(QStringLiteral("ToolTipIcon"), QString()); | 110 | setData(QStringLiteral("ToolTipIcon"), QString()); | ||
107 | setData(QStringLiteral("ToolTipSubTitle"), QString()); | 111 | setData(QStringLiteral("ToolTipSubTitle"), QString()); | ||
108 | setData(QStringLiteral("ToolTipTitle"), QString()); | 112 | setData(QStringLiteral("ToolTipTitle"), QString()); | ||
▲ Show 20 Lines • Show All 159 Lines • ▼ Show 20 Line(s) | 227 | } else { | |||
268 | 272 | | |||
269 | QIcon overlay; | 273 | QIcon overlay; | ||
270 | QStringList overlayNames; | 274 | QStringList overlayNames; | ||
271 | 275 | | |||
272 | //Icon | 276 | //Icon | ||
273 | { | 277 | { | ||
274 | KDbusImageVector image; | 278 | KDbusImageVector image; | ||
275 | QIcon icon; | 279 | QIcon icon; | ||
276 | QString iconName; | 280 | QString overlayIconName = properties[QStringLiteral("OverlayIconName")].toString(); | ||
277 | 281 | setData(QStringLiteral("OverlayIconName"), overlayIconName); | |||
278 | properties[QStringLiteral("OverlayIconPixmap")].value<QDBusArgument>() >> image; | 282 | properties[QStringLiteral("OverlayIconPixmap")].value<QDBusArgument>() >> image; | ||
279 | if (image.isEmpty()) { | 283 | if (image.isEmpty()) { | ||
280 | QString iconName = properties[QStringLiteral("OverlayIconName")].toString(); | 284 | if (!overlayIconName.isEmpty()) { | ||
281 | setData(QStringLiteral("OverlayIconName"), iconName); | 285 | overlayNames << overlayIconName; | ||
282 | if (!iconName.isEmpty()) { | 286 | overlay = QIcon(new KIconEngine(overlayIconName, iconLoader())); | ||
283 | overlayNames << iconName; | 287 | setData(QStringLiteral("OverlayIconPixmap"), QVariant()); | ||
284 | overlay = QIcon(new KIconEngine(iconName, iconLoader())); | | |||
285 | } | 288 | } | ||
286 | } else { | 289 | } else { | ||
287 | overlay = imageVectorToPixmap(image); | 290 | overlay = imageVectorToPixmap(image); | ||
291 | setData(QStringLiteral("OverlayIconPixmap"), overlay); | ||||
288 | } | 292 | } | ||
289 | 293 | QString iconName = properties[QStringLiteral("IconName")].toString(); | |||
294 | setData(QStringLiteral("IconName"), iconName); | ||||
290 | properties[QStringLiteral("IconPixmap")].value<QDBusArgument>() >> image; | 295 | properties[QStringLiteral("IconPixmap")].value<QDBusArgument>() >> image; | ||
291 | if (image.isEmpty()) { | 296 | if (image.isEmpty()) { | ||
292 | iconName = properties[QStringLiteral("IconName")].toString(); | | |||
293 | if (!iconName.isEmpty()) { | 297 | if (!iconName.isEmpty()) { | ||
294 | icon = QIcon(new KIconEngine(iconName, iconLoader(), overlayNames)); | 298 | icon = QIcon(new KIconEngine(iconName, iconLoader(), overlayNames)); | ||
295 | | ||||
296 | if (overlayNames.isEmpty() && !overlay.isNull()) { | 299 | if (overlayNames.isEmpty() && !overlay.isNull()) { | ||
297 | overlayIcon(&icon, &overlay); | 300 | overlayIcon(&icon, &overlay); | ||
298 | } | 301 | } | ||
299 | } | 302 | } | ||
303 | setData(QStringLiteral("IconPixmap"), QVariant()); | ||||
300 | } else { | 304 | } else { | ||
301 | icon = imageVectorToPixmap(image); | 305 | icon = imageVectorToPixmap(image); | ||
306 | setData(QStringLiteral("IconPixmap"), icon); | ||||
302 | if (!icon.isNull() && !overlay.isNull()) { | 307 | if (!icon.isNull() && !overlay.isNull()) { | ||
303 | overlayIcon(&icon, &overlay); | 308 | overlayIcon(&icon, &overlay); | ||
304 | } | 309 | } | ||
305 | } | 310 | } | ||
306 | setData(QStringLiteral("Icon"), icon.isNull() ? QVariant() : icon); | 311 | setData(QStringLiteral("Icon"), icon.isNull() ? QVariant() : icon); | ||
307 | setData(QStringLiteral("IconName"), iconName); | | |||
308 | } | 312 | } | ||
309 | 313 | | |||
310 | //Attention icon | 314 | //Attention icon | ||
311 | { | 315 | { | ||
312 | KDbusImageVector image; | 316 | KDbusImageVector image; | ||
313 | QIcon attentionIcon; | 317 | QIcon attentionIcon; | ||
314 | 318 | QString attentionIconName = properties[QStringLiteral("AttentionIconName")].toString(); | |||
319 | setData(QStringLiteral("AttentionIconName"), attentionIconName); | ||||
315 | properties[QStringLiteral("AttentionIconPixmap")].value<QDBusArgument>() >> image; | 320 | properties[QStringLiteral("AttentionIconPixmap")].value<QDBusArgument>() >> image; | ||
316 | if (image.isEmpty()) { | 321 | if (image.isEmpty()) { | ||
317 | QString iconName = properties[QStringLiteral("AttentionIconName")].toString(); | 322 | QString iconName = properties[QStringLiteral("AttentionIconName")].toString(); | ||
318 | setData(QStringLiteral("AttentionIconName"), iconName); | | |||
319 | if (!iconName.isEmpty()) { | 323 | if (!iconName.isEmpty()) { | ||
320 | attentionIcon = QIcon(new KIconEngine(iconName, iconLoader(), overlayNames)); | 324 | attentionIcon = QIcon(new KIconEngine(iconName, iconLoader(), overlayNames)); | ||
321 | | ||||
322 | if (overlayNames.isEmpty() && !overlay.isNull()) { | 325 | if (overlayNames.isEmpty() && !overlay.isNull()) { | ||
323 | overlayIcon(&attentionIcon, &overlay); | 326 | overlayIcon(&attentionIcon, &overlay); | ||
324 | } | 327 | } | ||
325 | } | 328 | } | ||
329 | setData(QStringLiteral("AttentionIconPixmap"), QVariant()); | ||||
326 | } else { | 330 | } else { | ||
327 | attentionIcon = imageVectorToPixmap(image); | 331 | attentionIcon = imageVectorToPixmap(image); | ||
332 | setData(QStringLiteral("AttentionIconPixmap"), attentionIcon); | ||||
328 | if (!attentionIcon.isNull() && !overlay.isNull()) { | 333 | if (!attentionIcon.isNull() && !overlay.isNull()) { | ||
329 | overlayIcon(&attentionIcon, &overlay); | 334 | overlayIcon(&attentionIcon, &overlay); | ||
330 | } | 335 | } | ||
331 | } | 336 | } | ||
332 | setData(QStringLiteral("AttentionIcon"), attentionIcon.isNull() ? QVariant() : attentionIcon); | 337 | setData(QStringLiteral("AttentionIcon"), attentionIcon.isNull() ? QVariant() : attentionIcon); | ||
333 | } | 338 | } | ||
334 | 339 | | |||
335 | //ToolTip | 340 | //ToolTip | ||
Show All 36 Lines | 376 | connect(m_menuImporter, &PlasmaDBusMenuImporter::menuUpdated, this, [this](QMenu *menu) { | |||
372 | if (menu == m_menuImporter->menu()) { | 377 | if (menu == m_menuImporter->menu()) { | ||
373 | contextMenuReady(); | 378 | contextMenuReady(); | ||
374 | } | 379 | } | ||
375 | }); | 380 | }); | ||
376 | } | 381 | } | ||
377 | } | 382 | } | ||
378 | } | 383 | } | ||
379 | } | 384 | } | ||
380 | | ||||
381 | checkForUpdate(); | 385 | checkForUpdate(); | ||
382 | call->deleteLater(); | 386 | call->deleteLater(); | ||
383 | } | 387 | } | ||
384 | 388 | | |||
385 | void StatusNotifierItemSource::contextMenuReady() | 389 | void StatusNotifierItemSource::contextMenuReady() | ||
386 | { | 390 | { | ||
387 | emit contextMenuReady(m_menuImporter->menu()); | 391 | emit contextMenuReady(m_menuImporter->menu()); | ||
388 | } | 392 | } | ||
▲ Show 20 Lines • Show All 132 Lines • Show Last 20 Lines |
I would suggest to extend removal to all *Changed roles. These are not used (were in KDE/Plasma 4).