Commit 7a8526b0 authored by Stefano Crocco's avatar Stefano Crocco
Browse files

Move the comparison inside KonqBrowserInterface

parent 6f4e071d
......@@ -22,13 +22,7 @@ void KonqBrowserInterface::toggleCompleteFullScreen(bool on)
// void KonqBrowserInterface::openUrl(const QUrl &url, const QString& mimetype, const QString &suggestedFileName)
// {
// KParts::ReadOnlyPart *part = m_mainWindow->m_currentView ? m_mainWindow->m_currentView->part() : nullptr;
// m_mainWindow->m_urlLoader->openUrl(part, url, mimetype, suggestedFileName);
// }
QString KonqBrowserInterface::partForLocalFile(const QString& path)
bool KonqBrowserInterface::isCorrectPartForLocalFile(KParts::ReadOnlyPart *part, const QString &path)
return UrlLoader::partForLocalFile(path);
return part->metaData().pluginId() == UrlLoader::partForLocalFile(path);
......@@ -33,8 +33,17 @@ public:
public slots:
void toggleCompleteFullScreen(bool on);
// void openUrl(const QUrl &url, const QString &mimetype, const QString &suggestedFileName=QString());
QString partForLocalFile(const QString &path);
* @brief Whether the given part is the correct one to use to open a local file
* This use @c KPluginMetadata::pluginId() to compare parts.
* @param part the part to test
* @param path the file path
* @return @e true if @p part is the correct part to use and @e false otherwise
bool isCorrectPartForLocalFile(KParts::ReadOnlyPart *part, const QString &path);
KonqMainWindow *m_mainWindow;
......@@ -134,6 +134,13 @@ public:
static bool isExecutable(const QString &mimeType);
QString suggestedFileName() const {return m_request.suggestedFileName;}
* @brief The @c ID of the part to use to open a local file
* @param path the file path
* @return the plugin id for the preferred part for @p file (as returned by @c KPluginMetaData::pluginId() or
* an empty string if no part could be found
static QString partForLocalFile(const QString &path);
......@@ -216,14 +216,12 @@ bool WebEnginePage::shouldOpenLocalUrl(const QUrl& url) const
KParts::BrowserInterface *bi = m_part->browserExtension()->browserInterface();
if (bi) {
QString partToUse;
bool success = success = QMetaObject::invokeMethod(bi, "partForLocalFile", Q_RETURN_ARG(QString, partToUse), Q_ARG(QString, url.path()));
if (success) {
return partToUse == m_part->metaData().pluginId();
return false;
bool useThisPart = false;
//We don't check whether bi is valid, as invokeMethod will fail if it's nullptr
//If invokeMethod fails, useThisPart will keep its default value (false) which is what we need to return, so there's no
//need to check the return value of invokeMethod
QMetaObject::invokeMethod(bi, "isCorrectPartForLocalFile", Q_RETURN_ARG(bool, useThisPart), Q_ARG(KParts::ReadOnlyPart*, part()), Q_ARG(QString, url.path()));
return useThisPart;
bool WebEnginePage::acceptNavigationRequest(const QUrl& url, NavigationType type, bool isMainFrame)
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