aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJ-P Nurmi <jpnurmi@qt.io>2016-07-21 17:02:14 +0200
committerJ-P Nurmi <jpnurmi@qt.io>2016-07-22 12:14:40 +0000
commit333c226f7cfc53a7e55a8e4d5502788d39847342 (patch)
tree6bb271ae891235c7f62175763202c1547c74b141
parentff3a9a6762eb4e54048afee168783aa9cf5391c2 (diff)
Don't leak hover events through modal overlays
Task-number: QTBUG-53419 Change-Id: I5c1ce684cff7954f9c011e991e3924741ad44367 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
-rw-r--r--src/quicktemplates2/qquickoverlay.cpp6
-rw-r--r--tests/auto/popup/tst_popup.cpp14
2 files changed, 19 insertions, 1 deletions
diff --git a/src/quicktemplates2/qquickoverlay.cpp b/src/quicktemplates2/qquickoverlay.cpp
index 1aec823e..028fa7b1 100644
--- a/src/quicktemplates2/qquickoverlay.cpp
+++ b/src/quicktemplates2/qquickoverlay.cpp
@@ -108,6 +108,12 @@ static QQuickItem *createDimmer(QQmlComponent *component, QQuickPopup *popup, QQ
item->setParentItem(parent);
item->stackBefore(popup->popupItem());
item->setZ(popup->z());
+ if (popup->isModal()) {
+ // TODO: switch to QStyleHints::useHoverEffects in Qt 5.8
+ item->setAcceptHoverEvents(true);
+ // item->setAcceptHoverEvents(QGuiApplication::styleHints()->useHoverEffects());
+ // connect(QGuiApplication::styleHints(), &QStyleHints::useHoverEffectsChanged, item, &QQuickItem::setAcceptHoverEvents);
+ }
component->completeCreate();
}
return item;
diff --git a/tests/auto/popup/tst_popup.cpp b/tests/auto/popup/tst_popup.cpp
index 6f4a2e2e..39956301 100644
--- a/tests/auto/popup/tst_popup.cpp
+++ b/tests/auto/popup/tst_popup.cpp
@@ -58,6 +58,7 @@ private slots:
void closePolicy();
void activeFocusOnClose1();
void activeFocusOnClose2();
+ void hover_data();
void hover();
};
@@ -331,8 +332,18 @@ void tst_popup::activeFocusOnClose2()
QVERIFY(popup1->hasActiveFocus());
}
+void tst_popup::hover_data()
+{
+ QTest::addColumn<bool>("modal");
+
+ QTest::newRow("modal") << true;
+ QTest::newRow("modeless") << false;
+}
+
void tst_popup::hover()
{
+ QFETCH(bool, modal);
+
QQuickApplicationHelper helper(this, QStringLiteral("hover.qml"));
QQuickApplicationWindow *window = helper.window;
window->show();
@@ -341,6 +352,7 @@ void tst_popup::hover()
QQuickPopup *popup = helper.window->property("popup").value<QQuickPopup*>();
QVERIFY(popup);
+ popup->setModal(modal);
QQuickButton *parentButton = helper.window->property("parentButton").value<QQuickButton*>();
QVERIFY(parentButton);
@@ -357,7 +369,7 @@ void tst_popup::hover()
// hover the parent button outside the popup
QTest::mouseMove(window, QPoint(window->width() - 1, window->height() - 1));
- QVERIFY(parentButton->isHovered());
+ QCOMPARE(parentButton->isHovered(), !modal);
QVERIFY(!childButton->isHovered());
// hover the popup background