McuSupport: Read versioned settings keys for MCU dependencies

In an accompanying change, the installer writes versioned
settings keys. The version string will be appended to the
existing key, after a single underscore character.

When reading from the settings, the plugin first looks for
keys matching one of the requested versions from the kit.

Optionally, if no key for a matching version is found, the
key for the newest version available is chosen. This only
applies to the Qul SDK package for the time being.

If no suitable versioned key is found, the plain unversioned
settings key is picked

Task-number: QTCREATORBUG-29194
Change-Id: I2db888390cfb64a4b7c78ebcf795543251cb7a1b
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
Sivert Krøvel
2024-03-06 19:00:35 +01:00
parent 18e1c36648
commit 68e178c041
5 changed files with 83 additions and 6 deletions

View File

@@ -42,12 +42,12 @@ McuPackage::McuPackage(const SettingsHandler::Ptr &settingsHandler,
const QString &downloadUrl,
const McuPackageVersionDetector *versionDetector,
const bool addToSystemPath,
const Utils::PathChooser::Kind &valueType)
const Utils::PathChooser::Kind &valueType,
const bool useNewestVersionKey)
: settingsHandler(settingsHandler)
, m_label(label)
, m_defaultPath(settingsHandler->getPath(settingsKey, QSettings::SystemScope, defaultPath))
, m_detectionPaths(detectionPaths)
, m_settingsKey(settingsKey)
, m_settingsKey(settingsHandler->getVersionedKey(settingsKey, QSettings::SystemScope, versions, useNewestVersionKey))
, m_versionDetector(versionDetector)
, m_versions(versions)
, m_cmakeVariableName(cmakeVarName)
@@ -56,7 +56,8 @@ McuPackage::McuPackage(const SettingsHandler::Ptr &settingsHandler,
, m_addToSystemPath(addToSystemPath)
, m_valueType(valueType)
{
m_path = this->settingsHandler->getPath(settingsKey, QSettings::UserScope, m_defaultPath);
m_defaultPath = settingsHandler->getPath(m_settingsKey, QSettings::SystemScope, defaultPath);
m_path = settingsHandler->getPath(m_settingsKey, QSettings::UserScope, m_defaultPath);
if (m_path.isEmpty()) {
m_path = FilePath::fromUserInput(qtcEnvironmentVariable(m_environmentVariableName));
}