forked from qt-creator/qt-creator
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:
@@ -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, [&] {
|
||||
|
||||
Reference in New Issue
Block a user