┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src/panels/terminal/terminalpanel.cpp
diff options
context:
space:
mode:
authorEgor Maksimov <[email protected]>2026-01-28 09:16:35 +0000
committerMéven Car <[email protected]>2026-01-28 09:16:35 +0000
commitad73de758fc1b2c5a48004adfb06559732cc305e (patch)
treeeaa7f41f7b670ddc42ce557acefd7f7923a7b957 /src/panels/terminal/terminalpanel.cpp
parent3ca892a70f0baf97c64ef87911dba502450184cf (diff)
panel/terminal: Add ability to disable konsole url sync
Sometimes when you work on the project using the build in konsole, most commands are meant to be run at the project root. This allows for user to disable URL sync so that one could browse the project tree without constantly needing go back to the root folder just to run a command. BUG: 306381
Diffstat (limited to 'src/panels/terminal/terminalpanel.cpp')
-rw-r--r--src/panels/terminal/terminalpanel.cpp31
1 files changed, 27 insertions, 4 deletions
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()));
}
});
}