Commit a2ebeeb6 authored by Kai Uwe Broulik's avatar Kai Uwe Broulik 🍇

Port Konsole and Kate runners and dataengine away from KToolInvocation

Instead use CommandLauncherJob.
Also set desktopFileName for nicer startup feedback

Differential Revision: https://phabricator.kde.org/D28512
parent 02c3233d
......@@ -8,8 +8,9 @@ set(konsoleprofilesengine_SRCS
add_library(plasma_engine_konsoleprofiles MODULE ${konsoleprofilesengine_SRCS})
target_link_libraries(plasma_engine_konsoleprofiles
KF5::Plasma
KF5::Notifications
KF5::KIOGui
KF5::Service
KF5::KIOCore
)
kcoreaddons_desktop_to_json(plasma_engine_konsoleprofiles plasma-dataengine-konsoleprofiles.desktop SERVICE_TYPES plasma-dataengine.desktop)
......
......@@ -19,9 +19,12 @@
#include "konsoleprofilesservice.h"
#include <QMap>
#include <KToolInvocation>
#include <QDebug>
#include <KNotificationJobUiDelegate>
#include <KIO/CommandLauncherJob>
KonsoleProfilesService::KonsoleProfilesService(QObject* parent, const QString& profileName)
: Plasma::Service(parent)
{
......@@ -49,11 +52,23 @@ qDebug() << "SERVICE START...operation: " << operation << " dest: " << destinati
if (operation == QLatin1String("open")) {
// Q_ASSERT(!jobParameters.isEmpty());
QStringList args;
args << QStringLiteral("--profile") << destination();
KToolInvocation::kdeinitExec(QStringLiteral("konsole"), args);
// Would be nice if we could just return this in createJob above
auto *job = new KIO::CommandLauncherJob(QStringLiteral("konsole"), {
QStringLiteral("--profile"), destination()
});
job->setDesktopName(QStringLiteral("org.kde.konsole"));
auto *delegate = new KNotificationJobUiDelegate;
delegate->setAutoErrorHandlingEnabled(true);
job->setUiDelegate(delegate);
connect(job, &KIO::CommandLauncherJob::result, this, [this, job] {
setError(job->error());
setErrorText(job->errorText());
emitResult();
});
setResult(true);
job->start();
}
}
......@@ -2,7 +2,7 @@ add_definitions(-DTRANSLATION_DOMAIN=\"plasma_runner_katesessions\")
set(krunner_katesessions_SRCS katesessions.cpp)
add_library(krunner_katesessions MODULE ${krunner_katesessions_SRCS})
target_link_libraries(krunner_katesessions KF5::KIOCore KF5::I18n KF5::Runner)
target_link_libraries(krunner_katesessions KF5::KIOGui KF5::Notifications KF5::I18n KF5::Runner)
install(TARGETS krunner_katesessions DESTINATION ${KDE_INSTALL_PLUGINDIR})
install(FILES plasma-runner-katesessions.desktop DESTINATION ${KDE_INSTALL_KSERVICES5DIR})
......@@ -28,7 +28,9 @@
#include <KDirWatch>
#include <KLocalizedString>
#include <KToolInvocation>
#include <KNotificationJobUiDelegate>
#include <KIO/CommandLauncherJob>
K_EXPORT_PLASMA_RUNNER(katesessionsrunner, KateSessions)
......@@ -114,8 +116,16 @@ void KateSessions::run(const Plasma::RunnerContext &context, const Plasma::Query
{
Q_UNUSED(context)
KToolInvocation::kdeinitExec(QStringLiteral("kate"), {QStringLiteral("--start"),
match.data().toString(), QStringLiteral("-n")});
auto *job = new KIO::CommandLauncherJob(QStringLiteral("kate"), {
QStringLiteral("--start"), match.data().toString(), QStringLiteral("-n")
});
job->setDesktopName(QStringLiteral("org.kde.kate"));
auto *delegate = new KNotificationJobUiDelegate;
delegate->setAutoErrorHandlingEnabled(true);
job->setUiDelegate(delegate);
job->start();
}
#include "katesessions.moc"
......@@ -7,7 +7,9 @@ set(krunner_konsoleprofiles_SRCS
add_library(krunner_konsoleprofiles MODULE ${krunner_konsoleprofiles_SRCS})
target_link_libraries(krunner_konsoleprofiles
KF5::Runner
KF5::KIOGui
KF5::I18n
KF5::Notifications
)
install(TARGETS krunner_konsoleprofiles DESTINATION ${KDE_INSTALL_PLUGINDIR})
......
......@@ -21,10 +21,11 @@
#include "konsoleprofiles.h"
// KF
#include <KIO/CommandLauncherJob>
#include <KConfig>
#include <KDirWatch>
#include <KToolInvocation>
#include <KLocalizedString>
#include <KConfig>
#include <KNotificationJobUiDelegate>
// Qt
#include <QFileInfo>
#include <QDir>
......@@ -173,11 +174,16 @@ void KonsoleProfiles::run(const Plasma::RunnerContext &context, const Plasma::Qu
return;
}
const QStringList args {
QStringLiteral("--profile"),
profile
};
KToolInvocation::kdeinitExec(QStringLiteral("konsole"), args);
auto *job = new KIO::CommandLauncherJob(QStringLiteral("konsole"), {
QStringLiteral("--profile"), profile
});
job->setDesktopName(QStringLiteral("org.kde.konsole"));
auto *delegate = new KNotificationJobUiDelegate;
delegate->setAutoErrorHandlingEnabled(true);
job->setUiDelegate(delegate);
job->start();
}
......
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