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>bb10
parent
494ced1329
commit
4e6dd1c50a
|
|
@ -402,6 +402,8 @@ QVariant QPlatformIntegration::styleHint(StyleHint hint) const
|
|||
return true;
|
||||
case ItemViewActivateItemOnSingleClick:
|
||||
return QPlatformTheme::defaultThemeHint(QPlatformTheme::ItemViewActivateItemOnSingleClick);
|
||||
case UiEffects:
|
||||
return QPlatformTheme::defaultThemeHint(QPlatformTheme::UiEffects);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
|
|
|||
|
|
@ -156,7 +156,8 @@ public:
|
|||
MousePressAndHoldInterval,
|
||||
TabFocusBehavior,
|
||||
ReplayMousePressOutsidePopup,
|
||||
ItemViewActivateItemOnSingleClick
|
||||
ItemViewActivateItemOnSingleClick,
|
||||
UiEffects
|
||||
};
|
||||
|
||||
virtual QVariant styleHint(StyleHint hint) const;
|
||||
|
|
|
|||
|
|
@ -444,6 +444,8 @@ QVariant QPlatformTheme::themeHint(ThemeHint hint) const
|
|||
return QGuiApplicationPrivate::platformIntegration()->styleHint(QPlatformIntegration::MousePressAndHoldInterval);
|
||||
case QPlatformTheme::ItemViewActivateItemOnSingleClick:
|
||||
return QGuiApplicationPrivate::platformIntegration()->styleHint(QPlatformIntegration::ItemViewActivateItemOnSingleClick);
|
||||
case QPlatformTheme::UiEffects:
|
||||
return QGuiApplicationPrivate::platformIntegration()->styleHint(QPlatformIntegration::UiEffects);
|
||||
default:
|
||||
return QPlatformTheme::defaultThemeHint(hint);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -270,7 +270,8 @@ public:
|
|||
AnimateComboUiEffect = 0x8,
|
||||
AnimateTooltipUiEffect = 0x10,
|
||||
FadeTooltipUiEffect = 0x20,
|
||||
AnimateToolBoxUiEffect = 0x40
|
||||
AnimateToolBoxUiEffect = 0x40,
|
||||
HoverEffect = 0x80
|
||||
};
|
||||
|
||||
enum IconOption {
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -70,6 +70,7 @@ class Q_GUI_EXPORT QStyleHints : public QObject
|
|||
Q_PROPERTY(bool useRtlExtensions READ useRtlExtensions STORED false CONSTANT FINAL)
|
||||
Q_PROPERTY(Qt::TabFocusBehavior tabFocusBehavior READ tabFocusBehavior NOTIFY tabFocusBehaviorChanged FINAL)
|
||||
Q_PROPERTY(bool singleClickActivation READ singleClickActivation STORED false CONSTANT FINAL)
|
||||
Q_PROPERTY(bool useHoverEffects READ useHoverEffects WRITE setUseHoverEffects NOTIFY useHoverEffectsChanged FINAL)
|
||||
|
||||
public:
|
||||
void setMouseDoubleClickInterval(int mouseDoubleClickInterval);
|
||||
|
|
@ -96,6 +97,8 @@ public:
|
|||
Qt::TabFocusBehavior tabFocusBehavior() const;
|
||||
void setTabFocusBehavior(Qt::TabFocusBehavior tabFocusBehavior);
|
||||
bool singleClickActivation() const;
|
||||
bool useHoverEffects() const;
|
||||
void setUseHoverEffects(bool useHoverEffects);
|
||||
|
||||
Q_SIGNALS:
|
||||
void cursorFlashTimeChanged(int cursorFlashTime);
|
||||
|
|
@ -105,6 +108,7 @@ Q_SIGNALS:
|
|||
void startDragDistanceChanged(int startDragDistance);
|
||||
void startDragTimeChanged(int startDragTime);
|
||||
void tabFocusBehaviorChanged(Qt::TabFocusBehavior tabFocusBehavior);
|
||||
void useHoverEffectsChanged(bool useHoverEffects);
|
||||
|
||||
private:
|
||||
friend class QGuiApplication;
|
||||
|
|
|
|||
|
|
@ -666,6 +666,8 @@ QVariant QGnomeTheme::themeHint(QPlatformTheme::ThemeHint hint) const
|
|||
return QVariant(int(GnomeKeyboardScheme));
|
||||
case QPlatformTheme::PasswordMaskCharacter:
|
||||
return QVariant(QChar(0x2022));
|
||||
case QPlatformTheme::UiEffects:
|
||||
return QVariant(int(HoverEffect));
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -329,6 +329,8 @@ QVariant QCocoaTheme::themeHint(ThemeHint hint) const
|
|||
}
|
||||
case QPlatformTheme::PasswordMaskCharacter:
|
||||
return QVariant(QChar(kBulletUnicode));
|
||||
case QPlatformTheme::UiEffects:
|
||||
return QVariant(int(HoverEffect));
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -347,7 +347,7 @@ static inline QStringList styleNames()
|
|||
|
||||
static inline int uiEffects()
|
||||
{
|
||||
int result = 0;
|
||||
int result = QPlatformTheme::HoverEffect;
|
||||
if (booleanSystemParametersInfo(SPI_GETUIEFFECTS, false))
|
||||
result |= QPlatformTheme::GeneralUiEffect;
|
||||
if (booleanSystemParametersInfo(SPI_GETMENUANIMATION, false))
|
||||
|
|
|
|||
Loading…
Reference in New Issue