summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSami Merila <sami.merila@nokia.com>2010-01-25 10:29:19 (GMT)
committerSami Merila <sami.merila@nokia.com>2010-01-25 10:29:19 (GMT)
commit7bbd14b371fe6d931b0c65b00bf36f3b9a2ac33c (patch)
treea44adb6778ed4a4feb443afd98d29e349256c05a
parentad1bc0ae6500092cbfb75ab869b3757add7ba4b7 (diff)
downloadQt-7bbd14b371fe6d931b0c65b00bf36f3b9a2ac33c.zip
Qt-7bbd14b371fe6d931b0c65b00bf36f3b9a2ac33c.tar.gz
Qt-7bbd14b371fe6d931b0c65b00bf36f3b9a2ac33c.tar.bz2
QListView::setAlternatingRowColors is not working
QS60Style does not really support alternating line/cell backgrounds. This is due to that no such thing exists on native side and we are using a graphical theme image as list/table background. For style, we'll use QPalette::Light with some transparecy to achieve this. Light is guaranteed to have good contrast with theme background as it is derived from QPalette::Button, which is calculated from button graphics, which *should* be used on top of theme background. Task-number: QTBUG-5980 Reviewed-by: Alessandro Portale
-rw-r--r--src/gui/styles/qs60style.cpp25
1 files changed, 21 insertions, 4 deletions
diff --git a/src/gui/styles/qs60style.cpp b/src/gui/styles/qs60style.cpp
index 28e94a3..5086549 100644
--- a/src/gui/styles/qs60style.cpp
+++ b/src/gui/styles/qs60style.cpp
@@ -675,8 +675,7 @@ void QS60StylePrivate::setThemePalette(QPalette *palette) const
s60Color(QS60StyleEnums::CL_QsnHighlightColors, 2, 0));
// set background image as a texture brush
palette->setBrush(QPalette::Window, backgroundTexture());
- // set these as transparent so that styled full screen theme background is visible
- palette->setColor(QPalette::AlternateBase, Qt::transparent);
+ // set as transparent so that styled full screen theme background is visible
palette->setBrush(QPalette::Base, Qt::transparent);
// set button and tooltipbase based on pixel colors
const QColor buttonColor = colorFromFrameGraphics(SF_ButtonNormal);
@@ -688,6 +687,9 @@ void QS60StylePrivate::setThemePalette(QPalette *palette) const
palette->setColor(QPalette::Midlight, palette->color(QPalette::Button).lighter(125));
palette->setColor(QPalette::Mid, palette->color(QPalette::Button).darker(150));
palette->setColor(QPalette::Shadow, Qt::black);
+ QColor alternateBase = palette->light().color();
+ alternateBase.setAlphaF(0.8);
+ palette->setColor(QPalette::AlternateBase, alternateBase);
QApplication::setPalette(*palette); //calling QApplication::setPalette clears palette hash
setThemePaletteHash(palette);
@@ -2210,7 +2212,6 @@ void QS60Style::drawPrimitive(PrimitiveElement element, const QStyleOption *opti
break;
#ifndef QT_NO_ITEMVIEWS
case PE_PanelItemViewItem:
- case PE_PanelItemViewRow: // ### Qt 5: remove
break;
#endif //QT_NO_ITEMVIEWS
@@ -2279,7 +2280,23 @@ void QS60Style::drawPrimitive(PrimitiveElement element, const QStyleOption *opti
}
}
break;
-
+ case PE_PanelItemViewRow: // ### Qt 5: remove
+#ifndef QT_NO_ITEMVIEWS
+ if (const QStyleOptionViewItemV4 *vopt = qstyleoption_cast<const QStyleOptionViewItemV4 *>(option)) {
+ if (vopt->palette.base().texture().cacheKey() != QS60StylePrivate::m_themePalette->base().texture().cacheKey()) {
+ //QPalette::Base has been changed, let commonstyle draw the item
+ commonStyleDraws = true;
+ } else {
+ QPalette::ColorGroup cg = vopt->state & QStyle::State_Enabled ? QPalette::Normal : QPalette::Disabled;
+ if (cg == QPalette::Normal && !(vopt->state & QStyle::State_Active))
+ cg = QPalette::Inactive;
+ if (vopt->features & QStyleOptionViewItemV2::Alternate)
+ painter->fillRect(vopt->rect, vopt->palette.brush(cg, QPalette::AlternateBase));
+ //apart from alternate base, no background for list item is drawn for S60Style
+ }
+ }
+#endif
+ break;
case PE_PanelScrollAreaCorner:
break;