Add option for globally changing the base environment for tools

Fixes: QTCREATORBUG-22123
Change-Id: I00a5bbdf92e5dab513cb12f3518a2abb1adbb9cd
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
This commit is contained in:
Eike Ziller
2020-11-16 16:40:12 +01:00
parent 05dca6f09e
commit e755094480
8 changed files with 370 additions and 220 deletions

View File

@@ -25,6 +25,7 @@
#include "systemsettings.h"
#include "coreconstants.h"
#include "coreplugin.h"
#include "editormanager/editormanager_p.h"
#include "fileutils.h"
#include "icore.h"
@@ -37,6 +38,7 @@
#include <utils/checkablemessagebox.h>
#include <utils/consoleprocess.h>
#include <utils/environment.h>
#include <utils/environmentdialog.h>
#include <utils/hostosinfo.h>
#include <utils/unixutils.h>
@@ -153,6 +155,20 @@ public:
updatePath();
m_ui.environmentChangesLabel->setElideMode(Qt::ElideRight);
m_environmentChanges = CorePlugin::environmentChanges();
updateEnvironmentChangesLabel();
connect(m_ui.environmentButton, &QPushButton::clicked, [this] {
Utils::optional<EnvironmentItems> changes
= Utils::EnvironmentDialog::getEnvironmentItems(m_ui.environmentButton,
m_environmentChanges);
if (!changes)
return;
m_environmentChanges = *changes;
updateEnvironmentChangesLabel();
updatePath();
});
connect(VcsManager::instance(), &VcsManager::configurationChanged,
this, &SystemSettingsWidget::updatePath);
}
@@ -165,10 +181,12 @@ private:
void resetTerminal();
void updateTerminalUi(const Utils::TerminalCommand &term);
void updatePath();
void updateEnvironmentChangesLabel();
void variableHelpDialogCreator(const QString &helpText);
Ui::SystemSettings m_ui;
QPointer<QMessageBox> m_dialog;
EnvironmentItems m_environmentChanges;
};
void SystemSettingsWidget::apply()
@@ -206,6 +224,8 @@ void SystemSettingsWidget::apply()
else
HostOsInfo::setOverrideFileNameCaseSensitivity(selectedSensitivity);
}
CorePlugin::setEnvironmentChanges(m_environmentChanges);
}
void SystemSettingsWidget::resetTerminal()
@@ -235,6 +255,14 @@ void SystemSettingsWidget::updatePath()
m_ui.patchChooser->setEnvironment(env);
}
void SystemSettingsWidget::updateEnvironmentChangesLabel()
{
const QString shortSummary = Utils::EnvironmentItem::toStringList(m_environmentChanges)
.join("; ");
m_ui.environmentChangesLabel->setText(shortSummary.isEmpty() ? tr("No changes to apply.")
: shortSummary);
}
void SystemSettingsWidget::variableHelpDialogCreator(const QString &helpText)
{
if (m_dialog) {