aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRainer Keller <Rainer.Keller@qt.io>2022-10-18 13:46:49 +0200
committerRainer Keller <Rainer.Keller@qt.io>2022-10-24 11:00:58 +0000
commit1db2a10b73fdd60caff71f30c0679a4c7191c03c (patch)
tree0d75243bd0aecab484a0b3f34f920c16859f056d
parent34d0f2e678087ded43f68faadfa88d9e72e6321e (diff)
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>
-rw-r--r--src/plugins/mcusupport/mcupackage.cpp19
1 files changed, 10 insertions, 9 deletions
diff --git a/src/plugins/mcusupport/mcupackage.cpp b/src/plugins/mcusupport/mcupackage.cpp
index d79fe8c8a8f..63a86442290 100644
--- a/src/plugins/mcusupport/mcupackage.cpp
+++ b/src/plugins/mcusupport/mcupackage.cpp
@@ -113,15 +113,12 @@ FilePath McuPackage::detectionPath() const
void McuPackage::setPath(const FilePath &newPath)
{
- m_path = newPath;
- updateStatus();
-}
+ if (m_path == newPath)
+ return;
-void McuPackage::updatePath()
-{
- m_path = m_fileChooser->rawFilePath();
- m_fileChooser->lineEdit()->button(FancyLineEdit::Right)->setEnabled(m_path != m_defaultPath);
+ m_path = newPath;
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();