<table><tr><td style="">kmaterka added inline comments.
</td><a style="text-decoration: none; padding: 4px 8px; margin: 0 8px 8px; float: right; color: #464C5C; font-weight: bold; border-radius: 3px; background-color: #F7F7F9; background-image: linear-gradient(to bottom,#fff,#f1f0f1); display: inline-block; border: 1px solid rgba(71,87,120,.2);" href="https://phabricator.kde.org/D24865">View Revision</a></tr></table><br /><div><strong>INLINE COMMENTS</strong><div><div style="margin: 6px 0 12px 0;"><div style="border: 1px solid #C7CCD9; border-radius: 3px;"><div style="padding: 0; background: #F7F7F7; border-color: #e3e4e8; border-style: solid; border-width: 0 0 1px 0; margin: 0;"><div style="color: #74777d; background: #eff2f4; padding: 6px 8px; overflow: hidden;"><a style="float: right; text-decoration: none;" href="https://phabricator.kde.org/D24865#inline-141224">View Inline</a><span style="color: #4b4d51; font-weight: bold;">broulik</span> wrote in <span style="color: #4b4d51; font-weight: bold;">systemtray.cpp:354</span></div>
<div style="margin: 8px 0; padding: 0 12px; color: #74777D;"><p style="padding: 0; margin: 8px;">I think you don't need any of that. If you convert it to a <tt style="background: #ebebeb; font-size: 13px;">QIcon</tt> which it is not, it will return a default-constructed (null) <tt style="background: #ebebeb; font-size: 13px;">QIcon</tt></p></div></div>
<div style="margin: 8px 0; padding: 0 12px;"><p style="padding: 0; margin: 8px;">You are of course correct, check will work without this. I wanted to be explicit here, I don't like to rely on implicit behavior. If QVariant is not QIcon type it is clear that it is not a valid icon. But if I convert it anyway, I need to know that it will create empty/null icon (default constructor). Documentation suggests to use canConvert: <a href="https://doc.qt.io/qt-5/qvariant.html#value" class="remarkup-link" target="_blank" rel="noreferrer">https://doc.qt.io/qt-5/qvariant.html#value</a><br />
value.isValid() || value.isNull() is added for the same reason, to be explicit.</p></div></div><br /><div style="border: 1px solid #C7CCD9; border-radius: 3px;"><div style="padding: 0; background: #F7F7F7; border-color: #e3e4e8; border-style: solid; border-width: 0 0 1px 0; margin: 0;"><div style="color: #74777d; background: #eff2f4; padding: 6px 8px; overflow: hidden;"><a style="float: right; text-decoration: none;" href="https://phabricator.kde.org/D24865#inline-141225">View Inline</a><span style="color: #4b4d51; font-weight: bold;">broulik</span> wrote in <span style="color: #4b4d51; font-weight: bold;">systemtray.cpp:358</span></div>
<div style="margin: 8px 0; padding: 0 12px; color: #74777D;"><p style="padding: 0; margin: 8px;">I am not sure you should check for <tt style="background: #ebebeb; font-size: 13px;">name</tt> being empty, since it could have just pixmaps inside, not a themed icon?</p></div></div>
<div style="margin: 8px 0; padding: 0 12px;"><p style="padding: 0; margin: 8px;">Yeah, this is tricky, probably requires a few words of comment.<br />
I'm checking if there is a name OR a pixmap assigned to be in parity with IconItem implementation. This code is from PlasmaCore.IconItem::setSource():</p>

<div class="remarkup-code-block" style="margin: 12px 0;" data-code-lang="text" data-sigil="remarkup-code-block"><pre class="remarkup-code" style="font: 11px/15px "Menlo", "Consolas", "Monaco", monospace; padding: 12px; margin: 0; background: rgba(71, 87, 120, 0.08);">// If the QIcon was created with QIcon::fromTheme(), try to load it as svg
if (source.canConvert<QIcon>() && !source.value<QIcon>().name().isEmpty()) {
    sourceString = source.value<QIcon>().name();
}
if (!sourceString.isEmpty()) {
    ...
} else if (source.canConvert<QIcon>()) {
    m_icon = source.value<QIcon>();
    ...
}</pre></div>

<p style="padding: 0; margin: 8px;">So even if there is no pixmap assigned (is it even possible? does make sense?) the icon is considered valid.<br />
The "Icon" is not just a pixmap passed from the client app, it is enhanced in the "StatusNotifierItemSource". Even if there is only "IconName" provided, StatusNotifierItemSource loads the icon from "IconName" (using KIconEngine), applies OverlayIcon* (if available) and passes it as "Icon".</p>

<p style="padding: 0; margin: 8px;">The specification says that "IconName" should be preferred over the "Icon" pixmap: <a href="https://www.freedesktop.org/wiki/Specifications/StatusNotifierItem/StatusNotifierItem/" class="remarkup-link" target="_blank" rel="noreferrer">freedesktop::StatusNotifierItem</a><br />
"StatusNotifierItemSource" loads icon from "IconName" (using KIconEngine) into "Icon" and then applies OverlayIcon* (if available).<br />
StatusNotifierItemSource takes IconName as a first source, but then in the presentation view (QML) it is the opposite - only "Icon" is useful.</p>

<p style="padding: 0; margin: 8px;">As a side note, there a two way to improve it:</p>

<ol class="remarkup-list">
<li class="remarkup-list-item">simplify the model and move all logic to presentation view, so: use "IconName" as a primary source, not "Icon" and apply any overlay icons in the presentation view (QML).</li>
<li class="remarkup-list-item">get rid of the "IconName" entirely, because it is already handled in the model (StatusNotifierItemSource). PlasmaCore.IconItem is probably don't needed as well, theme is (?) already handled in the model.</li>
</ol>

<p style="padding: 0; margin: 8px;">Anyway, the situation is quite messy.</p></div></div></div></div></div><br /><div><strong>REPOSITORY</strong><div><div>R120 Plasma Workspace</div></div></div><br /><div><strong>REVISION DETAIL</strong><div><a href="https://phabricator.kde.org/D24865">https://phabricator.kde.org/D24865</a></div></div><br /><div><strong>To: </strong>kmaterka, Plasma, broulik, Plasma: Workspaces<br /><strong>Cc: </strong>lbeltrame, plasma-devel, LeGast00n, The-Feren-OS-Dev, jraleigh, fbampaloukas, GB_2, ragreen, ZrenBot, ngraham, alexeymin, himcesjf, lesliezhai, ali-mohamed, jensreuterberg, abetts, sebas, apol, ahiemstra, mart<br /></div>