Merge branch 'qtquick2'
[profile/ivi/qtdeclarative.git] / src / declarative / graphicsitems / qdeclarativemousearea.cpp
index 271a704..20ca0f6 100644 (file)
@@ -660,6 +660,32 @@ void QDeclarativeMouseArea::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
         setHovered(false);
 }
 
+#ifndef QT_NO_CONTEXTMENU
+void QDeclarativeMouseArea::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
+{
+    bool acceptsContextMenuButton;
+#if defined(Q_OS_SYMBIAN)
+    // In Symbian a Long Tap on the screen will trigger. See QSymbianControl::HandleLongTapEventL().
+    acceptsContextMenuButton = acceptedButtons() & Qt::LeftButton;
+#elif defined(Q_WS_WINCE)
+    // ### WinCE can trigger context menu event with a gesture in the left button or a
+    // click with the right button. Since we have no way here to differentiate them when
+    // event happens, accepting either of the them will block the event.
+    acceptsContextMenuButton = acceptedButtons() & (Qt::LeftButton | Qt::RightButton);
+#else
+    acceptsContextMenuButton = acceptedButtons() & Qt::RightButton;
+#endif
+
+    if (isEnabled() && event->reason() == QGraphicsSceneContextMenuEvent::Mouse
+        && acceptsContextMenuButton) {
+        // Do not let the context menu event propagate to items behind.
+        return;
+    }
+
+    QDeclarativeItem::contextMenuEvent(event);
+}
+#endif // QT_NO_CONTEXTMENU
+
 bool QDeclarativeMouseArea::sceneEvent(QEvent *event)
 {
     bool rv = QDeclarativeItem::sceneEvent(event);