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:
Rainer Keller
2022-10-18 13:46:49 +02:00
parent 34d0f2e678
commit 1db2a10b73

View File

@@ -113,15 +113,12 @@ FilePath McuPackage::detectionPath() const
void McuPackage::setPath(const FilePath &newPath)
{
if (m_path == newPath)
return;
m_path = newPath;
updateStatus();
}
void McuPackage::updatePath()
{
m_path = m_fileChooser->rawFilePath();
m_fileChooser->lineEdit()->button(FancyLineEdit::Right)->setEnabled(m_path != m_defaultPath);
updateStatus();
emit changed();
}
void McuPackage::updateStatus()
@@ -274,8 +271,12 @@ QWidget *McuPackage::widget()
QObject::connect(this, &McuPackage::statusChanged, widget, [this] { updateStatusUi(); });
QObject::connect(m_fileChooser, &PathChooser::textChanged, this, [this] {
updatePath();
emit changed();
setPath(m_fileChooser->rawFilePath());
});
connect(this, &McuPackage::changed, m_fileChooser, [this] {
m_fileChooser->lineEdit()->button(FancyLineEdit::Right)->setEnabled(m_path != m_defaultPath);
m_fileChooser->setFilePath(m_path);
});
updateStatus();