forked from qt-creator/qt-creator
McuSupport: make package status enum class
Change-Id: I6d52e8e25e9934683371246ba05612f4f17450c1 Reviewed-by: Christiaan Janssen <christiaan.janssen@qt.io> Reviewed-by: Alessandro Portale <alessandro.portale@qt.io> Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
committed by
Christiaan Janssen
parent
041e8d178f
commit
7fedb56c65
@@ -37,7 +37,7 @@ class McuAbstractPackage : public QObject
|
|||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
enum Status {
|
enum class Status {
|
||||||
EmptyPath,
|
EmptyPath,
|
||||||
InvalidPath,
|
InvalidPath,
|
||||||
ValidPathInvalidPackage,
|
ValidPathInvalidPackage,
|
||||||
@@ -67,6 +67,7 @@ public:
|
|||||||
virtual void setAutomaticKitCreationEnabled(const bool enabled) = 0;
|
virtual void setAutomaticKitCreationEnabled(const bool enabled) = 0;
|
||||||
|
|
||||||
virtual QWidget *widget() = 0;
|
virtual QWidget *widget() = 0;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void changed();
|
void changed();
|
||||||
void statusChanged();
|
void statusChanged();
|
||||||
|
|||||||
@@ -38,8 +38,7 @@
|
|||||||
|
|
||||||
using namespace Utils;
|
using namespace Utils;
|
||||||
|
|
||||||
namespace McuSupport {
|
namespace McuSupport::Internal {
|
||||||
namespace Internal {
|
|
||||||
|
|
||||||
static bool automaticKitCreationFromSettings(QSettings::Scope scope = QSettings::UserScope)
|
static bool automaticKitCreationFromSettings(QSettings::Scope scope = QSettings::UserScope)
|
||||||
{
|
{
|
||||||
@@ -144,7 +143,7 @@ McuPackage::Status McuPackage::status() const
|
|||||||
|
|
||||||
bool McuPackage::validStatus() const
|
bool McuPackage::validStatus() const
|
||||||
{
|
{
|
||||||
return m_status == McuPackage::ValidPackage || m_status == McuPackage::ValidPackageMismatchedVersion;
|
return m_status == Status::ValidPackage || m_status == Status::ValidPackageMismatchedVersion;
|
||||||
}
|
}
|
||||||
|
|
||||||
const QString &McuPackage::environmentVariableName() const
|
const QString &McuPackage::environmentVariableName() const
|
||||||
@@ -219,9 +218,9 @@ void McuPackage::updateStatus()
|
|||||||
|
|
||||||
m_status = validPath ?
|
m_status = validPath ?
|
||||||
( validPackage ?
|
( validPackage ?
|
||||||
(validVersion ? ValidPackage : ValidPackageMismatchedVersion)
|
(validVersion ? Status::ValidPackage : Status::ValidPackageMismatchedVersion)
|
||||||
: ValidPathInvalidPackage )
|
: Status::ValidPathInvalidPackage )
|
||||||
: m_path.isEmpty() ? EmptyPath : InvalidPath;
|
: m_path.isEmpty() ? Status::EmptyPath : Status::InvalidPath;
|
||||||
|
|
||||||
emit statusChanged();
|
emit statusChanged();
|
||||||
}
|
}
|
||||||
@@ -229,8 +228,8 @@ void McuPackage::updateStatus()
|
|||||||
void McuPackage::updateStatusUi()
|
void McuPackage::updateStatusUi()
|
||||||
{
|
{
|
||||||
switch (m_status) {
|
switch (m_status) {
|
||||||
case ValidPackage: m_infoLabel->setType(InfoLabel::Ok); break;
|
case Status::ValidPackage: m_infoLabel->setType(InfoLabel::Ok); break;
|
||||||
case ValidPackageMismatchedVersion: m_infoLabel->setType(InfoLabel::Warning); break;
|
case Status::ValidPackageMismatchedVersion: m_infoLabel->setType(InfoLabel::Warning); break;
|
||||||
default: m_infoLabel->setType(InfoLabel::NotOk); break;
|
default: m_infoLabel->setType(InfoLabel::NotOk); break;
|
||||||
}
|
}
|
||||||
m_infoLabel->setText(statusText());
|
m_infoLabel->setText(statusText());
|
||||||
@@ -250,7 +249,7 @@ QString McuPackage::statusText() const
|
|||||||
|
|
||||||
QString response;
|
QString response;
|
||||||
switch (m_status) {
|
switch (m_status) {
|
||||||
case ValidPackage:
|
case Status::ValidPackage:
|
||||||
response = m_detectionPath.isEmpty()
|
response = m_detectionPath.isEmpty()
|
||||||
? ( m_detectedVersion.isEmpty()
|
? ( m_detectedVersion.isEmpty()
|
||||||
? tr("Path %1 exists.").arg(displayPackagePath)
|
? tr("Path %1 exists.").arg(displayPackagePath)
|
||||||
@@ -259,7 +258,7 @@ QString McuPackage::statusText() const
|
|||||||
: tr("Path %1 is valid, %2 was found.")
|
: tr("Path %1 is valid, %2 was found.")
|
||||||
.arg(displayPackagePath, displayDetectedPath);
|
.arg(displayPackagePath, displayDetectedPath);
|
||||||
break;
|
break;
|
||||||
case ValidPackageMismatchedVersion: {
|
case Status::ValidPackageMismatchedVersion: {
|
||||||
const QString versionWarning = m_versions.size() == 1 ?
|
const QString versionWarning = m_versions.size() == 1 ?
|
||||||
tr("but only version %1 is supported").arg(m_versions.first()) :
|
tr("but only version %1 is supported").arg(m_versions.first()) :
|
||||||
tr("but only versions %1 are supported").arg(displayVersions);
|
tr("but only versions %1 are supported").arg(displayVersions);
|
||||||
@@ -267,14 +266,14 @@ QString McuPackage::statusText() const
|
|||||||
.arg(displayPackagePath, displayDetectedPath, versionWarning);
|
.arg(displayPackagePath, displayDetectedPath, versionWarning);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ValidPathInvalidPackage:
|
case Status::ValidPathInvalidPackage:
|
||||||
response = tr("Path %1 exists, but does not contain %2.")
|
response = tr("Path %1 exists, but does not contain %2.")
|
||||||
.arg(displayPackagePath, displayRequiredPath);
|
.arg(displayPackagePath, displayRequiredPath);
|
||||||
break;
|
break;
|
||||||
case InvalidPath:
|
case Status::InvalidPath:
|
||||||
response = tr("Path %1 does not exist.").arg(displayPackagePath);
|
response = tr("Path %1 does not exist.").arg(displayPackagePath);
|
||||||
break;
|
break;
|
||||||
case EmptyPath:
|
case Status::EmptyPath:
|
||||||
response = m_detectionPath.isEmpty()
|
response = m_detectionPath.isEmpty()
|
||||||
? tr("Path is empty.")
|
? tr("Path is empty.")
|
||||||
: tr("Path is empty, %1 not found.")
|
: tr("Path is empty, %1 not found.")
|
||||||
@@ -305,5 +304,4 @@ bool McuToolChainPackage::isDesktopToolchain() const
|
|||||||
return m_type == Type::MSVC || m_type == Type::GCC;
|
return m_type == Type::MSVC || m_type == Type::GCC;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace McuSupport::Internal
|
||||||
} // namespace McuSupport
|
|
||||||
|
|||||||
@@ -305,7 +305,7 @@ void McuTarget::printPackageProblems() const
|
|||||||
package->label(),
|
package->label(),
|
||||||
package->statusText()),
|
package->statusText()),
|
||||||
true);
|
true);
|
||||||
if (package->status() == McuAbstractPackage::ValidPackageMismatchedVersion)
|
if (package->status() == McuAbstractPackage::Status::ValidPackageMismatchedVersion)
|
||||||
printMessage(tr("Warning creating kit for target %1, package %2: %3").arg(
|
printMessage(tr("Warning creating kit for target %1, package %2: %3").arg(
|
||||||
McuSupportOptions::kitName(this),
|
McuSupportOptions::kitName(this),
|
||||||
package->label(),
|
package->label(),
|
||||||
@@ -860,7 +860,7 @@ void McuSupportOptions::createAutomaticKits()
|
|||||||
qtForMCUsPackage->updateStatus();
|
qtForMCUsPackage->updateStatus();
|
||||||
if (!qtForMCUsPackage->validStatus()) {
|
if (!qtForMCUsPackage->validStatus()) {
|
||||||
switch (qtForMCUsPackage->status()) {
|
switch (qtForMCUsPackage->status()) {
|
||||||
case McuAbstractPackage::ValidPathInvalidPackage: {
|
case McuAbstractPackage::Status::ValidPathInvalidPackage: {
|
||||||
const QString displayPath = FilePath::fromString(qtForMCUsPackage->detectionPath())
|
const QString displayPath = FilePath::fromString(qtForMCUsPackage->detectionPath())
|
||||||
.toUserOutput();
|
.toUserOutput();
|
||||||
printMessage(tr("Path %1 exists, but does not contain %2.")
|
printMessage(tr("Path %1 exists, but does not contain %2.")
|
||||||
@@ -868,13 +868,13 @@ void McuSupportOptions::createAutomaticKits()
|
|||||||
true);
|
true);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case McuAbstractPackage::InvalidPath: {
|
case McuAbstractPackage::Status::InvalidPath: {
|
||||||
printMessage(tr("Path %1 does not exist. Add the path in Tools > Options > Devices > MCU.")
|
printMessage(tr("Path %1 does not exist. Add the path in Tools > Options > Devices > MCU.")
|
||||||
.arg(qtForMCUsPackage->path().toUserOutput()),
|
.arg(qtForMCUsPackage->path().toUserOutput()),
|
||||||
true);
|
true);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case McuAbstractPackage::EmptyPath: {
|
case McuAbstractPackage::Status::EmptyPath: {
|
||||||
printMessage(tr("Missing %1. Add the path in Tools > Options > Devices > MCU.")
|
printMessage(tr("Missing %1. Add the path in Tools > Options > Devices > MCU.")
|
||||||
.arg(qtForMCUsPackage->detectionPath()),
|
.arg(qtForMCUsPackage->detectionPath()),
|
||||||
true);
|
true);
|
||||||
|
|||||||
Reference in New Issue
Block a user