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>
This commit is contained in:
parent
aa3eaf9d2e
commit
a134b57152
@ -142,6 +142,8 @@ QT_BEGIN_NAMESPACE
|
|||||||
\value DialogSnapToDefaultButton (bool) Whether the mouse should snap to the default button when a dialog
|
\value DialogSnapToDefaultButton (bool) Whether the mouse should snap to the default button when a dialog
|
||||||
becomes visible.
|
becomes visible.
|
||||||
|
|
||||||
|
\value ContextMenuOnMouseRelease (bool) Whether the context menu should be shown on mouse release.
|
||||||
|
|
||||||
\sa themeHint(), QStyle::pixelMetric()
|
\sa themeHint(), QStyle::pixelMetric()
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -487,6 +489,7 @@ QVariant QPlatformTheme::defaultThemeHint(ThemeHint hint)
|
|||||||
case IconPixmapSizes:
|
case IconPixmapSizes:
|
||||||
return QVariant::fromValue(QList<int>());
|
return QVariant::fromValue(QList<int>());
|
||||||
case DialogSnapToDefaultButton:
|
case DialogSnapToDefaultButton:
|
||||||
|
case ContextMenuOnMouseRelease:
|
||||||
return QVariant(false);
|
return QVariant(false);
|
||||||
}
|
}
|
||||||
return QVariant();
|
return QVariant();
|
||||||
|
@ -106,7 +106,8 @@ public:
|
|||||||
TabAllWidgets,
|
TabAllWidgets,
|
||||||
IconPixmapSizes,
|
IconPixmapSizes,
|
||||||
PasswordMaskCharacter,
|
PasswordMaskCharacter,
|
||||||
DialogSnapToDefaultButton
|
DialogSnapToDefaultButton,
|
||||||
|
ContextMenuOnMouseRelease
|
||||||
};
|
};
|
||||||
|
|
||||||
enum DialogType {
|
enum DialogType {
|
||||||
|
@ -383,6 +383,8 @@ QVariant QWindowsTheme::themeHint(ThemeHint hint) const
|
|||||||
}
|
}
|
||||||
case DialogSnapToDefaultButton:
|
case DialogSnapToDefaultButton:
|
||||||
return QVariant(booleanSystemParametersInfo(SPI_GETSNAPTODEFBUTTON, false));
|
return QVariant(booleanSystemParametersInfo(SPI_GETSNAPTODEFBUTTON, false));
|
||||||
|
case ContextMenuOnMouseRelease:
|
||||||
|
return QVariant(true);
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -49,6 +49,7 @@
|
|||||||
#endif
|
#endif
|
||||||
#include <private/qwidgetbackingstore_p.h>
|
#include <private/qwidgetbackingstore_p.h>
|
||||||
#include <qpa/qwindowsysteminterface_p.h>
|
#include <qpa/qwindowsysteminterface_p.h>
|
||||||
|
#include <qpa/qplatformtheme.h>
|
||||||
#include <private/qgesturemanager_p.h>
|
#include <private/qgesturemanager_p.h>
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
@ -354,6 +355,9 @@ void QWidgetWindow::handleNonClientAreaMouseEvent(QMouseEvent *e)
|
|||||||
|
|
||||||
void QWidgetWindow::handleMouseEvent(QMouseEvent *event)
|
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()) {
|
if (qApp->d_func()->inPopupMode()) {
|
||||||
QWidget *activePopupWidget = qApp->activePopupWidget();
|
QWidget *activePopupWidget = qApp->activePopupWidget();
|
||||||
QWidget *popup = activePopupWidget;
|
QWidget *popup = activePopupWidget;
|
||||||
@ -438,7 +442,7 @@ void QWidgetWindow::handleMouseEvent(QMouseEvent *event)
|
|||||||
}
|
}
|
||||||
qt_replay_popup_mouse_event = false;
|
qt_replay_popup_mouse_event = false;
|
||||||
#ifndef QT_NO_CONTEXTMENU
|
#ifndef QT_NO_CONTEXTMENU
|
||||||
} else if (event->type() == QEvent::MouseButtonPress
|
} else if (event->type() == contextMenuTrigger
|
||||||
&& event->button() == Qt::RightButton
|
&& event->button() == Qt::RightButton
|
||||||
&& (openPopupCount == oldOpenPopupCount)) {
|
&& (openPopupCount == oldOpenPopupCount)) {
|
||||||
QWidget *popupEvent = popup;
|
QWidget *popupEvent = popup;
|
||||||
@ -487,7 +491,7 @@ void QWidgetWindow::handleMouseEvent(QMouseEvent *event)
|
|||||||
qt_last_mouse_receiver);
|
qt_last_mouse_receiver);
|
||||||
|
|
||||||
#ifndef QT_NO_CONTEXTMENU
|
#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());
|
QContextMenuEvent e(QContextMenuEvent::Mouse, mapped, event->globalPos(), event->modifiers());
|
||||||
QGuiApplication::sendSpontaneousEvent(receiver, &e);
|
QGuiApplication::sendSpontaneousEvent(receiver, &e);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user