summaryrefslogtreecommitdiffstats
path: root/src/widgets/kernel
diff options
context:
space:
mode:
authorMorten Johan Sorvig <morten.sorvig@nokia.com>2012-02-24 09:17:00 +0100
committerQt by Nokia <qt-info@nokia.com>2012-03-06 12:30:16 +0100
commit930a90d97835223587c2c8df1213c64295f3af97 (patch)
tree9a9d3e2fb3fc1e235511ed1a70743d18fc4b2a88 /src/widgets/kernel
parent9d5e721e96f19812a766a4c7d3f8b41f455f507c (diff)
Cocoa: Implement widget palettes.
Add roles to QPLatformTheme::Palette, map QWidget subclasses to those. Port Qt4 widget palette creation code to use the QPLatformTheme::Palette roles. Palette entries are disabled in this commit, this will be fixed later. Change-Id: I07babe3d7c76d306efc4ea4813c7161fdf36227f Reviewed-by: Friedemann Kleint <Friedemann.Kleint@nokia.com>
Diffstat (limited to 'src/widgets/kernel')
-rw-r--r--src/widgets/kernel/qapplication.cpp5
-rw-r--r--src/widgets/kernel/qapplication_qpa.cpp25
2 files changed, 29 insertions, 1 deletions
diff --git a/src/widgets/kernel/qapplication.cpp b/src/widgets/kernel/qapplication.cpp
index 53f4942310..bf2729a6d8 100644
--- a/src/widgets/kernel/qapplication.cpp
+++ b/src/widgets/kernel/qapplication.cpp
@@ -131,8 +131,11 @@ QApplicationPrivate *QApplicationPrivate::self = 0;
static void initSystemPalette()
{
if (!QApplicationPrivate::sys_pal)
- if (const QPalette *themePalette = QGuiApplicationPrivate::platformTheme()->palette())
+ if (const QPalette *themePalette = QGuiApplicationPrivate::platformTheme()->palette()) {
QApplicationPrivate::setSystemPalette(*themePalette);
+ QApplicationPrivate::initializeWidgetPaletteHash();
+ }
+
if (!QApplicationPrivate::sys_pal && QApplicationPrivate::app_style)
QApplicationPrivate::setSystemPalette(QApplicationPrivate::app_style->standardPalette());
}
diff --git a/src/widgets/kernel/qapplication_qpa.cpp b/src/widgets/kernel/qapplication_qpa.cpp
index 54c5c39396..6c91b89674 100644
--- a/src/widgets/kernel/qapplication_qpa.cpp
+++ b/src/widgets/kernel/qapplication_qpa.cpp
@@ -289,8 +289,33 @@ void QApplicationPrivate::cleanupMultitouch_sys()
{
}
+static void setPossiblePalette(const QPalette *palette, const char *className)
+{
+ if (palette == 0)
+ return;
+ QApplicationPrivate::setPalette_helper(*palette, className, false);
+}
+
+
void QApplicationPrivate::initializeWidgetPaletteHash()
{
+ QPlatformTheme *platformTheme = QGuiApplicationPrivate::platformTheme();
+ if (!platformTheme)
+ return;
+ setPossiblePalette(platformTheme->palette(QPlatformTheme::ToolButtonPalette), "QToolButton");
+ setPossiblePalette(platformTheme->palette(QPlatformTheme::ButtonPalette), "QAbstractButton");
+ setPossiblePalette(platformTheme->palette(QPlatformTheme::HeaderPalette), "QHeaderView");
+ setPossiblePalette(platformTheme->palette(QPlatformTheme::HeaderPalette), "Q3Header");
+ setPossiblePalette(platformTheme->palette(QPlatformTheme::ItemViewPalette), "QAbstractItemView");
+ setPossiblePalette(platformTheme->palette(QPlatformTheme::MessageBoxLabelPelette), "QMessageBoxLabel");
+ setPossiblePalette(platformTheme->palette(QPlatformTheme::TabBarPalette), "QTabBar");
+ setPossiblePalette(platformTheme->palette(QPlatformTheme::LabelPalette), "QLabel");
+ setPossiblePalette(platformTheme->palette(QPlatformTheme::GroupBoxPalette), "QGroupBox");
+ setPossiblePalette(platformTheme->palette(QPlatformTheme::MenuPalette), "QMenu");
+ setPossiblePalette(platformTheme->palette(QPlatformTheme::MenuBarPalette), "QMenuBar");
+ setPossiblePalette(platformTheme->palette(QPlatformTheme::TextEditPalette), "QTextEdit");
+ setPossiblePalette(platformTheme->palette(QPlatformTheme::TextEditPalette), "QTextControl");
+ setPossiblePalette(platformTheme->palette(QPlatformTheme::TextLineEditPalette), "QLineEdit");
}
#ifndef QT_NO_WHEELEVENT