diff options
author | Michael Brasser <michael.brasser@jollamobile.com> | 2013-11-26 14:47:56 -0600 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-12-10 17:36:05 +0100 |
commit | 16a26931d481a157f6ff09a3db1b0c3e33a7366d (patch) | |
tree | 2f6e8852da5636c327168b0863ed1c9d6a1d5d48 /src/gui | |
parent | 438a52e1a03932775e8ee88e30384985afca697e (diff) |
Allow the platform to specify a press and hold delay.
Press and hold is an interaction available on many platforms,
particularly when touch is involved. In Qt Quick this is exposed to the
user via MouseArea::onPressAndHold. This value should not be hard-coded,
but rather use a platform-specified default. This commit adds the
low-level hooks necessary for that to happen.
Task-number: QTBUG-24793
Change-Id: I621a8ac9de66b881e34336228056bffbb6306a70
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>
Reviewed-by: Paul Olav Tvete <paul.tvete@digia.com>
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/kernel/qplatformintegration.cpp | 2 | ||||
-rw-r--r-- | src/gui/kernel/qplatformintegration.h | 3 | ||||
-rw-r--r-- | src/gui/kernel/qplatformtheme.cpp | 7 | ||||
-rw-r--r-- | src/gui/kernel/qplatformtheme.h | 3 | ||||
-rw-r--r-- | src/gui/kernel/qstylehints.cpp | 11 | ||||
-rw-r--r-- | src/gui/kernel/qstylehints.h | 1 |
6 files changed, 25 insertions, 2 deletions
diff --git a/src/gui/kernel/qplatformintegration.cpp b/src/gui/kernel/qplatformintegration.cpp index 26aaf931b3..bec201f3f7 100644 --- a/src/gui/kernel/qplatformintegration.cpp +++ b/src/gui/kernel/qplatformintegration.cpp @@ -359,6 +359,8 @@ QVariant QPlatformIntegration::styleHint(StyleHint hint) const return true; case SetFocusOnTouchRelease: return QVariant(false); + case MousePressAndHoldInterval: + return QPlatformTheme::defaultThemeHint(QPlatformTheme::MousePressAndHoldInterval); } return 0; diff --git a/src/gui/kernel/qplatformintegration.h b/src/gui/kernel/qplatformintegration.h index 580fc15233..e3676b1be8 100644 --- a/src/gui/kernel/qplatformintegration.h +++ b/src/gui/kernel/qplatformintegration.h @@ -148,7 +148,8 @@ public: SynthesizeMouseFromTouchEvents, PasswordMaskCharacter, SetFocusOnTouchRelease, - ShowIsMaximized + ShowIsMaximized, + MousePressAndHoldInterval }; virtual QVariant styleHint(StyleHint hint) const; diff --git a/src/gui/kernel/qplatformtheme.cpp b/src/gui/kernel/qplatformtheme.cpp index 1844232efe..8b4b5c1812 100644 --- a/src/gui/kernel/qplatformtheme.cpp +++ b/src/gui/kernel/qplatformtheme.cpp @@ -79,6 +79,9 @@ QT_BEGIN_NAMESPACE \value MouseDoubleClickInterval (int) Mouse double click interval in ms, overriding QPlatformIntegration::styleHint. + \value MousePressAndHoldInterval (int) Mouse press and hold interval in ms, + overriding QPlatformIntegration::styleHint. + \value StartDragDistance (int) Start drag distance, overriding QPlatformIntegration::styleHint. @@ -423,6 +426,8 @@ QVariant QPlatformTheme::themeHint(ThemeHint hint) const return QGuiApplicationPrivate::platformIntegration()->styleHint(QPlatformIntegration::PasswordMaskDelay); case QPlatformTheme::PasswordMaskCharacter: return QGuiApplicationPrivate::platformIntegration()->styleHint(QPlatformIntegration::PasswordMaskCharacter); + case QPlatformTheme::MousePressAndHoldInterval: + return QGuiApplicationPrivate::platformIntegration()->styleHint(QPlatformIntegration::MousePressAndHoldInterval); default: return QPlatformTheme::defaultThemeHint(hint); } @@ -488,6 +493,8 @@ QVariant QPlatformTheme::defaultThemeHint(ThemeHint hint) return QVariant::fromValue(QList<int>()); case DialogSnapToDefaultButton: return QVariant(false); + case MousePressAndHoldInterval: + return QVariant(800); } return QVariant(); } diff --git a/src/gui/kernel/qplatformtheme.h b/src/gui/kernel/qplatformtheme.h index 4bddac5b1b..6e27261922 100644 --- a/src/gui/kernel/qplatformtheme.h +++ b/src/gui/kernel/qplatformtheme.h @@ -106,7 +106,8 @@ public: TabAllWidgets, IconPixmapSizes, PasswordMaskCharacter, - DialogSnapToDefaultButton + DialogSnapToDefaultButton, + MousePressAndHoldInterval }; enum DialogType { diff --git a/src/gui/kernel/qstylehints.cpp b/src/gui/kernel/qstylehints.cpp index 8d751d8615..e1468942af 100644 --- a/src/gui/kernel/qstylehints.cpp +++ b/src/gui/kernel/qstylehints.cpp @@ -128,6 +128,17 @@ int QStyleHints::mouseDoubleClickInterval() const } /*! + Returns the time limit in milliseconds that activates + a press and hold. + + \since 5.3 +*/ +int QStyleHints::mousePressAndHoldInterval() const +{ + return themeableHint(QPlatformTheme::MousePressAndHoldInterval, QPlatformIntegration::MousePressAndHoldInterval).toInt(); +} + +/*! Sets the \a startDragDistance. \internal \sa startDragDistance() diff --git a/src/gui/kernel/qstylehints.h b/src/gui/kernel/qstylehints.h index cc8d71108a..33fbe2965e 100644 --- a/src/gui/kernel/qstylehints.h +++ b/src/gui/kernel/qstylehints.h @@ -57,6 +57,7 @@ class Q_GUI_EXPORT QStyleHints : public QObject public: void setMouseDoubleClickInterval(int mouseDoubleClickInterval); int mouseDoubleClickInterval() const; + int mousePressAndHoldInterval() const; void setStartDragDistance(int startDragDistance); int startDragDistance() const; void setStartDragTime(int startDragTime); |