summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSami Merila <sami.merila@nokia.com>2011-06-29 11:36:09 (GMT)
committerSami Merila <sami.merila@nokia.com>2011-06-29 11:36:09 (GMT)
commit2197b8be6003ad3d0071564afb7080650202661b (patch)
tree57b783565a2cac02ab5a714cd803b7b0f0773127
parent177f466bc581f8ad5bd4e883e8bc342a0b6c7484 (diff)
downloadQt-2197b8be6003ad3d0071564afb7080650202661b.zip
Qt-2197b8be6003ad3d0071564afb7080650202661b.tar.gz
Qt-2197b8be6003ad3d0071564afb7080650202661b.tar.bz2
Fix QWidget::palettePropagation2() autotest on Symbian
Autotest fails since calling QApplication::setPalette() clears away QPalette hash (class specific palette information). QS60Style tries to re-set theme-specific hash after updating application palette with real theme background, but does not take into account that application might have defined own custom palette hash data. As a fix, store the previously set palette hash information and restore it after calling QApplication::setPalette(). Additionally, remove the palette change event sending, since QApplication will post that event anyway when palette is updated. Task-number: QT-5011 Reviewed-by: Miikka Heikkinen
-rw-r--r--src/gui/styles/qs60style_s60.cpp22
1 files changed, 18 insertions, 4 deletions
diff --git a/src/gui/styles/qs60style_s60.cpp b/src/gui/styles/qs60style_s60.cpp
index 5699dbb..783dc05 100644
--- a/src/gui/styles/qs60style_s60.cpp
+++ b/src/gui/styles/qs60style_s60.cpp
@@ -1433,12 +1433,26 @@ QPixmap QS60StylePrivate::backgroundTexture(bool skipCreation)
// Notify all widgets that palette is updated with the actual background texture.
QPalette pal = QApplication::palette();
pal.setBrush(QPalette::Window, *m_background);
+
+ //Application palette hash is automatically cleared when QApplication::setPalette is called.
+ //To avoid losing palette hash data, back it up before calling the setPalette() API and
+ //restore it afterwards.
+ typedef QHash<QByteArray, QPalette> PaletteHash;
+ PaletteHash hash;
+ if (qt_app_palettes_hash() || !qt_app_palettes_hash()->isEmpty())
+ hash = *qt_app_palettes_hash();
QApplication::setPalette(pal);
- setThemePaletteHash(&pal);
+ if (hash.isEmpty()) {
+ //set default theme palette hash
+ setThemePaletteHash(&pal);
+ } else {
+ for (int i = 0; i < hash.count() - 1; i++) {
+ QByteArray widgetClassName = hash.keys().at(i);
+ QApplication::setPalette(hash.value(widgetClassName), widgetClassName);
+ }
+ }
storeThemePalette(&pal);
- foreach (QWidget *widget, QApplication::allWidgets()){
- QEvent e(QEvent::PaletteChange);
- QApplication::sendEvent(widget, &e);
+ foreach (QWidget *widget, QApplication::allWidgets()) {
setThemePalette(widget);
widget->ensurePolished();
}