┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/dolphinmainwindow.cpp11
-rw-r--r--src/panels/terminal/terminalpanel.cpp31
-rw-r--r--src/panels/terminal/terminalpanel.h5
3 files changed, 43 insertions, 4 deletions
diff --git a/src/dolphinmainwindow.cpp b/src/dolphinmainwindow.cpp
index 2ad1cc8e3..62ff2fa45 100644
--- a/src/dolphinmainwindow.cpp
+++ b/src/dolphinmainwindow.cpp
@@ -2498,6 +2498,17 @@ void DolphinMainWindow::setupDockWidgets()
focusTerminalPanel->setIcon(QIcon::fromTheme(QStringLiteral("swap-panels")));
actionCollection()->setDefaultShortcut(focusTerminalPanel, Qt::CTRL | Qt::SHIFT | Qt::Key_F4);
connect(focusTerminalPanel, &QAction::triggered, this, &DolphinMainWindow::toggleTerminalPanelFocus);
+
+ QAction *switchTerminalUrlSync = actionCollection()->addAction(QStringLiteral("switch_terminal_url_sync"));
+ switchTerminalUrlSync->setText(i18nc("@action:inmenu", "Follow Directory Switch"));
+ switchTerminalUrlSync->setToolTip(
+ i18nc("@info:tooltip", "Determines if current working directory must be kept in sync with terminal whenever directory is changed."));
+ switchTerminalUrlSync->setCheckable(true);
+ connect(switchTerminalUrlSync, &QAction::toggled, m_terminalPanel, &TerminalPanel::switchSync);
+ switchTerminalUrlSync->setChecked(true);
+
+ m_terminalPanel->setSwitchTerminalUrlSyncAction(switchTerminalUrlSync);
+
} // endif "shell_access" allowed
#endif // HAVE_TERMINAL
diff --git a/src/panels/terminal/terminalpanel.cpp b/src/panels/terminal/terminalpanel.cpp
index 92ba18bf5..a357b31ac 100644
--- a/src/panels/terminal/terminalpanel.cpp
+++ b/src/panels/terminal/terminalpanel.cpp
@@ -31,6 +31,7 @@
TerminalPanel::TerminalPanel(QWidget *parent)
: Panel(parent)
, m_clearTerminal(true)
+ , m_syncUrl(true)
, m_mostLocalUrlJob(nullptr)
, m_layout(nullptr)
, m_terminal(nullptr)
@@ -40,6 +41,7 @@ TerminalPanel::TerminalPanel(QWidget *parent)
, m_konsolePartCurrentDirectory()
, m_sendCdToTerminalHistory()
, m_kiofuseInterface(QStringLiteral("org.kde.KIOFuse"), QStringLiteral("/org/kde/KIOFuse"), QDBusConnection::sessionBus())
+ , m_switchTerminalUrlSyncAction(nullptr)
{
m_layout = new QVBoxLayout(this);
m_layout->setContentsMargins(0, 0, 0, 0);
@@ -102,6 +104,16 @@ void TerminalPanel::dockVisibilityChanged()
}
}
+void TerminalPanel::switchSync(bool syncUrl)
+{
+ m_syncUrl = syncUrl;
+}
+
+void TerminalPanel::setSwitchTerminalUrlSyncAction(QAction *urlToggle)
+{
+ m_switchTerminalUrlSyncAction = urlToggle;
+}
+
QString TerminalPanel::runningProgramName() const
{
return m_terminal ? m_terminal->foregroundProcessName() : QString();
@@ -133,7 +145,7 @@ bool TerminalPanel::urlChanged()
return false;
}
- const bool sendInput = m_terminal && !hasProgramRunning() && isVisible();
+ const bool sendInput = m_terminal && !hasProgramRunning() && isVisible() && m_syncUrl;
if (sendInput) {
changeDir(url());
}
@@ -178,6 +190,10 @@ void TerminalPanel::showEvent(QShowEvent *event)
});
}
+ const QList<QAction *> additional = {m_switchTerminalUrlSyncAction};
+
+ QMetaObject::invokeMethod(m_konsolePart, "setContextMenuAdditionalActions", Q_ARG(QList<QAction *>, additional));
+
} else {
if (!m_konsolePartMissingMessage) {
const auto konsoleInstallUrl = QUrl("appstream://org.kde.konsole.desktop");
@@ -242,6 +258,13 @@ void TerminalPanel::changeDir(const QUrl &url)
sendCdToTerminalKIOFuse(url);
}
+void TerminalPanel::emitUrlChanged(const QUrl &url)
+{
+ if (m_syncUrl) {
+ Q_EMIT changeUrl(url);
+ }
+}
+
void TerminalPanel::sendCdToTerminal(const QString &dir, HistoryPolicy addToHistory)
{
if (dir == m_konsolePartCurrentDirectory // We are already there
@@ -320,7 +343,7 @@ void TerminalPanel::slotKonsolePartCurrentDirectoryChanged(const QString &dir)
KMountPoint::Ptr mountPoint = KMountPoint::currentMountPoints().findByPath(m_konsolePartCurrentDirectory);
if (mountPoint && mountPoint->mountType() != QStringLiteral("fuse.kio-fuse")) {
// Not in KIOFUse mount, so just switch to the corresponding URL.
- Q_EMIT changeUrl(url);
+ emitUrlChanged(url);
return;
}
@@ -330,11 +353,11 @@ void TerminalPanel::slotKonsolePartCurrentDirectoryChanged(const QString &dir)
watcher->deleteLater();
if (reply.isError()) {
// KIOFuse errored out... just show the normal URL
- Q_EMIT changeUrl(url);
+ emitUrlChanged(url);
} else {
// Our location happens to be in a KIOFuse mount and is mounted.
// Let's change the DolphinView to point to the remote URL equivalent.
- Q_EMIT changeUrl(QUrl::fromUserInput(reply.value()));
+ emitUrlChanged(QUrl::fromUserInput(reply.value()));
}
});
}
diff --git a/src/panels/terminal/terminalpanel.h b/src/panels/terminal/terminalpanel.h
index 8eee3c10f..0aaf921c0 100644
--- a/src/panels/terminal/terminalpanel.h
+++ b/src/panels/terminal/terminalpanel.h
@@ -55,6 +55,8 @@ public:
public Q_SLOTS:
void terminalExited();
void dockVisibilityChanged();
+ void switchSync(bool syncUrl);
+ void setSwitchTerminalUrlSyncAction(QAction *urlToggle);
Q_SIGNALS:
void hideTerminalPanel();
@@ -77,11 +79,13 @@ private:
enum class HistoryPolicy { AddToHistory, SkipHistory };
void changeDir(const QUrl &url);
+ void emitUrlChanged(const QUrl &url);
void sendCdToTerminal(const QString &path, HistoryPolicy addToHistory = HistoryPolicy::AddToHistory);
void sendCdToTerminalKIOFuse(const QUrl &url);
private:
bool m_clearTerminal;
+ bool m_syncUrl;
KIO::StatJob *m_mostLocalUrlJob;
QVBoxLayout *m_layout;
@@ -92,6 +96,7 @@ private:
QString m_konsolePartCurrentDirectory;
QQueue<QString> m_sendCdToTerminalHistory;
org::kde::KIOFuse::VFS m_kiofuseInterface;
+ QAction *m_switchTerminalUrlSyncAction;
};
#endif // TERMINALPANEL_H