diff options
| author | Miklos Marton <[email protected]> | 2017-10-12 23:17:51 +0200 |
|---|---|---|
| committer | Elvis Angelaccio <[email protected]> | 2017-10-12 23:21:49 +0200 |
| commit | bd47eb2e6d80315115bb3f58987162fcb4911b10 (patch) | |
| tree | d51172264a047f02e235cc2e78371330336e4792 /src/panels/terminal | |
| parent | 1ad3b7775ec7388352d3a02c704062baa5d0aca3 (diff) | |
Don't block unmounting when terminal panel's cwd is the mountpoint
When unmounting a removable media Dolphin checks if there are
some files open on the device before performing the unmount.
If the terminal window in dolphin is open and the to be unmounted path is open,
the unmount process will be blocked.
This patch sets the terminal window current path to the home directory upon unmount request
if the terminal directory is set to the mount path.
The unmount request could came from two sources:
The user could hit right click on the media in the dolphin's places panel and hit unmount.
The user could request an unmount from the indicator applet
This patch was originally written by Arjun AK for the kdelibs4 version
of Dolphin: https://git.reviewboard.kde.org/r/121613/
BUG: 158264
FIXED-IN: 17.11.80
Differential Revision: https://phabricator.kde.org/D7847
Diffstat (limited to 'src/panels/terminal')
| -rw-r--r-- | src/panels/terminal/terminalpanel.cpp | 18 | ||||
| -rw-r--r-- | src/panels/terminal/terminalpanel.h | 14 |
2 files changed, 29 insertions, 3 deletions
diff --git a/src/panels/terminal/terminalpanel.cpp b/src/panels/terminal/terminalpanel.cpp index e952f23a0..b7d3605aa 100644 --- a/src/panels/terminal/terminalpanel.cpp +++ b/src/panels/terminal/terminalpanel.cpp @@ -54,6 +54,19 @@ TerminalPanel::~TerminalPanel() { } +void TerminalPanel::goHome() +{ + sendCdToTerminal(QDir::homePath(), HistoryPolicy::SkipHistory); +} + +QString TerminalPanel::currentWorkingDirectory() +{ + if (m_terminal) { + return m_terminal->currentWorkingDirectory(); + } + return QString(); +} + void TerminalPanel::terminalExited() { m_terminal = 0; @@ -144,7 +157,7 @@ void TerminalPanel::changeDir(const QUrl& url) } } -void TerminalPanel::sendCdToTerminal(const QString& dir) +void TerminalPanel::sendCdToTerminal(const QString& dir, HistoryPolicy addToHistory) { if (dir == m_konsolePartCurrentDirectory) { m_clearTerminal = false; @@ -168,7 +181,8 @@ void TerminalPanel::sendCdToTerminal(const QString& dir) // the directory change, because this directory change is not caused by a "cd" command that the // user entered in the panel. Therefore, we have to remember 'dir'. Note that it could also be // a symbolic link -> remember the 'canonical' path. - m_sendCdToTerminalHistory.enqueue(QDir(dir).canonicalPath()); + if (addToHistory == HistoryPolicy::AddToHistory) + m_sendCdToTerminalHistory.enqueue(QDir(dir).canonicalPath()); if (m_clearTerminal) { m_terminal->sendInput(QStringLiteral(" clear\n")); diff --git a/src/panels/terminal/terminalpanel.h b/src/panels/terminal/terminalpanel.h index 75e198e1a..3de3b6d30 100644 --- a/src/panels/terminal/terminalpanel.h +++ b/src/panels/terminal/terminalpanel.h @@ -48,6 +48,13 @@ public: TerminalPanel(QWidget* parent = 0); virtual ~TerminalPanel(); + /** + * @brief This function is used to set the terminal panels's cwd to + * home when an unmounting request is receieved. + */ + void goHome(); + QString currentWorkingDirectory(); + public slots: void terminalExited(); void dockVisibilityChanged(); @@ -70,8 +77,13 @@ private slots: void slotKonsolePartCurrentDirectoryChanged(const QString& dir); private: + enum class HistoryPolicy { + AddToHistory, + SkipHistory + }; + void changeDir(const QUrl& url); - void sendCdToTerminal(const QString& path); + void sendCdToTerminal(const QString& path, HistoryPolicy addToHistory = HistoryPolicy::AddToHistory); private: bool m_clearTerminal; |
