Application Output: Fix name of output file

If a tab is re-used for a different application, the output file name
must change too.

Fixes: QTCREATORBUG-31099
Change-Id: I3413fca3a99757777db8cb771f0947f655d20ea4
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
This commit is contained in:
Eike Ziller
2024-07-10 14:49:14 +02:00
parent e46ee312dd
commit a13635ca6b

View File

@@ -399,6 +399,11 @@ void AppOutputPane::createNewOutputWindow(RunControl *rc)
&& thisWorkingDirectory == tab.runControl->workingDirectory()
&& thisEnvironment == tab.runControl->environment();
});
const auto updateOutputFileName = [this](int index, RunControl *rc) {
qobject_cast<OutputWindow *>(m_tabWidget->widget(index))
//: file name suggested for saving application output, %1 = run configuration display name
->setOutputFileNameHint(Tr::tr("application-output-%1.txt").arg(rc->displayName()));
};
if (tab != m_runControlTabs.end()) {
// Reuse this tab
if (tab->runControl)
@@ -414,6 +419,7 @@ void AppOutputPane::createNewOutputWindow(RunControl *rc)
const int tabIndex = m_tabWidget->indexOf(tab->window);
QTC_ASSERT(tabIndex != -1, return);
m_tabWidget->setTabText(tabIndex, rc->displayName());
updateOutputFileName(tabIndex, rc);
tab->window->scrollToBottom();
qCDebug(appOutputLog) << "AppOutputPane::createNewOutputWindow: Reusing tab"
@@ -429,8 +435,6 @@ void AppOutputPane::createNewOutputWindow(RunControl *rc)
ow->setWindowIcon(Icons::WINDOW.icon());
ow->setWordWrapEnabled(m_settings.wrapOutput);
ow->setMaxCharCount(m_settings.maxCharCount);
//: file name suggested for saving application output, %1 = run configuration display name
ow->setOutputFileNameHint(Tr::tr("application-output-%1.txt").arg(rc->displayName()));
auto updateFontSettings = [ow] {
ow->setBaseFont(TextEditor::TextEditorSettings::fontSettings().font());
@@ -456,6 +460,7 @@ void AppOutputPane::createNewOutputWindow(RunControl *rc)
m_runControlTabs.push_back(RunControlTab(rc, ow));
m_tabWidget->addTab(ow, rc->displayName());
updateOutputFileName(m_tabWidget->count() - 1, rc);
qCDebug(appOutputLog) << "AppOutputPane::createNewOutputWindow: Adding tab for" << rc;
updateCloseActions();
setFilteringEnabled(m_tabWidget->count() > 0);