Android: Support double click event
It's impossible to get the distance between two touch events down to 5 pixels on e.g. my Nexus 5. This patch makes it possible to tweak the distance through the platform theme, and sets the distance to 15% of an inch on Android. Also provides a way to override the default minimum of 5 pixels by using an environment variable. [ChangeLog][Android] Fixed double click events Task-number: QTBUG-36974 Change-Id: I23d94020c531747d6638b645133611614a2a0703 Reviewed-by: BogDan Vatra <bogdan@kde.org>
This commit is contained in:
parent
d87ddcf56f
commit
ca280bfe3b
@ -145,7 +145,7 @@ ulong QGuiApplicationPrivate::mousePressTime = 0;
|
||||
Qt::MouseButton QGuiApplicationPrivate::mousePressButton = Qt::NoButton;
|
||||
int QGuiApplicationPrivate::mousePressX = 0;
|
||||
int QGuiApplicationPrivate::mousePressY = 0;
|
||||
int QGuiApplicationPrivate::mouse_double_click_distance = 5;
|
||||
int QGuiApplicationPrivate::mouse_double_click_distance = -1;
|
||||
|
||||
static Qt::LayoutDirection layout_direction = Qt::LeftToRight;
|
||||
static bool force_reverse = false;
|
||||
@ -1255,6 +1255,8 @@ void QGuiApplicationPrivate::init()
|
||||
initPalette();
|
||||
QFont::initialize();
|
||||
|
||||
mouse_double_click_distance = platformTheme()->themeHint(QPlatformTheme::MouseDoubleClickDistance).toInt();
|
||||
|
||||
#ifndef QT_NO_CURSOR
|
||||
QCursorData::initialize();
|
||||
#endif
|
||||
|
@ -499,6 +499,8 @@ QVariant QPlatformTheme::defaultThemeHint(ThemeHint hint)
|
||||
return QVariant(false);
|
||||
case MousePressAndHoldInterval:
|
||||
return QVariant(800);
|
||||
case MouseDoubleClickDistance:
|
||||
return QVariant(5);
|
||||
}
|
||||
return QVariant();
|
||||
}
|
||||
|
@ -108,7 +108,8 @@ public:
|
||||
PasswordMaskCharacter,
|
||||
DialogSnapToDefaultButton,
|
||||
ContextMenuOnMouseRelease,
|
||||
MousePressAndHoldInterval
|
||||
MousePressAndHoldInterval,
|
||||
MouseDoubleClickDistance
|
||||
};
|
||||
|
||||
enum DialogType {
|
||||
|
@ -47,6 +47,7 @@
|
||||
#include <QVariant>
|
||||
#include <QFileInfo>
|
||||
#include <QCoreApplication>
|
||||
#include <private/qguiapplication_p.h>
|
||||
#include <qandroidplatformintegration.h>
|
||||
|
||||
QAndroidPlatformTheme::QAndroidPlatformTheme(QAndroidPlatformNativeInterface *androidPlatformNativeInterface)
|
||||
@ -179,7 +180,30 @@ QVariant QAndroidPlatformTheme::themeHint(ThemeHint hint) const
|
||||
return QStringList("android");
|
||||
}
|
||||
return QStringList("fusion");
|
||||
break;
|
||||
|
||||
case MouseDoubleClickDistance:
|
||||
{
|
||||
int minimumDistance = qgetenv("QT_ANDROID_MINIMUM_MOUSE_DOUBLE_CLICK_DISTANCE").toInt();
|
||||
int ret = minimumDistance;
|
||||
|
||||
QAndroidPlatformIntegration *platformIntegration
|
||||
= static_cast<QAndroidPlatformIntegration *>(QGuiApplicationPrivate::platformIntegration());
|
||||
QAndroidPlatformScreen *platformScreen = platformIntegration->screen();
|
||||
if (platformScreen != 0) {
|
||||
QScreen *screen = platformScreen->screen();
|
||||
qreal dotsPerInch = screen->physicalDotsPerInch();
|
||||
|
||||
// Allow 15% of an inch between clicks when double clicking
|
||||
int distance = qRound(dotsPerInch * 0.15);
|
||||
if (distance > minimumDistance)
|
||||
ret = distance;
|
||||
}
|
||||
|
||||
if (ret > 0)
|
||||
return ret;
|
||||
|
||||
// fall through
|
||||
}
|
||||
default:
|
||||
return QPlatformTheme::themeHint(hint);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user