<table><tr><td style="">dfaure 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/D2687" rel="noreferrer">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/D2687#inline-12723" rel="noreferrer">View Inline</a><span style="color: #4b4d51; font-weight: bold;">iconapplet.cpp:57</span></div>
<div style="font: 11px/15px "Menlo", "Consolas", "Monaco", monospace; white-space: pre-wrap; clear: both; padding: 4px 0; margin: 0;"><div style="padding: 0 8px; margin: 0 4px; background: #d0ffd0;"> <span style="color: #aa4000">if</span> <span class="p">(</span><span class="n">destroyed</span><span class="p">())</span> <span class="p">{</span>
</div><div style="padding: 0 8px; margin: 0 4px; background: #d0ffd0;"> <span class="n">QFile</span><span class="p">(</span><span class="n">m_localPath</span><span class="p">).</span><span class="n">remove</span><span class="p">();</span>
</div><div style="padding: 0 8px; margin: 0 4px; background: #d0ffd0;"> <span class="p">}</span>
</div></div></div>
<div style="margin: 8px 0; padding: 0 12px;"><p style="padding: 0; margin: 8px;">QFile::remove is enough, no need for a QFile instance.</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/D2687#inline-12724" rel="noreferrer">View Inline</a><span style="color: #4b4d51; font-weight: bold;">iconapplet.cpp:78</span></div>
<div style="font: 11px/15px "Menlo", "Consolas", "Monaco", monospace; white-space: pre-wrap; clear: both; padding: 4px 0; margin: 0;"><div style="padding: 0 8px; margin: 0 4px; background: #d0ffd0;"> <span style="color: #aa4000">if</span> <span class="p">(</span><span style="color: #aa2211">!</span><span class="n">m_url</span><span class="p">.</span><span class="n">isValid</span><span class="p">())</span> <span class="p">{</span>
</div><div style="padding: 0 8px; margin: 0 4px; background: #d0ffd0;"> <span style="color: #74777d">// invalid url, use dummy data ("nk</span>
</div><div style="padding: 0 8px; margin: 0 4px; background: #d0ffd0;"> <span class="n">populateFromDesktopFile</span><span class="p">(</span><span class="n">QString</span><span class="p">());</span>
</div></div></div>
<div style="margin: 8px 0; padding: 0 12px;"><p style="padding: 0; margin: 8px;">the end of the comment is weird ... ("nk ?</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/D2687#inline-12725" rel="noreferrer">View Inline</a><span style="color: #4b4d51; font-weight: bold;">iconapplet.cpp:90</span></div>
<div style="font: 11px/15px "Menlo", "Consolas", "Monaco", monospace; white-space: pre-wrap; clear: both; padding: 4px 0; margin: 0;"><div style="padding: 0 8px; margin: 0 4px; background: #d0ffd0;"> <span style="color: #74777d">// now create a desktop file</span>
</div><div style="padding: 0 8px; margin: 0 4px; background: #d0ffd0;"> <span style="color: #aa4000">const</span> <span class="n">QUrl</span> <span class="n">backingDesktopFile</span> <span style="color: #aa2211">=</span> <span class="n">QUrl</span><span style="color: #aa2211">::</span><span class="n">fromLocalFile</span><span class="p">(</span><span class="n">plasmaIconsFolderPath</span> <span style="color: #aa2211">+</span> <span class="n">QLatin1Char</span><span class="p">(</span><span style="color: #766510">'/'</span><span class="p">)</span>
</div><div style="padding: 0 8px; margin: 0 4px; background: #d0ffd0;"> <span style="color: #aa2211">+</span> <span class="n">KIO</span><span style="color: #aa2211">::</span><span class="n">suggestName</span><span class="p">(</span><span class="n">QUrl</span><span style="color: #aa2211">::</span><span class="n">fromLocalFile</span><span class="p">(</span><span class="n">plasmaIconsFolderPath</span><span class="p">),</span> <span class="n">m_url</span><span class="p">.</span><span class="n">fileName</span><span class="p">()));</span>
</div></div></div>
<div style="margin: 8px 0; padding: 0 12px;"><p style="padding: 0; margin: 8px;">Extract QUrl::fromLocalFile(plasmaIconsFolderPath) so you can use it twice?<br />
Like this:</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);">const QUrl dirUrl = QUrl::fromLocalFile(plasmaIconsFolderPath);
QUrl backingDesktopFile(dirUrl);
backingDesktopFile.setPath(dirUrl.path() + QLatin1Char('/') + KIO::suggestName(dirUrl, m_url.fileName());</pre></div></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/D2687#inline-12729" rel="noreferrer">View Inline</a><span style="color: #4b4d51; font-weight: bold;">iconapplet.cpp:108</span></div>
<div style="font: 11px/15px "Menlo", "Consolas", "Monaco", monospace; white-space: pre-wrap; clear: both; padding: 4px 0; margin: 0;"><div style="padding: 0 8px; margin: 0 4px; background: #d0ffd0;"> <span style="color: #74777d">// set no display so it does not mess with our system applications</span>
</div><div style="padding: 0 8px; margin: 0 4px; background: #d0ffd0;"> <span style="color: #74777d">// TODO shouldn't be neccessary as we don't have it in applications</span>
</div><div style="padding: 0 8px; margin: 0 4px; background: #d0ffd0;"> <span class="n">KDesktopFile</span><span class="p">(</span><span class="n">localBackingDesktopFile</span><span class="p">).</span><span class="n">desktopGroup</span><span class="p">().</span><span class="n">writeEntry</span><span class="p">(</span><span class="n">QStringLiteral</span><span class="p">(</span><span style="color: #766510">"Hidden"</span><span class="p">),</span> <span style="color: #304a96">true</span><span class="p">);</span>
</div></div></div>
<div style="margin: 8px 0; padding: 0 12px;"><p style="padding: 0; margin: 8px;">yep so remove it :-)</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/D2687#inline-12730" rel="noreferrer">View Inline</a><span style="color: #4b4d51; font-weight: bold;">iconapplet.cpp:235</span></div>
<div style="font: 11px/15px "Menlo", "Consolas", "Monaco", monospace; white-space: pre-wrap; clear: both; padding: 4px 0; margin: 0;"><div style="padding: 0 8px; margin: 0 4px; background: #d0ffd0;"><span class="p">{</span>
</div><div style="padding: 0 8px; margin: 0 4px; background: #d0ffd0;"> <span style="color: #74777d">//new KRun(QUrl::fromLocalFile(m_localPath));</span>
</div></div></div>
<div style="margin: 8px 0; padding: 0 12px;"><p style="padding: 0; margin: 8px;">So m_localPath is the full path to a Type=Link desktop file?<br />
Then this first line is the one that should work, creating a KRun with the desktop file as argument.</p>
<p style="padding: 0; margin: 8px;">For proof:</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);">wget http://www.davidfaure.fr/2016/testlink.desktop
kioclient5 exec $PWD/testlink.desktop</pre></div>
<p style="padding: 0; margin: 8px;">(which does exactly this, new KRun(url))</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/D2687#inline-12731" rel="noreferrer">View Inline</a><span style="color: #4b4d51; font-weight: bold;">iconapplet.cpp:237</span></div>
<div style="font: 11px/15px "Menlo", "Consolas", "Monaco", monospace; white-space: pre-wrap; clear: both; padding: 4px 0; margin: 0;"><div style="padding: 0 8px; margin: 0 4px; background: #d0ffd0;"> <span style="color: #74777d">// TODO doesnt find it usually</span>
</div><div style="padding: 0 8px; margin: 0 4px; background: #d0ffd0;"> <span class="n">KService</span> <span class="n">service</span><span class="p">(</span><span class="n">m_localPath</span><span class="p">);</span>
</div></div></div>
<div style="margin: 8px 0; padding: 0 12px;"><p style="padding: 0; margin: 8px;">KService is for Type=Application (or Type=Service) desktop files.</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/D2687#inline-12726" rel="noreferrer">View Inline</a><span style="color: #4b4d51; font-weight: bold;">iconapplet.cpp:258</span></div>
<div style="font: 11px/15px "Menlo", "Consolas", "Monaco", monospace; white-space: pre-wrap; clear: both; padding: 4px 0; margin: 0;"><div style="padding: 0 8px; margin: 0 4px; background: #d0ffd0;"> <span class="n">foreach</span> <span class="p">(</span><span style="color: #aa4000">const</span> <span class="n">QJsonValue</span> <span style="color: #aa2211">&</span><span class="n">droppedUrl</span><span class="p">,</span> <span class="n">droppedUrls</span><span class="p">)</span> <span class="p">{</span>
</div><div style="padding: 0 8px; margin: 0 4px; background: #d0ffd0;"> <span style="color: #aa4000">const</span> <span class="n">QUrl</span> <span class="n">url</span> <span style="color: #aa2211">=</span> <span class="n">QUrl</span><span style="color: #aa2211">::</span><span class="n">fromUserInput</span><span class="p">(</span><span class="n">droppedUrl</span><span class="p">.</span><span class="n">toString</span><span class="p">(),</span> <span class="n">QString</span><span class="p">(),</span> <span class="n">QUrl</span><span style="color: #aa2211">::</span><span class="n">AssumeLocalFile</span><span class="p">);</span>
</div><div style="padding: 0 8px; margin: 0 4px; background: #d0ffd0;"> <span style="color: #aa4000">if</span> <span class="p">(</span><span class="n">url</span><span class="p">.</span><span class="n">isValid</span><span class="p">())</span> <span class="p">{</span>
</div></div></div>
<div style="margin: 8px 0; padding: 0 12px;"><p style="padding: 0; margin: 8px;">Why the convoluted line here? Isn't droppedUrl.toString() always a full URL?</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/D2687#inline-12727" rel="noreferrer">View Inline</a><span style="color: #4b4d51; font-weight: bold;">iconapplet.cpp:304</span></div>
<div style="font: 11px/15px "Menlo", "Consolas", "Monaco", monospace; white-space: pre-wrap; clear: both; padding: 4px 0; margin: 0;"><div style="padding: 0 8px; margin: 0 4px; background: #d0ffd0;"> <span class="n">foreach</span> <span class="p">(</span><span style="color: #aa4000">const</span> <span class="n">QUrl</span> <span style="color: #aa2211">&</span><span class="n">url</span><span class="p">,</span> <span class="n">urls</span><span class="p">)</span> <span class="p">{</span>
</div><div style="padding: 0 8px; margin: 0 4px; background: #d0ffd0;"> <span style="color: #74777d">// TODO toEncoded?</span>
</div><div style="padding: 0 8px; margin: 0 4px; background: #d0ffd0;"> <span class="n">params</span> <span style="color: #aa2211">+=</span> <span class="n">QLatin1Char</span><span class="p">(</span><span style="color: #766510">' '</span><span class="p">)</span> <span style="color: #aa2211">+</span> <span class="n">KShell</span><span style="color: #aa2211">::</span><span class="n">quoteArg</span><span class="p">(</span><span class="n">url</span><span class="p">.</span><span class="n">isLocalFile</span><span class="p">()</span> <span style="color: #aa2211">?</span> <span class="n">url</span><span class="p">.</span><span class="n">toLocalFile</span><span class="p">()</span> <span style="color: #aa2211">:</span> <span class="n">url</span><span class="p">.</span><span class="n">toEncoded</span><span class="p">());</span>
</div></div></div>
<div style="margin: 8px 0; padding: 0 12px;"><p style="padding: 0; margin: 8px;">toString should be enough.</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/D2687#inline-12728" rel="noreferrer">View Inline</a><span style="color: #4b4d51; font-weight: bold;">iconapplet.cpp:308</span></div>
<div style="font: 11px/15px "Menlo", "Consolas", "Monaco", monospace; white-space: pre-wrap; clear: both; padding: 4px 0; margin: 0;"><div style="padding: 0 8px; margin: 0 4px; background: #d0ffd0;"> <span class="n">KRun</span><span style="color: #aa2211">::</span><span class="n">runCommand</span><span class="p">(</span><span class="n">KShell</span><span style="color: #aa2211">::</span><span class="n">quoteArg</span><span class="p">(</span><span class="n">m_url</span><span class="p">.</span><span class="n">path</span><span class="p">())</span> <span style="color: #aa2211">+</span> <span class="n">QLatin1Char</span><span class="p">(</span><span style="color: #766510">' '</span><span class="p">)</span> <span style="color: #aa2211">+</span> <span class="n">params</span><span class="p">,</span> <span style="color: #aa4000">nullptr</span><span class="p">);</span>
</div><div style="padding: 0 8px; margin: 0 4px; background: #d0ffd0;"> <span style="color: #aa4000">return</span> <span style="color: #304a96">true</span><span class="p">;</span>
</div></div></div>
<div style="margin: 8px 0; padding: 0 12px;"><p style="padding: 0; margin: 8px;">This one could be a case for QProcess::startDetached, no need for shell-quoting then.</p></div></div></div></div></div><br /><div><strong>REPOSITORY</strong><div><div>rPLASMAWORKSPACE Plasma Workspace</div></div></div><br /><div><strong>REVISION DETAIL</strong><div><a href="https://phabricator.kde.org/D2687" rel="noreferrer">https://phabricator.kde.org/D2687</a></div></div><br /><div><strong>EMAIL PREFERENCES</strong><div><a href="https://phabricator.kde.org/settings/panel/emailpreferences/" rel="noreferrer">https://phabricator.kde.org/settings/panel/emailpreferences/</a></div></div><br /><div><strong>To: </strong>broulik, Plasma, dfaure<br /><strong>Cc: </strong>mart, plasma-devel, lesliezhai, ali-mohamed, jensreuterberg, abetts, sebas<br /></div>