diff --git a/src/gui/applicationlauncherjob.h b/src/gui/applicationlauncherjob.h --- a/src/gui/applicationlauncherjob.h +++ b/src/gui/applicationlauncherjob.h @@ -59,6 +59,14 @@ */ explicit ApplicationLauncherJob(const KService::Ptr &service, QObject *parent = nullptr); + /** + * @brief Creates a ApplicationLauncherJob + * @param service the service (application desktop file) to run + * @param serviceAction the service action within the service to run + * @param parent the parent QObject + */ + explicit ApplicationLauncherJob(const KService::Ptr &service, const KServiceAction &serviceAction, QObject *parent = nullptr); + /** * Destructor. * Note that jobs auto-delete themselves after emitting result. diff --git a/src/gui/applicationlauncherjob.cpp b/src/gui/applicationlauncherjob.cpp --- a/src/gui/applicationlauncherjob.cpp +++ b/src/gui/applicationlauncherjob.cpp @@ -35,7 +35,7 @@ q->emitResult(); } } - const KService::Ptr m_service; + KService::Ptr m_service; QList m_urls; KIO::ApplicationLauncherJob::RunFlags m_runFlags; QString m_suggestedFileName; @@ -50,6 +50,14 @@ { } +KIO::ApplicationLauncherJob::ApplicationLauncherJob(const KService::Ptr &service, const KServiceAction &serviceAction, QObject *parent) + : ApplicationLauncherJob(service, parent) +{ + Q_ASSERT(d->m_service); + d->m_service.detach(); + d->m_service->setExec(serviceAction.exec()); +} + KIO::ApplicationLauncherJob::~ApplicationLauncherJob() { // Do *NOT* delete the KProcessRunner instances here.