forked from qt-creator/qt-creator
ProjectExplorer: Add kit environment flag to force MSVC English output
Enabled only on Windows. Task-number: QTCREATORBUG-316 Change-Id: I69fb92f2eafa089b51e91390bc3099982465c246 Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
This commit is contained in:
@@ -45,6 +45,7 @@
|
||||
#include <utils/pathchooser.h>
|
||||
#include <utils/environmentdialog.h>
|
||||
|
||||
#include <QCheckBox>
|
||||
#include <QComboBox>
|
||||
#include <QDialog>
|
||||
#include <QDialogButtonBox>
|
||||
@@ -412,8 +413,16 @@ void DeviceInformationConfigWidget::currentDeviceChanged()
|
||||
KitEnvironmentConfigWidget::KitEnvironmentConfigWidget(Kit *workingCopy, const KitInformation *ki) :
|
||||
KitConfigWidget(workingCopy, ki),
|
||||
m_summaryLabel(new QLabel),
|
||||
m_manageButton(new QPushButton)
|
||||
m_manageButton(new QPushButton),
|
||||
m_mainWidget(new QWidget)
|
||||
{
|
||||
auto *layout = new QVBoxLayout;
|
||||
layout->addWidget(m_summaryLabel);
|
||||
if (Utils::HostOsInfo::isWindowsHost())
|
||||
initMSVCOutputSwitch(layout);
|
||||
|
||||
m_mainWidget->setLayout(layout);
|
||||
|
||||
refresh();
|
||||
m_manageButton->setText(tr("Change..."));
|
||||
connect(m_manageButton, &QAbstractButton::clicked,
|
||||
@@ -422,7 +431,7 @@ KitEnvironmentConfigWidget::KitEnvironmentConfigWidget(Kit *workingCopy, const K
|
||||
|
||||
QWidget *KitEnvironmentConfigWidget::mainWidget() const
|
||||
{
|
||||
return m_summaryLabel;
|
||||
return m_mainWidget;
|
||||
}
|
||||
|
||||
QString KitEnvironmentConfigWidget::displayName() const
|
||||
@@ -452,6 +461,15 @@ void KitEnvironmentConfigWidget::makeReadOnly()
|
||||
QList<Utils::EnvironmentItem> KitEnvironmentConfigWidget::currentEnvironment() const
|
||||
{
|
||||
QList<Utils::EnvironmentItem> changes = EnvironmentKitInformation::environmentChanges(m_kit);
|
||||
|
||||
if (Utils::HostOsInfo::isWindowsHost()) {
|
||||
const Utils::EnvironmentItem forceMSVCEnglishItem("VSLANG", "1033");
|
||||
if (changes.indexOf(forceMSVCEnglishItem) >= 0) {
|
||||
m_vslangCheckbox->setCheckState(Qt::Checked);
|
||||
changes.removeAll(forceMSVCEnglishItem);
|
||||
}
|
||||
}
|
||||
|
||||
Utils::sort(changes, [](const Utils::EnvironmentItem &lhs, const Utils::EnvironmentItem &rhs)
|
||||
{ return QString::localeAwareCompare(lhs.name, rhs.name) < 0; });
|
||||
return changes;
|
||||
@@ -464,7 +482,7 @@ void KitEnvironmentConfigWidget::editEnvironmentChanges()
|
||||
Utils::EnvironmentDialog::Polisher polisher = [expander](QWidget *w) {
|
||||
Core::VariableChooser::addSupportForChildWidgets(w, expander);
|
||||
};
|
||||
const QList<Utils::EnvironmentItem>
|
||||
QList<Utils::EnvironmentItem>
|
||||
changes = Utils::EnvironmentDialog::getEnvironmentItems(&ok,
|
||||
m_summaryLabel,
|
||||
currentEnvironment(),
|
||||
@@ -473,6 +491,12 @@ void KitEnvironmentConfigWidget::editEnvironmentChanges()
|
||||
if (!ok)
|
||||
return;
|
||||
|
||||
if (Utils::HostOsInfo::isWindowsHost()) {
|
||||
const Utils::EnvironmentItem forceMSVCEnglishItem("VSLANG", "1033");
|
||||
if (m_vslangCheckbox->isChecked() && changes.indexOf(forceMSVCEnglishItem) < 0)
|
||||
changes.append(forceMSVCEnglishItem);
|
||||
}
|
||||
|
||||
EnvironmentKitInformation::setEnvironmentChanges(m_kit, changes);
|
||||
}
|
||||
|
||||
@@ -481,5 +505,21 @@ QWidget *KitEnvironmentConfigWidget::buttonWidget() const
|
||||
return m_manageButton;
|
||||
}
|
||||
|
||||
void KitEnvironmentConfigWidget::initMSVCOutputSwitch(QVBoxLayout *layout)
|
||||
{
|
||||
m_vslangCheckbox = new QCheckBox(tr("Force English MSVC compiler output (VSLANG=1033)"));
|
||||
layout->addWidget(m_vslangCheckbox);
|
||||
connect(m_vslangCheckbox, &QCheckBox::toggled, this, [this](bool checked) {
|
||||
QList<Utils::EnvironmentItem> changes
|
||||
= EnvironmentKitInformation::environmentChanges(m_kit);
|
||||
const Utils::EnvironmentItem forceMSVCEnglishItem("VSLANG", "1033");
|
||||
if (!checked && changes.indexOf(forceMSVCEnglishItem) >= 0)
|
||||
changes.removeAll(forceMSVCEnglishItem);
|
||||
if (checked && changes.indexOf(forceMSVCEnglishItem) < 0)
|
||||
changes.append(forceMSVCEnglishItem);
|
||||
EnvironmentKitInformation::setEnvironmentChanges(m_kit, changes);
|
||||
});
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace ProjectExplorer
|
||||
|
@@ -33,10 +33,12 @@
|
||||
#include <utils/environment.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QCheckBox;
|
||||
class QComboBox;
|
||||
class QLabel;
|
||||
class QPlainTextEdit;
|
||||
class QPushButton;
|
||||
class QVBoxLayout;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
namespace Utils { class PathChooser; }
|
||||
@@ -182,8 +184,12 @@ private:
|
||||
void editEnvironmentChanges();
|
||||
QList<Utils::EnvironmentItem> currentEnvironment() const;
|
||||
|
||||
void initMSVCOutputSwitch(QVBoxLayout *layout);
|
||||
|
||||
QLabel *m_summaryLabel;
|
||||
QPushButton *m_manageButton;
|
||||
QCheckBox *m_vslangCheckbox;
|
||||
QWidget *m_mainWidget;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
|
Reference in New Issue
Block a user