aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/terminal/terminalwidget.cpp
diff options
context:
space:
mode:
authorMarcus Tillmanns <[email protected]>2023-08-10 06:44:27 +0200
committerMarcus Tillmanns <[email protected]>2023-08-17 07:09:48 +0000
commit92355bf40d2ff6a44465aa085fe018db2e50e919 (patch)
treeb0484235b3ca3ba6ecc2c553d0ed4200261808ac /src/plugins/terminal/terminalwidget.cpp
parentd611fe6821347858e435e88efe98d972e29d2c91 (diff)
Terminal: Lazily open remote terminals
Move the burden of finding the shell of a device from the shell menu to the TerminalWidget, so that opening the shell menu does not block the ui. Change-Id: I7f2e5a891f20faa53a1e3eec879866219f9bee0b Reviewed-by: hjk <[email protected]>
Diffstat (limited to 'src/plugins/terminal/terminalwidget.cpp')
-rw-r--r--src/plugins/terminal/terminalwidget.cpp28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/plugins/terminal/terminalwidget.cpp b/src/plugins/terminal/terminalwidget.cpp
index 4b06c353433..326ed523915 100644
--- a/src/plugins/terminal/terminalwidget.cpp
+++ b/src/plugins/terminal/terminalwidget.cpp
@@ -16,6 +16,7 @@
#include <coreplugin/messagemanager.h>
#include <utils/algorithm.h>
+#include <utils/async.h>
#include <utils/environment.h>
#include <utils/fileutils.h>
#include <utils/hostosinfo.h>
@@ -82,6 +83,33 @@ void TerminalWidget::setupPty()
CommandLine shellCommand = m_openParameters.shellCommand.value_or(
CommandLine{settings().shell(), settings().shellArguments(), CommandLine::Raw});
+ if (shellCommand.executable().isRootPath()) {
+ writeToTerminal(Tr::tr("Connecting ...\r\n").toUtf8(), true);
+ // We still have to find the shell to start ...
+ m_findShellWatcher.reset(new QFutureWatcher<FilePath>());
+ connect(m_findShellWatcher.get(), &QFutureWatcher<FilePath>::finished, this, [this] {
+ const FilePath result = m_findShellWatcher->result();
+ if (!result.isEmpty()) {
+ m_openParameters.shellCommand->setExecutable(m_findShellWatcher->result());
+ restart(m_openParameters);
+ return;
+ }
+
+ writeToTerminal(
+ ("\r\n\033[31m" + Tr::tr("Could not find shell to start.") + "\r\n").toUtf8(), true);
+ });
+
+ m_findShellWatcher->setFuture(Utils::asyncRun([shellCommand] {
+ const FilePath result = Utils::Terminal::defaultShellForDevice(
+ shellCommand.executable());
+ if (result.isExecutableFile())
+ return result;
+ return FilePath{};
+ }));
+
+ return;
+ }
+
Environment env = m_openParameters.environment.value_or(Environment{})
.appliedToEnvironment(shellCommand.executable().deviceEnvironment());