McuSupport: Improvements with version detection

Task-number: QTCREATORBUG-25261
Change-Id: I1b378eb4a4d132b64e4c36e0a0cdafd402570785
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
This commit is contained in:
Christiaan Janssen
2021-03-04 17:07:49 +01:00
committed by christiaan.janssen
parent 08f8dd355d
commit b5781e6028
4 changed files with 46 additions and 14 deletions

View File

@@ -276,15 +276,18 @@ void McuPackage::updateStatus()
void McuPackage::updateStatusUi()
{
m_infoLabel->setType(validStatus() ? InfoLabel::Ok : InfoLabel::NotOk);
switch (m_status) {
case ValidPackage: m_infoLabel->setType(InfoLabel::Ok); break;
case ValidPackageMismatchedVersion: m_infoLabel->setType(InfoLabel::Warning); break;
default: m_infoLabel->setType(InfoLabel::NotOk); break;
}
m_infoLabel->setText(statusText());
}
QString McuPackage::statusText() const
{
const QString displayPackagePath = FilePath::fromString(m_path).toUserOutput();
const QString displayVersions = m_versions.isEmpty() ? "" :
QString(" (%1)").arg(QStringList(m_versions.toList()).join(" / "));
const QString displayVersions = QStringList(m_versions.toList()).join(" or ");
const QString displayRequiredPath = QString("%1 %2").arg(
FilePath::fromString(m_detectionPath).toUserOutput(),
displayVersions);
@@ -305,10 +308,10 @@ QString McuPackage::statusText() const
break;
case ValidPackageMismatchedVersion: {
const QString versionWarning = m_versions.size() == 1 ?
tr("version %1 is recommended").arg(m_versions.first()) :
tr("versions %1 are recommended").arg(displayVersions);
response = tr("Path %1 is valid, %2 was found, but %3.")
.arg(displayPackagePath, displayDetectedPath, versionWarning);
tr("but only version %1 is supported").arg(m_versions.first()) :
tr("but only versions %1 are supported").arg(displayVersions);
response = tr("Path %1 is valid, %2 was found, %3.")
.arg(displayPackagePath, displayDetectedPath, versionWarning);
break;
}
case ValidPathInvalidPackage:

View File

@@ -609,6 +609,7 @@ static McuTargetDescription parseDescriptionJson(const QByteArray &data)
};
}
// https://doc.qt.io/qtcreator/creator-developing-mcu.html#supported-qt-for-mcus-sdks
const QHash<QString, QString> oldSdkQtcRequiredVersion = {
{{"1.0"}, {"4.11.x"}},
{{"1.1"}, {"4.12.0 or 4.12.1"}},
@@ -622,8 +623,8 @@ bool checkDeprecatedSdkError(const Utils::FilePath &qulDir, QString &message)
if (oldSdkQtcRequiredVersion.contains(sdkDetectedVersion)) {
message = McuTarget::tr("Qt for MCUs SDK version %1 detected, "
"only supported by QtCreator version %2. "
"SDK version %3 or greater required."
"only supported by Qt Creator version %2. "
"This version of Qt Creator requires Qt for MCUs %3 or greater."
).arg(sdkDetectedVersion,
oldSdkQtcRequiredVersion.value(sdkDetectedVersion),
McuSupportOptions::minimalQulVersion().toString());

View File

@@ -31,7 +31,8 @@
namespace McuSupport {
namespace Internal {
class McuPackageVersionDetector : public QObject {
class McuPackageVersionDetector : public QObject
{
Q_OBJECT
public:
McuPackageVersionDetector();
@@ -40,7 +41,8 @@ public:
};
// Get version from the output of an executable
class McuPackageExecutableVersionDetector : public McuPackageVersionDetector {
class McuPackageExecutableVersionDetector : public McuPackageVersionDetector
{
public:
McuPackageExecutableVersionDetector(const QString &detectionPath,
const QStringList &detectionArgs,
@@ -53,7 +55,8 @@ private:
};
// Get version through parsing an XML file
class McuPackageXmlVersionDetector : public McuPackageVersionDetector {
class McuPackageXmlVersionDetector : public McuPackageVersionDetector
{
public:
McuPackageXmlVersionDetector(const QString &filePattern,
const QString &elementName,
@@ -68,7 +71,8 @@ private:
};
// Get version from the filename of a given file/dir in the package directory
class McuPackageDirectoryVersionDetector : public McuPackageVersionDetector {
class McuPackageDirectoryVersionDetector : public McuPackageVersionDetector
{
public:
McuPackageDirectoryVersionDetector(const QString &filePattern, const QString &versionRegExp, const bool isFile);
QString parseVersion(const QString &packagePath) const;
@@ -79,7 +83,8 @@ private:
};
// Get version from the path of the package itself
class McuPackagePathVersionDetector : public McuPackageVersionDetector {
class McuPackagePathVersionDetector : public McuPackageVersionDetector
{
public:
McuPackagePathVersionDetector(const QString &versionRegExp);
QString parseVersion(const QString &packagePath) const;