diff --git a/src/gui/kernel/qstylehints.cpp b/src/gui/kernel/qstylehints.cpp index 9b5b7a6f1e..732ede90d0 100644 --- a/src/gui/kernel/qstylehints.cpp +++ b/src/gui/kernel/qstylehints.cpp @@ -65,6 +65,20 @@ static inline QVariant themeableHint(QPlatformTheme::ThemeHint th, return QGuiApplicationPrivate::platformIntegration()->styleHint(ih); } +static inline QVariant themeableHint(QPlatformTheme::ThemeHint th) +{ + if (!QCoreApplication::instance()) { + qWarning("Must construct a QGuiApplication before accessing a platform theme hint."); + return QVariant(); + } + if (const QPlatformTheme *theme = QGuiApplicationPrivate::platformTheme()) { + const QVariant themeHint = theme->themeHint(th); + if (themeHint.isValid()) + return themeHint; + } + return QPlatformTheme::defaultThemeHint(th); +} + class QStyleHintsPrivate : public QObjectPrivate { Q_DECLARE_PUBLIC(QStyleHints) @@ -80,6 +94,8 @@ public: int m_showShortcutsInContextMenus = -1; int m_wheelScrollLines = -1; int m_mouseQuickSelectionThreshold = -1; + int m_mouseDoubleClickDistance = -1; + int m_touchDoubleTapDistance = -1; }; /*! @@ -132,6 +148,34 @@ int QStyleHints::mouseDoubleClickInterval() const themeableHint(QPlatformTheme::MouseDoubleClickInterval, QPlatformIntegration::MouseDoubleClickInterval).toInt(); } +/*! + \property QStyleHints::mouseDoubleClickDistance + \brief the maximum distance, in pixels, that the mouse can be moved between + two consecutive mouse clicks and still have it detected as a double-click + \since 5.14 +*/ +int QStyleHints::mouseDoubleClickDistance() const +{ + Q_D(const QStyleHints); + return d->m_mouseDoubleClickDistance >= 0 ? + d->m_mouseDoubleClickDistance : + themeableHint(QPlatformTheme::MouseDoubleClickDistance).toInt(); +} + +/*! + \property QStyleHints::touchDoubleTapDistance + \brief the maximum distance, in pixels, that a finger can be moved between + two consecutive taps and still have it detected as a double-tap + \since 5.14 +*/ +int QStyleHints::touchDoubleTapDistance() const +{ + Q_D(const QStyleHints); + return d->m_touchDoubleTapDistance >= 0 ? + d->m_touchDoubleTapDistance : + themeableHint(QPlatformTheme::TouchDoubleTapDistance).toInt(); +} + /*! Sets the \a mousePressAndHoldInterval. \internal diff --git a/src/gui/kernel/qstylehints.h b/src/gui/kernel/qstylehints.h index 9091db9624..30d8fdc64d 100644 --- a/src/gui/kernel/qstylehints.h +++ b/src/gui/kernel/qstylehints.h @@ -74,10 +74,14 @@ class Q_GUI_EXPORT QStyleHints : public QObject Q_PROPERTY(bool useHoverEffects READ useHoverEffects WRITE setUseHoverEffects NOTIFY useHoverEffectsChanged FINAL) Q_PROPERTY(int wheelScrollLines READ wheelScrollLines NOTIFY wheelScrollLinesChanged FINAL) Q_PROPERTY(int mouseQuickSelectionThreshold READ mouseQuickSelectionThreshold WRITE setMouseQuickSelectionThreshold NOTIFY mouseQuickSelectionThresholdChanged FINAL) + Q_PROPERTY(int mouseDoubleClickDistance READ mouseDoubleClickDistance STORED false CONSTANT FINAL) + Q_PROPERTY(int touchDoubleTapDistance READ touchDoubleTapDistance STORED false CONSTANT FINAL) public: void setMouseDoubleClickInterval(int mouseDoubleClickInterval); int mouseDoubleClickInterval() const; + int mouseDoubleClickDistance() const; + int touchDoubleTapDistance() const; void setMousePressAndHoldInterval(int mousePressAndHoldInterval); int mousePressAndHoldInterval() const; void setStartDragDistance(int startDragDistance);