From fc3207dfe1b615a856b6ad8eef22a8774e4a17f4 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Thu, 12 Jul 2012 09:54:50 +0200 Subject: Mirror potentially themeable style hints in QPlatformTheme. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Currently, most of the QStyleHint-values are potentially configureable by the user in certain desktop environments. Add them to the QPlatformTheme and query the theme first. Keep the values in QPlatformIntegration such that simple integrations that do not implement themes are not forced to implement them to change the values. Change-Id: I15742a5968df0ad5d7398cceae640dc7e541da52 Reviewed-by: David Faure Reviewed-by: Jørgen Lind --- src/gui/kernel/qstylehints.cpp | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) (limited to 'src/gui/kernel/qstylehints.cpp') diff --git a/src/gui/kernel/qstylehints.cpp b/src/gui/kernel/qstylehints.cpp index 99e37e4a41..acb31a2eb5 100644 --- a/src/gui/kernel/qstylehints.cpp +++ b/src/gui/kernel/qstylehints.cpp @@ -41,6 +41,7 @@ #include #include +#include #include QT_BEGIN_NAMESPACE @@ -50,6 +51,17 @@ static inline QVariant hint(QPlatformIntegration::StyleHint h) return QGuiApplicationPrivate::platformIntegration()->styleHint(h); } +static inline QVariant themeableHint(QPlatformTheme::ThemeHint th, + QPlatformIntegration::StyleHint ih) +{ + if (const QPlatformTheme *theme = QGuiApplicationPrivate::platformTheme()) { + const QVariant themeHint = theme->themeHint(th); + if (themeHint.isValid()) + return themeHint; + } + return QGuiApplicationPrivate::platformIntegration()->styleHint(ih); +} + /*! \class QStyleHints \since 5.0 @@ -64,37 +76,37 @@ QStyleHints::QStyleHints() int QStyleHints::mouseDoubleClickInterval() const { - return hint(QPlatformIntegration::MouseDoubleClickInterval).toInt(); + return themeableHint(QPlatformTheme::MouseDoubleClickInterval, QPlatformIntegration::MouseDoubleClickInterval).toInt(); } int QStyleHints::startDragDistance() const { - return hint(QPlatformIntegration::StartDragDistance).toInt(); + return themeableHint(QPlatformTheme::StartDragDistance, QPlatformIntegration::StartDragDistance).toInt(); } int QStyleHints::startDragTime() const { - return hint(QPlatformIntegration::StartDragTime).toInt(); + return themeableHint(QPlatformTheme::StartDragTime, QPlatformIntegration::StartDragTime).toInt(); } int QStyleHints::startDragVelocity() const { - return hint(QPlatformIntegration::StartDragVelocity).toInt(); + return themeableHint(QPlatformTheme::StartDragVelocity, QPlatformIntegration::StartDragVelocity).toInt(); } int QStyleHints::keyboardInputInterval() const { - return hint(QPlatformIntegration::KeyboardInputInterval).toInt(); + return themeableHint(QPlatformTheme::KeyboardInputInterval, QPlatformIntegration::KeyboardInputInterval).toInt(); } int QStyleHints::keyboardAutoRepeatRate() const { - return hint(QPlatformIntegration::KeyboardAutoRepeatRate).toInt(); + return themeableHint(QPlatformTheme::KeyboardAutoRepeatRate, QPlatformIntegration::KeyboardAutoRepeatRate).toInt(); } int QStyleHints::cursorFlashTime() const { - return hint(QPlatformIntegration::CursorFlashTime).toInt(); + return themeableHint(QPlatformTheme::CursorFlashTime, QPlatformIntegration::CursorFlashTime).toInt(); } bool QStyleHints::showIsFullScreen() const @@ -104,7 +116,7 @@ bool QStyleHints::showIsFullScreen() const int QStyleHints::passwordMaskDelay() const { - return hint(QPlatformIntegration::PasswordMaskDelay).toInt(); + return themeableHint(QPlatformTheme::PasswordMaskDelay, QPlatformIntegration::PasswordMaskDelay).toInt(); } qreal QStyleHints::fontSmoothingGamma() const -- cgit v1.2.3