From e0df583c14941ad355a127c47e978f0c968d1c93 Mon Sep 17 00:00:00 2001 From: Automatic Release Builder Date: Wed, 7 Oct 2020 18:35:04 +0100 Subject: [PATCH] Launcher: fix appearance of disabled add-ons. Spotted by Michael Danilov --- src/GUI/AddonsModel.cxx | 14 ++++++++++---- src/GUI/qml/AddOnsDelegate.qml | 2 ++ 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/GUI/AddonsModel.cxx b/src/GUI/AddonsModel.cxx index c879184af..c846fe1a0 100644 --- a/src/GUI/AddonsModel.cxx +++ b/src/GUI/AddonsModel.cxx @@ -208,18 +208,24 @@ QHash AddonsModel::roleNames() const return m_roleToName; } -void AddonsModel::enable(int index, bool enable) +void AddonsModel::enable(int row, bool enable) { - if ((index < 0) || (index >= m_addonsList.size())) { + if ((row < 0) || (row >= m_addonsList.size())) { return; } - auto path = m_addonsList[index]; + auto path = m_addonsList[row]; if (!m_addonsMap.contains(path)) return; - m_addonsMap[path].enable = enable && checkVersion(path); + const bool wasEnabled = m_addonsMap[path].enable; + const bool nowEnabled = enable && checkVersion(path); + if (wasEnabled == nowEnabled) + return; + m_addonsMap[path].enable = nowEnabled; + const auto mindex = index(row, 0); + emit dataChanged(mindex, mindex, {EnableRole}); emit modulesChanged(); } diff --git a/src/GUI/qml/AddOnsDelegate.qml b/src/GUI/qml/AddOnsDelegate.qml index 161065de6..ac7f2b859 100644 --- a/src/GUI/qml/AddOnsDelegate.qml +++ b/src/GUI/qml/AddOnsDelegate.qml @@ -75,6 +75,8 @@ Item { anchors.rightMargin: Style.margin height: contentRect.height + font.strikeout: !model.enable + verticalAlignment: Text.AlignVCenter wrapMode: Text.WordWrap }