diff --git a/src/widgets/krun.cpp b/src/widgets/krun.cpp --- a/src/widgets/krun.cpp +++ b/src/widgets/krun.cpp @@ -46,6 +46,7 @@ #include #include #include +#include #include #include @@ -83,8 +84,6 @@ #if HAVE_X11 #include -#elif defined(Q_OS_WIN) -#include #endif #include @@ -122,6 +121,14 @@ return KProtocolInfo::exec(protocol); } +static bool checkNeedPortalSupport() +{ + return !QStandardPaths::locate(QStandardPaths::RuntimeLocation, + QLatin1String("flatpak-info")).isEmpty() || + qEnvironmentVariableIsSet("SNAP"); +} + + // --------------------------------------------------------------------------- bool KRun::isExecutableFile(const QUrl &url, const QString &mimetype) @@ -947,6 +954,14 @@ return; } + if (checkNeedPortalSupport()) { + // use the function from QDesktopServices as it handles portals correctly + d->m_bFault = !QDesktopServices::openUrl(d->m_strURL); + d->m_bFinished = true; + d->startTimer(); + return; + } + if (!d->m_externalBrowser.isEmpty() && d->m_strURL.scheme().startsWith(QLatin1String("http"))) { if (d->runExecutable(d->m_externalBrowser)) { return;