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 ) ...@@ -187,6 +187,36 @@ void Part::sendInput( const QString& text )
activeSession()->emulation()->sendText(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* Part::createSession(const Profile::Ptr profile)
{ {
Session* session = SessionManager::instance()->createSession(profile); Session* session = SessionManager::instance()->createSession(profile);
......
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
// KDE // KDE
#include <KParts/Factory> #include <KParts/Factory>
#include <KParts/Part> #include <KParts/Part>
#include <kde_terminal_interface.h> #include <kde_terminal_interface_v2.h>
// Konsole // Konsole
#include "Profile.h" #include "Profile.h"
...@@ -56,10 +56,10 @@ protected: ...@@ -56,10 +56,10 @@ protected:
* A re-usable terminal emulator component using the KParts framework which can * A re-usable terminal emulator component using the KParts framework which can
* be used to embed terminal emulators into other applications. * 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_OBJECT
Q_INTERFACES(TerminalInterface) Q_INTERFACES(TerminalInterfaceV2)
public: public:
/** Constructs a new Konsole part with the specified parent. */ /** Constructs a new Konsole part with the specified parent. */
explicit Part(QWidget* parentWidget , QObject* parent = 0); explicit Part(QWidget* parentWidget , QObject* parent = 0);
...@@ -73,6 +73,15 @@ public: ...@@ -73,6 +73,15 @@ public:
/** Reimplemented from TerminalInterface. */ /** Reimplemented from TerminalInterface. */
virtual void sendInput( const QString& text ); 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: public slots:
/** /**
* Shows the dialog used to manage profiles in Konsole. The dialog * Shows the dialog used to manage profiles in Konsole. The dialog
......
...@@ -779,7 +779,7 @@ ProcessInfo* Session::getProcessInfo() ...@@ -779,7 +779,7 @@ ProcessInfo* Session::getProcessInfo()
{ {
ProcessInfo* process; ProcessInfo* process;
if (isChildActive()) if (isForegroundProcessActive())
process = _foregroundProcessInfo; process = _foregroundProcessInfo;
else else
{ {
...@@ -852,7 +852,7 @@ KUrl Session::getUrl() ...@@ -852,7 +852,7 @@ KUrl Session::getUrl()
bool ok = false; bool ok = false;
// check if foreground process is bookmark-able // check if foreground process is bookmark-able
if (isChildActive()) if (isForegroundProcessActive())
{ {
// for remote connections, save the user and host // for remote connections, save the user and host
// bright ideas to get the directory at the other end are welcome :) // bright ideas to get the directory at the other end are welcome :)
...@@ -1119,13 +1119,25 @@ int Session::processId() const ...@@ -1119,13 +1119,25 @@ int Session::processId() const
return _shellProcess->pid(); 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 // foreground process info is always updated after this
return updateForegroundProcessInfo() && (processId() != _foregroundPid); return updateForegroundProcessInfo() && (processId() != _foregroundPid);
} }
QString Session::childName() QString Session::foregroundProcessName()
{ {
QString name; QString name;
......
...@@ -329,11 +329,16 @@ public: ...@@ -329,11 +329,16 @@ public:
*/ */
int processId() const; 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. */ /** Returns true if the user has started a program in the session. */
bool isChildActive(); bool isForegroundProcessActive();
/** Returns the name of the current foreground process. */ /** Returns the name of the current foreground process. */
QString childName(); QString foregroundProcessName();
/** Returns the terminal session's window size in lines and columns. */ /** Returns the terminal session's window size in lines and columns. */
QSize size(); QSize size();
......
...@@ -567,9 +567,9 @@ void SessionController::saveSession() ...@@ -567,9 +567,9 @@ void SessionController::saveSession()
} }
bool SessionController::confirmClose() const 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 // 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 // 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