KTerminalLauncherJob Class

Header: #include <KTerminalLauncherJob>
CMake: find_package(KF6 REQUIRED COMPONENTS KIO)
target_link_libraries(mytarget PRIVATE KIOGui)
Inherits: KJob

Public Functions

KTerminalLauncherJob(const QString &command, QObject *parent = nullptr)
virtual ~KTerminalLauncherJob() override
void setProcessEnvironment(const QProcessEnvironment &environment)
void setStartupId(const QByteArray &startupId)
void setWorkingDirectory(const QString &workingDirectory)

Reimplemented Public Functions

virtual void start() override

Detailed Description

@class KTerminalLauncherJob kterminallauncherjob.h <KTerminalLauncherJob>

@brief KTerminalLauncherJob starts a terminal application, either for the user to use interactively, or to execute a command.

It creates a startup notification and finishes it on success or on error (for the taskbar). It also emits an error message if necessary (e.g. "program not found").

The job finishes when the application is successfully started. For error handling, either connect to the result() signal, or for a simple messagebox on error, you can do @code job->setUiDelegate(new KDialogJobUiDelegate(KJobUiDelegate::AutoHandlingEnabled, this)); @endcode

@since 5.83

Member Function Documentation

[explicit] KTerminalLauncherJob::KTerminalLauncherJob(const QString &command, QObject *parent = nullptr)

Creates a KTerminalLauncherJob. @param command the command to execute in a terminal, can be empty. @param parent the parent QObject

[override virtual noexcept] KTerminalLauncherJob::~KTerminalLauncherJob()

Destructor

Note that jobs auto-delete themselves after emitting result

void KTerminalLauncherJob::setProcessEnvironment(const QProcessEnvironment &environment)

Can be used to pass environment variables to the child process. @param environment set of environment variables to pass to the child process @see QProcessEnvironment

void KTerminalLauncherJob::setStartupId(const QByteArray &startupId)

Sets the platform-specific startup id of the command launch. @param startupId startup id, if any (otherwise ""). For X11, this would be the id for the Startup Notification protocol. For Wayland, this would be the token for the XDG Activation protocol.

void KTerminalLauncherJob::setWorkingDirectory(const QString &workingDirectory)

Sets the working directory from which to run the command. @param workingDirectory path of a local directory

[override virtual] void KTerminalLauncherJob::start()

Reimplements: KJob::start().

Starts the job. You must call this, after having called all the necessary setters.