summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew Knight <andrew.knight@digia.com>2014-07-04 15:20:35 +0300
committerAndrew Knight <andrew.knight@digia.com>2014-07-10 21:37:18 +0200
commitfff0844735f704289036a83ed3af87359483e530 (patch)
treef66aa87252b4e320f1003f0ea6d757b65f9d0e52
parentbb5b25e40d7d886961b423f0c3757684e1f47032 (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>
-rw-r--r--src/plugins/platforms/winrt/qwinrttheme.cpp70
-rw-r--r--src/plugins/platforms/winrt/qwinrttheme.h7
2 files changed, 77 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
diff --git a/src/plugins/platforms/winrt/qwinrttheme.h b/src/plugins/platforms/winrt/qwinrttheme.h
index 95bb736cd3..f7fd07c70d 100644
--- a/src/plugins/platforms/winrt/qwinrttheme.h
+++ b/src/plugins/platforms/winrt/qwinrttheme.h
@@ -47,6 +47,7 @@
QT_BEGIN_NAMESPACE
+class QWinRTThemePrivate;
class QWinRTTheme : public QPlatformTheme
{
public:
@@ -55,7 +56,13 @@ public:
bool usePlatformNativeDialog(DialogType type) const;
QPlatformDialogHelper *createPlatformDialogHelper(DialogType type) const;
+ const QPalette *palette(Palette type = SystemPalette) const Q_DECL_OVERRIDE;
+
static QVariant styleHint(QPlatformIntegration::StyleHint hint);
+
+private:
+ QScopedPointer<QWinRTThemePrivate> d_ptr;
+ Q_DECLARE_PRIVATE(QWinRTTheme)
};
QT_END_NAMESPACE