Search for usage in LXR

TerminalInterface Class Referenceabstract

#include <kde_terminal_interface.h>

Inherited by TerminalInterfaceV2.

Public Member Functions

virtual QString currentWorkingDirectory () const =0
virtual int foregroundProcessId ()=0
virtual QString foregroundProcessName ()=0
virtual void sendInput (const QString &text)=0
virtual void showShellInDir (const QString &dir)=0
virtual void startProgram (const QString &program, const QStringList &args)=0
virtual int terminalProcessId ()=0

Detailed Description

TerminalInterface is an interface implemented by KonsolePart to allow developers access to the KonsolePart in ways that are not possible through the normal KPart interface.

Note that besides the functions below here, KonsolePart also has some signals you can connect to. They aren't in this class cause we can't have signals without having a QObject, which TerminalInterface is not.

These are some signals you can connect to: void currentDirectoryChanged(const QString& dir);

See the example code below for how to connect to these.

Use it like this:

// Query the .desktop file to get service information about konsolepart
if (!service) {
QMessageBox::critical(this, tr("Konsole not installed"), tr("Please install the kde konsole and try again!"), QMessageBox::Ok);
return ;
// Create one instance of konsolepart
KParts::ReadOnlyPart *part = service->createInstance<KParts::ReadOnlyPart>(parent, parentWidget, QVariantList());
if (!part) {
// Cast the konsolepart to the TerminalInterface..
TerminalInterface *terminalIface = qobject_cast<TerminalInterface *>(part);
if (!terminalIface) {
// Now use the interface in all sorts of ways, e.g.
// terminalIface->showShellInDir(QDir::home().path());
// Or:
// QStringList list;
// list.append("python");
// terminalIface->startProgram( QString::fromUtf8( "/usr/bin/python" ), list);
// Or connect to one of the signals. Connect to the Part object,
// not to the TerminalInterface, since the latter is not a QObject,
// and as such does not have signals..:
connect(part, &KParts::ReadOnlyPart::currentDirectoryChanged, this, [this](const QString &dirPath) {
// etc.
Dominique Devriese devri[email protected][email protected][email protected]kde.o[email protected]rg

Definition at line 71 of file kde_terminal_interface.h.

Member Function Documentation

◆ currentWorkingDirectory()

virtual QString TerminalInterface::currentWorkingDirectory ( ) const
pure virtual

Returns the current working directory.

◆ foregroundProcessId()

virtual int TerminalInterface::foregroundProcessId ( )
pure virtual

Return foregound PID, If there is no foreground process running, returns -1.

◆ foregroundProcessName()

virtual QString TerminalInterface::foregroundProcessName ( )
pure virtual

Returns sub process name.

If there is no sub process running, returns empty QString

◆ sendInput()

virtual void TerminalInterface::sendInput ( const QString text)
pure virtual

This sends.

textas input to the currently running program..

◆ startProgram()

virtual void TerminalInterface::startProgram ( const QString program,
const QStringList args 
pure virtual

This starts program, with arguments args.

◆ terminalProcessId()

virtual int TerminalInterface::terminalProcessId ( )
pure virtual

Return terminal PID.

If no process is currently running, returns 0.

The documentation for this class was generated from the following file:
Base class for any "viewer" part.
Definition: readonlypart.h:51
static Ptr serviceByDesktopName(const QString &_name)
TerminalInterface is an interface implemented by KonsolePart to allow developers access to the Konsol...
QMessageBox::StandardButton critical(QWidget *parent, const QString &title, const QString &text, QMessageBox::StandardButtons buttons, QMessageBox::StandardButton defaultButton)
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Mon May 8 2023 03:53:51 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.