Commit 2fd589f1 authored by Ahmad Samir's avatar Ahmad Samir
Browse files

Port KRun (deprecated) to KIO::OpenUrlJob

parent 2c1ec710
......@@ -20,7 +20,14 @@
#include "EscapeSequenceUrlFilterHotSpot.h"
#include <kio_version.h>
#if KIO_VERSION < QT_VERSION_CHECK(5, 71, 0)
#include <KRun>
#else
#include <KIO/JobUiDelegate>
#include <KIO/OpenUrlJob>
#endif
#include <QApplication>
#include <QMouseEvent>
#include <QDebug>
......@@ -47,5 +54,11 @@ void EscapeSequenceUrlHotSpot::activate(QObject *obj)
{
Q_UNUSED(obj)
#if KIO_VERSION < QT_VERSION_CHECK(5, 71, 0)
new KRun(QUrl(_url), QApplication::activeWindow());
#else
auto *job = new KIO::OpenUrlJob(QUrl(_url));
job->setUiDelegate(new KIO::JobUiDelegate(KJobUiDelegate::AutoHandlingEnabled, QApplication::activeWindow()));
job->start();
#endif
}
......@@ -20,6 +20,14 @@
#include "UrlFilterHotspot.h"
#include <kio_version.h>
#if KIO_VERSION < QT_VERSION_CHECK(5, 71, 0)
#include <KRun>
#else
#include <KIO/JobUiDelegate>
#include <KIO/OpenUrlJob>
#endif
#include <QAction>
#include <QApplication>
#include <QClipboard>
......@@ -27,7 +35,6 @@
#include <QIcon>
#include <KLocalizedString>
#include <KRun>
#include <QMouseEvent>
#include "UrlFilter.h"
......@@ -91,7 +98,13 @@ void UrlFilterHotSpot::activate(QObject *object)
url.prepend(QLatin1String("mailto:"));
}
#if KIO_VERSION < QT_VERSION_CHECK(5, 71, 0)
new KRun(QUrl(url), QApplication::activeWindow());
#else
auto *job = new KIO::OpenUrlJob(QUrl(url));
job->setUiDelegate(new KIO::JobUiDelegate(KJobUiDelegate::AutoHandlingEnabled, QApplication::activeWindow()));
job->start();
#endif
}
}
......
......@@ -40,7 +40,6 @@
// KDE
#include <KLocalizedString>
#include <KNotification>
#include <KRun>
#include <KShell>
#include <KProcess>
#include <KConfigGroup>
......
......@@ -41,7 +41,6 @@
#include <KActionCollection>
#include <KLocalizedString>
#include <KMessageBox>
#include <KRun>
#include <KShell>
#include <KToggleAction>
#include <KSelectAction>
......@@ -56,6 +55,14 @@
#include <KNotification>
#include <KIO/CommandLauncherJob>
#include <kio_version.h>
#if KIO_VERSION < QT_VERSION_CHECK(5, 71, 0)
#include <KRun>
#else
#include <KIO/JobUiDelegate>
#include <KIO/OpenUrlJob>
#endif
// Konsole
#include "CopyInputDialog.h"
#include "Emulation.h"
......@@ -534,8 +541,15 @@ void SessionController::handleWebShortcutAction()
KUriFilterData filterData(action->data().toString());
if (KUriFilter::self()->filterUri(filterData, { QStringLiteral("kurisearchfilter") })) {
const QUrl& url = filterData.uri();
const QUrl url = filterData.uri();
#if KIO_VERSION < QT_VERSION_CHECK(5, 71, 0)
new KRun(url, QApplication::activeWindow());
#else
auto *job = new KIO::OpenUrlJob(url);
job->setUiDelegate(new KIO::JobUiDelegate(KJobUiDelegate::AutoHandlingEnabled, QApplication::activeWindow()));
job->start();
#endif
}
}
......@@ -1058,13 +1072,15 @@ void SessionController::closeSession()
// 2) transform url to get the desired result (ssh -> sftp, etc)
void SessionController::openBrowser()
{
const QUrl currentUrl = url();
const QUrl currentUrl = url().isLocalFile() ? url() : QUrl::fromLocalFile(QDir::homePath());
if (currentUrl.isLocalFile()) {
new KRun(currentUrl, QApplication::activeWindow(), true);
} else {
new KRun(QUrl::fromLocalFile(QDir::homePath()), QApplication::activeWindow(), true);
}
#if KIO_VERSION < QT_VERSION_CHECK(5, 71, 0)
new KRun(currentUrl, QApplication::activeWindow(), true);
#else
auto *job = new KIO::OpenUrlJob(currentUrl);
job->setUiDelegate(new KIO::JobUiDelegate(KJobUiDelegate::AutoHandlingEnabled, QApplication::activeWindow()));
job->start();
#endif
}
void SessionController::copy()
......
Markdown is supported
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