summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJens Bache-Wiig <jens.bache-wiig@nokia.com>2010-08-25 11:49:29 (GMT)
committerJens Bache-Wiig <jens.bache-wiig@nokia.com>2010-08-25 11:53:22 (GMT)
commit37e1bea301d3e4c4346fad16244067d62a093af6 (patch)
tree908a70224d1c9e919f9ab3a4e6f16d2c4d20d4be
parent41532e38ff2b5153b79374032112d435b42e48a2 (diff)
downloadQt-37e1bea301d3e4c4346fad16244067d62a093af6.zip
Qt-37e1bea301d3e4c4346fad16244067d62a093af6.tar.gz
Qt-37e1bea301d3e4c4346fad16244067d62a093af6.tar.bz2
Fixed item view background color in Gtk style
Autotests were modified to check for 50% color coverage as well. Before they were not really testing the bgcolor since they would accept only the red grid color as a valid test pass. Task-number: QTBUG-13125 Reviewed-by: ogoffart
-rw-r--r--src/gui/styles/qgtkstyle.cpp5
-rw-r--r--tests/auto/qstylesheetstyle/tst_qstylesheetstyle.cpp20
2 files changed, 21 insertions, 4 deletions
diff --git a/src/gui/styles/qgtkstyle.cpp b/src/gui/styles/qgtkstyle.cpp
index c989bd3..c5429dd 100644
--- a/src/gui/styles/qgtkstyle.cpp
+++ b/src/gui/styles/qgtkstyle.cpp
@@ -836,7 +836,10 @@ void QGtkStyle::drawPrimitive(PrimitiveElement element,
case PE_PanelItemViewItem:
if (const QStyleOptionViewItemV4 *vopt = qstyleoption_cast<const QStyleOptionViewItemV4 *>(option)) {
- if (vopt->backgroundBrush.style() != Qt::NoBrush) {
+ uint resolve_mask = vopt->palette.resolve();
+ if (vopt->backgroundBrush.style() != Qt::NoBrush
+ || (resolve_mask & (1 << QPalette::Base)))
+ {
QPointF oldBO = painter->brushOrigin();
painter->setBrushOrigin(vopt->rect.topLeft());
painter->fillRect(vopt->rect, vopt->backgroundBrush);
diff --git a/tests/auto/qstylesheetstyle/tst_qstylesheetstyle.cpp b/tests/auto/qstylesheetstyle/tst_qstylesheetstyle.cpp
index e370309..04b1e79 100644
--- a/tests/auto/qstylesheetstyle/tst_qstylesheetstyle.cpp
+++ b/tests/auto/qstylesheetstyle/tst_qstylesheetstyle.cpp
@@ -698,20 +698,25 @@ void tst_QStyleSheetStyle::fontPrecedence()
QCOMPARE(FONTSIZE(edit2), 26);
}
-static bool testForColors(const QImage& image, const QColor& color)
+// Ensure primary will only return true if the color covers more than 50% of pixels
+static bool testForColors(const QImage& image, const QColor& color, bool ensurePrimary=false)
{
int count = 0;
QRgb rgb = color.rgba();
+ int totalCount = image.height()*image.width();
for (int y = 0; y < image.height(); ++y) {
for (int x = 0; x < image.width(); ++x) {
// Because of antialiasing we allow a certain range of errors here.
QRgb pixel = image.pixel(x, y);
+
if (qAbs((int)(pixel & 0xff) - (int)(rgb & 0xff)) +
qAbs((int)((pixel & 0xff00) >> 8) - (int)((rgb & 0xff00) >> 8)) +
qAbs((int)((pixel & 0xff0000) >> 16) - (int)((rgb & 0xff0000) >> 16)) <= 50) {
- if (++count >= 10) {
+ count++;
+ if (!ensurePrimary && count >=10 )
+ return true;
+ else if (count > totalCount/2)
return true;
- }
}
}
}
@@ -1528,6 +1533,15 @@ void tst_QStyleSheetStyle::task188195_baseBackground()
tree.render(&image);
QVERIFY(testForColors(image, tree.palette().base().color()));
QVERIFY(!testForColors(image, QColor(0xab, 0x12, 0x51)));
+
+ QTableWidget table(12, 12);
+ table.setItem(0, 0, new QTableWidgetItem());
+ table.setStyleSheet( "QTableView {background-color: #ff0000}" );
+ table.show();
+ QTest::qWait(20);
+ image = QImage(table.width(), table.height(), QImage::Format_ARGB32);
+ table.render(&image);
+ QVERIFY(testForColors(image, Qt::red, true));
}
void tst_QStyleSheetStyle::task232085_spinBoxLineEditBg()