diff --git a/src/gui/commandlauncherjob.h b/src/gui/commandlauncherjob.h --- a/src/gui/commandlauncherjob.h +++ b/src/gui/commandlauncherjob.h @@ -63,6 +63,16 @@ */ explicit CommandLauncherJob(const QString &command, QObject *parent = nullptr); + /** + * @brief Creates a CommandLauncherJob + * @param executable the name of the executable + * @param args the commandline arguments to pass to the executable + * @param parent the parent QObject + * + * Please consider also calling setExecutable and setIcon for better startup notification. + */ + explicit CommandLauncherJob(const QString &executable, const QStringList &args, QObject *parent = nullptr); + /** * Destructor * Note that jobs auto-delete themselves after emitting result diff --git a/src/gui/commandlauncherjob.cpp b/src/gui/commandlauncherjob.cpp --- a/src/gui/commandlauncherjob.cpp +++ b/src/gui/commandlauncherjob.cpp @@ -27,9 +27,6 @@ class KIO::CommandLauncherJobPrivate { public: - explicit CommandLauncherJobPrivate(const QString &command) - : m_command(command) {} - QString m_command; QString m_desktopName; QString m_executable; @@ -41,8 +38,16 @@ }; KIO::CommandLauncherJob::CommandLauncherJob(const QString &command, QObject *parent) - : KJob(parent), d(new CommandLauncherJobPrivate(command)) + : KJob(parent), d(new CommandLauncherJobPrivate()) { + d->m_command = command; +} + +KIO::CommandLauncherJob::CommandLauncherJob(const QString &executable, const QStringList &args, QObject *parent) + : KJob(parent), d(new CommandLauncherJobPrivate()) +{ + d->m_executable = executable; + d->m_command = executable + QLatin1Char(' ') + KShell::joinArgs(args); } KIO::CommandLauncherJob::~CommandLauncherJob()