┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src/dolphinmainwindow.cpp
diff options
context:
space:
mode:
authorMiklos Marton <[email protected]>2017-10-12 23:17:51 +0200
committerElvis Angelaccio <[email protected]>2017-10-12 23:21:49 +0200
commitbd47eb2e6d80315115bb3f58987162fcb4911b10 (patch)
treed51172264a047f02e235cc2e78371330336e4792 /src/dolphinmainwindow.cpp
parent1ad3b7775ec7388352d3a02c704062baa5d0aca3 (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/dolphinmainwindow.cpp')
-rw-r--r--src/dolphinmainwindow.cpp68
1 files changed, 49 insertions, 19 deletions
diff --git a/src/dolphinmainwindow.cpp b/src/dolphinmainwindow.cpp
index 3df25001c..cd232577d 100644
--- a/src/dolphinmainwindow.cpp
+++ b/src/dolphinmainwindow.cpp
@@ -99,7 +99,10 @@ DolphinMainWindow::DolphinMainWindow() :
m_settingsDialog(),
m_controlButton(0),
m_updateToolBarTimer(0),
- m_lastHandleUrlStatJob(0)
+ m_lastHandleUrlStatJob(0),
+ m_terminalPanel(0),
+ m_placesPanel(0),
+ m_tearDownFromPlacesRequested(false)
{
Q_INIT_RESOURCE(dolphin);
@@ -247,6 +250,11 @@ void DolphinMainWindow::changeUrl(const QUrl &url)
void DolphinMainWindow::slotTerminalDirectoryChanged(const QUrl& url)
{
+ if (m_tearDownFromPlacesRequested && url == QUrl::fromLocalFile(QDir::homePath())) {
+ m_placesPanel->proceedWithTearDown();
+ m_tearDownFromPlacesRequested = false;
+ }
+
m_activeViewContainer->setAutoGrabFocus(false);
changeUrl(url);
m_activeViewContainer->setAutoGrabFocus(true);
@@ -994,6 +1002,25 @@ void DolphinMainWindow::setUrlAsCaption(const QUrl& url)
setWindowTitle(schemePrefix + fileName);
}
+void DolphinMainWindow::slotStorageTearDownFromPlacesRequested(const QString& mountPath)
+{
+ if (m_terminalPanel->currentWorkingDirectory().startsWith(mountPath)) {
+ m_tearDownFromPlacesRequested = true;
+ m_terminalPanel->goHome();
+ // m_placesPanel->proceedWithTearDown() will be called in slotTerminalDirectoryChanged
+ } else {
+ m_placesPanel->proceedWithTearDown();
+ }
+}
+
+void DolphinMainWindow::slotStorageTearDownExternallyRequested(const QString& mountPath)
+{
+ if (m_terminalPanel->currentWorkingDirectory().startsWith(mountPath)) {
+ m_tearDownFromPlacesRequested = false;
+ m_terminalPanel->goHome();
+ }
+}
+
void DolphinMainWindow::setupActions()
{
// setup 'File' menu
@@ -1246,21 +1273,21 @@ void DolphinMainWindow::setupDockWidgets()
terminalDock->setLocked(lock);
terminalDock->setObjectName(QStringLiteral("terminalDock"));
terminalDock->setAllowedAreas(Qt::TopDockWidgetArea | Qt::BottomDockWidgetArea);
- TerminalPanel* terminalPanel = new TerminalPanel(terminalDock);
- terminalPanel->setCustomContextMenuActions({lockLayoutAction});
- terminalDock->setWidget(terminalPanel);
+ m_terminalPanel = new TerminalPanel(terminalDock);
+ m_terminalPanel->setCustomContextMenuActions({lockLayoutAction});
+ terminalDock->setWidget(m_terminalPanel);
- connect(terminalPanel, &TerminalPanel::hideTerminalPanel, terminalDock, &DolphinDockWidget::hide);
- connect(terminalPanel, &TerminalPanel::changeUrl, this, &DolphinMainWindow::slotTerminalDirectoryChanged);
+ connect(m_terminalPanel, &TerminalPanel::hideTerminalPanel, terminalDock, &DolphinDockWidget::hide);
+ connect(m_terminalPanel, &TerminalPanel::changeUrl, this, &DolphinMainWindow::slotTerminalDirectoryChanged);
connect(terminalDock, &DolphinDockWidget::visibilityChanged,
- terminalPanel, &TerminalPanel::dockVisibilityChanged);
+ m_terminalPanel, &TerminalPanel::dockVisibilityChanged);
QAction* terminalAction = terminalDock->toggleViewAction();
createPanelAction(QIcon::fromTheme(QStringLiteral("utilities-terminal")), Qt::Key_F4, terminalAction, QStringLiteral("show_terminal_panel"));
addDockWidget(Qt::BottomDockWidgetArea, terminalDock);
connect(this, &DolphinMainWindow::urlChanged,
- terminalPanel, &TerminalPanel::setUrl);
+ m_terminalPanel, &TerminalPanel::setUrl);
if (GeneralSettings::version() < 200) {
terminalDock->hide();
@@ -1279,28 +1306,31 @@ void DolphinMainWindow::setupDockWidgets()
placesDock->setObjectName(QStringLiteral("placesDock"));
placesDock->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
- PlacesPanel* placesPanel = new PlacesPanel(placesDock);
- placesPanel->setCustomContextMenuActions({lockLayoutAction});
- placesDock->setWidget(placesPanel);
+ m_placesPanel = new PlacesPanel(placesDock);
+ m_placesPanel->setCustomContextMenuActions({lockLayoutAction});
+ placesDock->setWidget(m_placesPanel);
- QAction* placesAction = placesDock->toggleViewAction();
+ QAction *placesAction = placesDock->toggleViewAction();
createPanelAction(QIcon::fromTheme(QStringLiteral("bookmarks")), Qt::Key_F9, placesAction, QStringLiteral("show_places_panel"));
addDockWidget(Qt::LeftDockWidgetArea, placesDock);
- connect(placesPanel, &PlacesPanel::placeActivated,
+ connect(m_placesPanel, &PlacesPanel::placeActivated,
this, &DolphinMainWindow::slotPlaceActivated);
- connect(placesPanel, &PlacesPanel::placeMiddleClicked,
+ connect(m_placesPanel, &PlacesPanel::placeMiddleClicked,
this, &DolphinMainWindow::openNewTab);
- connect(placesPanel, &PlacesPanel::errorMessage,
+ connect(m_placesPanel, &PlacesPanel::errorMessage,
this, &DolphinMainWindow::showErrorMessage);
connect(this, &DolphinMainWindow::urlChanged,
- placesPanel, &PlacesPanel::setUrl);
+ m_placesPanel, &PlacesPanel::setUrl);
connect(placesDock, &DolphinDockWidget::visibilityChanged,
m_tabWidget, &DolphinTabWidget::slotPlacesPanelVisibilityChanged);
connect(this, &DolphinMainWindow::settingsChanged,
- placesPanel, &PlacesPanel::readSettings);
-
- m_tabWidget->slotPlacesPanelVisibilityChanged(placesPanel->isVisible());
+ m_placesPanel, &PlacesPanel::readSettings);
+ connect(m_placesPanel, &PlacesPanel::storageTearDownRequested,
+ this, &DolphinMainWindow::slotStorageTearDownFromPlacesRequested);
+ connect(m_placesPanel, &PlacesPanel::storageTearDownExternallyRequested,
+ this, &DolphinMainWindow::slotStorageTearDownExternallyRequested);
+ m_tabWidget->slotPlacesPanelVisibilityChanged(m_placesPanel->isVisible());
// Add actions into the "Panels" menu
KActionMenu* panelsMenu = new KActionMenu(i18nc("@action:inmenu View", "Panels"), this);