summaryrefslogtreecommitdiff
path: root/src/plugins/mcusupport/mcusupportoptionspage.cpp
diff options
context:
space:
mode:
authorEike Ziller <eike.ziller@qt.io>2020-05-15 14:49:11 +0200
committerEike Ziller <eike.ziller@qt.io>2020-05-15 14:49:11 +0200
commit52b7ec058b4cd18b1da3944c1e69a583a56aba63 (patch)
tree63a641735dee9e94363c16a6b9833f5e2ea8beb8 /src/plugins/mcusupport/mcusupportoptionspage.cpp
parent7414a47825895ac8a779911e3d641d782686b6c9 (diff)
parent921b56cd468b14f322cbb9e9441f1e32326b0b46 (diff)
downloadqt-creator-52b7ec058b4cd18b1da3944c1e69a583a56aba63.tar.gz
Merge remote-tracking branch 'origin/4.12'
Conflicts: src/plugins/mcusupport/mcusupportsdk.cpp Change-Id: I1583fa81adc0218ad4657baa347c08e9e29f88e6
Diffstat (limited to 'src/plugins/mcusupport/mcusupportoptionspage.cpp')
-rw-r--r--src/plugins/mcusupport/mcusupportoptionspage.cpp64
1 files changed, 38 insertions, 26 deletions
diff --git a/src/plugins/mcusupport/mcusupportoptionspage.cpp b/src/plugins/mcusupport/mcusupportoptionspage.cpp
index a9d4ea8277..0eac2b096c 100644
--- a/src/plugins/mcusupport/mcusupportoptionspage.cpp
+++ b/src/plugins/mcusupport/mcusupportoptionspage.cpp
@@ -43,6 +43,7 @@
#include <QFormLayout>
#include <QGroupBox>
#include <QLabel>
+#include <QPushButton>
#include <QVBoxLayout>
namespace McuSupport {
@@ -77,6 +78,8 @@ private:
QGroupBox *m_kitCreationGroupBox = nullptr;
Utils::InfoLabel *m_kitCreationInfoLabel = nullptr;
Utils::InfoLabel *m_statusInfoLabel = nullptr;
+ QPushButton *m_kitCreationPushButton = nullptr;
+ QPushButton *m_kitRemovalPushButton = nullptr;
};
McuSupportOptionsWidget::McuSupportOptionsWidget()
@@ -130,10 +133,24 @@ McuSupportOptionsWidget::McuSupportOptionsWidget()
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);
+ auto vLayout = new QHBoxLayout(m_kitCreationGroupBox);
+ vLayout->addWidget(m_kitCreationInfoLabel);
+ m_kitCreationPushButton = new QPushButton(tr("Create Kit"));
+ m_kitCreationPushButton->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Preferred);
+ connect(m_kitCreationPushButton, &QPushButton::clicked, this, [this] {
+ McuSupportOptions::newKit(currentMcuTarget(), m_options.qtForMCUsSdkPackage);
+ McuSupportOptions::registerQchFiles();
+ updateStatus();
+ });
+ m_kitRemovalPushButton = new QPushButton(tr("Remove Kit"));
+ m_kitRemovalPushButton->setSizePolicy(m_kitCreationPushButton->sizePolicy());
+ connect(m_kitRemovalPushButton, &QPushButton::clicked, this, [this] {
+ for (auto existingKit : McuSupportOptions::existingKits(currentMcuTarget()))
+ ProjectExplorer::KitManager::deregisterKit(existingKit);
+ updateStatus();
+ });
+ vLayout->addWidget(m_kitCreationPushButton);
+ vLayout->addWidget(m_kitRemovalPushButton);
}
mainLayout->addStretch();
@@ -162,15 +179,23 @@ void McuSupportOptionsWidget::updateStatus()
// Kit creation status
if (mcuTarget) {
const bool mcuTargetValid = mcuTarget->isValid();
- m_kitCreationInfoLabel->setType(mcuTargetValid ? Utils::InfoLabel::Ok
- : Utils::InfoLabel::NotOk);
- m_kitCreationInfoLabel->setText(
- mcuTargetValid ? QString::fromLatin1(
- "A kit <b>%1</b> for the selected target can be "
- "generated. Press Apply to generate it.")
- .arg(McuSupportOptions::kitName(mcuTarget))
- : "Provide the package paths in order to create a kit "
- "for your target.");
+ m_kitCreationPushButton->setVisible(mcuTargetValid);
+ m_kitRemovalPushButton->setVisible(mcuTargetValid);
+ if (mcuTargetValid) {
+ const bool mcuTargetKitExists = !McuSupportOptions::existingKits(mcuTarget).isEmpty();
+ m_kitCreationInfoLabel->setType(mcuTargetKitExists
+ ? Utils::InfoLabel::Information
+ : Utils::InfoLabel::Ok);
+ m_kitCreationInfoLabel->setText(mcuTargetKitExists
+ ? tr("A kit for the selected target exists.")
+ : tr("A kit for the selected target can be created."));
+ m_kitCreationPushButton->setEnabled(!mcuTargetKitExists);
+ m_kitRemovalPushButton->setEnabled(mcuTargetKitExists);
+ } else {
+ m_kitCreationInfoLabel->setType(Utils::InfoLabel::NotOk);
+ m_kitCreationInfoLabel->setText("Provide the package paths in order to create a kit "
+ "for your target.");
+ }
}
// Status label in the bottom
@@ -226,19 +251,6 @@ void McuSupportOptionsWidget::apply()
m_options.qtForMCUsSdkPackage->writeToSettings();
for (auto package : m_options.packages)
package->writeToSettings();
-
- if (!isVisible())
- return;
-
- McuSupportOptions::registerQchFiles();
-
- const McuTarget *mcuTarget = currentMcuTarget();
- if (!mcuTarget)
- return;
-
- for (auto existingKit : McuSupportOptions::existingKits(mcuTarget))
- ProjectExplorer::KitManager::deregisterKit(existingKit);
- McuSupportOptions::newKit(mcuTarget, m_options.qtForMCUsSdkPackage);
}
void McuSupportOptionsWidget::populateMcuTargetsComboBox()