forked from qt-creator/qt-creator
Terminal: Allow the underlying application to set title
Change-Id: I3530d645f16047df2546902d900e5e2fee8d071c Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io>
This commit is contained in:
committed by
Orgad Shaneh
parent
1bd2e84f9a
commit
9a7f45cc46
@@ -399,6 +399,18 @@ void TerminalWidget::setupSurface()
|
||||
if (TerminalSettings::instance().audibleBell.value())
|
||||
QApplication::beep();
|
||||
});
|
||||
connect(m_surface.get(),
|
||||
&Internal::TerminalSurface::titleChanged,
|
||||
this,
|
||||
[this](const QString &title) {
|
||||
const FilePath titleFile = FilePath::fromUserInput(title);
|
||||
if (!m_title.isEmpty()
|
||||
|| m_openParameters.shellCommand.value_or(CommandLine{}).executable()
|
||||
!= titleFile) {
|
||||
m_title = titleFile.isFile() ? titleFile.baseName() : title;
|
||||
}
|
||||
emit titleChanged();
|
||||
});
|
||||
|
||||
if (m_shellIntegration) {
|
||||
connect(m_shellIntegration.get(),
|
||||
@@ -442,6 +454,17 @@ QColor TerminalWidget::toQColor(std::variant<int, QColor> color) const
|
||||
return std::get<QColor>(color);
|
||||
}
|
||||
|
||||
QString TerminalWidget::title() const
|
||||
{
|
||||
const FilePath dir = cwd();
|
||||
QString title = m_title;
|
||||
if (title.isEmpty())
|
||||
title = currentCommand().isEmpty() ? shellName() : currentCommand().executable().fileName();
|
||||
if (dir.isEmpty())
|
||||
return title;
|
||||
return title + " - " + dir.fileName();
|
||||
}
|
||||
|
||||
void TerminalWidget::updateCopyState()
|
||||
{
|
||||
if (!hasFocus())
|
||||
|
||||
Reference in New Issue
Block a user