Go to:
Gentoo Home
Documentation
Forums
Lists
Bugs
Planet
Store
Wiki
Get Gentoo!
Gentoo's Bugzilla – Attachment 741546 Details for
Bug 815022
kde-apps/konqueror-21.08.1 with kde-frameworks/kio-5.86.0: Opens every url in separate window (and the default browser)
Home
|
New
–
[Ex]
|
Browse
|
Search
|
Privacy Policy
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Upstream KIO compatibility patch
kio.patch (text/plain), 7.74 KB, created by
Zoltan Puskas
on 2021-09-26 17:38:07 UTC
(
hide
)
Description:
Upstream KIO compatibility patch
Filename:
MIME Type:
Creator:
Zoltan Puskas
Created:
2021-09-26 17:38:07 UTC
Size:
7.74 KB
patch
obsolete
>diff --git a/src/konqrun.cpp b/src/konqrun.cpp >index 1a88e291574801db878706941a6af9742fced703..b45f5176735afa1875c9e4ce63e724e802ee077d 100644 >--- a/src/konqrun.cpp >+++ b/src/konqrun.cpp >@@ -27,8 +27,17 @@ > #include <kio/job.h> > #include <QMimeDatabase> > #include <QMimeType> >+#include <QHostInfo> >+#include <QFileInfo> >+ > #include <KIO/ApplicationLauncherJob> > #include <KIO/JobUiDelegate> >+#include <KUrlAuthorized> >+#include <KIO/DesktopExecParser> >+#include <KProtocolInfo> >+#include <KProtocolManager> >+#include <KApplicationTrader> >+#include <KJobWidgets> > > #include <KService> > #include <KMimeTypeTrader> >@@ -48,7 +57,7 @@ KonqRun::KonqRun(KonqMainWindow *mainWindow, KonqView *_childView, > // Don't use inline errors on reloading due to auto-refresh sites, but use them in all other cases > // (no reload or user-requested reload) > !req.args.reload() || req.userRequestedReload), >- m_pMainWindow(mainWindow), m_pView(_childView), m_bFoundMimeType(false), m_req(req) >+ m_pMainWindow(mainWindow), m_pView(_childView), m_bFoundMimeType(false), m_req(req), m_inlineErrors(!req.args.reload() || req.userRequestedReload) > { > setEnableExternalBrowser(false); > //qCDebug(KONQUEROR_LOG) << "KonqRun::KonqRun() " << this; >@@ -189,15 +198,121 @@ void KonqRun::handleError(KJob *job) > KParts::BrowserRun::handleError(job); > } > >+//Code copied from browserrun.cpp >+void KonqRun::switchToErrorUrl(KIO::Error error, QString stringUrl) >+{ >+ KRun::setUrl(makeErrorUrl(error, stringUrl, url())); >+ setJob(nullptr); >+ mimeTypeDetermined(QStringLiteral("text/html")); >+} >+ >+//Most of the code in this function has been copied copied from krun.cpp and browserrun.cpp > void KonqRun::init() > { >- KParts::BrowserRun::init(); >- // Maybe init went to the "let's try stat'ing" part. Then connect to info messages. >- // (in case it goes to scanFile, this will be done below) >- KIO::StatJob *job = dynamic_cast<KIO::StatJob *>(KRun::job()); >+ if (!url().isValid() || url().scheme().isEmpty()) { >+ if (m_inlineErrors && !url().isValid()) { >+ switchToErrorUrl(KIO::ERR_MALFORMED_URL, url().toString()); >+ return; >+ } >+ const QString error = !url().isValid() ? url().errorString() : url().toString(); >+ handleInitError(KIO::ERR_MALFORMED_URL, i18n("Malformed URL\n%1", error)); >+ qCWarning(KONQUEROR_LOG) << "Malformed URL:" << error; >+ setError(true); >+ setFinished(true); >+ return; >+ } >+ >+ if (!KUrlAuthorized::authorizeUrlAction(QStringLiteral("open"), QUrl(), url())) { >+ QString msg = KIO::buildErrorString(KIO::ERR_ACCESS_DENIED, url().toDisplayString()); >+ handleInitError(KIO::ERR_ACCESS_DENIED, msg); >+ setError(true); >+ setFinished(true); >+ return; >+ } >+ >+ if (url().scheme().startsWith(QLatin1String("http")) && usingWebEngine()) { >+ mimeTypeDetermined(QStringLiteral("text/html")); >+ } else if (url().isLocalFile() >+ && (url().host().isEmpty() || (url().host() == QLatin1String("localhost")) >+ || (url().host().compare(QHostInfo::localHostName(), Qt::CaseInsensitive) == 0))) { >+ const QString localPath = url().toLocalFile(); >+ if (!QFile::exists(localPath)) { >+ if (m_inlineErrors) { >+ switchToErrorUrl(KIO::ERR_DOES_NOT_EXIST, localPath); >+ } else { >+ handleInitError(KIO::ERR_DOES_NOT_EXIST, >+ i18n("<qt>Unable to run the command specified. " >+ "The file or folder <b>%1</b> does not exist.</qt>", >+ localPath.toHtmlEscaped())); >+ setError(true); >+ setFinished(true); >+ } >+ return; >+ } >+ >+ QMimeDatabase db; >+ QMimeType mime = db.mimeTypeForUrl(url()); >+ if (mime.isDefault() && !QFileInfo(localPath).isReadable()) { >+ // Unknown MIME type because the file is unreadable, no point in showing an open-with dialog (#261002) >+ const QString msg = KIO::buildErrorString(KIO::ERR_ACCESS_DENIED, localPath); >+ handleInitError(KIO::ERR_ACCESS_DENIED, msg); >+ setError(true); >+ setFinished(true); >+ return; >+ } else { >+ mimeTypeDetermined(mime.name()); >+ return; >+ } >+ } else if (KIO::DesktopExecParser::hasSchemeHandler(url()) && !KProtocolInfo::isKnownProtocol(url())) { >+ // looks for an application associated with x-scheme-handler/<protocol> >+ KService::Ptr service = KApplicationTrader::preferredService(QLatin1String("x-scheme-handler/") + url().scheme()); >+ if (service) { >+ // if there's one... >+ if (runApplication(*service, QList<QUrl>() << url(), window(), RunFlags{}, QString(), QByteArray())) { >+ setFinished(true); >+ return; >+ } >+ } else { >+ // fallback, look for associated helper protocol >+ Q_ASSERT(KProtocolInfo::isHelperProtocol(url().scheme())); >+ const auto exec = KProtocolInfo::exec(url().scheme()); >+ if (exec.isEmpty()) { >+ // use default MIME type opener for file >+ mimeTypeDetermined(KProtocolManager::defaultMimetype(url())); >+ return; >+ } else { >+ if (run(exec, QList<QUrl>() << url(), window(), QString(), QString(), QByteArray())) { >+ setFinished(true); >+ return; >+ } >+ } >+ } >+ } >+ >+ // Let's see whether it is a directory >+ >+ if (!KProtocolManager::supportsListing(url())) { >+ // No support for listing => it can't be a directory (example: http) >+ >+ if (!KProtocolManager::supportsReading(url())) { >+ // No support for reading files either => we can't do anything (example: mailto URL, with no associated app) >+ handleInitError(KIO::ERR_UNSUPPORTED_ACTION, i18n("Could not find any application or handler for %1", url().toDisplayString())); >+ setError(true); >+ setFinished(true); >+ return; >+ } >+ scanFile(); >+ return; >+ } >+ >+ // It may be a directory or a file, let's stat >+ KIO::JobFlags flags = progressInfo() ? KIO::DefaultFlags : KIO::HideProgressInfo; >+ KIO::StatJob *job = KIO::statDetails(url(), KIO::StatJob::SourceSide, KIO::StatBasic, flags); >+ KJobWidgets::setWindow(job, window()); >+ connect(job, &KJob::result, this, &KonqRun::slotStatResult); >+ setJob(job); > if (job && !job->error() && m_pView) { >- connect(job, SIGNAL(infoMessage(KJob*,QString,QString)), >- m_pView, SLOT(slotInfoMessage(KJob*,QString))); >+ connect(job, &KIO::StatJob::infoMessage, m_pView, &KonqView::slotInfoMessage); > } > } > >diff --git a/src/konqrun.h b/src/konqrun.h >index 591b91d19f93c109a8ce9385f1bd0b068e40b284..5be9614b726dfb93aff5a7124f81ac82c29012b8 100644 >--- a/src/konqrun.h >+++ b/src/konqrun.h >@@ -26,6 +26,8 @@ > #include "konqopenurlrequest.h" > #include <QUrl> > >+#include <KIO/Global> >+ > class KonqMainWindow; > class KonqView; > >@@ -69,6 +71,14 @@ protected: > void init() override; > void scanFile() override; > >+ /** >+ * Displays an error page appropriate to the given error code >+ * >+ * @param error the error code >+ * @param stringUrl the string representation of the URL which caused the error >+ */ >+ void switchToErrorUrl(KIO::Error error, QString stringUrl); >+ > protected Q_SLOTS: > void slotRedirection(KIO::Job *, const QUrl &); > >@@ -81,6 +91,7 @@ private: > bool m_bFoundMimeType; > KonqOpenURLRequest m_req; > QUrl m_mailto; >+ bool m_inlineErrors; > }; > > #endif // KONQRUN_H
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 815022
:
741546
|
742188