aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorVolker Hilsheimer <volker.hilsheimer@qt.io>2021-06-11 14:19:17 +0200
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2021-06-11 20:47:45 +0000
commit44e5f7f29c29811534ca02359fe5b4fbe1f54990 (patch)
tree1234e9e93bdce8fd51ad09744ddc60f499cdaf73 /src
parent3f7dab18b0eb992037c47a42fee8794528a6fb5a (diff)
Use Inactive color group in inactive windows
A palette has three color groups (Active, Inactive, Disabled), but we only listened to changes of the enabled state, and always used the Active color group for an enabled item. In order for the Inactive color group to take effect, we need to also trigger the update when the "active" property changes. Instead of connecting yet another signal, deliver WindowActivate/Deactivate to as well, and forward from contentItem to all children which can then update the current color group. Add a test case. Fixes: QTBUG-93752 Change-Id: I4f2b6121e822115aaa5c4faaa5d402932dacc67b Reviewed-by: Mitch Curtis <mitch.curtis@qt.io> (cherry picked from commit 3675f2b235f32e05cf6d754e81e0e8f8ddd59752) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'src')
-rw-r--r--src/quick/items/qquickitem.cpp7
-rw-r--r--src/quick/items/qquickpaletteproviderprivatebase_p.h11
-rw-r--r--src/quick/items/qquickwindow.cpp4
3 files changed, 19 insertions, 3 deletions
diff --git a/src/quick/items/qquickitem.cpp b/src/quick/items/qquickitem.cpp
index 7fe057ad70..5b8048c303 100644
--- a/src/quick/items/qquickitem.cpp
+++ b/src/quick/items/qquickitem.cpp
@@ -8505,6 +8505,13 @@ bool QQuickItem::event(QEvent *ev)
for (QQuickItem *item : d->childItems)
QCoreApplication::sendEvent(item, ev);
break;
+ case QEvent::WindowActivate:
+ case QEvent::WindowDeactivate:
+ if (d->palette())
+ d->setCurrentColorGroup();
+ for (QQuickItem *item : d->childItems)
+ QCoreApplication::sendEvent(item, ev);
+ break;
default:
return QObject::event(ev);
}
diff --git a/src/quick/items/qquickpaletteproviderprivatebase_p.h b/src/quick/items/qquickpaletteproviderprivatebase_p.h
index b1b5958329..9399462130 100644
--- a/src/quick/items/qquickpaletteproviderprivatebase_p.h
+++ b/src/quick/items/qquickpaletteproviderprivatebase_p.h
@@ -49,7 +49,7 @@
#include <QtQuick/private/qquickpalette_p.h>
#include <QtQuick/private/qquickabstractpaletteprovider_p.h>
-
+#include <QtGui/qwindow.h>
#include <QtQml/private/qlazilyallocated_p.h>
QT_BEGIN_NAMESPACE
@@ -150,6 +150,9 @@ public:
*/
virtual void updateChildrenPalettes(const QPalette &parentPalette);
+protected:
+ void setCurrentColorGroup();
+
private:
using PalettePtr = std::unique_ptr<QQuickPalette>;
using Self = QQuickPaletteProviderPrivateBase<I, Impl>;
@@ -160,7 +163,6 @@ private:
QQuickPalette *windowPalette() const;
- void setCurrentColorGroup();
void connectItem();
@@ -336,7 +338,10 @@ void QQuickPaletteProviderPrivateBase<I, Impl>::setCurrentColorGroup()
if constexpr (!isRootWindow<I>()) {
if (paletteData()) {
const bool enabled = itemWithPalette()->isEnabled();
- paletteData()->setCurrentGroup(enabled ? QPalette::Active : QPalette::Disabled);
+ const auto window = itemWithPalette()->window();
+ const bool active = window ? window->isActive() : true;
+ paletteData()->setCurrentGroup(enabled ? (active ? QPalette::Active : QPalette::Inactive)
+ : QPalette::Disabled);
}
}
}
diff --git a/src/quick/items/qquickwindow.cpp b/src/quick/items/qquickwindow.cpp
index e6bfde66ae..85df4a66b3 100644
--- a/src/quick/items/qquickwindow.cpp
+++ b/src/quick/items/qquickwindow.cpp
@@ -1512,6 +1512,10 @@ bool QQuickWindow::event(QEvent *e)
case QEvent::WindowDeactivate:
if (auto da = d->deliveryAgentPrivate())
da->handleWindowDeactivate(this);
+ Q_FALLTHROUGH();
+ case QEvent::WindowActivate:
+ if (d->contentItem)
+ QCoreApplication::sendEvent(d->contentItem, e);
break;
default:
break;