diff options
author | Andrew Knight <andrew.knight@digia.com> | 2014-07-04 15:20:35 +0300 |
---|---|---|
committer | Andrew Knight <andrew.knight@digia.com> | 2014-07-10 21:37:18 +0200 |
commit | fff0844735f704289036a83ed3af87359483e530 (patch) | |
tree | f66aa87252b4e320f1003f0ea6d757b65f9d0e52 /src/plugins/platforms/winrt/qwinrttheme.cpp | |
parent | bb5b25e40d7d886961b423f0c3757684e1f47032 (diff) |
winrt: Introduce theme palette
Use the colors returned by WinRT's UISettings class to construct the
system palette.
Change-Id: Id0d99c7b2e3df209de0755ee72a0d2bda67fda8c
Reviewed-by: Maurice Kalinowski <maurice.kalinowski@digia.com>
Reviewed-by: Jochen Seemann <seemann.jochen@gmail.com>
Diffstat (limited to 'src/plugins/platforms/winrt/qwinrttheme.cpp')
-rw-r--r-- | src/plugins/platforms/winrt/qwinrttheme.cpp | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/src/plugins/platforms/winrt/qwinrttheme.cpp b/src/plugins/platforms/winrt/qwinrttheme.cpp index 041c15fbf4..65ed9440b2 100644 --- a/src/plugins/platforms/winrt/qwinrttheme.cpp +++ b/src/plugins/platforms/winrt/qwinrttheme.cpp @@ -43,10 +43,13 @@ #include "qwinrtplatformmessagedialoghelper.h" #include <QtCore/qfunctions_winrt.h> +#include <QtGui/QPalette> #include <wrl.h> +#include <windows.ui.h> #include <windows.ui.viewmanagement.h> using namespace Microsoft::WRL; +using namespace ABI::Windows::UI; using namespace ABI::Windows::UI::ViewManagement; QT_BEGIN_NAMESPACE @@ -63,8 +66,67 @@ static IUISettings *uiSettings() return settings.Get(); } +class QWinRTThemePrivate +{ +public: + QPalette palette; +}; + QWinRTTheme::QWinRTTheme() + : d_ptr(new QWinRTThemePrivate) { + Q_D(QWinRTTheme); + + HRESULT hr; + union { Color ui; QRgb qt; } color; + + hr = uiSettings()->UIElementColor(UIElementType_ActiveCaption, &color.ui); + Q_ASSERT_SUCCEEDED(hr); + d->palette.setColor(QPalette::ToolTipBase, color.qt); + + hr = uiSettings()->UIElementColor(UIElementType_Background, &color.ui); + Q_ASSERT_SUCCEEDED(hr); + d->palette.setColor(QPalette::AlternateBase, color.qt); + + hr = uiSettings()->UIElementColor(UIElementType_ButtonFace, &color.ui); + Q_ASSERT_SUCCEEDED(hr); + d->palette.setColor(QPalette::Button, color.qt); + d->palette.setColor(QPalette::Midlight, QColor(color.qt).lighter(110)); + d->palette.setColor(QPalette::Light, QColor(color.qt).lighter(150)); + d->palette.setColor(QPalette::Mid, QColor(color.qt).dark(130)); + d->palette.setColor(QPalette::Dark, QColor(color.qt).dark(150)); + + hr = uiSettings()->UIElementColor(UIElementType_ButtonText, &color.ui); + Q_ASSERT_SUCCEEDED(hr); + d->palette.setColor(QPalette::ButtonText, color.qt); + d->palette.setColor(QPalette::Text, color.qt); + + hr = uiSettings()->UIElementColor(UIElementType_CaptionText, &color.ui); + Q_ASSERT_SUCCEEDED(hr); + d->palette.setColor(QPalette::ToolTipText, color.qt); + + hr = uiSettings()->UIElementColor(UIElementType_Highlight, &color.ui); + Q_ASSERT_SUCCEEDED(hr); + d->palette.setColor(QPalette::Highlight, color.qt); + + hr = uiSettings()->UIElementColor(UIElementType_HighlightText, &color.ui); + Q_ASSERT_SUCCEEDED(hr); + d->palette.setColor(QPalette::HighlightedText, color.qt); + + hr = uiSettings()->UIElementColor(UIElementType_Window, &color.ui); + Q_ASSERT_SUCCEEDED(hr); + d->palette.setColor(QPalette::Window, color.qt); + d->palette.setColor(QPalette::Base, color.qt); + +#ifdef Q_OS_WINPHONE + hr = uiSettings()->UIElementColor(UIElementType_TextHigh, &color.ui); + Q_ASSERT_SUCCEEDED(hr); + d->palette.setColor(QPalette::BrightText, color.qt); +#else + hr = uiSettings()->UIElementColor(UIElementType_Hotlight, &color.ui); + Q_ASSERT_SUCCEEDED(hr); + d->palette.setColor(QPalette::BrightText, color.qt); +#endif } bool QWinRTTheme::usePlatformNativeDialog(DialogType type) const @@ -135,4 +197,12 @@ QVariant QWinRTTheme::styleHint(QPlatformIntegration::StyleHint hint) return QVariant(); } +const QPalette *QWinRTTheme::palette(Palette type) const +{ + Q_D(const QWinRTTheme); + if (type == SystemPalette) + return &d->palette; + return QPlatformTheme::palette(type); +} + QT_END_NAMESPACE |