From da71c1c755b60a5f2544fd6708b97a8bc13f3679 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Mon, 9 Jan 2012 15:36:02 +0100 Subject: Introduce a QVariant themeHint() to QPlatformTheme. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Start on removing platform-specific code from QtWidgets. Change-Id: Ic2163a0ce6f2db2151cdf7ca93766b2d861eeb55 Reviewed-by: Samuel Rødal --- src/plugins/platforms/windows/qwindowstheme.cpp | 33 +++++++++++++++++++++++++ src/plugins/platforms/windows/qwindowstheme.h | 1 + 2 files changed, 34 insertions(+) (limited to 'src/plugins') diff --git a/src/plugins/platforms/windows/qwindowstheme.cpp b/src/plugins/platforms/windows/qwindowstheme.cpp index 4e1b004631..31adcfa167 100644 --- a/src/plugins/platforms/windows/qwindowstheme.cpp +++ b/src/plugins/platforms/windows/qwindowstheme.cpp @@ -41,13 +41,46 @@ #include "qwindowstheme.h" #include "qwindowsdialoghelpers.h" +#include "qwindowscontext.h" +#include "qt_windows.h" + +#include QT_BEGIN_NAMESPACE +static inline bool booleanSystemParametersInfo(UINT what, bool defaultValue) +{ + BOOL result; + if (SystemParametersInfo(what, 0, &result, 0)) + return result ? true : false; + return defaultValue; +} + +static inline bool dWordSystemParametersInfo(UINT what, DWORD defaultValue) +{ + DWORD result; + if (SystemParametersInfo(what, 0, &result, 0)) + return result; + return defaultValue; +} + QWindowsTheme::QWindowsTheme() { } +QVariant QWindowsTheme::themeHint(ThemeHint hint) const +{ + switch (hint) { + case TextCursorWidth: + return QVariant(int(dWordSystemParametersInfo(SPI_GETCARETWIDTH, 1u))); + case DropShadow: + return QVariant(booleanSystemParametersInfo(SPI_GETDROPSHADOW, false)); + case MaximumScrollBarDragDistance: + return QVariant(qRound(qreal(QWindowsContext::instance()->defaultDPI()) * 1.375)); + } + return QVariant(); +} + bool QWindowsTheme::usePlatformNativeDialog(const QDialog *dialog) const { return QWindowsDialogs::useHelper(dialog); diff --git a/src/plugins/platforms/windows/qwindowstheme.h b/src/plugins/platforms/windows/qwindowstheme.h index 67a0813835..9bb937d607 100644 --- a/src/plugins/platforms/windows/qwindowstheme.h +++ b/src/plugins/platforms/windows/qwindowstheme.h @@ -53,6 +53,7 @@ public: virtual bool usePlatformNativeDialog(const QDialog *dialog = 0) const; virtual QPlatformDialogHelper *createPlatformDialogHelper(QDialog *dialog = 0) const; + virtual QVariant themeHint(ThemeHint) const; }; QT_END_NAMESPACE -- cgit v1.2.3