Bug 399020 - Impossible to have different applications for HTML files and URLs
Summary: Impossible to have different applications for HTML files and URLs
Status: RESOLVED FIXED
Alias: None
Product: frameworks-kio
Classification: Frameworks and Libraries
Component: general (show other bugs)
Version: git master
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: David Faure
URL:
Keywords: usability
Depends on:
Blocks:
 
Reported: 2018-09-24 14:33 UTC by Serhiy Zahoriya
Modified: 2019-12-02 21:34 UTC (History)
5 users (show)

See Also:
Latest Commit:
Version Fixed In: 5.65


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Serhiy Zahoriya 2018-09-24 14:33:05 UTC
STEPS TO REPRODUCE
1. Try developing a Django project with convention that template files have .html extension.
2. Try setting Kate as file association for *.html files and open such file. The setting is ignored completely because default web browser overrides it.
3. Try changing setting of browser to "In an application based on the contents of the URL". Files open in Kate now. But all URLs too.

EXPECTED RESULT
There is a way to make files open in text editor and URLs in browser.

ACTUAL RESULT
No way to make files open in Kate and URLs in browser. You either have to remember that you have to open every HTML file through three clicks or have very hard time using any application that depends on opening links because they open in Kate.

SOFTWARE VERSIONS
KDE Plasma Version: 5.12.6
KDE Frameworks Version: 5.44.0
Qt Version: 5.9.5

ADDITIONAL INFORMATION
There is https://bugs.kde.org/show_bug.cgi?id=76327 but it's ancient and at first glance the explanation is less clear.
Comment 1 Kai Uwe Broulik 2018-09-25 07:37:20 UTC
This is an explicit special case in KRun, for whatever reason:

if (!d->m_externalBrowser.isEmpty() && (
                    mime.inherits(QStringLiteral("text/html")) ||
                    mime.inherits(QStringLiteral("application/xhtml+xml")))) {
            if (d->runExecutable(d->m_externalBrowser)) {
Comment 2 Serhiy Zahoriya 2018-09-25 08:17:47 UTC
I wanted to know why it was added but it was like this since code was moved https://cgit.kde.org/kio.git/commit/src/widgets/krun.cpp?id=c8ac9fd1774ec1b58d37ccdd3a1f767456596db0
Do you know where is the prior history if this file?
Comment 3 Kai Uwe Broulik 2018-09-25 08:23:33 UTC
Probably kdelibs: https://cgit.kde.org/kdelibs.git/tree/kio/kio/krun.cpp?h=KDE/4.14
Comment 4 Serhiy Zahoriya 2018-09-25 08:31:27 UTC
So it's https://cgit.kde.org/kdelibs.git/commit/kio/kio/krun.cpp?h=KDE/4.14&id=c230e107d213a67c0f1b5c033c00908053465c60
> Use BrowserApplication for local html files too.
> Discussed as part of review 103524.

https://git.reviewboard.kde.org/r/103524/

That is linked to https://bugs.kde.org/show_bug.cgi?id=182591
Comment 5 Ahmad Samir 2019-09-22 15:02:03 UTC
IMHO, there are two distinctive use cases here, opening http*:// links with a web browser (which is what the user wants most of the time); and opening local '.*html' files on the user's machine, usually with the intention to edit them; the two cases can/should be mutually exclusive. KRun shouldn't override user settings unconditionally.

Removing the afro-mentioned bit of code gives the choice back to the user, as he can set his preferred app to open local .html files, be it a web browser or a text editor. Also this won't impact new user accounts because most browsers .desktop files have Mimetype entries that cover most of the .html and co. types. So it'll either be the default app already or the user can select his favourite browser from the open with list.
Comment 6 Ahmad Samir 2019-10-21 11:51:11 UTC
https://phabricator.kde.org/D24828
Comment 7 Nate Graham 2019-12-02 21:34:08 UTC
Git commit afb2f80cbbe1d4095e897d88430a3b7295bb1114 by Nate Graham, on behalf of Ahmad Samir.
Committed on 02/12/2019 at 21:34.
Pushed by ngraham into branch 'master'.

KRun: don't override user preferred app when opening local *.*html and co. files

Summary:
KRun unconditionally opened files with mimetype text/html (and co.) with
the browser application set in kdeglobals, BrowserApplication=, and if it's
not set, it fells back to mimeapps.list (x-scheme-handler/http*).

IMHO, there are two distinctive use cases here, opening http*:// links
with a web browser (which is what the user wants most of the time); and
opening local '.*html' files on the user's machine, usually with the
intention to edit them; the two cases can/should be mutually exclusive.

This gives the choice back to the user, as he can set his preferred app
to open local .html files, be it a web browser or a text editor.

This won't impact new user accounts because most browsers .desktop files
have Mimetype entries that cover most of the .html and co. types. So it'll
either be the default app already or the user can select his favourite browser
from the open-with list.

Thanks to broulik for pin-pointing the location in the code that caused
this behaviour first.
FIXED-IN: 5.65

Test Plan:
- Set some web browser as the default in the component chooser kcm
- Open Dolphin and using any .html file set the default app to, say, kwrite
- Try to open a local .html file, notice that it opens in the web browser
  you set
- Apply the patch, then try again, it should be opened with kwrite

Reviewers: #frameworks, dfaure

Reviewed By: dfaure

Subscribers: kde-frameworks-devel

Tags: #frameworks

Differential Revision: https://phabricator.kde.org/D24828

M  +1    -7    src/widgets/krun.cpp

https://commits.kde.org/kio/afb2f80cbbe1d4095e897d88430a3b7295bb1114