Commit 919207c0 authored by Vlad Zahorodnii's avatar Vlad Zahorodnii Committed by Nate Graham
Browse files

applets/systemtray: Prefer IconName over IconPixmap

In case both IconName and IconPixmap are provided, the system tray
applet is going to prefer the pixmap.

That can create a dark icon on dark background bug because plasma can't
recolor pixmaps.

The SNI spec recommends visualizations to prefer icons over pixmaps:

> An icon can either be identified by its Freedesktop-compliant icon
> name, carried by this property of by the icon data itself, carried by
> the property IconPixmap. Visualizations are encouraged to prefer icon
> names over icon pixmaps if both are available (FIXME: still not very
> defined: could e the pixmap used as fallback if an icon name is not found?)

BUG: 418996
(cherry picked from commit 7363d0e0)
parent 4d3f9955
......@@ -288,64 +288,68 @@ void StatusNotifierItemSource::refreshCallback(QDBusPendingCallWatcher *call)
// Icon
{
KDbusImageVector image;
QIcon icon;
QString iconName;
properties[QStringLiteral("OverlayIconPixmap")].value<QDBusArgument>() >> image;
if (image.isEmpty()) {
QString iconName = properties[QStringLiteral("OverlayIconName")].toString();
m_overlayIconName = iconName;
if (!iconName.isEmpty()) {
overlayNames << iconName;
overlay = QIcon(new KIconEngine(iconName, iconLoader()));
// Prefer icon over pixmap. If the icon is unavailable fallback to pixmap.
m_overlayIconName = properties[QStringLiteral("OverlayIconName")].toString();
if (!m_overlayIconName.isEmpty()) {
overlayNames << m_overlayIconName;
overlay = QIcon(new KIconEngine(m_overlayIconName, iconLoader()));
}
if (overlay.isNull()) {
KDbusImageVector image;
properties[QStringLiteral("OverlayIconPixmap")].value<QDBusArgument>() >> image;
if (!image.isEmpty()) {
overlay = imageVectorToPixmap(image);
}
} else {
overlay = imageVectorToPixmap(image);
}
properties[QStringLiteral("IconPixmap")].value<QDBusArgument>() >> image;
if (image.isEmpty()) {
iconName = properties[QStringLiteral("IconName")].toString();
if (!iconName.isEmpty()) {
icon = QIcon(new KIconEngine(iconName, iconLoader(), overlayNames));
if (overlayNames.isEmpty() && !overlay.isNull()) {
// Prefer icon over pixmap. If the icon is unavailable fallback to pixmap.
iconName = properties[QStringLiteral("IconName")].toString();
if (!iconName.isEmpty()) {
icon = QIcon(new KIconEngine(iconName, iconLoader(), overlayNames));
if (!icon.isNull() && !overlay.isNull() && overlayNames.isEmpty()) {
overlayIcon(&icon, &overlay);
}
}
if (icon.isNull()) {
KDbusImageVector image;
properties[QStringLiteral("IconPixmap")].value<QDBusArgument>() >> image;
if (!image.isEmpty()) {
icon = imageVectorToPixmap(image);
if (!icon.isNull() && !overlay.isNull()) {
overlayIcon(&icon, &overlay);
}
}
} else {
icon = imageVectorToPixmap(image);
if (!icon.isNull() && !overlay.isNull()) {
overlayIcon(&icon, &overlay);
}
}
m_icon = icon;
m_iconName = iconName;
}
// Attention icon
{
KDbusImageVector image;
QIcon attentionIcon;
properties[QStringLiteral("AttentionIconPixmap")].value<QDBusArgument>() >> image;
if (image.isEmpty()) {
QString iconName = properties[QStringLiteral("AttentionIconName")].toString();
m_attentionIconName = iconName;
if (!iconName.isEmpty()) {
attentionIcon = QIcon(new KIconEngine(iconName, iconLoader(), overlayNames));
if (overlayNames.isEmpty() && !overlay.isNull()) {
m_attentionIconName = properties[QStringLiteral("AttentionIconName")].toString();
if (!m_attentionIconName.isEmpty()) {
attentionIcon = QIcon(new KIconEngine(m_attentionIconName, iconLoader(), overlayNames));
if (!attentionIcon.isNull() && !overlay.isNull() && overlayNames.isEmpty()) {
overlayIcon(&attentionIcon, &overlay);
}
}
if (attentionIcon.isNull()) {
KDbusImageVector image;
properties[QStringLiteral("AttentionIconPixmap")].value<QDBusArgument>() >> image;
if (!image.isEmpty()) {
attentionIcon = imageVectorToPixmap(image);
if (!attentionIcon.isNull() && !overlay.isNull()) {
overlayIcon(&attentionIcon, &overlay);
}
}
} else {
attentionIcon = imageVectorToPixmap(image);
if (!attentionIcon.isNull() && !overlay.isNull()) {
overlayIcon(&attentionIcon, &overlay);
}
}
m_attentionIcon = attentionIcon;
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment