KNewFileMenu: Fix creating link to application
Review Request #128501 - Created July 22, 2016 and submitted
|Chinmoy Ranjan Pradhan|
Fix for the bug https://bugs.kde.org/show_bug.cgi?id=363673 . The bug occurs because KPropertiesDialog is initialized (inside KNewFileMenuPrivate::executeOtherDesktopFile) 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 _k_slotOtherDesktopFile and _k_slotAbortDialog so that whether or not the user creates a Link to Application, the temporary is always deleted)
Please rebase onto current master, I added some code in the slot for unittest purposes.
This belongs to 128499, it shouldn't be here.
My recent changes for the unittest need this connection to applied() after all.
Can you leave it, and use another slot for connecting to propertiesClosed()?
Let's say _k_slotOtherDesktopFileClosed().
You don't need the connect to rejected() btw, with my recent fixes propertiesClosed() is always emitted whichever way the dialog is closed (accepted, or rejected with Esc, Alt+F4, windowmanager button, Cancel).
Ah, maybe it was for the case of clicking OK? For that you just need the QFile::remove in the existing slot as well, then (the one connected to applied()).