<html>
<body>
<div style="font-family: Verdana, Arial, Helvetica, Sans-Serif;">
<table bgcolor="#f9f3c9" width="100%" cellpadding="12" style="border: 1px #c9c399 solid; border-radius: 6px; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
<tr>
<td>
This is an automatically generated e-mail. To reply, visit:
<a href="https://git.reviewboard.kde.org/r/128471/">https://git.reviewboard.kde.org/r/128471/</a>
</td>
</tr>
</table>
<br />
<pre style="white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;"><p style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: inherit;">Nice fixes!</p>
<p style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: inherit;">Just some comments.</p></pre>
<br />
<div>
<table width="100%" border="0" bgcolor="white" style="border: 1px solid #C0C0C0; border-collapse: collapse; margin: 2px padding: 2px;">
<thead>
<tr>
<th colspan="4" bgcolor="#F0F0F0" style="border-bottom: 1px solid #C0C0C0; font-size: 9pt; padding: 4px 8px; text-align: left;">
<a href="https://git.reviewboard.kde.org/r/128471/diff/3/?file=471981#file471981line457" style="color: black; font-weight: bold; text-decoration: underline;">src/filewidgets/knewfilemenu.cpp</a>
<span style="font-weight: normal;">
(Diff revision 3)
</span>
</th>
</tr>
</thead>
<tbody>
<tr>
<th bgcolor="#e9eaa8" style="border-right: 1px solid #C0C0C0;" align="right"><font size="2">455</font></th>
<td bgcolor="#fdfebc" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "> <span class="n">text</span> <span class="o">=</span> <span class="n">KIO</span><span class="o">::</span><span class="n">suggestName</span><span class="p">(</span><span class="o">*</span><span class="n">it</span><span class="p">,</span> <span class="n">text</span><span class="p">);</span></pre></td>
<th bgcolor="#e9eaa8" style="border-left: 1px solid #C0C0C0; border-right: 1px solid #C0C0C0;" align="right"><font size="2">457</font></th>
<td bgcolor="#fdfebc" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "> <span class="n">text</span> <span class="o">=</span> <span class="n">KIO</span><span class="o">::</span><span class="n">suggestName</span><span class="p">(</span><span class="n"><span class="hl">mostLocalUrl</span></span><span class="p"><span class="hl">(</span></span><span class="o">*</span><span class="n">it</span><span class="p"><span class="hl">)</span>,</span> <span class="n">text</span><span class="p">);</span></pre></td>
</tr>
</tbody>
</table>
<div style="margin-left: 2em;">
<pre style="white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;"><p style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: inherit;">You should call mostLocalUrl only once, it's an expensive operation (KIO Job).</p></pre>
</div>
</div>
<br />
<div>
<table width="100%" border="0" bgcolor="white" style="border: 1px solid #C0C0C0; border-collapse: collapse; margin: 2px padding: 2px;">
<thead>
<tr>
<th colspan="4" bgcolor="#F0F0F0" style="border-bottom: 1px solid #C0C0C0; font-size: 9pt; padding: 4px 8px; text-align: left;">
<a href="https://git.reviewboard.kde.org/r/128471/diff/3/?file=471981#file471981line470" style="color: black; font-weight: bold; text-decoration: underline;">src/filewidgets/knewfilemenu.cpp</a>
<span style="font-weight: normal;">
(Diff revision 3)
</span>
</th>
</tr>
</thead>
<tbody>
<tr>
<th bgcolor="#b1ebb0" style="border-right: 1px solid #C0C0C0;" align="right"><font size="2"></font></th>
<td bgcolor="#c5ffc4" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "></pre></td>
<th bgcolor="#b1ebb0" style="border-left: 1px solid #C0C0C0; border-right: 1px solid #C0C0C0;" align="right"><font size="2">470</font></th>
<td bgcolor="#c5ffc4" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "> <span class="n">group</span><span class="p">.</span><span class="n">writeEntry</span><span class="p">(</span><span class="s">"Name"</span><span class="p">,</span> <span class="n">text</span><span class="p">.</span><span class="n">remove</span><span class="p">(</span><span class="n">QStringLiteral</span><span class="p">(</span><span class="s">".desktop"</span><span class="p">)));</span></pre></td>
</tr>
</tbody>
</table>
<div style="margin-left: 2em;">
<pre style="white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;"><p style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: inherit;">You could have kept a copy of the text without .desktop before the append above ;)</p>
<p style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: inherit;"><div class="codehilite" style="background: #f8f8f8"><pre style="line-height: 125%">QString name = text;
text.append(...);
</pre></div>
</p>
<p style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: inherit;">and using writeEntry("Name", name) here.</p></pre>
</div>
</div>
<br />
<div>
<table width="100%" border="0" bgcolor="white" style="border: 1px solid #C0C0C0; border-collapse: collapse; margin: 2px padding: 2px;">
<thead>
<tr>
<th colspan="4" bgcolor="#F0F0F0" style="border-bottom: 1px solid #C0C0C0; font-size: 9pt; padding: 4px 8px; text-align: left;">
<a href="https://git.reviewboard.kde.org/r/128471/diff/3/?file=471981#file471981line471" style="color: black; font-weight: bold; text-decoration: underline;">src/filewidgets/knewfilemenu.cpp</a>
<span style="font-weight: normal;">
(Diff revision 3)
</span>
</th>
</tr>
</thead>
<tbody>
<tr>
<th bgcolor="#b1ebb0" style="border-right: 1px solid #C0C0C0;" align="right"><font size="2"></font></th>
<td bgcolor="#c5ffc4" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "></pre></td>
<th bgcolor="#b1ebb0" style="border-left: 1px solid #C0C0C0; border-right: 1px solid #C0C0C0;" align="right"><font size="2">471</font></th>
<td bgcolor="#c5ffc4" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "> <span class="n">df</span><span class="p">.</span><span class="n">sync</span><span class="p">();</span></pre></td>
</tr>
</tbody>
</table>
<div style="margin-left: 2em;">
<pre style="white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;"><p style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: inherit;">This line can be removed given that the KDesktopFile destructor will of course sync to disk.</p></pre>
</div>
</div>
<br />
<div>
<table width="100%" border="0" bgcolor="white" style="border: 1px solid #C0C0C0; border-collapse: collapse; margin: 2px padding: 2px;">
<thead>
<tr>
<th colspan="4" bgcolor="#F0F0F0" style="border-bottom: 1px solid #C0C0C0; font-size: 9pt; padding: 4px 8px; text-align: left;">
<a href="https://git.reviewboard.kde.org/r/128471/diff/3/?file=471981#file471981line496" style="color: black; font-weight: bold; text-decoration: underline;">src/filewidgets/knewfilemenu.cpp</a>
<span style="font-weight: normal;">
(Diff revision 3)
</span>
</th>
</tr>
</thead>
<tbody>
<tr>
<th bgcolor="#b1ebb0" style="border-right: 1px solid #C0C0C0;" align="right"><font size="2"></font></th>
<td bgcolor="#c5ffc4" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "></pre></td>
<th bgcolor="#b1ebb0" style="border-left: 1px solid #C0C0C0; border-right: 1px solid #C0C0C0;" align="right"><font size="2">496</font></th>
<td bgcolor="#c5ffc4" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "> <span class="n">QMimeType</span> <span class="n">mime</span> <span class="o">=</span> <span class="n">db</span><span class="p">.</span><span class="n">mimeTypeForUrl</span><span class="p">(</span><span class="n">QUrl</span><span class="o">::</span><span class="n">fromLocalFile</span><span class="p">(</span><span class="n">entry</span><span class="p">.</span><span class="n">templatePath</span><span class="p">));</span></pre></td>
</tr>
</tbody>
</table>
<div style="margin-left: 2em;">
<pre style="white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;"><p style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: inherit;">You can use mimeTypeForFile(entry.templatePath) to avoid the conversion to QUrl.</p></pre>
</div>
</div>
<br />
<div>
<table width="100%" border="0" bgcolor="white" style="border: 1px solid #C0C0C0; border-collapse: collapse; margin: 2px padding: 2px;">
<thead>
<tr>
<th colspan="4" bgcolor="#F0F0F0" style="border-bottom: 1px solid #C0C0C0; font-size: 9pt; padding: 4px 8px; text-align: left;">
<a href="https://git.reviewboard.kde.org/r/128471/diff/3/?file=471981#file471981line506" style="color: black; font-weight: bold; text-decoration: underline;">src/filewidgets/knewfilemenu.cpp</a>
<span style="font-weight: normal;">
(Diff revision 3)
</span>
</th>
</tr>
</thead>
<tbody>
<tr>
<th bgcolor="#e9eaa8" style="border-right: 1px solid #C0C0C0;" align="right"><font size="2">481</font></th>
<td bgcolor="#fdfebc" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "> <span class="n">text</span> <span class="o">=</span> <span class="n">KIO</span><span class="o">::</span><span class="n">suggestName</span><span class="p">(</span><span class="n">m_popupFiles</span><span class="p">.</span><span class="n">first</span><span class="p">(),</span> <span class="n">text</span><span class="p">);</span></pre></td>
<th bgcolor="#e9eaa8" style="border-left: 1px solid #C0C0C0; border-right: 1px solid #C0C0C0;" align="right"><font size="2">506</font></th>
<td bgcolor="#fdfebc" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "> <span class="n">text</span> <span class="o">=</span> <span class="n">KIO</span><span class="o">::</span><span class="n">suggestName</span><span class="p">(</span><span class="n">m<span class="hl">ostLocalUrl</span></span><span class="p"><span class="hl">(</span></span><span class="n"><span class="hl">m</span>_popupFiles</span><span class="p">.</span><span class="n">first</span><span class="p">()<span class="hl">)</span>,</span> <span class="n">text</span><span class="p">);</span></pre></td>
</tr>
</tbody>
</table>
<div style="margin-left: 2em;">
<pre style="white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;"><p style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: inherit;">Same here. (In fact this means these 5 lines about creating the QUrl based on the typed text could be factorized into a helper method)</p></pre>
</div>
</div>
<br />
<div>
<table width="100%" border="0" bgcolor="white" style="border: 1px solid #C0C0C0; border-collapse: collapse; margin: 2px padding: 2px;">
<thead>
<tr>
<th colspan="4" bgcolor="#F0F0F0" style="border-bottom: 1px solid #C0C0C0; font-size: 9pt; padding: 4px 8px; text-align: left;">
<a href="https://git.reviewboard.kde.org/r/128471/diff/3/?file=471981#file471981line789" style="color: black; font-weight: bold; text-decoration: underline;">src/filewidgets/knewfilemenu.cpp</a>
<span style="font-weight: normal;">
(Diff revision 3)
</span>
</th>
</tr>
</thead>
<tbody>
<tr>
<th bgcolor="#b1ebb0" style="border-right: 1px solid #C0C0C0;" align="right"><font size="2"></font></th>
<td bgcolor="#c5ffc4" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "></pre></td>
<th bgcolor="#b1ebb0" style="border-left: 1px solid #C0C0C0; border-right: 1px solid #C0C0C0;" align="right"><font size="2">789</font></th>
<td bgcolor="#c5ffc4" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "> <span class="k">if</span><span class="p">(</span><span class="o">!</span><span class="n">m_tempFileToDelete</span><span class="p">.</span><span class="n">isEmpty</span><span class="p">()</span> <span class="o">&&</span> <span class="n">QFile</span><span class="o">::</span><span class="n">exists</span><span class="p">(</span><span class="n">m_tempFileToDelete</span><span class="p">))</span> <span class="p">{</span></pre></td>
</tr>
</tbody>
</table>
<div style="margin-left: 2em;">
<pre style="white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">The QFile::exists check is redundant. QFile::remove will do nothing if the file doesn't exist.
Coding style: space after "if"
Documentation: adjust the docu for _k_slotAbortDialog at the top of the file
(it describes the implementation, bad idea, it should rather describe when this is called)</pre>
</div>
</div>
<br />
<div>
<table width="100%" border="0" bgcolor="white" style="border: 1px solid #C0C0C0; border-collapse: collapse; margin: 2px padding: 2px;">
<thead>
<tr>
<th colspan="4" bgcolor="#F0F0F0" style="border-bottom: 1px solid #C0C0C0; font-size: 9pt; padding: 4px 8px; text-align: left;">
<a href="https://git.reviewboard.kde.org/r/128471/diff/3/?file=471981#file471981line960" style="color: black; font-weight: bold; text-decoration: underline;">src/filewidgets/knewfilemenu.cpp</a>
<span style="font-weight: normal;">
(Diff revision 3)
</span>
</th>
</tr>
</thead>
<tbody>
<tr>
<th bgcolor="#b1ebb0" style="border-right: 1px solid #C0C0C0;" align="right"><font size="2"></font></th>
<td bgcolor="#c5ffc4" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "></pre></td>
<th bgcolor="#b1ebb0" style="border-left: 1px solid #C0C0C0; border-right: 1px solid #C0C0C0;" align="right"><font size="2">960</font></th>
<td bgcolor="#c5ffc4" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "> <span class="k">if</span><span class="p">(</span><span class="o">!</span><span class="n">m_tempFileToDelete</span><span class="p">.</span><span class="n">isEmpty</span><span class="p">()</span> <span class="o">&&</span> <span class="n">QFile</span><span class="o">::</span><span class="n">exists</span><span class="p">(</span><span class="n">m_tempFileToDelete</span><span class="p">))</span> <span class="p">{</span></pre></td>
</tr>
</tbody>
</table>
<div style="margin-left: 2em;">
<pre style="white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;"><p style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: inherit;">Same as in _k_slotAbortDialog</p></pre>
</div>
</div>
<br />
<p>- David Faure</p>
<br />
<p>On July 18th, 2016, 4:32 p.m. UTC, Chinmoy Ranjan Pradhan wrote:</p>
<table bgcolor="#fefadf" width="100%" cellspacing="0" cellpadding="12" style="border: 1px #888a85 solid; border-radius: 6px; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
<tr>
<td>
<div>Review request for kdelibs and David Faure.</div>
<div>By Chinmoy Ranjan Pradhan.</div>
<p style="color: grey;"><i>Updated July 18, 2016, 4:32 p.m.</i></p>
<div style="margin-top: 1.5em;">
<b style="color: #575012; font-size: 10pt;">Repository: </b>
kio
</div>
<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Description </h1>
<table width="100%" bgcolor="#ffffff" cellspacing="0" cellpadding="10" style="border: 1px solid #b8b5a0">
<tr>
<td>
<pre style="margin: 0; padding: 0; white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;"><p style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: inherit;">This patch fixes couple of issues with KNewFileMenu.</p>
<p style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: inherit;">Fix 1: When creating a new file, if a file with the default name already exist then a new name is suggested by <em style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: normal;">KIO::suggestName</em>. Now this works fine until the scheme of file's url is "file" but in case the scheme is "desktop" (<em style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: normal;">like when the url in dolphin is set to desktop:/ or "Folder View Settings > Location" is set to desktop:/</em>) then the check for file's existence fails because <em style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: normal;">QFile::
exists</em> doesn't understand the "desktop" scheme. So <em style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: normal;">KIO::suggestName</em> is not called and no
new filename is suggested in case a file with the same filename already exist. To fix this i used <em style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: normal;">KNewFileMenuPrivate::mostLocalUrl</em> in <em style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: normal;">KNewFileFileMenu::executeRealFileorDir</em> which will resolve "desktop:/" to the user's desktop path. </p>
<p style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: inherit;">Fix 2: If a user tries to create a new file and proceeds with the default filename then the file created will have no extension. This happens (<em style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: normal;">inside KNewFileFileMenu::executeRealFileorDir</em>) because the filename is read from the <em style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: normal;">Name</em> section of the desktop file. To fix this, read the URL(the url is in <em style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: normal;">templatePath</em>) from the desktop file, determine the file extension from there and append
it in the filename.</p>
<p style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: inherit;">Fix 3: Fix for the bug https://bugs.kde.org/show_bug.cgi?id=363673 . The bug occurs because KPropertiesDialog is initialized (<em style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: normal;">inside KNewFileMenuPrivate::executeOtherDesktopFile</em>) with path of a resource file. Now KPropertiesDialog only show properties if the file is a local file(i guess). Thats why clicking on "Link to Application" and then clicking 'ok' shows an error message . To Fix this i used QTemporaryFile to copy the contents of the application template shipped with kio and then initialize KPropertiesDialog with the temporary files' path.
(I added KNewFileMenuPrivate::mostLocalUrl here to ensure new filename is suggested when inside "desktop:/".)
(The temporary file created here must be deleted so i also added QFile::remove to <em style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: normal;">_k_slotOtherDesktopFile and _k_slotAbortDialog</em> so that whether or not the user creates a Link to Application, the temporary is always deleted)</p></pre>
</td>
</tr>
</table>
<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Diffs</b> </h1>
<ul style="margin-left: 3em; padding-left: 0;">
<li>src/filewidgets/knewfilemenu.cpp <span style="color: grey">(2e613b1)</span></li>
</ul>
<p><a href="https://git.reviewboard.kde.org/r/128471/diff/" style="margin-left: 3em;">View Diff</a></p>
<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">File Attachments </h1>
<li><a href="https://git.reviewboard.kde.org/media/uploaded/files/2016/07/18/d01841f8-08e3-4609-bd82-b54ea446cdf5__linktoapplication.png">linktoapplication.png</a></li>
<li><a href="https://git.reviewboard.kde.org/media/uploaded/files/2016/07/18/759ea00e-a65f-4dde-a05a-d297b63c2c1b__errormessage.png">errormessage.png</a></li>
<li><a href="https://git.reviewboard.kde.org/media/uploaded/files/2016/07/18/fbd04e13-c2d3-4acc-a4dc-b4a9053e2cb6__newfile.png">no extension and no new filename</a></li>
<li><a href="https://git.reviewboard.kde.org/media/uploaded/files/2016/07/18/6cbb3f10-9513-478b-a865-9fc791c006d5__linktoapplication_afterpatch.png">after_patch</a></li>
<li><a href="https://git.reviewboard.kde.org/media/uploaded/files/2016/07/18/2e9f5fa5-eaaa-4abc-a0ac-f492fb01faa3__newfile_aftepatch.png">after_patch</a></li>
</ul>
</td>
</tr>
</table>
</div>
</body>
</html>