diff options
author | Mitch Curtis <mitch.curtis@qt.io> | 2019-02-04 16:19:55 +0100 |
---|---|---|
committer | Mitch Curtis <mitch.curtis@qt.io> | 2019-02-05 13:28:44 +0000 |
commit | 4e5601ac1c7aec6aba9ba09fe7adb7a0462da2f0 (patch) | |
tree | bdd0c234d3ebf328c2268ffdea9b1bca9d988a8b /src/quicktemplates2/qquickcontrol.cpp | |
parent | a59ab3ec93bc873225ccbd118ec81d023b5cb62d (diff) |
Popup: ensure that "palette" is reevaluated when enabled state changes
When changing the enabled state of a Menu after component completion,
the background would not change. The problem was that
QQuickPopup::paletteChanged() was not being emitted when the enabled
state changed, resulting in QQuickControl::palette() (which
QQuickPopup::palette() forwards calls to via its popupItem) not
being called. QQuickControl::palette() changes the palette's current
color group to QPalette::Disabled when it is disabled, so if it's not
called, the popup's colors won't change.
Fix the issue by adding a virtual enabledChange() function to
QQuickControl, which QQuickPopupItem can override to emit both
QQuickPopup::enabledChanged() (saving a connection in the process)
and QQuickPopup::paletteChanged(). This ensures that bindings to
QQuickPopup::palette are re-evaluated.
The patch adds a virtual instead of just emitting paletteChanged()
in QQuickPopup::setEnabled(), because we also want to be notified
of indirect enabled state changes, such as those coming from
parent items.
Change-Id: Ibdbd05f27b5a74fe731bda9d6698cbf6b8f81785
Fixes: QTBUG-73447
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
Diffstat (limited to 'src/quicktemplates2/qquickcontrol.cpp')
-rw-r--r-- | src/quicktemplates2/qquickcontrol.cpp | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/src/quicktemplates2/qquickcontrol.cpp b/src/quicktemplates2/qquickcontrol.cpp index 1fa70662..a61df3ca 100644 --- a/src/quicktemplates2/qquickcontrol.cpp +++ b/src/quicktemplates2/qquickcontrol.cpp @@ -943,6 +943,7 @@ void QQuickControl::itemChange(QQuickItem::ItemChange change, const QQuickItem:: switch (change) { case ItemEnabledHasChanged: emit paletteChanged(); + enabledChange(); break; case ItemVisibleHasChanged: #if QT_CONFIG(quicktemplates2_hover) @@ -2184,6 +2185,10 @@ void QQuickControl::geometryChanged(const QRectF &newGeometry, const QRectF &old emit availableHeightChanged(); } +void QQuickControl::enabledChange() +{ +} + void QQuickControl::fontChange(const QFont &newFont, const QFont &oldFont) { Q_UNUSED(newFont); |