From 2e965ca8b766389e93540eb95aa5dd9d258cae11 Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Fri, 17 Jan 2014 15:00:07 +0100 Subject: [PATCH] Android: default palette taken from the Holo Light theme Currently QAndroidPlatformTheme::palette has been returning null so the default colors came from elsewhere. Now they will default to colors taken from the Holo Light theme to the extent possible. Change-Id: I022c5ef679d9d0dcb76721a4d520492bc8a6f4cf Reviewed-by: BogDan Vatra --- .../android/qandroidplatformtheme.cpp | 34 ++++++++++++++++++- .../platforms/android/qandroidplatformtheme.h | 3 ++ 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/src/plugins/platforms/android/qandroidplatformtheme.cpp b/src/plugins/platforms/android/qandroidplatformtheme.cpp index ab29541f15..5468c00a57 100644 --- a/src/plugins/platforms/android/qandroidplatformtheme.cpp +++ b/src/plugins/platforms/android/qandroidplatformtheme.cpp @@ -52,6 +52,38 @@ QAndroidPlatformTheme::QAndroidPlatformTheme(QAndroidPlatformNativeInterface *androidPlatformNativeInterface) { m_androidPlatformNativeInterface = androidPlatformNativeInterface; + QColor background(229, 229, 229); + QColor light = background.lighter(150); + QColor mid(background.darker(130)); + QColor midLight = mid.lighter(110); + QColor base(249, 249, 249); + QColor disabledBase(background); + QColor dark = background.darker(150); + QColor darkDisabled = dark.darker(110); + QColor text = Qt::black; + QColor highlightedText = Qt::black; + QColor disabledText = QColor(190, 190, 190); + QColor button(241, 241, 241); + QColor shadow(201, 201, 201); + QColor highlight(148, 210, 231); + QColor disabledShadow = shadow.lighter(150); + + m_defaultPalette = QPalette(Qt::black,background,light,dark,mid,text,base); + m_defaultPalette.setBrush(QPalette::Midlight, midLight); + m_defaultPalette.setBrush(QPalette::Button, button); + m_defaultPalette.setBrush(QPalette::Shadow, shadow); + m_defaultPalette.setBrush(QPalette::HighlightedText, highlightedText); + + m_defaultPalette.setBrush(QPalette::Disabled, QPalette::Text, disabledText); + m_defaultPalette.setBrush(QPalette::Disabled, QPalette::WindowText, disabledText); + m_defaultPalette.setBrush(QPalette::Disabled, QPalette::ButtonText, disabledText); + m_defaultPalette.setBrush(QPalette::Disabled, QPalette::Base, disabledBase); + m_defaultPalette.setBrush(QPalette::Disabled, QPalette::Dark, darkDisabled); + m_defaultPalette.setBrush(QPalette::Disabled, QPalette::Shadow, disabledShadow); + + m_defaultPalette.setBrush(QPalette::Active, QPalette::Highlight, highlight); + m_defaultPalette.setBrush(QPalette::Inactive, QPalette::Highlight, highlight); + m_defaultPalette.setBrush(QPalette::Disabled, QPalette::Highlight, highlight.lighter(150)); } QPlatformMenuBar *QAndroidPlatformTheme::createPlatformMenuBar() const @@ -102,7 +134,7 @@ const QPalette *QAndroidPlatformTheme::palette(Palette type) const QHash::const_iterator it = m_androidPlatformNativeInterface->m_palettes.find(paletteType(type)); if (it != m_androidPlatformNativeInterface->m_palettes.end()) return &(it.value()); - return 0; + return &m_defaultPalette; } static inline int fontType(QPlatformTheme::Font type) diff --git a/src/plugins/platforms/android/qandroidplatformtheme.h b/src/plugins/platforms/android/qandroidplatformtheme.h index 544061a7a2..9df445ef17 100644 --- a/src/plugins/platforms/android/qandroidplatformtheme.h +++ b/src/plugins/platforms/android/qandroidplatformtheme.h @@ -43,6 +43,8 @@ #define QANDROIDPLATFORMTHEME_H #include +#include + class QAndroidPlatformNativeInterface; class QAndroidPlatformTheme: public QPlatformTheme { @@ -61,6 +63,7 @@ public: private: QAndroidPlatformNativeInterface * m_androidPlatformNativeInterface; + QPalette m_defaultPalette; }; #endif // QANDROIDPLATFORMTHEME_H