From 705e3f68df83dca165e3cddb914d3816155323f8 Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Fri, 18 Nov 2016 09:07:07 +0100 Subject: [PATCH] add TouchDoubleTapDistance platform theme hint MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Double-tapping on a touchscreen typically requires a higher threshold than double-clicking with a mouse, because it's harder to hit the same point twice with your finger. This is intended for use in QtQuick's new TapHandler. [ChangeLog][QtGui] environment variable QT_DBL_TAP_DIST customizes the amount of movement allowed when detecting a double tap via touch. Change-Id: I83a9be363f22c1086fd39580aa95055f2b3ff5c7 Reviewed-by: Jan Arve Sæther --- src/gui/kernel/qplatformtheme.cpp | 13 +++++++++++++ src/gui/kernel/qplatformtheme.h | 3 ++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/gui/kernel/qplatformtheme.cpp b/src/gui/kernel/qplatformtheme.cpp index 9c140f1d68..eef8b817fd 100644 --- a/src/gui/kernel/qplatformtheme.cpp +++ b/src/gui/kernel/qplatformtheme.cpp @@ -149,6 +149,11 @@ QT_BEGIN_NAMESPACE \value ContextMenuOnMouseRelease (bool) Whether the context menu should be shown on mouse release. + \value TouchDoubleTapDistance (int) The maximum distance in logical pixels which a touchpoint can travel + between taps in order for the tap sequence to be handled as a double tap. + The default value is double the MouseDoubleClickDistance, or 10 logical pixels + if that is not specified. + \sa themeHint(), QStyle::pixelMetric() */ @@ -533,6 +538,14 @@ QVariant QPlatformTheme::defaultThemeHint(ThemeHint hint) } case WheelScrollLines: return QVariant(3); + case TouchDoubleTapDistance: + { + bool ok = false; + int dist = qEnvironmentVariableIntValue("QT_DBL_TAP_DIST", &ok); + if (!ok) + dist = defaultThemeHint(MouseDoubleClickDistance).toInt(&ok) * 2; + return QVariant(ok ? dist : 10); + } } return QVariant(); } diff --git a/src/gui/kernel/qplatformtheme.h b/src/gui/kernel/qplatformtheme.h index 686dbed4b1..4135e31517 100644 --- a/src/gui/kernel/qplatformtheme.h +++ b/src/gui/kernel/qplatformtheme.h @@ -114,7 +114,8 @@ public: ContextMenuOnMouseRelease, MousePressAndHoldInterval, MouseDoubleClickDistance, - WheelScrollLines + WheelScrollLines, + TouchDoubleTapDistance }; enum DialogType {