diff options
author | Sami Merilä <sami.merila@nokia.com> | 2009-05-26 08:10:56 (GMT) |
---|---|---|
committer | Sami Merilä <sami.merila@nokia.com> | 2009-05-26 08:10:56 (GMT) |
commit | ff0418c46ffe5270365b6d53298e3ea9014d14ac (patch) | |
tree | 63b1392ba7a6387e402baaf3bd7b858d010f3b17 | |
parent | 53b98fea3517c64a7f67693333e3c1af56d42a68 (diff) | |
download | Qt-ff0418c46ffe5270365b6d53298e3ea9014d14ac.zip Qt-ff0418c46ffe5270365b6d53298e3ea9014d14ac.tar.gz Qt-ff0418c46ffe5270365b6d53298e3ea9014d14ac.tar.bz2 |
S60Style: Add reason for clearing style specific caches.
-rw-r--r-- | src/gui/styles/qs60style.cpp | 31 | ||||
-rw-r--r-- | src/gui/styles/qs60style_p.h | 9 | ||||
-rw-r--r-- | src/gui/styles/qs60style_simulated.cpp | 2 | ||||
-rw-r--r-- | src/gui/styles/qs60style_symbian.cpp | 4 |
4 files changed, 28 insertions, 18 deletions
diff --git a/src/gui/styles/qs60style.cpp b/src/gui/styles/qs60style.cpp index f8cf885..5026d5c 100644 --- a/src/gui/styles/qs60style.cpp +++ b/src/gui/styles/qs60style.cpp @@ -350,14 +350,24 @@ QFont QS60StylePrivate::s60Font( return result; } -//todo: you could pass a reason to clear cache here, so that we could -// deduce whether or not the specific cache needs to be cleared -void QS60StylePrivate::clearCaches() +void QS60StylePrivate::clearCaches(QS60StylePrivate::CacheClearReason reason) { - m_colorCache.clear(); - m_mappedFontsCache.clear(); - QPixmapCache::clear(); - m_backgroundValid = false; + switch(reason){ + case CC_LayoutChange: + // when layout changes, the colors remain in cache + m_mappedFontsCache.clear(); //todo: can font change, when layout changes? + m_backgroundValid = false; + QPixmapCache::clear(); + break; + case CC_ThemeChange: //todo: can font change when theme changes? + case CC_UndefinedChange: + default: + m_colorCache.clear(); + m_mappedFontsCache.clear(); + QPixmapCache::clear(); + m_backgroundValid = false; + break; + } } // Since S60Style has 'button' and 'tooltip' as a graphic, we don't have any native color which to use @@ -381,7 +391,6 @@ QColor QS60StylePrivate::colorFromFrameGraphics(QS60StylePrivate::SkinFrameEleme const int pixels = frameImage.numBytes()/sizeof(QRgb); const int bytesPerLine = frameImage.bytesPerLine(); Q_ASSERT(bytesPerLine); - const int rows = frameImage.numBytes()/(sizeof(QRgb)*bytesPerLine); int estimatedRed = 0; int estimatedGreen = 0; @@ -761,8 +770,6 @@ void QS60Style::drawComplexControl(ComplexControl control, const QStyleOptionCom const QS60StylePrivate::SkinElementFlags flags = (option->state & State_Enabled) ? QS60StylePrivate::SF_StateEnabled : QS60StylePrivate::SF_StateDisabled; SubControls sub = option->subControls; - Q_D(const QS60Style); - switch (control) { #ifndef QT_NO_SCROLLBAR case CC_ScrollBar: @@ -2413,7 +2420,6 @@ QRect QS60Style::subControlRect(ComplexControl control, const QStyleOptionComple //slightly indent text and boxes, so that dialog border does not mess with them. const int horizontalSpacing = QS60StylePrivate::pixelMetric(QStyle::PM_LayoutHorizontalSpacing); - const int bottomMargin = QS60StylePrivate::pixelMetric(QStyle::PM_LayoutBottomMargin); ret.adjust(2,horizontalSpacing-3,0,0); break; case SC_GroupBoxFrame: { @@ -2518,13 +2524,10 @@ QRect QS60Style::subElementRect(SubElement element, const QStyleOption *opt, con } } else if (const QStyleOptionMenuItem *menuItem = qstyleoption_cast<const QStyleOptionMenuItem *>(opt)) { const bool checkable = menuItem->checkType != QStyleOptionMenuItem::NotCheckable; - const bool subMenu = menuItem->menuItemType == QStyleOptionMenuItem::SubMenu; int indicatorWidth = checkable ? pixelMetric(PM_ListViewIconSize, opt, widget) : pixelMetric(PM_SmallIconSize, opt, widget); ret = menuItem->rect; - const int verticalSpacing = - QS60StylePrivate::pixelMetric(QStyle::PM_LayoutVerticalSpacing); if (element == SE_ItemViewItemDecoration) { if (menuItem->direction == Qt::RightToLeft) diff --git a/src/gui/styles/qs60style_p.h b/src/gui/styles/qs60style_p.h index 37c6ec7..ba7dca3 100644 --- a/src/gui/styles/qs60style_p.h +++ b/src/gui/styles/qs60style_p.h @@ -331,6 +331,13 @@ public: SF_StateDisabled = 0x0020, SF_ColorSkinned = 0x0040, }; + + enum CacheClearReason { + CC_UndefinedChange = 0, + CC_LayoutChange, + CC_ThemeChange + }; + Q_DECLARE_FLAGS(SkinElementFlags, SkinElementFlag) // draws skin element @@ -365,7 +372,7 @@ public: QFont s60Font(QS60StyleEnums::FontCategories fontCategory, int pointSize = -1) const; // clears all style caches (fonts, colors, pixmaps) - void clearCaches(); + void clearCaches(CacheClearReason reason = CC_UndefinedChange); // returns themed background texture static QPixmap backgroundTexture(); diff --git a/src/gui/styles/qs60style_simulated.cpp b/src/gui/styles/qs60style_simulated.cpp index f10da2b..65336ae 100644 --- a/src/gui/styles/qs60style_simulated.cpp +++ b/src/gui/styles/qs60style_simulated.cpp @@ -289,7 +289,7 @@ void QS60Style::setS60Theme(const QHash<QString, QPicture> &parts, Q_D(QS60Style); QS60StyleModeSpecifics::m_partPictures = parts; QS60StyleModeSpecifics::m_colors = colors; - d->clearCaches(); + d->clearCaches(QS60StylePrivate::CC_ThemeChange); } QT_END_NAMESPACE diff --git a/src/gui/styles/qs60style_symbian.cpp b/src/gui/styles/qs60style_symbian.cpp index 48b759a..3fc4c8c 100644 --- a/src/gui/styles/qs60style_symbian.cpp +++ b/src/gui/styles/qs60style_symbian.cpp @@ -1352,7 +1352,7 @@ void QS60StyleModeSpecifics::colorGroupAndIndex( void QS60Style::handleDynamicLayoutVariantSwitch() { Q_D(QS60Style); - d->clearCaches(); + d->clearCaches(QS60StylePrivate::CC_LayoutChange); #ifdef QT_S60STYLE_LAYOUTDATA_SIMULATED d->setActiveLayout(); #endif // QT_S60STYLE_LAYOUTDATA_SIMULATED @@ -1365,7 +1365,7 @@ void QS60Style::handleDynamicLayoutVariantSwitch() void QS60Style::handleSkinChange() { Q_D(QS60Style); - d->clearCaches(); + d->clearCaches(QS60StylePrivate::CC_ThemeChange); d->setThemePalette(qApp); foreach (QWidget *topLevelWidget, QApplication::allWidgets()){ QEvent e(QEvent::StyleChange); |