forked from qt-creator/qt-creator
McuSupport: Use signals to propagate path changes from McuPackages
Instead of calling the update function manually unconditionally it will be called through a connection. Change-Id: Ibfd3efd0fbaa66c4857d8a15c202472e1f00f576 Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: Rainer Keller <Rainer.Keller@qt.io>
This commit is contained in:
@@ -113,15 +113,12 @@ FilePath McuPackage::detectionPath() const
|
|||||||
|
|
||||||
void McuPackage::setPath(const FilePath &newPath)
|
void McuPackage::setPath(const FilePath &newPath)
|
||||||
{
|
{
|
||||||
|
if (m_path == newPath)
|
||||||
|
return;
|
||||||
|
|
||||||
m_path = newPath;
|
m_path = newPath;
|
||||||
updateStatus();
|
updateStatus();
|
||||||
}
|
emit changed();
|
||||||
|
|
||||||
void McuPackage::updatePath()
|
|
||||||
{
|
|
||||||
m_path = m_fileChooser->rawFilePath();
|
|
||||||
m_fileChooser->lineEdit()->button(FancyLineEdit::Right)->setEnabled(m_path != m_defaultPath);
|
|
||||||
updateStatus();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void McuPackage::updateStatus()
|
void McuPackage::updateStatus()
|
||||||
@@ -274,8 +271,12 @@ QWidget *McuPackage::widget()
|
|||||||
QObject::connect(this, &McuPackage::statusChanged, widget, [this] { updateStatusUi(); });
|
QObject::connect(this, &McuPackage::statusChanged, widget, [this] { updateStatusUi(); });
|
||||||
|
|
||||||
QObject::connect(m_fileChooser, &PathChooser::textChanged, this, [this] {
|
QObject::connect(m_fileChooser, &PathChooser::textChanged, this, [this] {
|
||||||
updatePath();
|
setPath(m_fileChooser->rawFilePath());
|
||||||
emit changed();
|
});
|
||||||
|
|
||||||
|
connect(this, &McuPackage::changed, m_fileChooser, [this] {
|
||||||
|
m_fileChooser->lineEdit()->button(FancyLineEdit::Right)->setEnabled(m_path != m_defaultPath);
|
||||||
|
m_fileChooser->setFilePath(m_path);
|
||||||
});
|
});
|
||||||
|
|
||||||
updateStatus();
|
updateStatus();
|
||||||
|
Reference in New Issue
Block a user