From: Friedemann Kleint Date: Thu, 12 Jul 2012 07:54:50 +0000 (+0200) Subject: Mirror potentially themeable style hints in QPlatformTheme. X-Git-Tag: v5.0.0-beta1~734 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=fc3207dfe1b615a856b6ad8eef22a8774e4a17f4;p=profile%2Fivi%2Fqtbase.git Mirror potentially themeable style hints in QPlatformTheme. 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 --- diff --git a/src/gui/kernel/qplatformintegration.cpp b/src/gui/kernel/qplatformintegration.cpp index d9e9c75..b713b71 100644 --- a/src/gui/kernel/qplatformintegration.cpp +++ b/src/gui/kernel/qplatformintegration.cpp @@ -48,6 +48,7 @@ #include #include #include +#include #include QT_BEGIN_NAMESPACE @@ -279,25 +280,25 @@ QVariant QPlatformIntegration::styleHint(StyleHint hint) const { switch (hint) { case CursorFlashTime: - return 1000; + return QPlatformTheme::defaultThemeHint(QPlatformTheme::CursorFlashTime); case KeyboardInputInterval: - return 400; + return QPlatformTheme::defaultThemeHint(QPlatformTheme::KeyboardInputInterval); case KeyboardAutoRepeatRate: - return 30; + return QPlatformTheme::defaultThemeHint(QPlatformTheme::KeyboardAutoRepeatRate); case MouseDoubleClickInterval: - return 400; + return QPlatformTheme::defaultThemeHint(QPlatformTheme::MouseDoubleClickInterval); case StartDragDistance: - return 10; + return QPlatformTheme::defaultThemeHint(QPlatformTheme::StartDragDistance); case StartDragTime: - return 500; + return QPlatformTheme::defaultThemeHint(QPlatformTheme::StartDragTime); case ShowIsFullScreen: return false; case PasswordMaskDelay: - return 0; + return QPlatformTheme::defaultThemeHint(QPlatformTheme::PasswordMaskDelay); case FontSmoothingGamma: return qreal(1.7); case StartDragVelocity: - return 0; // no limit + return QPlatformTheme::defaultThemeHint(QPlatformTheme::StartDragVelocity); case UseRtlExtensions: return QVariant(false); } diff --git a/src/gui/kernel/qplatformtheme.cpp b/src/gui/kernel/qplatformtheme.cpp index d1ca8b7..14336ab 100644 --- a/src/gui/kernel/qplatformtheme.cpp +++ b/src/gui/kernel/qplatformtheme.cpp @@ -63,6 +63,30 @@ QT_BEGIN_NAMESPACE This enum describes the available theme hints. + \value CursorFlashTime (int) Cursor flash time in ms, overriding + QPlatformIntegration::styleHint. + + \value KeyboardInputInterval (int) Keyboard input interval in ms, overriding + QPlatformIntegration::styleHint. + + \value MouseDoubleClickInterval (int) Mouse double click interval in ms, + overriding QPlatformIntegration::styleHint. + + \value StartDragDistance (int) Start drag distance, + overriding QPlatformIntegration::styleHint. + + \value StartDragTime (int) Start drag time in ms,, + overriding QPlatformIntegration::styleHint. + + \value KeyboardAutoRepeatRate (int) Keyboard auto repeat rate, + overriding QPlatformIntegration::styleHint. + + \value PasswordMaskDelay (int) Pass word mask delay in ms,, + overriding QPlatformIntegration::styleHint. + + \value StartDragVelocity (int) Velocity of a drag, + overriding QPlatformIntegration::styleHint. + \value TextCursorWidth (int) Determines the width of the text cursor. \value DropShadow (bool) Determines whether the drop shadow effect for @@ -139,7 +163,28 @@ const QFont *QPlatformTheme::font(Font type) const QVariant QPlatformTheme::themeHint(ThemeHint hint) const { + return QPlatformTheme::defaultThemeHint(hint); +} + +QVariant QPlatformTheme::defaultThemeHint(ThemeHint hint) +{ switch (hint) { + case QPlatformTheme::CursorFlashTime: + return QVariant(1000); + case QPlatformTheme::KeyboardInputInterval: + return QVariant(400); + case QPlatformTheme::KeyboardAutoRepeatRate: + return QVariant(30); + case QPlatformTheme::MouseDoubleClickInterval: + return QVariant(400); + case QPlatformTheme::StartDragDistance: + return QVariant(10); + case QPlatformTheme::StartDragTime: + return QVariant(500); + case QPlatformTheme::PasswordMaskDelay: + return QVariant(int(0)); + case QPlatformTheme::StartDragVelocity: + return QVariant(int(0)); // no limit case QPlatformTheme::UseFullScreenForPopupMenu: return QVariant(false); case QPlatformTheme::WindowAutoPlacement: diff --git a/src/gui/kernel/qplatformtheme.h b/src/gui/kernel/qplatformtheme.h index 5ead94c..107c57b 100644 --- a/src/gui/kernel/qplatformtheme.h +++ b/src/gui/kernel/qplatformtheme.h @@ -72,6 +72,14 @@ class Q_GUI_EXPORT QPlatformTheme { public: enum ThemeHint { + CursorFlashTime, + KeyboardInputInterval, + MouseDoubleClickInterval, + StartDragDistance, + StartDragTime, + KeyboardAutoRepeatRate, + PasswordMaskDelay, + StartDragVelocity, TextCursorWidth, DropShadow, MaximumScrollBarDragDistance, @@ -180,6 +188,8 @@ public: virtual const QFont *font(Font type = SystemFont) const; virtual QVariant themeHint(ThemeHint hint) const; + + static QVariant defaultThemeHint(ThemeHint hint); }; QT_END_NAMESPACE diff --git a/src/gui/kernel/qstylehints.cpp b/src/gui/kernel/qstylehints.cpp index 99e37e4..acb31a2 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