forked from qt-creator/qt-creator
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:
@@ -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_qtForMCUsSdkGroupBox = new QGroupBox(m_options.qtForMCUsSdkPackage->label());
|
{
|
||||||
m_qtForMCUsSdkGroupBox->setFlat(true);
|
m_statusInfoLabel = new Utils::InfoLabel;
|
||||||
auto qtForMCUsSdkGroupBoxLayout = new QVBoxLayout(m_qtForMCUsSdkGroupBox);
|
m_statusInfoLabel->setElideMode(Qt::ElideNone);
|
||||||
qtForMCUsSdkGroupBoxLayout->addWidget(m_options.qtForMCUsSdkPackage->widget());
|
m_statusInfoLabel->setOpenExternalLinks(false);
|
||||||
mainLayout->addWidget(m_qtForMCUsSdkGroupBox);
|
mainLayout->addWidget(m_statusInfoLabel);
|
||||||
|
connect(m_statusInfoLabel, &QLabel::linkActivated, this, []{
|
||||||
|
Core::ICore::showOptionsDialog(
|
||||||
|
CMakeProjectManager::Constants::CMAKE_SETTINGSPAGE_ID,
|
||||||
|
Core::ICore::mainWindow());
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
m_mcuTargetsGroupBox = new QGroupBox(tr("Targets supported by the %1")
|
{
|
||||||
.arg(m_qtForMCUsSdkGroupBox->title()));
|
m_qtForMCUsSdkGroupBox = new QGroupBox(m_options.qtForMCUsSdkPackage->label());
|
||||||
m_mcuTargetsGroupBox->setFlat(true);
|
m_qtForMCUsSdkGroupBox->setFlat(true);
|
||||||
mainLayout->addWidget(m_mcuTargetsGroupBox);
|
auto layout = new QVBoxLayout(m_qtForMCUsSdkGroupBox);
|
||||||
auto qtForMCUsTargetsGroupBoxLayout = new QVBoxLayout(m_mcuTargetsGroupBox);
|
layout->addWidget(m_options.qtForMCUsSdkPackage->widget());
|
||||||
m_mcuTargetsComboBox = new QComboBox;
|
mainLayout->addWidget(m_qtForMCUsSdkGroupBox);
|
||||||
m_mcuTargetsComboBox->addItems(
|
}
|
||||||
Utils::transform<QStringList>(m_options.mcuTargets, [this](McuTarget *t){
|
|
||||||
return m_options.kitName(t);
|
|
||||||
}));
|
|
||||||
qtForMCUsTargetsGroupBoxLayout->addWidget(m_mcuTargetsComboBox);
|
|
||||||
|
|
||||||
m_packagesGroupBox = new QGroupBox(tr("Requirements"));
|
{
|
||||||
m_packagesGroupBox->setFlat(true);
|
m_mcuTargetsGroupBox = new QGroupBox(tr("Targets supported by the %1")
|
||||||
mainLayout->addWidget(m_packagesGroupBox);
|
.arg(m_qtForMCUsSdkGroupBox->title()));
|
||||||
m_packagesLayout = new QFormLayout;
|
m_mcuTargetsGroupBox->setFlat(true);
|
||||||
m_packagesGroupBox->setLayout(m_packagesLayout);
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
m_kitCreationGroupBox = new QGroupBox(tr("Create a Kit"));
|
{
|
||||||
m_kitCreationGroupBox->setFlat(true);
|
m_packagesGroupBox = new QGroupBox(tr("Requirements"));
|
||||||
mainLayout->addWidget(m_kitCreationGroupBox);
|
m_packagesGroupBox->setFlat(true);
|
||||||
auto kitCreationGroupBoxLayout = new QVBoxLayout(m_kitCreationGroupBox);
|
mainLayout->addWidget(m_packagesGroupBox);
|
||||||
m_kitCreationInfoLabel = new Utils::InfoLabel;
|
m_packagesLayout = new QFormLayout;
|
||||||
m_kitCreationInfoLabel->setOpenExternalLinks(false);
|
m_packagesGroupBox->setLayout(m_packagesLayout);
|
||||||
m_kitCreationInfoLabel->setElideMode(Qt::ElideNone);
|
}
|
||||||
m_kitCreationInfoLabel->setWordWrap(true);
|
|
||||||
kitCreationGroupBoxLayout->addWidget(m_kitCreationInfoLabel);
|
{
|
||||||
|
m_kitCreationGroupBox = new QGroupBox(tr("Create a Kit"));
|
||||||
|
m_kitCreationGroupBox->setFlat(true);
|
||||||
|
mainLayout->addWidget(m_kitCreationGroupBox);
|
||||||
|
m_kitCreationInfoLabel = new Utils::InfoLabel;
|
||||||
|
m_kitCreationInfoLabel->setElideMode(Qt::ElideNone);
|
||||||
|
m_kitCreationInfoLabel->setWordWrap(true);
|
||||||
|
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;
|
||||||
|
m_mcuTargetsGroupBox->setVisible(ready);
|
||||||
|
m_packagesGroupBox->setVisible(ready && !mcuTarget->packages().isEmpty());
|
||||||
|
m_kitCreationGroupBox->setVisible(ready);
|
||||||
|
}
|
||||||
|
|
||||||
QStringList errorStrings;
|
// Kit creation status
|
||||||
if (!mcuTarget->isValid())
|
{
|
||||||
errorStrings << "Provide the package paths in order to create a kit for your target.";
|
const bool mcuTargetValid = mcuTarget->isValid();
|
||||||
if (!cMakeAvailable())
|
m_kitCreationInfoLabel->setType(mcuTargetValid ? Utils::InfoLabel::Ok
|
||||||
errorStrings << "No CMake tool was detected. Add a CMake tool in the "
|
: Utils::InfoLabel::NotOk);
|
||||||
"<a href=\"cmake\">CMake options</a> and press Apply.";
|
m_kitCreationInfoLabel->setText(
|
||||||
|
mcuTargetValid ? QString::fromLatin1(
|
||||||
|
"A kit <b>%1</b> for the selected target can be "
|
||||||
|
"generated. Press Apply to generate it.")
|
||||||
|
.arg(m_options.kitName(mcuTarget))
|
||||||
|
: "Provide the package paths in order to create a kit "
|
||||||
|
"for your target.");
|
||||||
|
}
|
||||||
|
|
||||||
m_kitCreationInfoLabel->setText(
|
// Status label in the bottom
|
||||||
errorStrings.isEmpty()
|
{
|
||||||
? QString::fromLatin1("A kit <b>%1</b> for the selected target can be generated. "
|
m_statusInfoLabel->setVisible(!cMakeAvailable);
|
||||||
"Press Apply to generate it.").arg(m_options.kitName(
|
if (m_statusInfoLabel->isVisible()) {
|
||||||
mcuTarget))
|
m_statusInfoLabel->setType(Utils::InfoLabel::NotOk);
|
||||||
: errorStrings.join("<br/>"));
|
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();
|
||||||
|
|||||||
Reference in New Issue
Block a user