From e7dc9a35aa7b0e16457526647a8884ff3b4da4fe Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Thu, 5 Nov 2009 11:08:11 +0100 Subject: Fix textControl so that it ignores mouse press events when needed This fixes the issue in the itemviews that the selection would not change when clicking on rich text labels. Task-number: QTBUG-4516 Reviewed-by: ogoffart --- src/gui/text/qtextcontrol.cpp | 24 ++++++++++++++---------- src/gui/text/qtextcontrol_p_p.h | 4 ++-- tests/auto/qtableview/tst_qtableview.cpp | 19 +++++++++++++++++++ 3 files changed, 35 insertions(+), 12 deletions(-) diff --git a/src/gui/text/qtextcontrol.cpp b/src/gui/text/qtextcontrol.cpp index 3f6545c..b727c19 100644 --- a/src/gui/text/qtextcontrol.cpp +++ b/src/gui/text/qtextcontrol.cpp @@ -911,7 +911,7 @@ void QTextControl::processEvent(QEvent *e, const QMatrix &matrix, QWidget *conte break; case QEvent::MouseButtonPress: { QMouseEvent *ev = static_cast(e); - d->mousePressEvent(ev->button(), matrix.map(ev->pos()), ev->modifiers(), + d->mousePressEvent(ev, ev->button(), matrix.map(ev->pos()), ev->modifiers(), ev->buttons(), ev->globalPos()); break; } case QEvent::MouseMove: { @@ -979,7 +979,7 @@ void QTextControl::processEvent(QEvent *e, const QMatrix &matrix, QWidget *conte #ifndef QT_NO_GRAPHICSVIEW case QEvent::GraphicsSceneMousePress: { QGraphicsSceneMouseEvent *ev = static_cast(e); - d->mousePressEvent(ev->button(), matrix.map(ev->pos()), ev->modifiers(), ev->buttons(), + d->mousePressEvent(ev, ev->button(), matrix.map(ev->pos()), ev->modifiers(), ev->buttons(), ev->screenPos()); break; } case QEvent::GraphicsSceneMouseMove: { @@ -1465,7 +1465,7 @@ QRectF QTextControl::selectionRect() const return selectionRect(d->cursor); } -void QTextControlPrivate::mousePressEvent(Qt::MouseButton button, const QPointF &pos, Qt::KeyboardModifiers modifiers, +void QTextControlPrivate::mousePressEvent(QEvent *e, Qt::MouseButton button, const QPointF &pos, Qt::KeyboardModifiers modifiers, Qt::MouseButtons buttons, const QPoint &globalPos) { Q_Q(QTextControl); @@ -1479,11 +1479,11 @@ void QTextControlPrivate::mousePressEvent(Qt::MouseButton button, const QPointF cursor.clearSelection(); } } - if (!(button & Qt::LeftButton)) - return; - - if (!((interactionFlags & Qt::TextSelectableByMouse) || (interactionFlags & Qt::TextEditable))) - return; + if (!(button & Qt::LeftButton) || + !((interactionFlags & Qt::TextSelectableByMouse) || (interactionFlags & Qt::TextEditable))) { + e->ignore(); + return; + } cursorIsFocusIndicator = false; const QTextCursor oldSelection = cursor; @@ -1507,8 +1507,10 @@ void QTextControlPrivate::mousePressEvent(Qt::MouseButton button, const QPointF trippleClickTimer.stop(); } else { int cursorPos = q->hitTest(pos, Qt::FuzzyHit); - if (cursorPos == -1) + if (cursorPos == -1) { + e->ignore(); return; + } #if !defined(QT_NO_IM) QTextLayout *layout = cursor.block().layout(); @@ -1519,8 +1521,10 @@ void QTextControlPrivate::mousePressEvent(Qt::MouseButton button, const QPointF button, buttons, modifiers); ctx->mouseHandler(cursorPos - cursor.position(), &ev); } - if (!layout->preeditAreaText().isEmpty()) + if (!layout->preeditAreaText().isEmpty()) { + e->ignore(); return; + } } #endif if (modifiers == Qt::ShiftModifier) { diff --git a/src/gui/text/qtextcontrol_p_p.h b/src/gui/text/qtextcontrol_p_p.h index ca9db9f..66459f6 100644 --- a/src/gui/text/qtextcontrol_p_p.h +++ b/src/gui/text/qtextcontrol_p_p.h @@ -131,10 +131,10 @@ public: QString anchorForCursor(const QTextCursor &anchor) const; void keyPressEvent(QKeyEvent *e); - void mousePressEvent(Qt::MouseButton button, const QPointF &pos, + void mousePressEvent(QEvent *e, Qt::MouseButton button, const QPointF &pos, Qt::KeyboardModifiers modifiers, Qt::MouseButtons buttons, - const QPoint &globalPos = QPoint()); + const QPoint &globalPos); void mouseMoveEvent(Qt::MouseButtons buttons, const QPointF &pos); void mouseReleaseEvent(Qt::MouseButton button, const QPointF &pos); void mouseDoubleClickEvent(QEvent *e, Qt::MouseButton button, const QPointF &pos); diff --git a/tests/auto/qtableview/tst_qtableview.cpp b/tests/auto/qtableview/tst_qtableview.cpp index 227ca6f..f571e8a 100644 --- a/tests/auto/qtableview/tst_qtableview.cpp +++ b/tests/auto/qtableview/tst_qtableview.cpp @@ -197,6 +197,7 @@ private slots: void task259308_scrollVerticalHeaderSwappedSections(); void task191545_dragSelectRows(); void taskQTBUG_5062_spansInconsistency(); + void taskQTBUG_4516_clickOnRichTextLabel(); void mouseWheel_data(); void mouseWheel(); @@ -3885,6 +3886,24 @@ void tst_QTableView::taskQTBUG_5062_spansInconsistency() VERIFY_SPANS_CONSISTENCY(&view); } +void tst_QTableView::taskQTBUG_4516_clickOnRichTextLabel() +{ + QTableView view; + QStandardItemModel model(5,5); + view.setModel(&model); + QLabel label("rich text"); + label.setTextFormat(Qt::RichText); + view.setIndexWidget(model.index(1,1), &label); + view.setCurrentIndex(model.index(0,0)); + QCOMPARE(view.currentIndex(), model.index(0,0)); + + QTest::mouseClick(&label, Qt::LeftButton); + QCOMPARE(view.currentIndex(), model.index(1,1)); + + +} + + void tst_QTableView::changeHeaderData() { QTableView view; -- cgit v0.12 From c93ca96552b70a6bd7332aec3504485e82d4d032 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Thu, 5 Nov 2009 10:52:55 +0100 Subject: Stylesheet: Fix lineedit size with an empty stylesheet with some styles Now passes tst_QStyleSheetStyle::emptyStyleSheet with gtk style Somehow there were some wrong and uneeded default padding for the QLineEdit with some styles Task-number: QTBUG-5434 Reviewed-by: axis --- src/gui/styles/qstylesheetstyle_default.cpp | 43 ----------------------------- 1 file changed, 43 deletions(-) diff --git a/src/gui/styles/qstylesheetstyle_default.cpp b/src/gui/styles/qstylesheetstyle_default.cpp index 406633e..f79f8e0 100644 --- a/src/gui/styles/qstylesheetstyle_default.cpp +++ b/src/gui/styles/qstylesheetstyle_default.cpp @@ -203,49 +203,6 @@ StyleSheet QStyleSheetStyle::getDefaultStyleSheet() const ADD_STYLE_RULE; } - /*QLineEdit[style="QCleanlooksStyle"] { - padding-top: 2px; - padding-bottom: 2px; - }*/ - if (baseStyle()->inherits("QCleanlooksStyle")) - { - SET_ELEMENT_NAME(QLatin1String("QLineEdit")); - ADD_BASIC_SELECTOR; - ADD_SELECTOR; - - - SET_PROPERTY(QLatin1String("padding-top"), PaddingTop); - ADD_VALUE(Value::Identifier, QString::fromLatin1("2px")); - ADD_DECLARATION; - - SET_PROPERTY(QLatin1String("padding-bottom"), PaddingBottom); - ADD_VALUE(Value::Identifier, QString::fromLatin1("2px")); - ADD_DECLARATION; - - ADD_STYLE_RULE; - } - - /*QLineEdit[style="QWindowsXPStyle"], - QLineEdit[style="QWindowsVistaStyle"], - QLineEdit[style="QGtkStyle"] { - padding-top: 1px; - padding-bottom: 1px; - }*/ - if (baseStyle()->inherits("QWindowsXPStyle") || baseStyle()->inherits("QGtkStyle")) - { - SET_ELEMENT_NAME(QLatin1String("QLineEdit")); - - SET_PROPERTY(QLatin1String("padding-top"), PaddingTop); - ADD_VALUE(Value::Identifier, QString::fromLatin1("1px")); - ADD_DECLARATION; - - SET_PROPERTY(QLatin1String("padding-bottom"), PaddingBottom); - ADD_VALUE(Value::Identifier, QString::fromLatin1("1px")); - ADD_DECLARATION; - - ADD_STYLE_RULE; - } - /*QFrame { border: native; }*/ -- cgit v0.12 From ff87ab95b42c87528c4dff16382a5894c6ddd4c3 Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Thu, 5 Nov 2009 11:44:17 +0100 Subject: Fix autotest to match API changes --- tests/auto/qanimationgroup/tst_qanimationgroup.cpp | 84 +++++++++++----------- 1 file changed, 42 insertions(+), 42 deletions(-) diff --git a/tests/auto/qanimationgroup/tst_qanimationgroup.cpp b/tests/auto/qanimationgroup/tst_qanimationgroup.cpp index 81c51ed..b4e4a49 100644 --- a/tests/auto/qanimationgroup/tst_qanimationgroup.cpp +++ b/tests/auto/qanimationgroup/tst_qanimationgroup.cpp @@ -165,9 +165,9 @@ void tst_QAnimationGroup::emptyGroup() QCOMPARE(groupStateChangedSpy.count(), 2); - QCOMPARE(qVariantValue(groupStateChangedSpy.at(0).at(1)), + QCOMPARE(qVariantValue(groupStateChangedSpy.at(0).first()), QAnimationGroup::Running); - QCOMPARE(qVariantValue(groupStateChangedSpy.at(1).at(1)), + QCOMPARE(qVariantValue(groupStateChangedSpy.at(1).first()), QAnimationGroup::Stopped); QCOMPARE(group.state(), QAnimationGroup::Stopped); @@ -180,9 +180,9 @@ void tst_QAnimationGroup::emptyGroup() group.start(); - QCOMPARE(qVariantValue(groupStateChangedSpy.at(2).at(1)), + QCOMPARE(qVariantValue(groupStateChangedSpy.at(2).first()), QAnimationGroup::Running); - QCOMPARE(qVariantValue(groupStateChangedSpy.at(3).at(1)), + QCOMPARE(qVariantValue(groupStateChangedSpy.at(3).first()), QAnimationGroup::Stopped); QCOMPARE(group.state(), QAnimationGroup::Stopped); @@ -259,54 +259,54 @@ void tst_QAnimationGroup::setCurrentTime() QCOMPARE(notTimeDriven->state(), QAnimationGroup::Stopped); QCOMPARE(loopsForever->state(), QAnimationGroup::Stopped); - QCOMPARE(group.currentTime(), 1); - QCOMPARE(sequence->currentTime(), 1); - QCOMPARE(a1_s_o1->currentTime(), 1); - QCOMPARE(a2_s_o1->currentTime(), 0); - QCOMPARE(a3_s_o1->currentTime(), 0); - QCOMPARE(a1_s_o2->currentTime(), 1); - QCOMPARE(a1_s_o3->currentTime(), 0); - QCOMPARE(a1_p_o1->currentTime(), 1); - QCOMPARE(a1_p_o2->currentTime(), 1); - QCOMPARE(a1_p_o3->currentTime(), 1); - QCOMPARE(notTimeDriven->currentTime(), 1); - QCOMPARE(loopsForever->currentTime(), 1); + QCOMPARE(group.currentLoopTime(), 1); + QCOMPARE(sequence->currentLoopTime(), 1); + QCOMPARE(a1_s_o1->currentLoopTime(), 1); + QCOMPARE(a2_s_o1->currentLoopTime(), 0); + QCOMPARE(a3_s_o1->currentLoopTime(), 0); + QCOMPARE(a1_s_o2->currentLoopTime(), 1); + QCOMPARE(a1_s_o3->currentLoopTime(), 0); + QCOMPARE(a1_p_o1->currentLoopTime(), 1); + QCOMPARE(a1_p_o2->currentLoopTime(), 1); + QCOMPARE(a1_p_o3->currentLoopTime(), 1); + QCOMPARE(notTimeDriven->currentLoopTime(), 1); + QCOMPARE(loopsForever->currentLoopTime(), 1); // Current time = 250 group.setCurrentTime(250); - QCOMPARE(group.currentTime(), 250); - QCOMPARE(sequence->currentTime(), 250); - QCOMPARE(a1_s_o1->currentTime(), 250); - QCOMPARE(a2_s_o1->currentTime(), 0); - QCOMPARE(a3_s_o1->currentTime(), 0); - QCOMPARE(a1_s_o2->currentTime(), 250); - QCOMPARE(a1_s_o3->currentTime(), 0); - QCOMPARE(a1_p_o1->currentTime(), 250); - QCOMPARE(a1_p_o2->currentTime(), 0); + QCOMPARE(group.currentLoopTime(), 250); + QCOMPARE(sequence->currentLoopTime(), 250); + QCOMPARE(a1_s_o1->currentLoopTime(), 250); + QCOMPARE(a2_s_o1->currentLoopTime(), 0); + QCOMPARE(a3_s_o1->currentLoopTime(), 0); + QCOMPARE(a1_s_o2->currentLoopTime(), 250); + QCOMPARE(a1_s_o3->currentLoopTime(), 0); + QCOMPARE(a1_p_o1->currentLoopTime(), 250); + QCOMPARE(a1_p_o2->currentLoopTime(), 0); QCOMPARE(a1_p_o2->currentLoop(), 1); - QCOMPARE(a1_p_o3->currentTime(), 250); - QCOMPARE(notTimeDriven->currentTime(), 250); - QCOMPARE(loopsForever->currentTime(), 0); + QCOMPARE(a1_p_o3->currentLoopTime(), 250); + QCOMPARE(notTimeDriven->currentLoopTime(), 250); + QCOMPARE(loopsForever->currentLoopTime(), 0); QCOMPARE(loopsForever->currentLoop(), 1); QCOMPARE(sequence->currentAnimation(), a2_s_o1); // Current time = 251 group.setCurrentTime(251); - QCOMPARE(group.currentTime(), 251); - QCOMPARE(sequence->currentTime(), 251); - QCOMPARE(a1_s_o1->currentTime(), 250); - QCOMPARE(a2_s_o1->currentTime(), 1); + QCOMPARE(group.currentLoopTime(), 251); + QCOMPARE(sequence->currentLoopTime(), 251); + QCOMPARE(a1_s_o1->currentLoopTime(), 250); + QCOMPARE(a2_s_o1->currentLoopTime(), 1); QCOMPARE(a2_s_o1->currentLoop(), 0); - QCOMPARE(a3_s_o1->currentTime(), 0); - QCOMPARE(sequence2->currentTime(), 251); - QCOMPARE(a1_s_o2->currentTime(), 250); - QCOMPARE(a1_s_o3->currentTime(), 1); - QCOMPARE(a1_p_o1->currentTime(), 250); - QCOMPARE(a1_p_o2->currentTime(), 1); + QCOMPARE(a3_s_o1->currentLoopTime(), 0); + QCOMPARE(sequence2->currentLoopTime(), 251); + QCOMPARE(a1_s_o2->currentLoopTime(), 250); + QCOMPARE(a1_s_o3->currentLoopTime(), 1); + QCOMPARE(a1_p_o1->currentLoopTime(), 250); + QCOMPARE(a1_p_o2->currentLoopTime(), 1); QCOMPARE(a1_p_o2->currentLoop(), 1); - QCOMPARE(a1_p_o3->currentTime(), 250); - QCOMPARE(notTimeDriven->currentTime(), 251); - QCOMPARE(loopsForever->currentTime(), 1); + QCOMPARE(a1_p_o3->currentLoopTime(), 250); + QCOMPARE(notTimeDriven->currentLoopTime(), 251); + QCOMPARE(loopsForever->currentLoopTime(), 1); QCOMPARE(sequence->currentAnimation(), a2_s_o1); } @@ -356,7 +356,7 @@ void tst_QAnimationGroup::addChildTwice() parent->addAnimation(subGroup); QCOMPARE(parent->animationCount(), 1); - parent->clearAnimations(); + parent->clear(); QCOMPARE(parent->animationCount(), 0); -- cgit v0.12 From b2c60696dd54656c1a0d588342cc3c7beee70876 Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Thu, 5 Nov 2009 11:48:31 +0100 Subject: Fixed Q3DockArea::setAcceptDockWindow which didn't work at all Task-number: QTBUG-2026 Reviewed-by: ogoffart --- src/qt3support/widgets/q3dockarea.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/qt3support/widgets/q3dockarea.cpp b/src/qt3support/widgets/q3dockarea.cpp index bb34622..fbe235e 100644 --- a/src/qt3support/widgets/q3dockarea.cpp +++ b/src/qt3support/widgets/q3dockarea.cpp @@ -1139,7 +1139,7 @@ void Q3DockArea::setAcceptDockWindow(Q3DockWindow *dw, bool accept) { if (accept) forbiddenWidgets.removeAll(dw); - else if (forbiddenWidgets.contains(dw)) + else if (!forbiddenWidgets.contains(dw)) forbiddenWidgets.append(dw); } -- cgit v0.12 From 4bf7f90a27377f439e86d6175e5e3cdebd131be0 Mon Sep 17 00:00:00 2001 From: Andreas Aardal Hanssen Date: Thu, 5 Nov 2009 12:12:22 +0100 Subject: Always set a clip on the painter in QGraphicsView. This allows items to check painter->clipRegion() to find out what the imposed clip is, in order to cull elements that don't need to be painted. This is an alternative approach to getting the same information from QStyleOptionGraphicsItem::exposedRect. It's better because it's a pull operation, but it's slightly worse because it doesn't include the complete system clip, and because QRegion has integer resolution only (whereas QGraphicsItem's coordinate uses qreal. A better approach may be to access QPainter's combined clip region; this option is open for future versions of Qt. Original patch by Warwick (which is why he's on reviewed-by), but the patch was modified to operate in device instead of logical coordinates. Reviewed-by: jasplin Reviewed-by: Warwick Allison --- src/gui/graphicsview/qgraphicsview.cpp | 3 ++ tests/auto/qgraphicsview/tst_qgraphicsview.cpp | 72 ++++++++++++++++++++++++++ 2 files changed, 75 insertions(+) diff --git a/src/gui/graphicsview/qgraphicsview.cpp b/src/gui/graphicsview/qgraphicsview.cpp index c88f678..d1dd26f 100644 --- a/src/gui/graphicsview/qgraphicsview.cpp +++ b/src/gui/graphicsview/qgraphicsview.cpp @@ -3252,10 +3252,13 @@ void QGraphicsView::paintEvent(QPaintEvent *event) // Determine the exposed region d->exposedRegion = event->region(); + if (d->exposedRegion.isEmpty()) + d->exposedRegion = viewport()->rect(); QRectF exposedSceneRect = mapToScene(d->exposedRegion.boundingRect()).boundingRect(); // Set up the painter QPainter painter(viewport()); + painter.setClipRect(event->rect(), Qt::IntersectClip); #ifndef QT_NO_RUBBERBAND if (d->rubberBanding && !d->rubberBandRect.isEmpty()) painter.save(); diff --git a/tests/auto/qgraphicsview/tst_qgraphicsview.cpp b/tests/auto/qgraphicsview/tst_qgraphicsview.cpp index f07453c..9c6aa39 100644 --- a/tests/auto/qgraphicsview/tst_qgraphicsview.cpp +++ b/tests/auto/qgraphicsview/tst_qgraphicsview.cpp @@ -217,6 +217,7 @@ private slots: void update(); void inputMethodSensitivity(); void inputContextReset(); + void defaultClipIntersectToView(); // task specific tests below me void task172231_untransformableItems(); @@ -3692,6 +3693,77 @@ void tst_QGraphicsView::inputContextReset() QCOMPARE(inputContext.resets, 0); } +class ViewClipTester : public QGraphicsView +{ +public: + ViewClipTester(QGraphicsScene *scene = 0) + : QGraphicsView(scene) + { } + QRegion clipRegion; + +protected: + void drawBackground(QPainter *painter, const QRectF &rect) + { + clipRegion = painter->clipRegion(); + } +}; + +class ItemClipTester : public QGraphicsRectItem +{ +public: + ItemClipTester() : QGraphicsRectItem(0, 0, 20, 20) + { + setBrush(Qt::blue); + } + QRegion clipRegion; + + void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0) + { + clipRegion = painter->clipRegion(); + QGraphicsRectItem::paint(painter, option, widget); + } +}; + +void tst_QGraphicsView::defaultClipIntersectToView() +{ + QGraphicsScene scene; + ItemClipTester *tester = new ItemClipTester; + scene.addItem(tester); + + ViewClipTester view(&scene); + view.setAlignment(Qt::AlignTop | Qt::AlignLeft); + view.setFrameStyle(0); + view.resize(200, 200); + view.show(); + QTRY_COMPARE(QApplication::activeWindow(), (QWidget *)&view); + + QRect viewRect(0, 0, 200, 200); + QCOMPARE(view.clipRegion, QRegion(viewRect)); + QCOMPARE(tester->clipRegion, QRegion(viewRect)); + + view.viewport()->update(0, 0, 5, 5); + view.viewport()->update(10, 10, 5, 5); + qApp->processEvents(); + viewRect = QRect(0, 0, 15, 15); + QCOMPARE(view.clipRegion, QRegion(viewRect)); + QCOMPARE(tester->clipRegion, QRegion(viewRect)); + + view.scale(2, 2); + qApp->processEvents(); + + viewRect.moveTop(-viewRect.height()); + viewRect = QRect(0, 0, 100, 100); + QCOMPARE(view.clipRegion, QRegion(viewRect)); + QCOMPARE(tester->clipRegion, QRegion(viewRect)); + + view.viewport()->update(0, 0, 5, 5); + view.viewport()->update(10, 10, 5, 5); + qApp->processEvents(); + viewRect = QRect(0, 0, 8, 8); + QCOMPARE(view.clipRegion, QRegion(viewRect)); + QCOMPARE(tester->clipRegion, QRegion(viewRect)); +} + void tst_QGraphicsView::task253415_reconnectUpdateSceneOnSceneChanged() { QGraphicsView view; -- cgit v0.12 From 23390af0bfb8828e0e58819a5ad2249f34e12205 Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Thu, 5 Nov 2009 13:48:28 +0100 Subject: Another fix for the registration of the animations --- src/corelib/animation/qabstractanimation.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/corelib/animation/qabstractanimation.cpp b/src/corelib/animation/qabstractanimation.cpp index 0cdc40c..d46ac92 100644 --- a/src/corelib/animation/qabstractanimation.cpp +++ b/src/corelib/animation/qabstractanimation.cpp @@ -348,13 +348,16 @@ void QAbstractAnimationPrivate::setState(QAbstractAnimation::State newState) state = newState; QWeakPointer guard(q); - //unregistration of the animation must always happen before calls to + //(un)registration of the animation must always happen before calls to //virtual function (updateState) to ensure a correct state of the timer + bool isTopLevel = !group || group->state() == QAbstractAnimation::Stopped; if (oldState == QAbstractAnimation::Running) { if (newState == QAbstractAnimation::Paused && hasRegisteredTimer) QUnifiedTimer::instance()->ensureTimerUpdate(); //the animation, is not running any more QUnifiedTimer::instance()->unregisterAnimation(q); + } else { + QUnifiedTimer::instance()->registerAnimation(q, isTopLevel); } q->updateState(newState, oldState); @@ -371,8 +374,6 @@ void QAbstractAnimationPrivate::setState(QAbstractAnimation::State newState) break; case QAbstractAnimation::Running: { - bool isTopLevel = !group || group->state() == QAbstractAnimation::Stopped; - QUnifiedTimer::instance()->registerAnimation(q, isTopLevel); // this ensures that the value is updated now that the animation is running if (oldState == QAbstractAnimation::Stopped) { -- cgit v0.12 From fc8bada79e686004faf5613202859e79ab49f1ab Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Thu, 5 Nov 2009 14:08:35 +0100 Subject: API review from yesterday made a bug appear for the pause animations --- src/corelib/animation/qabstractanimation.cpp | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/corelib/animation/qabstractanimation.cpp b/src/corelib/animation/qabstractanimation.cpp index d46ac92..f967081 100644 --- a/src/corelib/animation/qabstractanimation.cpp +++ b/src/corelib/animation/qabstractanimation.cpp @@ -50,7 +50,7 @@ animations that plug into the rest of the animation framework. The progress of an animation is given by its current time - (currentTime()), which is measured in milliseconds from the start + (currentLoopTime()), which is measured in milliseconds from the start of the animation (0) to its end (duration()). The value is updated automatically while the animation is running. It can also be set directly with setCurrentTime(). @@ -214,6 +214,10 @@ void QUnifiedTimer::restartAnimationTimer() { if (runningLeafAnimations == 0 && !runningPauseAnimations.isEmpty()) { int closestTimeToFinish = closestPauseAnimationTimeToFinish(); + if (closestTimeToFinish < 0) { + qDebug() << runningPauseAnimations; + qDebug() << closestPauseAnimationTimeToFinish(); + } animationTimer.start(closestTimeToFinish, this); isPauseTimerActive = true; } else if (!animationTimer.isActive() || isPauseTimerActive) { @@ -288,9 +292,11 @@ void QUnifiedTimer::registerRunningAnimation(QAbstractAnimation *animation) if (QAbstractAnimationPrivate::get(animation)->isGroup) return; - if (QAbstractAnimationPrivate::get(animation)->isPause) + if (QAbstractAnimationPrivate::get(animation)->isPause) { + if (animation->duration() == -1) + qDebug() << "toto"; runningPauseAnimations << animation; - else + } else runningLeafAnimations++; } @@ -314,9 +320,9 @@ int QUnifiedTimer::closestPauseAnimationTimeToFinish() int timeToFinish; if (animation->direction() == QAbstractAnimation::Forward) - timeToFinish = animation->duration() - animation->currentTime(); + timeToFinish = animation->duration() - animation->currentLoopTime(); else - timeToFinish = animation->currentTime(); + timeToFinish = animation->currentLoopTime(); if (timeToFinish < closestTimeToFinish) closestTimeToFinish = timeToFinish; @@ -737,7 +743,7 @@ void QAbstractAnimation::start(DeletionPolicy policy) signal, and state() returns Stopped. The current time is not changed. If the animation stops by itself after reaching the end (i.e., - currentTime() == duration() and currentLoop() > loopCount() - 1), the + currentLoopTime() == duration() and currentLoop() > loopCount() - 1), the finished() signal is emitted. \sa start(), state() -- cgit v0.12 From 393f53184a35f380ddd7cf44a0947c2309c373bc Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Thu, 5 Nov 2009 14:13:34 +0100 Subject: Revert "Make animation timer slightly more accurate with default interval of 15" The new threashold for using the multimedia timer is 20, so we can get back to 16 ms for the interval. This reverts commit bdcde683bc863d0c574b1e4d64b5a16ba0130596. --- src/corelib/animation/qabstractanimation.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/corelib/animation/qabstractanimation.cpp b/src/corelib/animation/qabstractanimation.cpp index f967081..edc1503 100644 --- a/src/corelib/animation/qabstractanimation.cpp +++ b/src/corelib/animation/qabstractanimation.cpp @@ -156,8 +156,7 @@ #ifndef QT_NO_ANIMATION -//with 15 ms we get more accuracy on windows (it uses the multimedia timer) -#define DEFAULT_TIMER_INTERVAL 15 +#define DEFAULT_TIMER_INTERVAL 16 #define STARTSTOP_TIMER_DELAY 0 QT_BEGIN_NAMESPACE -- cgit v0.12