forked from qt-creator/qt-creator
McuSupport: Make hardcoded target list "semi data-driven"
This change pushes the hard-coded list a bit towards a "data-driven" approach. That way, the planned switch to the .json files based apporach (see UL-2012) becomes less of a change. Some target entries are added to match the current target list in Qt for MCUs packages. If we don't manage to get the .json-based target listing in place, this could even serve as fall-back. Task-number: UL-2012 Change-Id: If39e5d581ac19468b6f52ed221ec2d39bfab9f80 Reviewed-by: hjk <hjk@qt.io> Reviewed-by: Marco Bubke <marco.bubke@qt.io>
This commit is contained in:
@@ -62,6 +62,7 @@ public:
|
||||
private:
|
||||
void apply() final;
|
||||
|
||||
void populateMcuTargetsComboBox();
|
||||
void showEvent(QShowEvent *event) final;
|
||||
|
||||
QString m_armGccPath;
|
||||
@@ -108,14 +109,12 @@ McuSupportOptionsWidget::McuSupportOptionsWidget()
|
||||
m_mcuTargetsGroupBox->setFlat(true);
|
||||
mainLayout->addWidget(m_mcuTargetsGroupBox);
|
||||
m_mcuTargetsComboBox = new QComboBox;
|
||||
m_mcuTargetsComboBox->addItems(
|
||||
Utils::transform<QStringList>(m_options.mcuTargets, [this](McuTarget *t){
|
||||
return m_options.kitName(t);
|
||||
}));
|
||||
auto layout = new QVBoxLayout(m_mcuTargetsGroupBox);
|
||||
layout->addWidget(m_mcuTargetsComboBox);
|
||||
connect(m_mcuTargetsComboBox, &QComboBox::currentTextChanged,
|
||||
this, &McuSupportOptionsWidget::showMcuTargetPackages);
|
||||
connect(m_options.qtForMCUsSdkPackage, &McuPackage::changed,
|
||||
this, &McuSupportOptionsWidget::populateMcuTargetsComboBox);
|
||||
}
|
||||
|
||||
{
|
||||
@@ -147,15 +146,13 @@ McuSupportOptionsWidget::McuSupportOptionsWidget()
|
||||
void McuSupportOptionsWidget::updateStatus()
|
||||
{
|
||||
const McuTarget *mcuTarget = currentMcuTarget();
|
||||
if (!mcuTarget)
|
||||
return;
|
||||
|
||||
const bool cMakeAvailable = !CMakeProjectManager::CMakeToolManager::cmakeTools().isEmpty();
|
||||
|
||||
// Page elements
|
||||
{
|
||||
m_qtForMCUsSdkGroupBox->setVisible(cMakeAvailable);
|
||||
const bool ready = cMakeAvailable &&
|
||||
const bool ready = cMakeAvailable && mcuTarget &&
|
||||
m_options.qtForMCUsSdkPackage->status() == McuPackage::ValidPackage;
|
||||
m_mcuTargetsGroupBox->setVisible(ready);
|
||||
m_packagesGroupBox->setVisible(ready && !mcuTarget->packages().isEmpty());
|
||||
@@ -163,7 +160,7 @@ void McuSupportOptionsWidget::updateStatus()
|
||||
}
|
||||
|
||||
// Kit creation status
|
||||
{
|
||||
if (mcuTarget) {
|
||||
const bool mcuTargetValid = mcuTarget->isValid();
|
||||
m_kitCreationInfoLabel->setType(mcuTargetValid ? Utils::InfoLabel::Ok
|
||||
: Utils::InfoLabel::NotOk);
|
||||
@@ -213,13 +210,15 @@ void McuSupportOptionsWidget::showMcuTargetPackages()
|
||||
McuTarget *McuSupportOptionsWidget::currentMcuTarget() const
|
||||
{
|
||||
const int mcuTargetIndex = m_mcuTargetsComboBox->currentIndex();
|
||||
return m_options.mcuTargets.isEmpty() ? nullptr : m_options.mcuTargets.at(mcuTargetIndex);
|
||||
return (mcuTargetIndex == -1 || m_options.mcuTargets.isEmpty())
|
||||
? nullptr
|
||||
: m_options.mcuTargets.at(mcuTargetIndex);
|
||||
}
|
||||
|
||||
void McuSupportOptionsWidget::showEvent(QShowEvent *event)
|
||||
{
|
||||
Q_UNUSED(event)
|
||||
updateStatus();
|
||||
populateMcuTargetsComboBox();
|
||||
}
|
||||
|
||||
void McuSupportOptionsWidget::apply()
|
||||
@@ -241,6 +240,17 @@ void McuSupportOptionsWidget::apply()
|
||||
m_options.newKit(mcuTarget);
|
||||
}
|
||||
|
||||
void McuSupportOptionsWidget::populateMcuTargetsComboBox()
|
||||
{
|
||||
m_options.populatePackagesAndTargets();
|
||||
m_mcuTargetsComboBox->clear();
|
||||
m_mcuTargetsComboBox->addItems(
|
||||
Utils::transform<QStringList>(m_options.mcuTargets, [this](McuTarget *t){
|
||||
return m_options.kitName(t);
|
||||
}));
|
||||
updateStatus();
|
||||
}
|
||||
|
||||
McuSupportOptionsPage::McuSupportOptionsPage()
|
||||
{
|
||||
setId(Core::Id(Constants::SETTINGS_ID));
|
||||
|
||||
Reference in New Issue
Block a user