diff options
Diffstat (limited to 'src/gui/kernel/qstylehints.cpp')
-rw-r--r-- | src/gui/kernel/qstylehints.cpp | 86 |
1 files changed, 60 insertions, 26 deletions
diff --git a/src/gui/kernel/qstylehints.cpp b/src/gui/kernel/qstylehints.cpp index cb07888170..5029701f24 100644 --- a/src/gui/kernel/qstylehints.cpp +++ b/src/gui/kernel/qstylehints.cpp @@ -2,6 +2,7 @@ // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include <qstylehints.h> +#include "qstylehints_p.h" #include <qpa/qplatformintegration.h> #include <qpa/qplatformtheme.h> #include <private/qguiapplication_p.h> @@ -43,25 +44,6 @@ static inline QVariant themeableHint(QPlatformTheme::ThemeHint th) return QPlatformTheme::defaultThemeHint(th); } -class QStyleHintsPrivate : public QObjectPrivate -{ - Q_DECLARE_PUBLIC(QStyleHints) -public: - int m_mouseDoubleClickInterval = -1; - int m_mousePressAndHoldInterval = -1; - int m_startDragDistance = -1; - int m_startDragTime = -1; - int m_keyboardInputInterval = -1; - int m_cursorFlashTime = -1; - int m_tabFocusBehavior = -1; - int m_uiEffects = -1; - int m_showShortcutsInContextMenus = -1; - int m_wheelScrollLines = -1; - int m_mouseQuickSelectionThreshold = -1; - int m_mouseDoubleClickDistance = -1; - int m_touchDoubleTapDistance = -1; -}; - /*! \class QStyleHints \since 5.0 @@ -71,11 +53,10 @@ public: An object of this class, obtained from QGuiApplication, provides access to certain global user interface parameters of the current platform. - Access is read only; typically the platform itself provides the user a way to tune these - parameters. - - Access to these parameters are useful when implementing custom user interface components, in that - they allow the components to exhibit the same behaviour and feel as other components. + Access to most settings is read only. The platform itself usually provides the user with + ways to tune these parameters. Authors of custom user interface components should read + relevant settings to allow the components to exhibit the same behavior and feel as other + components. \sa QGuiApplication::styleHints() */ @@ -123,7 +104,7 @@ int QStyleHints::mouseDoubleClickDistance() const Q_D(const QStyleHints); return d->m_mouseDoubleClickDistance >= 0 ? d->m_mouseDoubleClickDistance : - themeableHint(QPlatformTheme::MouseDoubleClickDistance).toInt(); + themeableHint(QPlatformTheme::MouseDoubleClickDistance, QPlatformIntegration::MouseDoubleClickDistance).toInt(); } /*! @@ -141,6 +122,18 @@ int QStyleHints::touchDoubleTapDistance() const } /*! + \property QStyleHints::colorScheme + \brief the color scheme of the platform theme. + \sa Qt::ColorScheme + \since 6.5 +*/ +Qt::ColorScheme QStyleHints::colorScheme() const +{ + Q_D(const QStyleHints); + return d->colorScheme(); +} + +/*! Sets the \a mousePressAndHoldInterval. \internal \sa mousePressAndHoldInterval() @@ -286,15 +279,29 @@ int QStyleHints::keyboardInputInterval() const themeableHint(QPlatformTheme::KeyboardInputInterval, QPlatformIntegration::KeyboardInputInterval).toInt(); } +#if QT_DEPRECATED_SINCE(6, 5) /*! \property QStyleHints::keyboardAutoRepeatRate \brief the rate, in events per second, in which additional repeated key presses will automatically be generated if a key is being held down. + \deprecated [6.5] Use keyboardAutoRepeatRateF() instead */ int QStyleHints::keyboardAutoRepeatRate() const { return themeableHint(QPlatformTheme::KeyboardAutoRepeatRate, QPlatformIntegration::KeyboardAutoRepeatRate).toInt(); } +#endif + +/*! + \property QStyleHints::keyboardAutoRepeatRateF + \since 6.5 + \brief the rate, in events per second, in which additional repeated key + presses will automatically be generated if a key is being held down. +*/ +qreal QStyleHints::keyboardAutoRepeatRateF() const +{ + return themeableHint(QPlatformTheme::KeyboardAutoRepeatRate, QPlatformIntegration::KeyboardAutoRepeatRate).toReal(); +} /*! Sets the \a cursorFlashTime. @@ -370,6 +377,8 @@ bool QStyleHints::showIsMaximized() const Since Qt 5.13, the setShowShortcutsInContextMenus() function can be used to override the platform default. + + \sa Qt::AA_DontShowShortcutsInContextMenus */ bool QStyleHints::showShortcutsInContextMenus() const { @@ -440,7 +449,7 @@ bool QStyleHints::useRtlExtensions() const */ bool QStyleHints::setFocusOnTouchRelease() const { - return hint(QPlatformIntegration::SetFocusOnTouchRelease).toBool(); + return themeableHint(QPlatformTheme::SetFocusOnTouchRelease, QPlatformIntegration::SetFocusOnTouchRelease).toBool(); } /*! @@ -584,6 +593,31 @@ int QStyleHints::mouseQuickSelectionThreshold() const return themeableHint(QPlatformTheme::MouseQuickSelectionThreshold, QPlatformIntegration::MouseQuickSelectionThreshold).toInt(); } +/*! + \internal + QStyleHintsPrivate::updateColorScheme - set a new color scheme. + + This function is called by the QPA plugin when the system theme changes. This in + turn might be the result of an explicit request of a color scheme via setColorScheme. + + Set \a colorScheme as the new color scheme of the QStyleHints. + The colorSchemeChanged signal will be emitted if present and new color scheme differ. + */ +void QStyleHintsPrivate::updateColorScheme(Qt::ColorScheme colorScheme) +{ + if (m_colorScheme == colorScheme) + return; + m_colorScheme = colorScheme; + Q_Q(QStyleHints); + emit q->colorSchemeChanged(colorScheme); +} + +QStyleHintsPrivate *QStyleHintsPrivate::get(QStyleHints *q) +{ + Q_ASSERT(q); + return q->d_func(); +} + QT_END_NAMESPACE #include "moc_qstylehints.cpp" |