diff options
author | Yoann Lopes <yoann.lopes@nokia.com> | 2010-04-21 11:24:27 (GMT) |
---|---|---|
committer | Yoann Lopes <yoann.lopes@nokia.com> | 2010-04-21 11:43:45 (GMT) |
commit | ad0c6b17cde4a3ce0041d1a54b96ccb5a6792520 (patch) | |
tree | 34693630d3a836252715505e536c9c28ec9c64aa | |
parent | 48b2025663c93003cd00b807bb74d220c933b78b (diff) | |
download | Qt-ad0c6b17cde4a3ce0041d1a54b96ccb5a6792520.zip Qt-ad0c6b17cde4a3ce0041d1a54b96ccb5a6792520.tar.gz Qt-ad0c6b17cde4a3ce0041d1a54b96ccb5a6792520.tar.bz2 |
Fixes wrong QGraphicsView's viewport cursor reset.
The cursor was reset even when it had not been previously saved.
Autotest included.
Task-number: QTBUG-7438
Reviewed-by: bnilsen
-rw-r--r-- | src/gui/graphicsview/qgraphicsview.cpp | 12 | ||||
-rw-r--r-- | tests/auto/qgraphicsview/tst_qgraphicsview.cpp | 28 |
2 files changed, 35 insertions, 5 deletions
diff --git a/src/gui/graphicsview/qgraphicsview.cpp b/src/gui/graphicsview/qgraphicsview.cpp index a767987..114de85 100644 --- a/src/gui/graphicsview/qgraphicsview.cpp +++ b/src/gui/graphicsview/qgraphicsview.cpp @@ -733,11 +733,13 @@ void QGraphicsViewPrivate::_q_unsetViewportCursor() } // Restore the original viewport cursor. - hasStoredOriginalCursor = false; - if (dragMode == QGraphicsView::ScrollHandDrag) - viewport->setCursor(Qt::OpenHandCursor); - else - viewport->setCursor(originalCursor); + if (hasStoredOriginalCursor) { + hasStoredOriginalCursor = false; + if (dragMode == QGraphicsView::ScrollHandDrag) + viewport->setCursor(Qt::OpenHandCursor); + else + viewport->setCursor(originalCursor); + } } #endif diff --git a/tests/auto/qgraphicsview/tst_qgraphicsview.cpp b/tests/auto/qgraphicsview/tst_qgraphicsview.cpp index 1c19fab..5e889f4 100644 --- a/tests/auto/qgraphicsview/tst_qgraphicsview.cpp +++ b/tests/auto/qgraphicsview/tst_qgraphicsview.cpp @@ -239,6 +239,7 @@ private slots: void QTBUG_4151_clipAndIgnore_data(); void QTBUG_4151_clipAndIgnore(); void QTBUG_5859_exposedRect(); + void QTBUG_7438_cursor(); }; void tst_QGraphicsView::initTestCase() @@ -4063,5 +4064,32 @@ void tst_QGraphicsView::QTBUG_5859_exposedRect() QCOMPARE(item.lastExposedRect, scene.lastBackgroundExposedRect); } +void tst_QGraphicsView::QTBUG_7438_cursor() +{ +#ifndef QT_NO_CURSOR +#if defined(Q_OS_WINCE) + QSKIP("Qt/CE does not have regular cursor support", SkipAll); +#endif + QGraphicsScene scene; + QGraphicsItem *item = scene.addRect(QRectF(-10, -10, 20, 20)); + item->setFlag(QGraphicsItem::ItemIsMovable); + + QGraphicsView view(&scene); + view.setFixedSize(400, 400); + view.show(); + QTest::qWaitForWindowShown(&view); + + QCOMPARE(view.viewport()->cursor().shape(), QCursor().shape()); + view.viewport()->setCursor(Qt::PointingHandCursor); + QCOMPARE(view.viewport()->cursor().shape(), Qt::PointingHandCursor); + sendMouseMove(view.viewport(), view.mapFromScene(0, 0)); + QCOMPARE(view.viewport()->cursor().shape(), Qt::PointingHandCursor); + sendMousePress(view.viewport(), view.mapFromScene(0, 0)); + QCOMPARE(view.viewport()->cursor().shape(), Qt::PointingHandCursor); + sendMouseRelease(view.viewport(), view.mapFromScene(0, 0)); + QCOMPARE(view.viewport()->cursor().shape(), Qt::PointingHandCursor); +#endif +} + QTEST_MAIN(tst_QGraphicsView) #include "tst_qgraphicsview.moc" |