summaryrefslogtreecommitdiffstats
path: root/src/gui/kernel/qstylehints.cpp
diff options
context:
space:
mode:
authorJ-P Nurmi <jpnurmi@qt.io>2016-06-29 15:58:23 +0200
committerJ-P Nurmi <jpnurmi@qt.io>2016-07-20 18:33:59 +0000
commit4e6dd1c50a08877189891806ed0dc977aafceade (patch)
tree69753811900e27ec3910cfce03a4e541cbee3038 /src/gui/kernel/qstylehints.cpp
parent494ced13292fa9d7b572f5310090f6b8fab36e26 (diff)
Add QStyleHints::useHoverEffects
The delivery of hover events creates unnecessary overhead on touch platforms. This allows Qt Quick Controls 2 to determine whether the underlying platform wants hover effects. The hover effects are enabled by default for the classic desktop platforms: Linux, Windows & macOS. Change-Id: Ia4e7b5c0fcb7af8f1c47e06fb28086cffdf35976 Task-number: QTBUG-50003 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Mitch Curtis <mitch.curtis@qt.io> Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Diffstat (limited to 'src/gui/kernel/qstylehints.cpp')
-rw-r--r--src/gui/kernel/qstylehints.cpp32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/gui/kernel/qstylehints.cpp b/src/gui/kernel/qstylehints.cpp
index ecc2886a04..7ccf1d86b0 100644
--- a/src/gui/kernel/qstylehints.cpp
+++ b/src/gui/kernel/qstylehints.cpp
@@ -77,6 +77,7 @@ public:
, m_keyboardInputInterval(-1)
, m_cursorFlashTime(-1)
, m_tabFocusBehavior(-1)
+ , m_uiEffects(-1)
{}
int m_mouseDoubleClickInterval;
@@ -86,6 +87,7 @@ public:
int m_keyboardInputInterval;
int m_cursorFlashTime;
int m_tabFocusBehavior;
+ int m_uiEffects;
};
/*!
@@ -451,4 +453,34 @@ bool QStyleHints::singleClickActivation() const
return themeableHint(QPlatformTheme::ItemViewActivateItemOnSingleClick, QPlatformIntegration::ItemViewActivateItemOnSingleClick).toBool();
}
+/*!
+ \property QStyleHints::useHoverEffects
+ \brief \c true if UI elements should use hover effects. This is the
+ standard behavior on desktop platforms with a mouse pointer, whereas
+ on touch platforms the overhead of hover event delivery can be avoided.
+
+ \since 5.8
+*/
+bool QStyleHints::useHoverEffects() const
+{
+ Q_D(const QStyleHints);
+ return (d->m_uiEffects >= 0 ?
+ d->m_uiEffects :
+ themeableHint(QPlatformTheme::UiEffects, QPlatformIntegration::UiEffects).toInt()) & QPlatformTheme::HoverEffect;
+}
+
+void QStyleHints::setUseHoverEffects(bool useHoverEffects)
+{
+ Q_D(QStyleHints);
+ if (d->m_uiEffects >= 0 && useHoverEffects == bool(d->m_uiEffects & QPlatformTheme::HoverEffect))
+ return;
+ if (d->m_uiEffects == -1)
+ d->m_uiEffects = 0;
+ if (useHoverEffects)
+ d->m_uiEffects |= QPlatformTheme::HoverEffect;
+ else
+ d->m_uiEffects &= ~QPlatformTheme::HoverEffect;
+ emit useHoverEffectsChanged(useHoverEffects);
+}
+
QT_END_NAMESPACE