forked from qt-creator/qt-creator
McuSupport: Use Utils::InfoLabel in McuSupportOptionsPage
Task-number: QTCREATORBUG-23346 Change-Id: I75cd156db4715b3d55b11e665f46a2f31bbb6b1a Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -39,6 +39,7 @@
|
||||
#include <projectexplorer/devicesupport/devicemanager.h>
|
||||
#include <utils/algorithm.h>
|
||||
#include <utils/fileutils.h>
|
||||
#include <utils/infolabel.h>
|
||||
#include <utils/pathchooser.h>
|
||||
#include <utils/qtcassert.h>
|
||||
#include <utils/utilsicons.h>
|
||||
@@ -93,12 +94,7 @@ QWidget *McuPackage::widget()
|
||||
|
||||
auto layout = new QGridLayout(m_widget);
|
||||
layout->setContentsMargins(0, 0, 0, 0);
|
||||
m_statusIcon = new QLabel;
|
||||
m_statusIcon->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::MinimumExpanding);
|
||||
m_statusIcon->setAlignment(Qt::AlignTop);
|
||||
m_statusLabel = new QLabel;
|
||||
m_statusLabel->setWordWrap(true);
|
||||
m_statusLabel->setAlignment(Qt::AlignTop | Qt::AlignLeft);
|
||||
m_infoLabel = new Utils::InfoLabel();
|
||||
|
||||
if (!m_downloadUrl.isEmpty()) {
|
||||
auto downLoadButton = new QToolButton;
|
||||
@@ -111,8 +107,7 @@ QWidget *McuPackage::widget()
|
||||
}
|
||||
|
||||
layout->addWidget(m_fileChooser, 0, 0, 1, 2);
|
||||
layout->addWidget(m_statusIcon, 1, 0);
|
||||
layout->addWidget(m_statusLabel, 1, 1, 1, -1);
|
||||
layout->addWidget(m_infoLabel, 1, 0, 1, -1);
|
||||
|
||||
m_fileChooser->setPath(m_path);
|
||||
|
||||
@@ -182,9 +177,8 @@ void McuPackage::updateStatus()
|
||||
|
||||
m_status = validPath ? (validPackage ? ValidPackage : ValidPathInvalidPackage) : InvalidPath;
|
||||
|
||||
static const QPixmap okIcon = Utils::Icons::OK.pixmap();
|
||||
static const QPixmap notOkIcon = Utils::Icons::BROKEN.pixmap();
|
||||
m_statusIcon->setPixmap(m_status == ValidPackage ? okIcon : notOkIcon);
|
||||
m_infoLabel->setType(m_status == ValidPackage ? Utils::InfoLabel::Ok
|
||||
: Utils::InfoLabel::NotOk);
|
||||
|
||||
QString statusText;
|
||||
switch (m_status) {
|
||||
@@ -198,7 +192,7 @@ void McuPackage::updateStatus()
|
||||
statusText = tr("Path does not exist.");
|
||||
break;
|
||||
}
|
||||
m_statusLabel->setText(statusText);
|
||||
m_infoLabel->setText(statusText);
|
||||
}
|
||||
|
||||
McuTarget::McuTarget(const QString &vendor, const QString &model,
|
||||
|
||||
@@ -29,10 +29,10 @@
|
||||
#include <QVector>
|
||||
|
||||
QT_FORWARD_DECLARE_CLASS(QWidget)
|
||||
QT_FORWARD_DECLARE_CLASS(QLabel)
|
||||
|
||||
namespace Utils {
|
||||
class PathChooser;
|
||||
class InfoLabel;
|
||||
}
|
||||
|
||||
namespace ProjectExplorer {
|
||||
@@ -79,8 +79,7 @@ private:
|
||||
|
||||
QWidget *m_widget = nullptr;
|
||||
Utils::PathChooser *m_fileChooser = nullptr;
|
||||
QLabel *m_statusIcon = nullptr;
|
||||
QLabel *m_statusLabel = nullptr;
|
||||
Utils::InfoLabel *m_infoLabel = nullptr;
|
||||
|
||||
const QString m_label;
|
||||
const QString m_defaultPath;
|
||||
|
||||
@@ -33,6 +33,7 @@
|
||||
#include <projectexplorer/kitmanager.h>
|
||||
#include <projectexplorer/projectexplorerconstants.h>
|
||||
#include <utils/algorithm.h>
|
||||
#include <utils/infolabel.h>
|
||||
#include <utils/qtcassert.h>
|
||||
#include <utils/utilsicons.h>
|
||||
|
||||
@@ -70,8 +71,7 @@ private:
|
||||
QMap <McuPackage*, QWidget*> m_packageWidgets;
|
||||
QMap <McuTarget*, QWidget*> m_mcuTargetPacketWidgets;
|
||||
QFormLayout *m_packagesLayout = nullptr;
|
||||
QLabel *m_statusIcon = nullptr;
|
||||
QLabel *m_statusLabel = nullptr;
|
||||
Utils::InfoLabel *m_infoLabel = nullptr;
|
||||
QComboBox *m_mcuTargetComboBox = nullptr;
|
||||
};
|
||||
|
||||
@@ -99,23 +99,18 @@ McuSupportOptionsWidget::McuSupportOptionsWidget(const McuSupportOptions *option
|
||||
m_packagesLayout = new QFormLayout;
|
||||
m_packagesGroupBox->setLayout(m_packagesLayout);
|
||||
|
||||
m_statusIcon = new QLabel;
|
||||
m_statusIcon->setAlignment(Qt::AlignBottom);
|
||||
m_statusLabel = new QLabel;
|
||||
m_statusLabel->setWordWrap(true);
|
||||
m_statusLabel->setAlignment(Qt::AlignBottom | Qt::AlignLeft);
|
||||
m_statusLabel->setOpenExternalLinks(false);
|
||||
auto statusWidget = new QWidget;
|
||||
auto statusLayout = new QHBoxLayout(statusWidget);
|
||||
statusLayout->setMargin(0);
|
||||
statusLayout->addWidget(m_statusIcon, 0);
|
||||
statusLayout->addWidget(m_statusLabel, 2);
|
||||
mainLayout->addWidget(statusWidget, 2);
|
||||
mainLayout->addStretch();
|
||||
|
||||
m_infoLabel = new Utils::InfoLabel;
|
||||
m_infoLabel->setOpenExternalLinks(false);
|
||||
m_infoLabel->setElideMode(Qt::ElideNone);
|
||||
m_infoLabel->setWordWrap(true);
|
||||
mainLayout->addWidget(m_infoLabel);
|
||||
|
||||
connect(options, &McuSupportOptions::changed, this, &McuSupportOptionsWidget::updateStatus);
|
||||
connect(m_mcuTargetComboBox, &QComboBox::currentTextChanged,
|
||||
this, &McuSupportOptionsWidget::showMcuTargetPackages);
|
||||
connect(m_statusLabel, &QLabel::linkActivated, this, []{
|
||||
connect(m_infoLabel, &QLabel::linkActivated, this, []{
|
||||
Core::ICore::showOptionsDialog(
|
||||
CMakeProjectManager::Constants::CMAKE_SETTINGSPAGE_ID,
|
||||
Core::ICore::mainWindow());
|
||||
@@ -130,9 +125,8 @@ void McuSupportOptionsWidget::updateStatus()
|
||||
if (!mcuTarget)
|
||||
return;
|
||||
|
||||
static const QPixmap okIcon = Utils::Icons::OK.pixmap();
|
||||
static const QPixmap notOkIcon = Utils::Icons::BROKEN.pixmap();
|
||||
m_statusIcon->setPixmap(cMakeAvailable() && mcuTarget->isValid() ? okIcon : notOkIcon);
|
||||
m_infoLabel->setType(cMakeAvailable() && mcuTarget->isValid()
|
||||
? Utils::InfoLabel::Ok : Utils::InfoLabel::NotOk);
|
||||
|
||||
QStringList errorStrings;
|
||||
if (!mcuTarget->isValid())
|
||||
@@ -141,7 +135,7 @@ void McuSupportOptionsWidget::updateStatus()
|
||||
errorStrings << "No CMake tool was detected. Add a CMake tool in the "
|
||||
"<a href=\"cmake\">CMake options</a> and press Apply.";
|
||||
|
||||
m_statusLabel->setText(errorStrings.isEmpty()
|
||||
m_infoLabel->setText(errorStrings.isEmpty()
|
||||
? QString::fromLatin1("A kit <b>%1</b> for the selected target can be generated. "
|
||||
"Press Apply to generate it.").arg(m_options->kitName(
|
||||
mcuTarget))
|
||||
|
||||
Reference in New Issue
Block a user