Terminal: Enable TerminalProcessInterface

Adds a new helper app "process_stub" that replaces the previous.
"process_stub_unix/win". The purpose was and is to allow processes
to be "injected" into other hosts apps like terminals while still
being able to control and debug them.

A new base class called "TerminalInterface" is used for both the new
Terminal plugin and the legacy TerminalProcess implementation.

Fixes: QTCREATORBUG-16364
Change-Id: If21273fe53ad545d1a768c17c83db4bf2fd85395
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
Marcus Tillmanns
2023-03-07 17:55:38 +01:00
parent 2d2eef1c2c
commit 0870f2583b
34 changed files with 1276 additions and 1502 deletions

View File

@@ -23,18 +23,19 @@
namespace Terminal {
using namespace Utils;
using namespace Utils::Terminal;
TerminalPane::TerminalPane(QObject *parent)
: Core::IOutputPane(parent)
{
Core::Context context("Terminal.Window");
m_newTerminal.setIcon(Utils::Icons::PLUS_TOOLBAR.icon());
m_newTerminal.setIcon(Icons::PLUS_TOOLBAR.icon());
m_newTerminal.setToolTip(Tr::tr("Create a new Terminal."));
connect(&m_newTerminal, &QAction::triggered, this, [this] { openTerminal({}); });
m_closeTerminal.setIcon(Utils::Icons::CLOSE_TOOLBAR.icon());
m_closeTerminal.setIcon(Icons::CLOSE_TOOLBAR.icon());
m_closeTerminal.setToolTip(Tr::tr("Close the current Terminal."));
m_closeTerminal.setEnabled(false);
@@ -109,21 +110,22 @@ static std::optional<FilePath> startupProjectDirectory()
return project->projectDirectory();
}
void TerminalPane::openTerminal(Utils::Terminal::OpenTerminalParameters parameters)
void TerminalPane::openTerminal(const OpenTerminalParameters &parameters)
{
OpenTerminalParameters parametersCopy{parameters};
showPage(0);
if (!parameters.workingDirectory) {
if (!parametersCopy.workingDirectory) {
const std::optional<FilePath> projectDir = startupProjectDirectory();
if (projectDir) {
if (!parameters.shellCommand
|| parameters.shellCommand->executable().ensureReachable(*projectDir)) {
parameters.workingDirectory = *projectDir;
if (!parametersCopy.shellCommand
|| parametersCopy.shellCommand->executable().ensureReachable(*projectDir)) {
parametersCopy.workingDirectory = *projectDir;
}
}
}
auto terminalWidget = new TerminalWidget(m_tabWidget, parameters);
auto terminalWidget = new TerminalWidget(m_tabWidget, parametersCopy);
m_tabWidget->setCurrentIndex(m_tabWidget->addTab(terminalWidget, Tr::tr("Terminal")));
setupTerminalWidget(terminalWidget);
@@ -143,6 +145,19 @@ void TerminalPane::addTerminal(TerminalWidget *terminal, const QString &title)
emit navigateStateUpdate();
}
TerminalWidget *TerminalPane::stoppedTerminalWithId(const Id &identifier) const
{
QTC_ASSERT(m_tabWidget, return nullptr);
for (int i = 0; i < m_tabWidget->count(); ++i) {
auto terminal = qobject_cast<TerminalWidget *>(m_tabWidget->widget(i));
if (terminal->processState() == QProcess::NotRunning && terminal->identifier() == identifier)
return terminal;
}
return nullptr;
}
QWidget *TerminalPane::outputWidget(QWidget *parent)
{
if (!m_tabWidget) {