aboutsummaryrefslogtreecommitdiffstats
path: root/src/templates/qquickoverlay.cpp
diff options
context:
space:
mode:
authorJ-P Nurmi <jpnurmi@theqtcompany.com>2016-02-25 14:39:59 +0100
committerJ-P Nurmi <jpnurmi@theqtcompany.com>2016-02-29 14:05:29 +0000
commit9358b9f27a6f164009020923cef090c680d27c8a (patch)
tree2da0facc33ca8d8f9ec0e185b7aae0b942cf726b /src/templates/qquickoverlay.cpp
parent229eb7624c650fb1b73799ebdca033efe6500fe8 (diff)
Route overlay events to QQuickPopup::overlayEvent()
This cleans up QQuickOverlay a bit, and prepares QQuickPopup so that it's possible for QQuickDrawer to override overlayEvent() to handle the necessary events at the window edge, instead of overlaying the whole window with a transparent item. Change-Id: I6b7bf26fd99e81b61adac42ec04eb93423e36677 Task-number: QTBUG-51007 Reviewed-by: Mitch Curtis <mitch.curtis@theqtcompany.com>
Diffstat (limited to 'src/templates/qquickoverlay.cpp')
-rw-r--r--src/templates/qquickoverlay.cpp68
1 files changed, 17 insertions, 51 deletions
diff --git a/src/templates/qquickoverlay.cpp b/src/templates/qquickoverlay.cpp
index b20088ba..acee3187 100644
--- a/src/templates/qquickoverlay.cpp
+++ b/src/templates/qquickoverlay.cpp
@@ -197,52 +197,26 @@ void QQuickOverlay::geometryChanged(const QRectF &newGeometry, const QRectF &old
d->resizeBackground();
}
-void QQuickOverlay::keyPressEvent(QKeyEvent *event)
+bool QQuickOverlay::event(QEvent *event)
{
Q_D(QQuickOverlay);
- event->setAccepted(d->modalPopups > 0);
-}
-
-void QQuickOverlay::keyReleaseEvent(QKeyEvent *event)
-{
- Q_D(QQuickOverlay);
- event->setAccepted(d->modalPopups > 0);
-}
-
-void QQuickOverlay::mousePressEvent(QMouseEvent *event)
-{
- Q_D(QQuickOverlay);
- event->setAccepted(d->modalPopups > 0);
- emit pressed();
-
- for (auto it = d->popups.rbegin(), end = d->popups.rend(); it != end; ++it) {
- if (QQuickPopupPrivate::get(*it)->tryClose(this, event))
- break;
+ switch (event->type()) {
+ case QEvent::MouseButtonPress:
+ emit pressed();
+ break;
+ case QEvent::MouseButtonRelease:
+ emit released();
+ break;
+ default:
+ break;
}
-}
-
-void QQuickOverlay::mouseMoveEvent(QMouseEvent *event)
-{
- Q_D(QQuickOverlay);
- event->setAccepted(d->modalPopups > 0);
-}
-
-void QQuickOverlay::mouseReleaseEvent(QMouseEvent *event)
-{
- Q_D(QQuickOverlay);
- event->setAccepted(d->modalPopups > 0);
- emit released();
for (auto it = d->popups.rbegin(), end = d->popups.rend(); it != end; ++it) {
- if (QQuickPopupPrivate::get(*it)->tryClose(this, event))
- break;
+ if ((*it)->overlayEvent(this, event))
+ return true;
}
-}
-void QQuickOverlay::wheelEvent(QWheelEvent *event)
-{
- Q_D(QQuickOverlay);
- event->setAccepted(d->modalPopups > 0);
+ return QQuickItem::event(event);
}
bool QQuickOverlay::childMouseEventFilter(QQuickItem *item, QEvent *event)
@@ -256,26 +230,18 @@ bool QQuickOverlay::childMouseEventFilter(QQuickItem *item, QEvent *event)
while (item->parentItem() != this)
item = item->parentItem();
- bool modalBlocked = false;
- const QQuickItemPrivate *priv = QQuickItemPrivate::get(this);
- const QList<QQuickItem *> &sortedChildren = priv->paintOrderChildItems();
+ const QList<QQuickItem *> sortedChildren = d->paintOrderChildItems();
for (auto it = sortedChildren.rbegin(), end = sortedChildren.rend(); it != end; ++it) {
QQuickItem *popupItem = *it;
if (popupItem == item)
break;
QQuickPopup *popup = qobject_cast<QQuickPopup *>(popupItem->parent());
- if (popup) {
- QQuickPopup::ClosePolicy policy = popup->closePolicy();
- if (policy.testFlag(QQuickPopup::OnPressOutside) || policy.testFlag(QQuickPopup::OnPressOutsideParent))
- popup->close();
-
- if (!modalBlocked && popup->isModal())
- modalBlocked = true;
- }
+ if (popup && popup->overlayEvent(item, event))
+ return true;
}
- return modalBlocked;
+ return false;
}
QT_END_NAMESPACE