Commit 9ec6d94a authored by Rahman Duran's avatar Rahman Duran
Browse files

Implemented new TerminalInterfaceV2 functions.

svn path=/trunk/KDE/kdebase/apps/konsole/; revision=946379
parent dd9df43b
......@@ -187,6 +187,36 @@ void Part::sendInput( const QString& text )
activeSession()->emulation()->sendText(text);
}
int Part::terminalProcessId()
{
Q_ASSERT( activeSession() );
return activeSession()->processId();
}
int Part::foregroundProcessId()
{
Q_ASSERT( activeSession() );
if (activeSession()->isForegroundProcessActive()) {
return activeSession()->foregroundProcessId();
} else {
return -1;
}
}
QString Part::foregroundProcessName()
{
Q_ASSERT( activeSession() );
if (activeSession()->isForegroundProcessActive()) {
return activeSession()->foregroundProcessName();
} else {
return "";
}
}
Session* Part::createSession(const Profile::Ptr profile)
{
Session* session = SessionManager::instance()->createSession(profile);
......
......@@ -23,7 +23,7 @@
// KDE
#include <KParts/Factory>
#include <KParts/Part>
#include <kde_terminal_interface.h>
#include <kde_terminal_interface_v2.h>
// Konsole
#include "Profile.h"
......@@ -56,10 +56,10 @@ protected:
* A re-usable terminal emulator component using the KParts framework which can
* be used to embed terminal emulators into other applications.
*/
class Part : public KParts::ReadOnlyPart , public TerminalInterface
class Part : public KParts::ReadOnlyPart , public TerminalInterfaceV2
{
Q_OBJECT
Q_INTERFACES(TerminalInterface)
Q_INTERFACES(TerminalInterfaceV2)
public:
/** Constructs a new Konsole part with the specified parent. */
explicit Part(QWidget* parentWidget , QObject* parent = 0);
......@@ -73,6 +73,15 @@ public:
/** Reimplemented from TerminalInterface. */
virtual void sendInput( const QString& text );
/** Reimplemented from TerminalInterfaceV2. */
virtual int terminalProcessId();
/** Reimplemented from TerminalInterfaceV2. */
virtual int foregroundProcessId();
/** Reimplemented from TerminalInterfaceV2. */
virtual QString foregroundProcessName();
public slots:
/**
* Shows the dialog used to manage profiles in Konsole. The dialog
......
......@@ -779,7 +779,7 @@ ProcessInfo* Session::getProcessInfo()
{
ProcessInfo* process;
if (isChildActive())
if (isForegroundProcessActive())
process = _foregroundProcessInfo;
else
{
......@@ -852,7 +852,7 @@ KUrl Session::getUrl()
bool ok = false;
// check if foreground process is bookmark-able
if (isChildActive())
if (isForegroundProcessActive())
{
// for remote connections, save the user and host
// bright ideas to get the directory at the other end are welcome :)
......@@ -1119,13 +1119,25 @@ int Session::processId() const
return _shellProcess->pid();
}
bool Session::isChildActive()
int Session::foregroundProcessId()
{
int pid;
bool ok = false;
pid = getProcessInfo()->pid(&ok);
if (!ok)
pid = -1;
return pid;
}
bool Session::isForegroundProcessActive()
{
// foreground process info is always updated after this
return updateForegroundProcessInfo() && (processId() != _foregroundPid);
}
QString Session::childName()
QString Session::foregroundProcessName()
{
QString name;
......
......@@ -329,11 +329,16 @@ public:
*/
int processId() const;
/**
* Returns the foreground PID. Returns -1 if there is none.
*/
int foregroundProcessId();
/** Returns true if the user has started a program in the session. */
bool isChildActive();
bool isForegroundProcessActive();
/** Returns the name of the current foreground process. */
QString childName();
QString foregroundProcessName();
/** Returns the terminal session's window size in lines and columns. */
QSize size();
......
......@@ -567,9 +567,9 @@ void SessionController::saveSession()
}
bool SessionController::confirmClose() const
{
if (_session->isChildActive())
if (_session->isForegroundProcessActive())
{
QString title = _session->childName();
QString title = _session->foregroundProcessName();
// hard coded for now. In future make it possible for the user to specify which programs
// are ignored when considering whether to display a confirmation
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment