<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 />
<blockquote style="margin-left: 1em; border-left: 2px solid #d0d0d0; padding-left: 10px;">
<p style="margin-top: 0;">On July 19th, 2016, 5:29 p.m. UTC, <b>David Faure</b> wrote:</p>
<blockquote style="margin-left: 1em; border-left: 2px solid #d0d0d0; padding-left: 10px;">
<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>
<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>
</blockquote>
</blockquote>
<pre style="margin-left: 1em; 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;">The method <em style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: normal;">getFileExtension</em> will query the file extension and will return it with a leading dot. The variable <em style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: normal;">m_fileExtension</em> will store the file extention. Once the RealFile dialog is accepted the extension is appended to <em style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: normal;">m_text</em>. Additionally, before appending a check is performed to determine if the user has already entered the extension with the filename or not.</p></pre>
<br />
<blockquote style="margin-left: 1em; border-left: 2px solid #d0d0d0; padding-left: 10px;">
<p style="margin-top: 0;">On July 19th, 2016, 5:29 p.m. UTC, <b>David Faure</b> wrote:</p>
<blockquote style="margin-left: 1em; border-left: 2px solid #d0d0d0; padding-left: 10px;">
<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>
<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>
</blockquote>
</blockquote>
<pre style="margin-left: 1em; 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;">To remove the redundant checks i used a bool variable <em style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: normal;">usingTemplate</em> which is true only when a resource file is being used. Based on its truth value connections is made to the slot <em style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: normal;">_k_slotOtherDesktopFile</em> where the temporary file will be removed.</p>
<p style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: inherit;">Calling <em style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: normal;">executeStrategy</em> from <em style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: normal;">_k_slotOtherDesktopFile</em> is useless because <em style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: normal;">m_src</em> is empty(there will be no file handling). So i removed this call and added QFile::remove.</p></pre>
<br />
<p>- Chinmoy</p>
<br />
<p>On July 20th, 2016, 7:09 a.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 KDE Frameworks and David Faure.</div>
<div>By Chinmoy Ranjan Pradhan.</div>
<p style="color: grey;"><i>Updated July 20, 2016, 7:09 a.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>