Add option to allow execution as well as opening of scripts and desktop files
Review Request #120171 - Created Sept. 12, 2014 and submitted
| Information | |
|---|---|
| Arjun AK | |
| kde-baseapps | |
| master | |
| 275405 | |
| Reviewers | |
| dolphin, usability | |
| dfaure | |
This patch allows the user to execute (in background, within the embedded terminal, external terminal) or open an executable file (scripts, desktop files...). When the user clicks on an executable file, a dialog pops up which contains options to either open it or execute it. Clicking on execute runs the program in the background (dolphin's current behaviour).
The settings dialog has further options to fine-tune how the file is executed. The program can either be executed in the background or inside the embedded konsole or in an external terminal.
In case there is a process already running in the embedded terminal, with user's permission it will be terminated and the selected program will be started.
See also:
https://git.reviewboard.kde.org/r/118939/
Files
Issues
- 1
- 11
- 17
- 29
| Description | From | Last Updated |
|---|---|---|
| Final nitpick: please use a proper name instead of value, behaviourOnLaunch maybe? |
|
Change Summary:
Quote the command
Change Summary:
Oops, missed a return statement. Also revert to dolphin's old behaviour when opening remote files.
Diff: |
Revision 3 (+348 -5)
|
|---|
The general direction looks ok to me (but the dolphin maintainer will have the final word on that). Some comments.
-
dolphin/src/dolphinmainwindow.cpp (Diff revision 3) -
missing space after if
-
dolphin/src/dolphinmainwindow.cpp (Diff revision 3) -
mime->name() is simpler to read
-
dolphin/src/dolphinmainwindow.cpp (Diff revision 3) -
should be mime->is("application/x-desktop") to take inheritance into account (just in case)
-
dolphin/src/dolphinmainwindow.cpp (Diff revision 3) -
strange indentation, no? (I don't know the dolphin coding style though)
-
dolphin/src/dolphinmainwindow.cpp (Diff revision 3) -
the nested switch makes the method a bit hard to read, maybe split the whole handling of "always ask" into a separate method?
-
dolphin/src/dolphinmainwindow.cpp (Diff revision 3) -
I guess you mean url.toLocalFile()
(path and toLocalFile do the same on Unix for local paths but not on Windows, e.g. file:///c:/a.txt leads to path=/c:/a.txt (directly extracted from the path component of the URL) and toLocalFile=c:/a.txt (which QFile can use))
-
dolphin/src/panels/terminal/terminalpanel.cpp (Diff revision 3) -
toLocalFile()
(in all cases this assumes that the url is local, so either assert that here or verify callers)
I had planned to work on this for quite some time, but there was always something that looked more urgent, so I never got round to it. I apprecitate that you took this effort now, and I'm sure that many users will appreciate it too!
I strongly recommend to add the usability team as reviewers to this request though, to discuss with them what the best solution for this issue is. I am not sure if we really want to provide that many options to the user. Adding more options always looks great at first sight, but they may confuse the user, make the settings dialog less usable, and they add more code paths, which make the long-term maintenance harder and possibly lead to lots of new subtle bugs.
In particular, the "embedded terminal" and "external terminal" options offer very similar functionality, so it seems questionable if we really want both. Even more so if one of them ("embedded") requires more changes to the code and a new "do you want to replace the running program" dialog, and will most likely introduce new bugs (in my experience, any change to the terminal panel is likely to cause unexpected problems, which may be very hard to fix, see, e.g., https://bugs.kde.org/show_bug.cgi?id=305085 ).
Moreover, I think it might be worth considering to offer all options in the "What do you want to do" dialog already (Execute/Open/Open in terminal/Cancel), but these are just my 2 cents - this should really be discussed with the usability team.
Is this on the right layer in Dolphin? What about Folder View in Plasma?
Change Summary:
Fixed mentiond issues.
Diff: |
Revision 4 (+241 -5)
|
|---|
Change Summary:
Removed execute in external and embedded terminal
Diff: |
Revision 5 (+270 -3)
|
|---|
-
dolphin/src/dolphinmainwindow.h (Diff revision 5) -
Description please
-
dolphin/src/dolphinmainwindow.cpp (Diff revision 5) -
Remove the empty line
-
dolphin/src/dolphinmainwindow.cpp (Diff revision 5) -
Just remove the KRun pointer "run" if you don't need it.
-
dolphin/src/dolphinmainwindow.cpp (Diff revision 5) -
switch () {
case Open: {
...
break;
}
case AlwaysAsk:
...;
break;case Execute:
...;
break;
} -
dolphin/src/dolphinmainwindow.cpp (Diff revision 5) -
Remove the unused KRun pointer + curly brackets
-
dolphin/src/dolphinmainwindow.cpp (Diff revision 5) -
Maybe you want a scoped pointer instead? See http://qt-project.org/doc/qt-5/qscopedpointer.html
If you use the scoped pointer you can remove the "delete dialog;" at the end of this method
-
dolphin/src/dolphinmainwindow.cpp (Diff revision 5) -
.data() is not needed
-
dolphin/src/dolphinmainwindow.cpp (Diff revision 5) -
switch () {
case Open: {
...
break;
}
case AlwaysAsk:
...;
break;case Execute:
...;
break;
} -
dolphin/src/dolphinmainwindow.cpp (Diff revision 5) -
Remove unused KRun* run
-
dolphin/src/dolphinviewcontainer.h (Diff revision 5) -
I think we should name this signal "fileActivated" instead of "fileClicked".
-
dolphin/src/settings/general/behaviorsettingspage.h (Diff revision 5) -
Give them better names please.
-
dolphin/src/settings/general/behaviorsettingspage.cpp (Diff revision 5) -
only 1 space between
-
dolphin/src/settings/general/behaviorsettingspage.cpp (Diff revision 5) -
revert the unrelated new line change
-
dolphin/src/settings/general/behaviorsettingspage.cpp (Diff revision 5) -
Remove empty new line
-
dolphin/src/views/executablefileopendialog.h (Diff revision 5) -
m_ prefix
-
dolphin/src/views/executablefileopendialog.cpp (Diff revision 5) -
Can be removed
-
dolphin/src/views/executablefileopendialog.cpp (Diff revision 5) -
Can be removed
I have found a problem with your patch. The "executable file open dialog" doesn't only appear for
executable scripts, it appears for all different kinds of executables, which is wrong I guess.So you have to check if the file is an executable text file.
-
dolphin/src/settings/general/behaviorsettingspage.cpp (Diff revision 5) -
@usability team:
What do you think about the label and radio buttons text?e.g. Nautilus has the following settings:
Executable Text Files
(*) Run executable text files when they are opened
( ) View executable text files when they are opened
( ) Ask each time
Yep, this could go into KIO for sharing between file managers.
I'm not sure how/where though; probably KRun. But the real question is whether the config should be shared between apps or not.
It's easier to code, but it might be better to let each app handle the configuration part of it, otherwise we have more weird "shared settings which don't belong in any app's KCM because it's unexpected that they affect all apps", right?Well, one solution is using KGlobal::config() (KSharedConfig::openConfig in KF5) in KRun and letting apps write to that.
-
dolphin/src/dolphinmainwindow.cpp (Diff revision 5) -
Why by file content and not the more general findByFile, which also takes extensions into account? Users generally name things properly, better trust them.
Change Summary:
Use a single checkbox in Settings->General->Confirmations->"Ask for confirmation in all KDE applications"
Diff: |
Revision 6 (+16) |
|---|
So in Plasma we have icon launcher which uses KRun to open the applications http://quickgit.kde.org/?p=plasma-workspace.git&a=blob&h=a2a3f81d48ff72543d97c70b5e457b75087310b3&hb=f8e1012c7f1c9a8adfb42ff161ebec379e24a037&f=applets%2Ficon%2Fplugin%2Ficon_p.cpp
Now in case of launchers this is obvious that one want to launch that application and not do something else, so can we add some option to disable this confirmation box in KRun?
-
dolphin/src/settings/general/confirmationssettingspage.cpp (Diff revision 6) -
Nitpick: One space too much
-
dolphin/src/settings/general/confirmationssettingspage.cpp (Diff revision 6) -
The m_confirmScriptExecution check isn't needed, it is guaranteed that the pointer is valid. Maybe you mean m_confirmScriptExection->isChecked() instead?
Can you please move the scriptExecutionGroup below the confirmationGroup sync?
And you need to sync the scriptExecutionGroup as well.
-
dolphin/src/settings/general/confirmationssettingspage.cpp (Diff revision 6) -
I think we should set it to alwaysAsk instead of deleting it, makes it more obvious.
-
dolphin/src/settings/general/confirmationssettingspage.cpp (Diff revision 6) -
const
Thanks for working on this, awesome! :D
-
dolphin/src/dolphinviewcontainer.cpp (Diff revision 7) -
Final nitpick: please use a proper name instead of value, behaviourOnLaunch maybe?
-
dolphin/src/dolphinviewcontainer.cpp (Diff revision 7) -
Hmm ... this is already done by KRun, isn't it?
KRun *run = new KRun(item.targetUrl(), this);
run->setShowScriptExecutionPrompt(true);Should be enough
