KTerminalLauncherJob Class
KTerminalLauncherJob starts a terminal application, either for the user to use interactively, or to execute a command. More...
Header: | #include <KTerminalLauncherJob> |
CMake: | find_package(KF6 REQUIRED COMPONENTS KIO) target_link_libraries(mytarget PRIVATE KIOGui) |
Since: | KDE Frameworks 5.83 |
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
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
job->setUiDelegate(new KDialogJobUiDelegate(KJobUiDelegate::AutoHandlingEnabled, this));
Member Function Documentation
[explicit]
KTerminalLauncherJob::KTerminalLauncherJob(const QString &command, QObject *parent = nullptr)
Creates a KTerminalLauncherJob.
command the command to execute in a terminal, can be empty.
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.
environment set of environment variables to pass to the child process
See also QProcessEnvironment.
void KTerminalLauncherJob::setStartupId(const QByteArray &startupId)
Sets the platform-specific startup id of the command launch.
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.
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.