summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorSamuel Rødal <sroedal@trolltech.com>2010-01-14 12:46:52 (GMT)
committerPrasanth Ullattil <prasanth.ullattil@nokia.com>2010-01-27 15:30:27 (GMT)
commitd867c403dfbc284e2f564939622854900ab66919 (patch)
tree0061554fa83e3d4f3db4a410f1adb4c562798451 /tests
parent00371f6b694c98e44799a15058002ab58ab389d5 (diff)
downloadQt-d867c403dfbc284e2f564939622854900ab66919.zip
Qt-d867c403dfbc284e2f564939622854900ab66919.tar.gz
Qt-d867c403dfbc284e2f564939622854900ab66919.tar.bz2
Fixed child items with graphics effects not inheriting opacity.
We need to invalidate the graphics source pixmap cache for both child items and parent items when changing the opacity of a graphics item. Reviewed-by: Bjørn Erik Nilsen
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qgraphicseffect/tst_qgraphicseffect.cpp34
1 files changed, 32 insertions, 2 deletions
diff --git a/tests/auto/qgraphicseffect/tst_qgraphicseffect.cpp b/tests/auto/qgraphicseffect/tst_qgraphicseffect.cpp
index 51e2a57..795431b 100644
--- a/tests/auto/qgraphicseffect/tst_qgraphicseffect.cpp
+++ b/tests/auto/qgraphicseffect/tst_qgraphicseffect.cpp
@@ -71,6 +71,7 @@ private slots:
void colorize();
void drawPixmapItem();
void deviceCoordinateTranslateCaching();
+ void inheritOpacity();
};
void tst_QGraphicsEffect::initTestCase()
@@ -79,8 +80,8 @@ void tst_QGraphicsEffect::initTestCase()
class CustomItem : public QGraphicsRectItem
{
public:
- CustomItem(qreal x, qreal y, qreal width, qreal height)
- : QGraphicsRectItem(x, y, width, height), numRepaints(0),
+ CustomItem(qreal x, qreal y, qreal width, qreal height, QGraphicsItem *parent = 0)
+ : QGraphicsRectItem(x, y, width, height, parent), numRepaints(0),
m_painter(0), m_styleOption(0)
{}
@@ -560,6 +561,35 @@ void tst_QGraphicsEffect::deviceCoordinateTranslateCaching()
QVERIFY(item->numRepaints == numRepaints);
}
+void tst_QGraphicsEffect::inheritOpacity()
+{
+ QGraphicsScene scene;
+ QGraphicsRectItem *rectItem = new QGraphicsRectItem(0, 0, 10, 10);
+ CustomItem *item = new CustomItem(0, 0, 10, 10, rectItem);
+
+ scene.addItem(rectItem);
+
+ item->setGraphicsEffect(new DeviceEffect);
+ item->setPen(Qt::NoPen);
+ item->setBrush(Qt::red);
+
+ rectItem->setOpacity(0.5);
+
+ QGraphicsView view(&scene);
+ view.show();
+ QTest::qWaitForWindowShown(&view);
+
+ QTRY_VERIFY(item->numRepaints >= 1);
+
+ int numRepaints = item->numRepaints;
+
+ rectItem->setOpacity(1);
+ QTest::qWait(50);
+
+ // item should have been rerendered due to opacity changing
+ QTRY_VERIFY(item->numRepaints > numRepaints);
+}
+
QTEST_MAIN(tst_QGraphicsEffect)
#include "tst_qgraphicseffect.moc"