diff options
author | Alexis Menard <alexis.menard@nokia.com> | 2009-11-30 13:58:43 (GMT) |
---|---|---|
committer | Alexis Menard <alexis.menard@nokia.com> | 2009-11-30 14:09:02 (GMT) |
commit | 011d3aa2bdf49127169f0726b78e13e8e9bcd73e (patch) | |
tree | 2b1c5da212a2bc2f4efaa7324a172d365ff4e4cb /tests/auto/qgraphicswidget | |
parent | 069d544f698ba020a329bdc45169ed08e8dd0357 (diff) | |
download | Qt-011d3aa2bdf49127169f0726b78e13e8e9bcd73e.zip Qt-011d3aa2bdf49127169f0726b78e13e8e9bcd73e.tar.gz Qt-011d3aa2bdf49127169f0726b78e13e8e9bcd73e.tar.bz2 |
Only call updateFont if the font have changed.
When receiving the polish event, we call updateFont only if the font
has changed (from the QApplication::font()). This avoid to clear sizeHints
cache.
Task-number:QTBUG-6272
Reviewed-by:janarve
Diffstat (limited to 'tests/auto/qgraphicswidget')
-rw-r--r-- | tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp b/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp index 3b98c2f..3303df5 100644 --- a/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp +++ b/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp @@ -106,6 +106,7 @@ private slots: void font_data(); void font(); void fontPropagation(); + void fontChangedEvent(); void fontPropagationWidgetItemWidget(); void fontPropagationSceneChange(); void geometry_data(); @@ -673,6 +674,40 @@ void tst_QGraphicsWidget::fontPropagation() QCOMPARE(child2->font().pointSize(), 43); } +void tst_QGraphicsWidget::fontChangedEvent() +{ + QGraphicsWidget *root = new QGraphicsWidget; + QGraphicsScene scene; + scene.addItem(root); + + // Check that only the application fonts apply. + QFont appFont = QApplication::font(); + QCOMPARE(scene.font(), appFont); + QCOMPARE(root->font(), appFont); + + EventSpy rootSpyFont(root, QEvent::FontChange); + EventSpy rootSpyPolish(root, QEvent::Polish); + QCOMPARE(rootSpyFont.count(), 0); + QApplication::processEvents(); //The polish event is sent + QCOMPARE(rootSpyPolish.count(), 1); + QApplication::processEvents(); //Process events to see if we get the font change event + //The font is still the same so no fontChangeEvent + QCOMPARE(rootSpyFont.count(), 0); + + QFont font; + font.setPointSize(43); + root->setFont(font); + QApplication::processEvents(); //Process events to get the font change event + //The font changed + QCOMPARE(rootSpyFont.count(), 1); + + //then roll back to the default one. + root->setFont(appFont); + QApplication::processEvents(); //Process events to get the font change event + //The font changed + QCOMPARE(rootSpyFont.count(), 2); +} + void tst_QGraphicsWidget::fontPropagationWidgetItemWidget() { QGraphicsWidget *widget = new QGraphicsWidget; |