Terminal: Allow the underlying application to set title

Change-Id: I3530d645f16047df2546902d900e5e2fee8d071c
Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io>
This commit is contained in:
Orgad Shaneh
2023-07-03 12:21:30 +03:00
committed by Orgad Shaneh
parent 1bd2e84f9a
commit 9a7f45cc46
6 changed files with 35 additions and 11 deletions

View File

@@ -219,23 +219,15 @@ void TerminalPane::setupTerminalWidget(TerminalWidget *terminal)
if (!terminal)
return;
const auto setTabText = [this, terminal]() {
const auto setTabText = [this, terminal] {
const int index = m_tabWidget.indexOf(terminal);
const FilePath cwd = terminal->cwd();
const QString exe = terminal->currentCommand().isEmpty()
? terminal->shellName()
: terminal->currentCommand().executable().fileName();
if (cwd.isEmpty())
m_tabWidget.setTabText(index, exe);
else
m_tabWidget.setTabText(index, exe + " - " + cwd.fileName());
m_tabWidget.setTabText(index, terminal->title());
};
connect(terminal, &TerminalWidget::started, this, setTabText);
connect(terminal, &TerminalWidget::cwdChanged, this, setTabText);
connect(terminal, &TerminalWidget::commandChanged, this, setTabText);
connect(terminal, &TerminalWidget::titleChanged, this, setTabText);
if (!terminal->shellName().isEmpty())
setTabText();