aboutsummaryrefslogtreecommitdiffstats
path: root/src/quicktemplates2/qquickdrawer.cpp
diff options
context:
space:
mode:
authorJ-P Nurmi <jpnurmi@qt.io>2016-09-03 21:16:03 +0200
committerJ-P Nurmi <jpnurmi@qt.io>2016-09-06 15:20:07 +0000
commitbc0fdae8fad4e199792b3f00ebcb74bd80473227 (patch)
treeabb864d517e7f32ffebd80cb5dde97137ba1756e /src/quicktemplates2/qquickdrawer.cpp
parent671a4a83bc709e5f871ed5d5b76ad078140283bf (diff)
Fix drawer visibility and overlay event handling
Drawers were visible all the time, lurking at the window edges to be able to catch presses and drag themselves visible when appropriate. This change moves the handling of window edge presses from QQuickDrawer to QQuickOverlay, making it possible to show and hide drawers like any other popups. Instead of having all drawers visible all the time, we just keep QQuickOverlay visible when there are any registered drawers, even hidden ones. Furthermore, this change makes modal popup/drawer background dimming items accept mouse press events just like they accept hover events to ensure that a modal overlay does not leak input events through. When the background dimming of a modal drawer has been dragged over the drag-threshold, the drawer simply steals/grabs mouse to start dragging of the drawer. Task-number: QTBUG-54794 Task-number: QTBUG-54800 Task-number: QTBUG-55022 Task-number: QTBUG-55703 Task-number: QTBUG-55713 Change-Id: I65fb38fcf1466d4e41192c4321d80fb90b49da9a Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Diffstat (limited to 'src/quicktemplates2/qquickdrawer.cpp')
-rw-r--r--src/quicktemplates2/qquickdrawer.cpp40
1 files changed, 11 insertions, 29 deletions
diff --git a/src/quicktemplates2/qquickdrawer.cpp b/src/quicktemplates2/qquickdrawer.cpp
index 551352de..44fc8f50 100644
--- a/src/quicktemplates2/qquickdrawer.cpp
+++ b/src/quicktemplates2/qquickdrawer.cpp
@@ -191,6 +191,12 @@ bool QQuickDrawerPrivate::startDrag(QQuickWindow *window, QMouseEvent *event)
break;
}
+ if (drag) {
+ prepareEnterTransition();
+ reposition();
+ handleMousePressEvent(window->contentItem(), event);
+ }
+
return drag;
}
@@ -289,21 +295,12 @@ bool QQuickDrawerPrivate::ungrabMouse(QMouseEvent *event)
bool QQuickDrawerPrivate::handleMousePressEvent(QQuickItem *item, QMouseEvent *event)
{
- pressPoint = event->windowPos();
offset = 0;
-
- if (qFuzzyIsNull(position)) {
- // only accept pressing at drag margins when fully closed
- event->setAccepted(startDrag(item->window(), event));
- } else {
- if (modal)
- event->setAccepted(item->isAncestorOf(popupItem));
- else
- event->setAccepted(false);
- }
-
+ pressPoint = event->windowPos();
velocityCalculator.startMeasuring(pressPoint, event->timestamp());
+ // don't block press events a) outside a non-modal drawer, or b) to drawer children
+ event->setAccepted(modal && !popupItem->isAncestorOf(item));
return event->isAccepted();
}
@@ -384,7 +381,7 @@ void QQuickDrawerPrivate::finalizeEnterTransition()
void QQuickDrawerPrivate::finalizeExitTransition(bool hide)
{
- QQuickPopupPrivate::finalizeExitTransition(hide = false);
+ QQuickPopupPrivate::finalizeExitTransition(hide);
}
QQuickDrawer::QQuickDrawer(QObject *parent) :
@@ -448,12 +445,8 @@ void QQuickDrawer::setPosition(qreal position)
d->position = position;
if (isComponentComplete())
d->reposition();
- if (d->dimmer) {
+ if (d->dimmer)
d->dimmer->setOpacity(position);
- // TODO: check QStyleHints::useHoverEffects in Qt 5.8
- d->dimmer->setAcceptHoverEvents(d->modal && position > 0.0);
- // d->dimmer->setAcceptHoverEvents(d->modal && position > 0.0 && QGuiApplication::styleHints()->useHoverEffects());
- }
emit positionChanged();
}
@@ -548,15 +541,4 @@ bool QQuickDrawer::overlayEvent(QQuickItem *item, QEvent *event)
}
}
-void QQuickDrawer::componentComplete()
-{
- Q_D(QQuickDrawer);
- QQuickPopup::componentComplete();
- if (d->window) {
- bool notify = false;
- d->prepareEnterTransition(notify);
- d->reposition();
- }
-}
-
QT_END_NAMESPACE