From 07baa7bb68d3d3c8ed1f564ea42efa80684b3a23 Mon Sep 17 00:00:00 2001 From: Antti Savolainen Date: Mon, 20 Apr 2026 09:48:28 +0000 Subject: terminalpanel: allow refreshing the terminal location When a program is running on front while the graphical view is being changed, that can make the terminal and file view working directories out of sync. I wasn't able to find a signal from Konsole for when the foreground program exits, so having the terminal respond to F5 is the second best thing. BUG: 510557 --- src/dolphinmainwindow.cpp | 2 ++ src/dolphinmainwindow.h | 5 +++++ src/panels/panel.cpp | 9 +++++++++ src/panels/panel.h | 6 ++++++ src/panels/terminal/terminalpanel.cpp | 3 ++- src/panels/terminal/terminalpanel.h | 1 + 6 files changed, 25 insertions(+), 1 deletion(-) diff --git a/src/dolphinmainwindow.cpp b/src/dolphinmainwindow.cpp index 12ca26898..e6da0f5e0 100644 --- a/src/dolphinmainwindow.cpp +++ b/src/dolphinmainwindow.cpp @@ -1171,6 +1171,7 @@ void DolphinMainWindow::reloadView() clearStatusBar(); m_activeViewContainer->reload(); m_activeViewContainer->statusBar()->updateSpaceInfo(); + Q_EMIT urlRefreshed(m_activeViewContainer->url()); } void DolphinMainWindow::stopLoading() @@ -2467,6 +2468,7 @@ void DolphinMainWindow::setupDockWidgets() addDockWidget(Qt::BottomDockWidgetArea, terminalDock); connect(this, &DolphinMainWindow::urlChanged, m_terminalPanel, &TerminalPanel::setUrl); + connect(this, &DolphinMainWindow::urlRefreshed, m_terminalPanel, &TerminalPanel::refreshUrl); if (GeneralSettings::version() < 200) { terminalDock->hide(); diff --git a/src/dolphinmainwindow.h b/src/dolphinmainwindow.h index cd9f238aa..9c41f73fe 100644 --- a/src/dolphinmainwindow.h +++ b/src/dolphinmainwindow.h @@ -245,6 +245,11 @@ Q_SIGNALS: */ void urlChanged(const QUrl &url); + /** + * Is sent when the view is refreshed + */ + void urlRefreshed(const QUrl &url); + /** * Is emitted if information of an item is requested to be shown e. g. in the panel. * If item is null, no item information request is pending. diff --git a/src/panels/panel.cpp b/src/panels/panel.cpp index e8250c62b..94f80f7e7 100644 --- a/src/panels/panel.cpp +++ b/src/panels/panel.cpp @@ -54,6 +54,15 @@ void Panel::setUrl(const QUrl &url) } } +void Panel::refreshUrl(const QUrl &url) +{ + const QUrl oldUrl = m_url; + m_url = url; + if (!urlChanged()) { + m_url = oldUrl; + } +} + void Panel::readSettings() { } diff --git a/src/panels/panel.h b/src/panels/panel.h index 5f1fabb4a..23136a4b9 100644 --- a/src/panels/panel.h +++ b/src/panels/panel.h @@ -45,6 +45,12 @@ public Q_SLOTS: */ void setUrl(const QUrl &url); + /** + * This is invoked whenever the folder being displayed in the + * active Dolphin view is refreshed. + */ + void refreshUrl(const QUrl &url); + /** * Refreshes the view to get synchronized with the settings. */ diff --git a/src/panels/terminal/terminalpanel.cpp b/src/panels/terminal/terminalpanel.cpp index a357b31ac..2ed6cd33e 100644 --- a/src/panels/terminal/terminalpanel.cpp +++ b/src/panels/terminal/terminalpanel.cpp @@ -145,9 +145,10 @@ bool TerminalPanel::urlChanged() return false; } - const bool sendInput = m_terminal && !hasProgramRunning() && isVisible() && m_syncUrl; + const bool sendInput = m_terminal && !hasProgramRunning() && isVisible() && m_syncUrl && url() != m_url; if (sendInput) { changeDir(url()); + m_url = url(); } return true; diff --git a/src/panels/terminal/terminalpanel.h b/src/panels/terminal/terminalpanel.h index 0aaf921c0..7f4e9e36c 100644 --- a/src/panels/terminal/terminalpanel.h +++ b/src/panels/terminal/terminalpanel.h @@ -86,6 +86,7 @@ private: private: bool m_clearTerminal; bool m_syncUrl; + QUrl m_url; KIO::StatJob *m_mostLocalUrlJob; QVBoxLayout *m_layout; -- cgit v1.3