McuSupport: Introduce a separate status label

The status label will notify about missing CMake, etc.

The Kit Creation info label should only inform about the kit options for
the currently selected target.

Change-Id: I8786fe287f5fa28b46bb0e6d2d88517ec2593e05
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
This commit is contained in:
Alessandro Portale
2020-03-10 06:58:37 +01:00
parent 0702f65a52
commit 4e4b8965a9

View File

@@ -48,11 +48,6 @@
namespace McuSupport { namespace McuSupport {
namespace Internal { namespace Internal {
static bool cMakeAvailable()
{
return !CMakeProjectManager::CMakeToolManager::cmakeTools().isEmpty();
}
class McuSupportOptionsWidget : public Core::IOptionsPageWidget class McuSupportOptionsWidget : public Core::IOptionsPageWidget
{ {
Q_DECLARE_TR_FUNCTIONS(McuSupport::Internal::McuSupportOptionsWidget) Q_DECLARE_TR_FUNCTIONS(McuSupport::Internal::McuSupportOptionsWidget)
@@ -80,56 +75,71 @@ private:
QComboBox *m_mcuTargetsComboBox = nullptr; QComboBox *m_mcuTargetsComboBox = nullptr;
QGroupBox *m_kitCreationGroupBox = nullptr; QGroupBox *m_kitCreationGroupBox = nullptr;
Utils::InfoLabel *m_kitCreationInfoLabel = nullptr; Utils::InfoLabel *m_kitCreationInfoLabel = nullptr;
Utils::InfoLabel *m_statusInfoLabel = nullptr;
}; };
McuSupportOptionsWidget::McuSupportOptionsWidget() McuSupportOptionsWidget::McuSupportOptionsWidget()
{ {
auto mainLayout = new QVBoxLayout(this); auto mainLayout = new QVBoxLayout(this);
{
m_statusInfoLabel = new Utils::InfoLabel;
m_statusInfoLabel->setElideMode(Qt::ElideNone);
m_statusInfoLabel->setOpenExternalLinks(false);
mainLayout->addWidget(m_statusInfoLabel);
connect(m_statusInfoLabel, &QLabel::linkActivated, this, []{
Core::ICore::showOptionsDialog(
CMakeProjectManager::Constants::CMAKE_SETTINGSPAGE_ID,
Core::ICore::mainWindow());
});
}
{
m_qtForMCUsSdkGroupBox = new QGroupBox(m_options.qtForMCUsSdkPackage->label()); m_qtForMCUsSdkGroupBox = new QGroupBox(m_options.qtForMCUsSdkPackage->label());
m_qtForMCUsSdkGroupBox->setFlat(true); m_qtForMCUsSdkGroupBox->setFlat(true);
auto qtForMCUsSdkGroupBoxLayout = new QVBoxLayout(m_qtForMCUsSdkGroupBox); auto layout = new QVBoxLayout(m_qtForMCUsSdkGroupBox);
qtForMCUsSdkGroupBoxLayout->addWidget(m_options.qtForMCUsSdkPackage->widget()); layout->addWidget(m_options.qtForMCUsSdkPackage->widget());
mainLayout->addWidget(m_qtForMCUsSdkGroupBox); mainLayout->addWidget(m_qtForMCUsSdkGroupBox);
}
{
m_mcuTargetsGroupBox = new QGroupBox(tr("Targets supported by the %1") m_mcuTargetsGroupBox = new QGroupBox(tr("Targets supported by the %1")
.arg(m_qtForMCUsSdkGroupBox->title())); .arg(m_qtForMCUsSdkGroupBox->title()));
m_mcuTargetsGroupBox->setFlat(true); m_mcuTargetsGroupBox->setFlat(true);
mainLayout->addWidget(m_mcuTargetsGroupBox); mainLayout->addWidget(m_mcuTargetsGroupBox);
auto qtForMCUsTargetsGroupBoxLayout = new QVBoxLayout(m_mcuTargetsGroupBox);
m_mcuTargetsComboBox = new QComboBox; m_mcuTargetsComboBox = new QComboBox;
m_mcuTargetsComboBox->addItems( m_mcuTargetsComboBox->addItems(
Utils::transform<QStringList>(m_options.mcuTargets, [this](McuTarget *t){ Utils::transform<QStringList>(m_options.mcuTargets, [this](McuTarget *t){
return m_options.kitName(t); return m_options.kitName(t);
})); }));
qtForMCUsTargetsGroupBoxLayout->addWidget(m_mcuTargetsComboBox); auto layout = new QVBoxLayout(m_mcuTargetsGroupBox);
layout->addWidget(m_mcuTargetsComboBox);
connect(m_mcuTargetsComboBox, &QComboBox::currentTextChanged,
this, &McuSupportOptionsWidget::showMcuTargetPackages);
}
{
m_packagesGroupBox = new QGroupBox(tr("Requirements")); m_packagesGroupBox = new QGroupBox(tr("Requirements"));
m_packagesGroupBox->setFlat(true); m_packagesGroupBox->setFlat(true);
mainLayout->addWidget(m_packagesGroupBox); mainLayout->addWidget(m_packagesGroupBox);
m_packagesLayout = new QFormLayout; m_packagesLayout = new QFormLayout;
m_packagesGroupBox->setLayout(m_packagesLayout); m_packagesGroupBox->setLayout(m_packagesLayout);
}
{
m_kitCreationGroupBox = new QGroupBox(tr("Create a Kit")); m_kitCreationGroupBox = new QGroupBox(tr("Create a Kit"));
m_kitCreationGroupBox->setFlat(true); m_kitCreationGroupBox->setFlat(true);
mainLayout->addWidget(m_kitCreationGroupBox); mainLayout->addWidget(m_kitCreationGroupBox);
auto kitCreationGroupBoxLayout = new QVBoxLayout(m_kitCreationGroupBox);
m_kitCreationInfoLabel = new Utils::InfoLabel; m_kitCreationInfoLabel = new Utils::InfoLabel;
m_kitCreationInfoLabel->setOpenExternalLinks(false);
m_kitCreationInfoLabel->setElideMode(Qt::ElideNone); m_kitCreationInfoLabel->setElideMode(Qt::ElideNone);
m_kitCreationInfoLabel->setWordWrap(true); m_kitCreationInfoLabel->setWordWrap(true);
kitCreationGroupBoxLayout->addWidget(m_kitCreationInfoLabel); auto layout = new QVBoxLayout(m_kitCreationGroupBox);
layout->addWidget(m_kitCreationInfoLabel);
}
mainLayout->addStretch(); mainLayout->addStretch();
connect(&m_options, &McuSupportOptions::changed, this, &McuSupportOptionsWidget::updateStatus); connect(&m_options, &McuSupportOptions::changed, this, &McuSupportOptionsWidget::updateStatus);
connect(m_mcuTargetsComboBox, &QComboBox::currentTextChanged,
this, &McuSupportOptionsWidget::showMcuTargetPackages);
connect(m_kitCreationInfoLabel, &QLabel::linkActivated, this, []{
Core::ICore::showOptionsDialog(
CMakeProjectManager::Constants::CMAKE_SETTINGSPAGE_ID,
Core::ICore::mainWindow());
});
showMcuTargetPackages(); showMcuTargetPackages();
} }
@@ -140,27 +150,41 @@ void McuSupportOptionsWidget::updateStatus()
if (!mcuTarget) if (!mcuTarget)
return; return;
m_kitCreationInfoLabel->setType(cMakeAvailable() && mcuTarget->isValid() const bool cMakeAvailable = !CMakeProjectManager::CMakeToolManager::cmakeTools().isEmpty();
? Utils::InfoLabel::Ok : Utils::InfoLabel::NotOk);
const bool sdkValid = m_options.qtForMCUsSdkPackage->status() == McuPackage::ValidPackage; // Page elements
m_mcuTargetsGroupBox->setVisible(sdkValid); {
m_packagesGroupBox->setVisible(sdkValid && !mcuTarget->packages().isEmpty()); m_qtForMCUsSdkGroupBox->setVisible(cMakeAvailable);
m_kitCreationGroupBox->setVisible(sdkValid); const bool ready = cMakeAvailable &&
m_options.qtForMCUsSdkPackage->status() == McuPackage::ValidPackage;
QStringList errorStrings; m_mcuTargetsGroupBox->setVisible(ready);
if (!mcuTarget->isValid()) m_packagesGroupBox->setVisible(ready && !mcuTarget->packages().isEmpty());
errorStrings << "Provide the package paths in order to create a kit for your target."; m_kitCreationGroupBox->setVisible(ready);
if (!cMakeAvailable()) }
errorStrings << "No CMake tool was detected. Add a CMake tool in the "
"<a href=\"cmake\">CMake options</a> and press Apply.";
// Kit creation status
{
const bool mcuTargetValid = mcuTarget->isValid();
m_kitCreationInfoLabel->setType(mcuTargetValid ? Utils::InfoLabel::Ok
: Utils::InfoLabel::NotOk);
m_kitCreationInfoLabel->setText( m_kitCreationInfoLabel->setText(
errorStrings.isEmpty() mcuTargetValid ? QString::fromLatin1(
? QString::fromLatin1("A kit <b>%1</b> for the selected target can be generated. " "A kit <b>%1</b> for the selected target can be "
"Press Apply to generate it.").arg(m_options.kitName( "generated. Press Apply to generate it.")
mcuTarget)) .arg(m_options.kitName(mcuTarget))
: errorStrings.join("<br/>")); : "Provide the package paths in order to create a kit "
"for your target.");
}
// Status label in the bottom
{
m_statusInfoLabel->setVisible(!cMakeAvailable);
if (m_statusInfoLabel->isVisible()) {
m_statusInfoLabel->setType(Utils::InfoLabel::NotOk);
m_statusInfoLabel->setText("No CMake tool was detected. Add a CMake tool in the "
"<a href=\"cmake\">CMake options</a> and press Apply.");
}
}
} }
void McuSupportOptionsWidget::showMcuTargetPackages() void McuSupportOptionsWidget::showMcuTargetPackages()
@@ -205,7 +229,7 @@ void McuSupportOptionsWidget::apply()
QTC_ASSERT(m_options.qtForMCUsSdkPackage, return); QTC_ASSERT(m_options.qtForMCUsSdkPackage, return);
if (!isVisible() || !cMakeAvailable()) if (!isVisible())
return; return;
const McuTarget *mcuTarget = currentMcuTarget(); const McuTarget *mcuTarget = currentMcuTarget();