McuSupport: Implement support for parsing path type from json

The json kit files have an entry named "type" which is intended to
specify whether a specific path points to a file or a directory (or
something else). Until now, this entry has not been handled and all
lineEdits expect a path, thus appearing red in the UI if supplied with
a file. With this patch, support for the type "file" is added, with the
possibility to support further types in parseLineEditType.

Currently, only File and ExistingDirectory are supported, with the
latter being used by default whenever no "type" entry is specified.

Task-number: UL-6610
Change-Id: I252d4eff76d4a11b92ce55a0c0964446072e48c1
Reviewed-by: Daniele Bortolotti <daniele.bortolotti@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
Sivert Krøvel
2022-10-31 21:09:19 +01:00
parent 2c04c644d0
commit 8fa0c2c390
7 changed files with 85 additions and 22 deletions

View File

@@ -37,7 +37,8 @@ McuPackage::McuPackage(const SettingsHandler::Ptr &settingsHandler,
const QStringList &versions,
const QString &downloadUrl,
const McuPackageVersionDetector *versionDetector,
const bool addToSystemPath)
const bool addToSystemPath,
const Utils::PathChooser::Kind &valueType)
: settingsHandler(settingsHandler)
, m_label(label)
, m_defaultPath(settingsHandler->getPath(settingsKey, QSettings::SystemScope, defaultPath))
@@ -49,6 +50,7 @@ McuPackage::McuPackage(const SettingsHandler::Ptr &settingsHandler,
, m_environmentVariableName(envVarName)
, m_downloadUrl(downloadUrl)
, m_addToSystemPath(addToSystemPath)
, m_valueType(valueType)
{
m_path = FilePath::fromUserInput(qtcEnvironmentVariable(m_environmentVariableName));
if (!m_path.exists()) {
@@ -245,6 +247,7 @@ QWidget *McuPackage::widget()
{
auto *widget = new QWidget;
m_fileChooser = new PathChooser(widget);
m_fileChooser->setExpectedKind(m_valueType);
m_fileChooser->lineEdit()->setButtonIcon(FancyLineEdit::Right, Icons::RESET.icon());
m_fileChooser->lineEdit()->setButtonVisible(FancyLineEdit::Right, true);
connect(m_fileChooser->lineEdit(), &FancyLineEdit::rightButtonClicked, this, [&] {