summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJekyll Wu <adaptee@gmail.com>2012-03-23 14:16:21 (GMT)
committerJekyll Wu <adaptee@gmail.com>2012-03-23 14:55:15 (GMT)
commit675dbcb2fe777b22044510579321148989d29cfb (patch)
treef6c46e722aac5243ac6c526e8dec4f6a617bc191
parenta7f71fe903df30b9aaa27f02df35d0eef92fb597 (diff)
Emit signal currentDirectoryChanged(QString) after current directory changes
Note: the signal is not emitted immediately after the current directory changes. There is noticable delay (usually below 1 second) at the moment. FEATURE: 156919 REVIEW: 104372 FIXED-IN:4.9.0
-rw-r--r--src/Part.cpp4
-rw-r--r--src/Part.h5
-rw-r--r--src/Session.cpp9
-rw-r--r--src/Session.h7
-rw-r--r--src/SessionController.cpp3
-rw-r--r--src/SessionController.h6
6 files changed, 33 insertions, 1 deletions
diff --git a/src/Part.cpp b/src/Part.cpp
index 75b1b1b..3051ab7 100644
--- a/src/Part.cpp
+++ b/src/Part.cpp
@@ -220,6 +220,8 @@ void Part::activeViewChanged(SessionController* controller)
removeChildClient(_pluggedController);
disconnect(_pluggedController, SIGNAL(titleChanged(ViewProperties*)), this,
SLOT(activeViewTitleChanged(ViewProperties*)));
+ disconnect(_pluggedController,SIGNAL(currentDirectoryChanged(QString)),this,
+ SIGNAL(currentDirectoryChanged(QString)));
}
// insert new controller
@@ -227,6 +229,8 @@ void Part::activeViewChanged(SessionController* controller)
connect(controller, SIGNAL(titleChanged(ViewProperties*)), this,
SLOT(activeViewTitleChanged(ViewProperties*)));
activeViewTitleChanged(controller);
+ connect(controller,SIGNAL(currentDirectoryChanged(QString)),this,
+ SIGNAL(currentDirectoryChanged(QString)));
const char* displaySignal = SIGNAL(overrideShortcutCheck(QKeyEvent*,bool&));
const char* partSlot = SLOT(overrideTerminalShortcut(QKeyEvent*,bool&));
diff --git a/src/Part.h b/src/Part.h
index 39b176d..bb9a5c5 100644
--- a/src/Part.h
+++ b/src/Part.h
@@ -167,6 +167,11 @@ signals:
*/
void activityDetected();
+ /**
+ * Emitted when the current working directory of the active session has changed.
+ */
+ void currentDirectoryChanged(const QString& dir);
+
protected:
/** Reimplemented from KParts::PartBase. */
virtual bool openFile();
diff --git a/src/Session.cpp b/src/Session.cpp
index 5ab5334..2913b87 100644
--- a/src/Session.cpp
+++ b/src/Session.cpp
@@ -279,7 +279,14 @@ QString Session::currentWorkingDirectory()
ProcessInfo* Session::updateWorkingDirectory()
{
ProcessInfo* process = getProcessInfo();
- _currentWorkingDir = process->validCurrentDir();
+
+ const QString currentDir = process->validCurrentDir();
+ if ( currentDir != _currentWorkingDir )
+ {
+ _currentWorkingDir = currentDir;
+ emit currentDirectoryChanged(_currentWorkingDir);
+ }
+
return process;
}
diff --git a/src/Session.h b/src/Session.h
index abf9529..fde006e 100644
--- a/src/Session.h
+++ b/src/Session.h
@@ -567,6 +567,13 @@ signals:
*/
void stateChanged(int state);
+ /**
+ * Emitted when the current working directory of this session changes.
+ *
+ * @param dir The new current woking directory of the session.
+ */
+ void currentDirectoryChanged(const QString& dir);
+
/** Emitted when a bell event occurs in the session. */
void bellRequest(const QString& message);
diff --git a/src/SessionController.cpp b/src/SessionController.cpp
index 0ee550d..2a5d920 100644
--- a/src/SessionController.cpp
+++ b/src/SessionController.cpp
@@ -143,6 +143,9 @@ SessionController::SessionController(Session* session , TerminalDisplay* view, Q
// listen to title and icon changes
connect(_session, SIGNAL(titleChanged()), this, SLOT(sessionTitleChanged()));
+ connect( _session , SIGNAL(currentDirectoryChanged(QString)) ,
+ this , SIGNAL(currentDirectoryChanged(QString)) );
+
// listen for color changes
connect(_session, SIGNAL(changeBackgroundColorRequest(QColor)), _view, SLOT(setBackgroundColor(QColor)));
connect(_session, SIGNAL(changeForegroundColorRequest(QColor)), _view, SLOT(setForegroundColor(QColor)));
diff --git a/src/SessionController.h b/src/SessionController.h
index 3c749b0..d2d0765 100644
--- a/src/SessionController.h
+++ b/src/SessionController.h
@@ -172,6 +172,12 @@ signals:
void rawTitleChanged();
+ /**
+ * Emitted when the curreent working directory of the session associated with
+ * the controller is changed.
+ */
+ void currentDirectoryChanged(const QString& dir);
+
public slots:
/**
* Issues a command to the session to navigate to the specified URL.