diff options
author | Marcus Tillmanns <[email protected]> | 2023-03-14 09:09:55 +0100 |
---|---|---|
committer | Marcus Tillmanns <[email protected]> | 2023-03-21 15:09:15 +0000 |
commit | 44074accc7eb2fe0659ccd5166975d54dfb5cc68 (patch) | |
tree | ddf6f2bacdb8c10248a17bcb35c66d84e7876f6f /src/libs/utils/terminalhooks.cpp | |
parent | 50a214de9e8444f3e43e9b1013c95072f8ff196f (diff) |
Terminal: Use QtcProcess to start terminal window
Previously DesktopDevice::openTerminal used custom code to open a
terminal window. This patch changes it to use QtcProcess with
TerminalMode::On.
This also removes the need for "openTerminal.py" on macOS.
Change-Id: Iec978bdd19487ff8e59dcd88c35c2d01b0681022
Reviewed-by: Cristian Adam <[email protected]>
Diffstat (limited to 'src/libs/utils/terminalhooks.cpp')
-rw-r--r-- | src/libs/utils/terminalhooks.cpp | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/src/libs/utils/terminalhooks.cpp b/src/libs/utils/terminalhooks.cpp index 8187229cbf5..6ee46b33616 100644 --- a/src/libs/utils/terminalhooks.cpp +++ b/src/libs/utils/terminalhooks.cpp @@ -3,10 +3,10 @@ #include "terminalhooks.h" -#include "terminalinterface.h" #include "filepath.h" #include "qtcprocess.h" #include "terminalcommand.h" +#include "terminalinterface.h" #include <QTemporaryFile> @@ -14,10 +14,9 @@ namespace Utils::Terminal { FilePath defaultShellForDevice(const FilePath &deviceRoot) { - if (!deviceRoot.needsDevice()) - return {}; + if (deviceRoot.osType() == OsTypeWindows) + return deviceRoot.withNewPath("cmd.exe").searchInPath(); - // TODO: Windows ? const Environment env = deviceRoot.deviceEnvironment(); FilePath shell = FilePath::fromUserInput(env.value_or("SHELL", "/bin/sh")); @@ -41,18 +40,23 @@ class ExternalTerminalProcessImpl final : public TerminalInterface void startStubProcess(const CommandLine &cmd, const ProcessSetupData &) override { + const TerminalCommand terminal = TerminalCommand::terminalEmulator(); + if (HostOsInfo::isWindowsHost()) { m_terminalProcess.setCommand(cmd); QObject::connect(&m_terminalProcess, &QtcProcess::done, this, [this] { m_interface->onStubExited(); }); + m_terminalProcess.setCreateConsoleOnWindows(true); + m_terminalProcess.setProcessMode(ProcessMode::Writer); m_terminalProcess.start(); - } else if (HostOsInfo::isMacHost()) { + } else if (HostOsInfo::isMacHost() && terminal.command == "Terminal.app") { QTemporaryFile f; f.setAutoRemove(false); f.open(); f.setPermissions(QFile::ExeUser | QFile::ReadUser | QFile::WriteUser); f.write("#!/bin/sh\n"); + f.write("clear\n"); f.write(QString("exec '%1' %2\n") .arg(cmd.executable().nativePath()) .arg(cmd.arguments()) @@ -64,11 +68,10 @@ class ExternalTerminalProcessImpl final : public TerminalInterface = QString("tell app \"Terminal\" to do script \"'%1'; rm -f '%1'; exit\"") .arg(path); - m_terminalProcess.setCommand({"osascript", {"-e", exe}}); + m_terminalProcess.setCommand( + {"osascript", {"-e", "tell app \"Terminal\" to activate", "-e", exe}}); m_terminalProcess.runBlocking(); } else { - const TerminalCommand terminal = TerminalCommand::terminalEmulator(); - CommandLine cmdLine = {terminal.command, {terminal.executeArgs}}; cmdLine.addCommandLineAsArgs(cmd, CommandLine::Raw); |