diff options
author | Liang Qi <[email protected]> | 2016-09-30 00:16:40 +0200 |
---|---|---|
committer | Liang Qi <[email protected]> | 2016-09-30 00:16:40 +0200 |
commit | 0bf14044178d7aa212ac7e28530f9077790a3df4 (patch) | |
tree | 4c403571abbc5e18c6962ba67d9cb584d8e121c4 /src/quick/items | |
parent | 0aea009425242417bffdb171c8eca02ff52f4a7b (diff) | |
parent | 79cfc8788d6267eeb263983466ba21758f618dcd (diff) |
Merge remote-tracking branch 'origin/5.6' into 5.7
Conflicts:
tests/auto/quick/qquicktext/tst_qquicktext.cpp
Change-Id: I241cd418bb7e7b95e0a0a2ee4c465d48be2a5582
Diffstat (limited to 'src/quick/items')
-rw-r--r-- | src/quick/items/qquickanimatedsprite.cpp | 32 | ||||
-rw-r--r-- | src/quick/items/qquickanimatedsprite_p.h | 1 | ||||
-rw-r--r-- | src/quick/items/qquickflickable.cpp | 4 | ||||
-rw-r--r-- | src/quick/items/qquickmousearea.cpp | 2 | ||||
-rw-r--r-- | src/quick/items/qquicktext.cpp | 6 |
5 files changed, 28 insertions, 17 deletions
diff --git a/src/quick/items/qquickanimatedsprite.cpp b/src/quick/items/qquickanimatedsprite.cpp index 77c7ae106b..6207a86877 100644 --- a/src/quick/items/qquickanimatedsprite.cpp +++ b/src/quick/items/qquickanimatedsprite.cpp @@ -41,6 +41,7 @@ #include "qquicksprite_p.h" #include "qquickspriteengine_p.h" #include <QtQuick/private/qsgcontext_p.h> +#include <QtQuick/private/qquickitem_p.h> #include <private/qsgadaptationlayer_p.h> #include <private/qqmlglobal_p.h> #include <QtQuick/qsgnode.h> @@ -368,7 +369,7 @@ void QQuickAnimatedSprite::start() } emit currentFrameChanged(0); emit runningChanged(true); - update(); + maybeUpdate(); } void QQuickAnimatedSprite::stop() @@ -378,7 +379,7 @@ void QQuickAnimatedSprite::stop() return; m_pauseOffset = 0; emit runningChanged(false); - update(); + maybeUpdate(); } /*! @@ -396,7 +397,15 @@ void QQuickAnimatedSprite::advance(int frames) m_curFrame += m_spriteEngine->maxFrames(); m_curFrame = m_curFrame % m_spriteEngine->maxFrames(); emit currentFrameChanged(m_curFrame); - update(); + maybeUpdate(); +} + +void QQuickAnimatedSprite::maybeUpdate() +{ + QQuickItemPrivate *priv = QQuickItemPrivate::get(this); + const QLazilyAllocated<QQuickItemPrivate::ExtraData> &extraData = priv->extra; + if ((extraData.isAllocated() && extraData->effectRefCount > 0) || priv->effectiveVisible) + update(); } /*! @@ -414,7 +423,7 @@ void QQuickAnimatedSprite::pause() m_pauseOffset = m_timestamp.elapsed(); m_paused = true; emit pausedChanged(true); - update(); + maybeUpdate(); } /*! @@ -432,7 +441,7 @@ void QQuickAnimatedSprite::resume() m_pauseOffset = m_pauseOffset - m_timestamp.elapsed(); m_paused = false; emit pausedChanged(false); - update(); + maybeUpdate(); } void QQuickAnimatedSprite::createEngine() @@ -444,7 +453,6 @@ void QQuickAnimatedSprite::createEngine() m_spriteEngine = new QQuickSpriteEngine(QList<QQuickSprite*>(spriteList), this); m_spriteEngine->startAssemblingImage(); reset(); - update(); } static QSGGeometry::Attribute AnimatedSprite_Attributes[] = { @@ -482,10 +490,10 @@ QSGGeometryNode* QQuickAnimatedSprite::buildNode() return 0; } else if (m_spriteEngine->status() == QQuickPixmap::Null) { m_spriteEngine->startAssemblingImage(); - update();//Schedule another update, where we will check again + maybeUpdate();//Schedule another update, where we will check again return 0; } else if (m_spriteEngine->status() == QQuickPixmap::Loading) { - update();//Schedule another update, where we will check again + maybeUpdate();//Schedule another update, where we will check again return 0; } @@ -547,7 +555,7 @@ QSGGeometryNode* QQuickAnimatedSprite::buildNode() void QQuickAnimatedSprite::reset() { m_pleaseReset = true; - update(); + maybeUpdate(); } QSGNode *QQuickAnimatedSprite::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *) @@ -568,7 +576,7 @@ QSGNode *QQuickAnimatedSprite::updatePaintNode(QSGNode *oldNode, UpdatePaintNode if (m_running) { if (!m_paused) - update(); + maybeUpdate(); if (node) { node->markDirty(QSGNode::DirtyMaterial); @@ -624,7 +632,7 @@ void QQuickAnimatedSprite::prepareNextFrame(QSGGeometryNode *node) frameAt = 0; m_running = false; emit runningChanged(false); - update(); + maybeUpdate(); } } else { frameAt = m_curFrame; @@ -632,7 +640,7 @@ void QQuickAnimatedSprite::prepareNextFrame(QSGGeometryNode *node) if (m_curFrame != lastFrame) { if (isCurrentFrameChangedConnected()) emit currentFrameChanged(m_curFrame); - update(); + maybeUpdate(); } qreal frameCount = m_spriteEngine->spriteFrames(); diff --git a/src/quick/items/qquickanimatedsprite_p.h b/src/quick/items/qquickanimatedsprite_p.h index 1e5981c1a4..9d8b4dad40 100644 --- a/src/quick/items/qquickanimatedsprite_p.h +++ b/src/quick/items/qquickanimatedsprite_p.h @@ -366,6 +366,7 @@ protected: void componentComplete() Q_DECL_OVERRIDE; QSGNode *updatePaintNode(QSGNode *, UpdatePaintNodeData *) Q_DECL_OVERRIDE; private: + void maybeUpdate(); bool isCurrentFrameChangedConnected(); void prepareNextFrame(QSGGeometryNode *node); void reloadImage(); diff --git a/src/quick/items/qquickflickable.cpp b/src/quick/items/qquickflickable.cpp index c838eae3c7..49117d27d1 100644 --- a/src/quick/items/qquickflickable.cpp +++ b/src/quick/items/qquickflickable.cpp @@ -1573,7 +1573,7 @@ void QQuickFlickable::timerEvent(QTimerEvent *event) d->movementEndingTimer.stop(); d->pressed = false; d->stealMouse = false; - if (!d->velocityTimeline.isActive()) + if (!d->velocityTimeline.isActive() && !d->timeline.isActive()) movementEnding(true, true); } } @@ -1626,7 +1626,7 @@ void QQuickFlickable::viewportMoved(Qt::Orientations orient) void QQuickFlickablePrivate::viewportAxisMoved(AxisData &data, qreal minExtent, qreal maxExtent, qreal vSize, QQuickTimeLineCallback::Callback fixupCallback) { - if (pressed || calcVelocity) { + if (!scrollingPhase && (pressed || calcVelocity)) { int elapsed = data.velocityTime.restart(); if (elapsed > 0) { qreal velocity = (data.lastPos - data.move.value()) * 1000 / elapsed; diff --git a/src/quick/items/qquickmousearea.cpp b/src/quick/items/qquickmousearea.cpp index 234105986a..609666d32b 100644 --- a/src/quick/items/qquickmousearea.cpp +++ b/src/quick/items/qquickmousearea.cpp @@ -672,6 +672,7 @@ void QQuickMouseArea::mousePressEvent(QMouseEvent *event) Q_D(QQuickMouseArea); d->moved = false; d->stealMouse = d->preventStealing; + d->overThreshold = false; if (!d->enabled || !(event->button() & acceptedMouseButtons())) { QQuickItem::mousePressEvent(event); } else { @@ -952,6 +953,7 @@ bool QQuickMouseArea::sendMouseEvent(QMouseEvent *event) if (!d->pressed) { // no other buttons are pressed d->stealMouse = false; + d->overThreshold = false; if (c && c->mouseGrabberItem() == this) ungrabMouse(); emit canceled(); diff --git a/src/quick/items/qquicktext.cpp b/src/quick/items/qquicktext.cpp index 8288554028..80321cf5d1 100644 --- a/src/quick/items/qquicktext.cpp +++ b/src/quick/items/qquicktext.cpp @@ -897,11 +897,11 @@ QRectF QQuickTextPrivate::setupTextLayout(qreal *const baseline) // If the width of the item has changed and it's possible the result of wrapping, // eliding, scaling has changed, or the text is not left aligned do another layout. - if ((lineWidth < qMin(oldWidth, naturalWidth) || (widthExceeded && lineWidth > oldWidth)) + if ((!qFuzzyCompare(lineWidth, oldWidth) || (widthExceeded && lineWidth > oldWidth)) && (singlelineElide || multilineElide || canWrap || horizontalFit || q->effectiveHAlign() != QQuickText::AlignLeft)) { widthChanged = true; - widthExceeded = false; + widthExceeded = lineWidth >= qMin(oldWidth, naturalWidth); heightExceeded = false; continue; } @@ -936,7 +936,7 @@ QRectF QQuickTextPrivate::setupTextLayout(qreal *const baseline) bool wasInLayout = internalWidthUpdate; internalWidthUpdate = true; - q->setImplicitHeight(naturalHeight); + q->setImplicitHeight(naturalHeight + q->topPadding() + q->bottomPadding()); internalWidthUpdate = wasInLayout; multilineElide = elideMode == QQuickText::ElideRight |