KonqRun is replaced with
UrlLoader class which has the task to decide how an URL should be opened. How it does this depends on whether the mimetype of the URL is known, on whether the URL corresponds to a local file and whether its scheme is
http(s) or not.
If the mimetype isn't known:
- if the URL is local, the mimetype is immediately determined using
KDesktopFile::hasLinkTypeare also used to manage archive files and link-type
.desktopfiles. This code has been taken from
KonqMainWindow::openUrland moved here
- if the URL has
http(s)scheme, it's treated as if its mimetype were
text/html, so that it'll be opened in
- in all other cases,
KIO::OpenUrlJobis used to determine the mimetype.
Once the mimetype has been determined,
KonqFMSettings::shouldEmbed is used together with the arguments passed to the constructor, to determine if the URL should be embedded or not. In both cases, the user is asked whether to open/embed or save, except for html and xhtml files (currently, these mimetypes are hardcoded: a better way to handle this case should be found). In case the URL should be opened,
KIO::ApplicationLauncerJob is used to do so. If the URL should be executed, this is done using
KIO::OpenUrlJob. If the URL should be embedded,
KMainWindow::openView is used. When everything is done, the
finished signal is emitted.
UrlLoader does nothing on creation. It needs to be started using
UrlLoader::start. This determines the mimetype and whether to embed, open or save the URL but only if it can do it without using
KIO::OpenUrlJob. At this point, if the mimetype is known, it's able to tell
KonqMainWindow whether the file should be embedded in the current view, in another tab or in the view given as argument. This allows
KonqMainWindow to create a new tab, if needed, and to pass
UrlLoader the correct view to use. If the mimetype is still unknown, a new tab is used. At this point,
UrlLoader::goOn which executes the job to determine the mimetype, if needed, and embeds, opens or saves the URL.
Another change has been made in
WebEnginePage::acceptNavigationRequest. When asked to load a local URL, it'll check, using
UrlLoader which part is supposed to handle that mimetype: if it's another part, it won't load it and ask Konqueror to do so. This removes the need to use a special property to tell
acceptNavigationRequest had been called in response to the application asking to open the URL or by itself because the user clicked on a link. This is needed, for example, to avoid that the
Home link in the introduction page is opened in
WebEnginePart while permitting to use it to open local html files.
All of this needs a lot of polishing (there are some
qDebug which should be removed, some class and function names could be improved, ...) but before doing so, I'd like an opinion about it. One thing in particular I'd like to know is whether it's possible to create a
KService from a
UrlLoader, I tried using
KParts::PartLoader::partsForMimeType instead of
KMimeTypeTrader::preferredService, as advised in the documentation. However, I couldn't find out how to create a
KService from the returned
KPluginMetaData. I thought that using
KPluginMetaData::pluginId was the correct way, but it only worked with some parts (WebEngine and Dolphin) but not other (Ark and Okular).