Commit 121d2ef5 authored by Stefano Crocco's avatar Stefano Crocco Committed by David Faure
Browse files

Use browserExtension instead of relying on mimeTypes

parent 4f96b58e
......@@ -25,6 +25,7 @@
#include <KProtocolManager>
#include <KApplicationTrader>
#include <KJobWidgets>
#include <KParts/PartLoader>
#include <KService>
#include <KMimeTypeTrader>
......@@ -311,12 +312,16 @@ void KonqRun::init()
bool KonqRun::usingWebEngine() const
if (m_pView) {
return m_pView->part()->componentName() == "webenginepart";
//We need to find out if the user configured Konqueror to use WebEnginePart by default or not.
//If the current part can display html files, it could be a WebEnginePart, so we can check it.
//If the current part can't display html files, it will never be a webengine part, so it doesn't
//tell anything about user configuration. In this case, always check the preferred part.
KParts::ReadOnlyPart *part = m_pView ? m_pView->part() : nullptr;
if (m_pView->isWebBrowsingPart()) {
return part->componentName() == "webenginepart";
} else {
KService::Ptr service = KMimeTypeTrader::self()->preferredService("text/html", "KParts/ReadOnlyPart");
return service->desktopEntryName() == "webenginepart";
QVector<KPluginMetaData> parts = KParts::PartLoader::partsForMimeType("text/html");
return !parts.isEmpty() && == "WebEngine";
......@@ -1216,6 +1216,16 @@ bool KonqView::supportsMimeType(const QString &mimeType) const
return false;
bool KonqView::isWebBrowsingPart() const
if (!m_pPart) {
return false;
const QString partName = m_pPart->componentName();
return partName == QLatin1String("webenginepart") || partName == QLatin1String("khtml") || partName == QLatin1String("kwebkitpart");
void HistoryEntry::saveConfig(KConfigGroup &config, const QString &prefix, const KonqFrameBase::Options &options)
if (options & KonqFrameBase::SaveUrls) {
......@@ -339,6 +339,18 @@ public:
bool supportsMimeType(const QString &mimeType) const;
* Whether the view in this part is suitable for web browsing.
* @return @b true if the part is suitable for browsing and @b false otherwise
* @warning Unfortunately, as far as I know, there's no way to detect whether a part is
* suitable for browsing. This function works by hardcoding the component names of such
* parts (currently only khtml, kwebkitpart and webenginepart). If other browsing parts
* will be added, the list should be changed or another way must be found.
bool isWebBrowsingPart() const;
// True if showing a directory
bool showsDirectory() const;
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment