summaryrefslogtreecommitdiffstats
path: root/src/widgets
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@digia.com>2013-12-03 12:45:29 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-12-10 16:46:22 +0100
commita134b57152964e1279f62606cce0a7e7f521c32a (patch)
treef89376b7cb728443ea45ae0196b10d210c5d0931 /src/widgets
parentaa3eaf9d2ec4927df51e7d773a66f68ec5e4fce9 (diff)
Windows: Show context menu on mouse release.
Introduce a hint to QPlatformTheme to control the behavior. Task-number: QTBUG-35231 Change-Id: Ia28e153a8dd3f1931321a222d8906ca87166ed62 Reviewed-by: Shawn Rutledge <shawn.rutledge@digia.com> Reviewed-by: Joerg Bornemann <joerg.bornemann@digia.com>
Diffstat (limited to 'src/widgets')
-rw-r--r--src/widgets/kernel/qwidgetwindow.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/widgets/kernel/qwidgetwindow.cpp b/src/widgets/kernel/qwidgetwindow.cpp
index 2e96247873..167102c633 100644
--- a/src/widgets/kernel/qwidgetwindow.cpp
+++ b/src/widgets/kernel/qwidgetwindow.cpp
@@ -49,6 +49,7 @@
#endif
#include <private/qwidgetbackingstore_p.h>
#include <qpa/qwindowsysteminterface_p.h>
+#include <qpa/qplatformtheme.h>
#include <private/qgesturemanager_p.h>
QT_BEGIN_NAMESPACE
@@ -354,6 +355,9 @@ void QWidgetWindow::handleNonClientAreaMouseEvent(QMouseEvent *e)
void QWidgetWindow::handleMouseEvent(QMouseEvent *event)
{
+ static const QEvent::Type contextMenuTrigger =
+ QGuiApplicationPrivate::platformTheme()->themeHint(QPlatformTheme::ContextMenuOnMouseRelease).toBool() ?
+ QEvent::MouseButtonRelease : QEvent::MouseButtonPress;
if (qApp->d_func()->inPopupMode()) {
QWidget *activePopupWidget = qApp->activePopupWidget();
QWidget *popup = activePopupWidget;
@@ -438,7 +442,7 @@ void QWidgetWindow::handleMouseEvent(QMouseEvent *event)
}
qt_replay_popup_mouse_event = false;
#ifndef QT_NO_CONTEXTMENU
- } else if (event->type() == QEvent::MouseButtonPress
+ } else if (event->type() == contextMenuTrigger
&& event->button() == Qt::RightButton
&& (openPopupCount == oldOpenPopupCount)) {
QWidget *popupEvent = popup;
@@ -487,7 +491,7 @@ void QWidgetWindow::handleMouseEvent(QMouseEvent *event)
qt_last_mouse_receiver);
#ifndef QT_NO_CONTEXTMENU
- if (event->type() == QEvent::MouseButtonPress && event->button() == Qt::RightButton) {
+ if (event->type() == contextMenuTrigger && event->button() == Qt::RightButton) {
QContextMenuEvent e(QContextMenuEvent::Mouse, mapped, event->globalPos(), event->modifiers());
QGuiApplication::sendSpontaneousEvent(receiver, &e);
}