forked from qt-creator/qt-creator
McuSupport: Expand path macros when resetting paths
Path macros were expanded when applying new paths in the
McuSupport options widget, but not when pushing the reset button.
This resulted in paths like {Env:PROGRAMFILES}/SEGGER/JLink,
which are displayed as an error in the UI. The reset-button is
now connected via a signal in McuPackage to the options widget,
since the macro expander is not accessible to the package object
directly.
Task-number: QTCREATORBUG-28500
Change-Id: I962c6eb83142be87e02debbf34f0602683fe6966
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Yasser Grimes <yasser.grimes@qt.io>
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
This commit is contained in:
@@ -55,6 +55,7 @@ public:
|
|||||||
signals:
|
signals:
|
||||||
void changed();
|
void changed();
|
||||||
void statusChanged();
|
void statusChanged();
|
||||||
|
void reset();
|
||||||
|
|
||||||
}; // class McuAbstractPackage
|
}; // class McuAbstractPackage
|
||||||
} // namespace McuSupport::Internal
|
} // namespace McuSupport::Internal
|
||||||
|
|||||||
@@ -256,9 +256,7 @@ QWidget *McuPackage::widget()
|
|||||||
m_fileChooser->setExpectedKind(m_valueType);
|
m_fileChooser->setExpectedKind(m_valueType);
|
||||||
m_fileChooser->lineEdit()->setButtonIcon(FancyLineEdit::Right, Icons::RESET.icon());
|
m_fileChooser->lineEdit()->setButtonIcon(FancyLineEdit::Right, Icons::RESET.icon());
|
||||||
m_fileChooser->lineEdit()->setButtonVisible(FancyLineEdit::Right, true);
|
m_fileChooser->lineEdit()->setButtonVisible(FancyLineEdit::Right, true);
|
||||||
connect(m_fileChooser->lineEdit(), &FancyLineEdit::rightButtonClicked, this, [&] {
|
connect(m_fileChooser->lineEdit(), &FancyLineEdit::rightButtonClicked, this, &McuPackage::reset);
|
||||||
m_fileChooser->setFilePath(m_defaultPath);
|
|
||||||
});
|
|
||||||
|
|
||||||
auto layout = new QGridLayout(widget);
|
auto layout = new QGridLayout(widget);
|
||||||
layout->setContentsMargins(0, 0, 0, 0);
|
layout->setContentsMargins(0, 0, 0, 0);
|
||||||
|
|||||||
@@ -277,6 +277,15 @@ void McuSupportOptionsWidget::showMcuTargetPackages()
|
|||||||
|
|
||||||
for (const auto &package : packages) {
|
for (const auto &package : packages) {
|
||||||
QWidget *packageWidget = package->widget();
|
QWidget *packageWidget = package->widget();
|
||||||
|
QWeakPointer packagePtr(package);
|
||||||
|
connect(package.get(), &McuPackage::reset, this, [this, packagePtr] (){
|
||||||
|
McuPackagePtr package = packagePtr.lock();
|
||||||
|
if (package) {
|
||||||
|
MacroExpanderPtr macroExpander
|
||||||
|
= m_options.sdkRepository.getMacroExpander(*currentMcuTarget());
|
||||||
|
package->setPath(macroExpander->expand(package->defaultPath()));
|
||||||
|
}
|
||||||
|
});
|
||||||
m_packagesLayout->addRow(package->label(), packageWidget);
|
m_packagesLayout->addRow(package->label(), packageWidget);
|
||||||
packageWidget->show();
|
packageWidget->show();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user