Commit 56c1b43b authored by David Faure's avatar David Faure

Port to KIO::ApplicationLauncherJob

parent 2811c052
......@@ -8,7 +8,7 @@ set (RELEASE_SERVICE_VERSION "${RELEASE_SERVICE_VERSION_MAJOR}.${RELEASE_SERVICE
project(ark VERSION ${RELEASE_SERVICE_VERSION})
set(QT_MIN_VERSION 5.10.0)
set(KF5_MIN_VERSION 5.61.0)
set(KF5_MIN_VERSION 5.70.0)
find_package(ECM ${KF5_MIN_VERSION} REQUIRED NO_MODULE)
set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules)
......
......@@ -24,9 +24,11 @@
#include <QMenu>
#include <QMimeDatabase>
#include <KPluginFactory>
#include <KDialogJobUiDelegate>
#include <KIO/ApplicationLauncherJob>
#include <KLocalizedString>
#include <KRun>
#include <KPluginFactory>
#include <KService>
#include <algorithm>
......@@ -99,7 +101,11 @@ QAction *CompressFileItemAction::createAction(const QIcon& icon, const QString&
QAction *action = new QAction(icon, name, parent);
connect(action, &QAction::triggered, this, [exec, urls, parent]() {
KRun::run(exec, urls, parent);
KService::Ptr service(new KService(QStringLiteral("ark"), exec, QString()));
KIO::ApplicationLauncherJob *job = new KIO::ApplicationLauncherJob(service);
job->setUrls(urls);
job->setUiDelegate(new KDialogJobUiDelegate(KJobUiDelegate::AutoHandlingEnabled, parent));
job->start();
});
return action;
......
......@@ -24,9 +24,11 @@
#include <QFileInfo>
#include <QMenu>
#include <KPluginFactory>
#include <KDialogJobUiDelegate>
#include <KIO/ApplicationLauncherJob>
#include <KLocalizedString>
#include <KRun>
#include <KPluginFactory>
#include <KService>
#include "mimetypes.h"
#include "pluginmanager.h"
......@@ -104,7 +106,11 @@ QAction *ExtractFileItemAction::createAction(const QIcon& icon, const QString& n
QAction *action = new QAction(icon, name, parent);
connect(action, &QAction::triggered, this, [exec, urls, parent]() {
KRun::run(exec, urls, parent);
KService::Ptr service(new KService(QStringLiteral("ark"), exec, QString()));
KIO::ApplicationLauncherJob *job = new KIO::ApplicationLauncherJob(service);
job->setUrls(urls);
job->setUiDelegate(new KDialogJobUiDelegate(KJobUiDelegate::AutoHandlingEnabled, parent));
job->start();
});
return action;
......
......@@ -22,12 +22,13 @@
#include "arkviewer.h"
#include "ark_debug.h"
#include <KIO/JobUiDelegate>
#include <KIO/ApplicationLauncherJob>
#include <KLocalizedString>
#include <KMimeTypeTrader>
#include <KMessageBox>
#include <KParts/ReadOnlyPart>
#include <KParts/OpenUrlArguments>
#include <KRun>
#include <KXMLGUIFactory>
#include <QFile>
......@@ -96,9 +97,12 @@ void ArkViewer::view(const QString& fileName)
qCDebug(ARK) << "Using external viewer";
const QList<QUrl> fileUrlList = {QUrl::fromLocalFile(fileName)};
// The last argument (tempFiles) set to true means that the temporary
// file will be removed when the viewer application exits.
KRun::runService(*viewer, fileUrlList, nullptr, true);
KIO::ApplicationLauncherJob *job = new KIO::ApplicationLauncherJob(viewer);
job->setUrls(fileUrlList);
job->setUiDelegate(new KIO::JobUiDelegate(KJobUiDelegate::AutoHandlingEnabled, nullptr));
// The temporary file will be removed when the viewer application exits.
job->setRunFlags(KIO::ApplicationLauncherJob::DeleteTemporaryFiles);
job->start();
return;
}
......
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