diff options
author | Liang Qi <liang.qi@theqtcompany.com> | 2015-12-18 19:17:30 +0100 |
---|---|---|
committer | Liang Qi <liang.qi@theqtcompany.com> | 2015-12-18 19:17:30 +0100 |
commit | 9f38956fc9a58a2fdfd83c91d65502964047eda3 (patch) | |
tree | 3156fa78c621e3588b230d8334944d4c9e857d45 /src/quick | |
parent | 57cd6337a87f4a8a77ea7136c60a32d2825426df (diff) | |
parent | 839d2d3e2368bc8e107d22203b0611c852f54319 (diff) |
Merge remote-tracking branch 'origin/5.6' into dev
Conflicts:
tests/auto/quick/qquicklistview/tst_qquicklistview.cpp
Change-Id: I9588a3e2c7d590e031dd4c66905a79f0d74d3ac8
Diffstat (limited to 'src/quick')
-rw-r--r-- | src/quick/items/qquickdrag.cpp | 1 | ||||
-rw-r--r-- | src/quick/items/qquickdroparea.cpp | 2 | ||||
-rw-r--r-- | src/quick/items/qquickflickable.cpp | 10 | ||||
-rw-r--r-- | src/quick/items/qquickimagebase.cpp | 40 | ||||
-rw-r--r-- | src/quick/items/qquickitemview_p_p.h | 4 | ||||
-rw-r--r-- | src/quick/items/qquicklistview.cpp | 59 | ||||
-rw-r--r-- | src/quick/items/qquickpainteditem.cpp | 2 | ||||
-rw-r--r-- | src/quick/items/qquickrendercontrol.cpp | 19 | ||||
-rw-r--r-- | src/quick/items/qquickrendercontrol_p.h | 1 | ||||
-rw-r--r-- | src/quick/items/qquicktextedit_p.h | 8 | ||||
-rw-r--r-- | src/quick/items/qquickwindow.cpp | 9 | ||||
-rw-r--r-- | src/quick/scenegraph/shaders/rendernode_core.frag | 4 | ||||
-rw-r--r-- | src/quick/scenegraph/shaders/styledtext_core.frag | 6 | ||||
-rw-r--r-- | src/quick/util/qquickanimation.cpp | 33 | ||||
-rw-r--r-- | src/quick/util/qquickanimation_p_p.h | 2 | ||||
-rw-r--r-- | src/quick/util/qquickanimatorcontroller.cpp | 5 | ||||
-rw-r--r-- | src/quick/util/qquickanimatorjob_p.h | 2 |
17 files changed, 139 insertions, 68 deletions
diff --git a/src/quick/items/qquickdrag.cpp b/src/quick/items/qquickdrag.cpp index 2612b855bd..279f5e5299 100644 --- a/src/quick/items/qquickdrag.cpp +++ b/src/quick/items/qquickdrag.cpp @@ -135,6 +135,7 @@ public: \l {supportedActions}{drop action} chosen by the recipient of the event, otherwise it will return Qt.IgnoreAction. + \sa {Qt Quick Examples - Drag and Drop}, {Qt Quick Examples - externaldraganddrop} */ void QQuickDragAttachedPrivate::itemGeometryChanged(QQuickItem *, const QRectF &newGeometry, const QRectF &oldGeometry) diff --git a/src/quick/items/qquickdroparea.cpp b/src/quick/items/qquickdroparea.cpp index e46d546a16..b582433800 100644 --- a/src/quick/items/qquickdroparea.cpp +++ b/src/quick/items/qquickdroparea.cpp @@ -102,6 +102,8 @@ QQuickDropAreaPrivate::~QQuickDropAreaPrivate() The \l drag.source property is communicated to the source of a drag event as the recipient of a drop on the drag target. + + \sa {Qt Quick Examples - Drag and Drop}, {Qt Quick Examples - externaldraganddrop} */ QQuickDropArea::QQuickDropArea(QQuickItem *parent) diff --git a/src/quick/items/qquickflickable.cpp b/src/quick/items/qquickflickable.cpp index 9d6c51f37a..092d4afdd9 100644 --- a/src/quick/items/qquickflickable.cpp +++ b/src/quick/items/qquickflickable.cpp @@ -344,10 +344,12 @@ bool QQuickFlickablePrivate::flick(AxisData &data, qreal minExtent, qreal maxExt accel = v2 / (2.0f * qAbs(dist)); resetTimeline(data); - if (boundsBehavior & QQuickFlickable::OvershootBounds) - timeline.accel(data.move, v, accel); - else - timeline.accel(data.move, v, accel, maxDistance); + if (!data.inOvershoot) { + if (boundsBehavior & QQuickFlickable::OvershootBounds) + timeline.accel(data.move, v, accel); + else + timeline.accel(data.move, v, accel, maxDistance); + } timeline.callback(QQuickTimeLineCallback(&data.move, fixupCallback, this)); if (&data == &hData) diff --git a/src/quick/items/qquickimagebase.cpp b/src/quick/items/qquickimagebase.cpp index 073fe58e7b..47952d86bd 100644 --- a/src/quick/items/qquickimagebase.cpp +++ b/src/quick/items/qquickimagebase.cpp @@ -36,6 +36,7 @@ #include <QtGui/qguiapplication.h> #include <QtGui/qscreen.h> +#include <QtGui/qicon.h> #include <QtQml/qqmlinfo.h> #include <QtQml/qqmlfile.h> @@ -338,20 +339,6 @@ void QQuickImageBase::pixmapChange() setImplicitSize(d->pix.width() / d->devicePixelRatio, d->pix.height() / d->devicePixelRatio); } -// /path/to/foo.png -> path/too/foo@2x.png -static QString image2xPath(const QString &path) -{ - const int dotIndex = path.lastIndexOf(QLatin1Char('.')); - if (dotIndex == -1) - return path + QLatin1String("@2x"); - if (path.contains(QLatin1String("@2x."))) - return path; - - QString retinaPath = path; - retinaPath.insert(dotIndex, QStringLiteral("@2x")); - return retinaPath; -} - void QQuickImageBase::resolve2xLocalFile(const QUrl &url, qreal targetDevicePixelRatio, QUrl *sourceUrl, qreal *sourceDevicePixelRatio) { Q_ASSERT(sourceUrl); @@ -369,23 +356,20 @@ void QQuickImageBase::resolve2xLocalFile(const QUrl &url, qreal targetDevicePixe return; // Special case: the url in the QML source refers directly to an "@2x" file. - if (localFile.contains(QLatin1String("@2x"))) { - *sourceDevicePixelRatio = qreal(2.0); - return; + int atLocation = localFile.lastIndexOf(QLatin1Char('@')); + if (atLocation > 0 && atLocation + 3 < localFile.size()) { + if (localFile[atLocation + 1].isDigit() + && localFile[atLocation + 2] == QLatin1Char('x') + && localFile[atLocation + 3] == QLatin1Char('.')) { + *sourceDevicePixelRatio = localFile[atLocation + 1].digitValue(); + return; + } } - // Don't load @2x files non normal-dpi displays. - if (!(targetDevicePixelRatio > qreal(1.0))) - return; - // Look for an @2x version - QString localFile2x = image2xPath(localFile); - if (!QFile::exists(localFile2x)) - return; - - // @2x file found found: Change url and devicePixelRatio - *sourceUrl = QUrl::fromLocalFile(localFile2x); - *sourceDevicePixelRatio = qreal(2.0); + QString localFileX = qt_findAtNxFile(localFile, targetDevicePixelRatio, sourceDevicePixelRatio); + if (localFileX != localFile) + *sourceUrl = QUrl::fromLocalFile(localFileX); } bool QQuickImageBase::autoTransform() const diff --git a/src/quick/items/qquickitemview_p_p.h b/src/quick/items/qquickitemview_p_p.h index 3b6407a9f5..2b3da20b34 100644 --- a/src/quick/items/qquickitemview_p_p.h +++ b/src/quick/items/qquickitemview_p_p.h @@ -56,7 +56,7 @@ QT_BEGIN_NAMESPACE -class FxViewItem +class Q_AUTOTEST_EXPORT FxViewItem { public: FxViewItem(QQuickItem *, QQuickItemView *, bool own, QQuickItemViewAttached *attached); @@ -123,7 +123,7 @@ public: }; -class QQuickItemViewPrivate : public QQuickFlickablePrivate, public QQuickItemViewTransitionChangeListener, public QAnimationJobChangeListener +class Q_AUTOTEST_EXPORT QQuickItemViewPrivate : public QQuickFlickablePrivate, public QQuickItemViewTransitionChangeListener, public QAnimationJobChangeListener { Q_DECLARE_PUBLIC(QQuickItemView) public: diff --git a/src/quick/items/qquicklistview.cpp b/src/quick/items/qquicklistview.cpp index 59ecc0b893..80e4a431a1 100644 --- a/src/quick/items/qquicklistview.cpp +++ b/src/quick/items/qquicklistview.cpp @@ -3146,12 +3146,13 @@ bool QQuickListViewPrivate::applyInsertionChange(const QQmlChangeSet::Change &ch int i = 0; qreal from = tempPos - displayMarginBeginning - buffer; - for (i = count-1; i >= 0; --i) { - if (pos > from && insertionIdx < visibleIndex) { - // item won't be visible, just note the size for repositioning - insertResult->sizeChangesBeforeVisiblePos += averageSize + spacing; - pos -= averageSize + spacing; - } else { + if (insertionIdx < visibleIndex) { + if (pos >= from) { + // items won't be visible, just note the size for repositioning + insertResult->sizeChangesBeforeVisiblePos += count * (averageSize + spacing); + } + } else { + for (i = count-1; i >= 0 && pos >= from; --i) { // item is before first visible e.g. in cache buffer FxViewItem *item = 0; if (change.isMove() && (item = currentChanges.removedItems.take(change.moveKey(modelIndex + i)))) @@ -3166,17 +3167,33 @@ bool QQuickListViewPrivate::applyInsertionChange(const QQmlChangeSet::Change &ch insertResult->changedFirstItem = true; if (!change.isMove()) { addedItems->append(item); - item->transitionNextReposition(transitioner, QQuickItemViewTransitioner::AddTransition, true); + if (transitioner) + item->transitionNextReposition(transitioner, QQuickItemViewTransitioner::AddTransition, true); + else + static_cast<FxListItemSG *>(item)->setPosition(pos, true); } insertResult->sizeChangesBeforeVisiblePos += item->size() + spacing; pos -= item->size() + spacing; + index++; + } + } + + int firstOkIdx = -1; + for (int i = 0; i <= insertionIdx && i < visibleItems.count() - 1; i++) { + if (visibleItems.at(i)->index + 1 != visibleItems.at(i + 1)->index) { + firstOkIdx = i + 1; + break; } - index++; } + for (int i = 0; i < firstOkIdx; i++) { + FxViewItem *nvItem = visibleItems.takeFirst(); + addedItems->removeOne(nvItem); + removeItem(nvItem); + } + } else { - int i = 0; qreal to = buffer + displayMarginEnd + tempPos + size(); - for (i = 0; i < count && pos <= to; ++i) { + for (int i = 0; i < count && pos <= to; ++i) { FxViewItem *item = 0; if (change.isMove() && (item = currentChanges.removedItems.take(change.moveKey(modelIndex + i)))) item->index = modelIndex + i; @@ -3196,12 +3213,32 @@ bool QQuickListViewPrivate::applyInsertionChange(const QQmlChangeSet::Change &ch movingIntoView->append(MovedItem(item, change.moveKey(item->index))); } else { addedItems->append(item); - item->transitionNextReposition(transitioner, QQuickItemViewTransitioner::AddTransition, true); + if (transitioner) + item->transitionNextReposition(transitioner, QQuickItemViewTransitioner::AddTransition, true); + else + static_cast<FxListItemSG *>(item)->setPosition(pos, true); } insertResult->sizeChangesAfterVisiblePos += item->size() + spacing; pos += item->size() + spacing; ++index; } + + if (0 < index && index < visibleItems.count()) { + FxViewItem *prevItem = visibleItems.at(index - 1); + FxViewItem *item = visibleItems.at(index); + if (prevItem->index != item->index - 1) { + int i = index; + qreal prevPos = prevItem->position(); + while (i < visibleItems.count()) { + FxListItemSG *nvItem = static_cast<FxListItemSG *>(visibleItems.takeLast()); + insertResult->sizeChangesAfterVisiblePos -= nvItem->size() + spacing; + addedItems->removeOne(nvItem); + if (nvItem->transitionScheduledOrRunning()) + nvItem->setPosition(prevPos + (nvItem->index - prevItem->index) * averageSize); + removeItem(nvItem); + } + } + } } updateVisibleIndex(); diff --git a/src/quick/items/qquickpainteditem.cpp b/src/quick/items/qquickpainteditem.cpp index 4172b83419..c9b5d34cc9 100644 --- a/src/quick/items/qquickpainteditem.cpp +++ b/src/quick/items/qquickpainteditem.cpp @@ -483,7 +483,7 @@ void QQuickPaintedItem::setFillColor(const QColor &c) \brief The item's render target. This property defines which render target the QPainter renders into, it can be either - QSGPaintedItem::Image, QSGPaintedItem::FramebufferObject or QSGPaintedItem::InvertedYFramebufferObject. + QQuickPaintedItem::Image, QQuickPaintedItem::FramebufferObject or QQuickPaintedItem::InvertedYFramebufferObject. Each has certain benefits, typically performance versus quality. Using a framebuffer object avoids a costly upload of the image contents to the texture in graphics memory, diff --git a/src/quick/items/qquickrendercontrol.cpp b/src/quick/items/qquickrendercontrol.cpp index cc4cec443a..d00b02c005 100644 --- a/src/quick/items/qquickrendercontrol.cpp +++ b/src/quick/items/qquickrendercontrol.cpp @@ -129,11 +129,6 @@ QQuickRenderControlPrivate::QQuickRenderControlPrivate() rc = new QSGRenderContext(sg); } -QQuickRenderControlPrivate::~QQuickRenderControlPrivate() -{ - delete rc; -} - void QQuickRenderControlPrivate::cleanup() { delete sg; @@ -162,13 +157,25 @@ QQuickRenderControl::~QQuickRenderControl() if (d->window) QQuickWindowPrivate::get(d->window)->renderControl = 0; + + // It is likely that the cleanup in windowDestroyed() is not called since + // the standard pattern is to destroy the rendercontrol before the QQuickWindow. + // Do it here. + d->windowDestroyed(); + + delete d->rc; } void QQuickRenderControlPrivate::windowDestroyed() { - if (window == 0) { + if (window) { rc->invalidate(); QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); + + delete QQuickWindowPrivate::get(window)->animationController; + QQuickWindowPrivate::get(window)->animationController = 0; + + window = 0; } } diff --git a/src/quick/items/qquickrendercontrol_p.h b/src/quick/items/qquickrendercontrol_p.h index 8837ed79dc..6fe475bb93 100644 --- a/src/quick/items/qquickrendercontrol_p.h +++ b/src/quick/items/qquickrendercontrol_p.h @@ -56,7 +56,6 @@ public: Q_DECLARE_PUBLIC(QQuickRenderControl) QQuickRenderControlPrivate(); - ~QQuickRenderControlPrivate(); static QQuickRenderControlPrivate *get(QQuickRenderControl *renderControl) { return renderControl->d_func(); diff --git a/src/quick/items/qquicktextedit_p.h b/src/quick/items/qquicktextedit_p.h index f8b7100cfa..de72071319 100644 --- a/src/quick/items/qquicktextedit_p.h +++ b/src/quick/items/qquicktextedit_p.h @@ -295,11 +295,11 @@ Q_SIGNALS: void selectionColorChanged(const QColor &color); void selectedTextColorChanged(const QColor &color); void fontChanged(const QFont &font); - void horizontalAlignmentChanged(HAlignment alignment); - void verticalAlignmentChanged(VAlignment alignment); + void horizontalAlignmentChanged(QQuickTextEdit::HAlignment alignment); + void verticalAlignmentChanged(QQuickTextEdit::VAlignment alignment); void wrapModeChanged(); void lineCountChanged(); - void textFormatChanged(TextFormat textFormat); + void textFormatChanged(QQuickTextEdit::TextFormat textFormat); void readOnlyChanged(bool isReadOnly); void cursorVisibleChanged(bool isCursorVisible); void cursorDelegateChanged(); @@ -308,7 +308,7 @@ Q_SIGNALS: void textMarginChanged(qreal textMargin); Q_REVISION(1) void selectByKeyboardChanged(bool selectByKeyboard); void selectByMouseChanged(bool selectByMouse); - void mouseSelectionModeChanged(SelectionMode mode); + void mouseSelectionModeChanged(QQuickTextEdit::SelectionMode mode); void linkActivated(const QString &link); Q_REVISION(2) void linkHovered(const QString &link); void canPasteChanged(); diff --git a/src/quick/items/qquickwindow.cpp b/src/quick/items/qquickwindow.cpp index 2ba802a19e..8d86dfc96e 100644 --- a/src/quick/items/qquickwindow.cpp +++ b/src/quick/items/qquickwindow.cpp @@ -632,6 +632,15 @@ bool QQuickWindowPrivate::translateTouchToMouse(QQuickItem *item, QTouchEvent *e if (mouseGrabberItem) { QScopedPointer<QMouseEvent> me(touchToMouseEvent(QEvent::MouseButtonRelease, p, event, mouseGrabberItem, false)); QCoreApplication::sendEvent(item, me.data()); + + if (item->acceptHoverEvents() && p.screenPos() != QGuiApplicationPrivate::lastCursorPosition) { + QPointF localMousePos(qInf(), qInf()); + if (QWindow *w = item->window()) + localMousePos = item->mapFromScene(w->mapFromGlobal(QGuiApplicationPrivate::lastCursorPosition.toPoint())); + QMouseEvent mm(QEvent::MouseMove, localMousePos, QGuiApplicationPrivate::lastCursorPosition, + Qt::NoButton, Qt::NoButton, event->modifiers()); + QCoreApplication::sendEvent(item, &mm); + } if (mouseGrabberItem) // might have ungrabbed due to event mouseGrabberItem->ungrabMouse(); return me->isAccepted(); diff --git a/src/quick/scenegraph/shaders/rendernode_core.frag b/src/quick/scenegraph/shaders/rendernode_core.frag index 7c187265df..b29301b058 100644 --- a/src/quick/scenegraph/shaders/rendernode_core.frag +++ b/src/quick/scenegraph/shaders/rendernode_core.frag @@ -4,9 +4,9 @@ uniform sampler2D tex; in vec2 t; -out vec4 color; +out vec4 fragColor; void main() { fragColor = texture(tex, t); -}
\ No newline at end of file +} diff --git a/src/quick/scenegraph/shaders/styledtext_core.frag b/src/quick/scenegraph/shaders/styledtext_core.frag index 50f64c64a2..5480e95a42 100644 --- a/src/quick/scenegraph/shaders/styledtext_core.frag +++ b/src/quick/scenegraph/shaders/styledtext_core.frag @@ -3,7 +3,7 @@ in vec2 sampleCoord; in vec2 shiftedSampleCoord; -out vec4 color; +out vec4 fragColor; uniform sampler2D _qt_texture; uniform vec4 color; @@ -11,8 +11,8 @@ uniform vec4 styleColor; void main() { - float glyph = texture(_qt_texture, sampleCoord).a; + float glyph = texture(_qt_texture, sampleCoord).r; float style = clamp(texture(_qt_texture, shiftedSampleCoord).r - glyph, 0.0, 1.0); fragColor = style * styleColor + glyph * color; -}
\ No newline at end of file +} diff --git a/src/quick/util/qquickanimation.cpp b/src/quick/util/qquickanimation.cpp index 1d0dbf64b3..22bfd7aef1 100644 --- a/src/quick/util/qquickanimation.cpp +++ b/src/quick/util/qquickanimation.cpp @@ -178,14 +178,22 @@ void QQuickAbstractAnimationPrivate::commence() } } -QQmlProperty QQuickAbstractAnimationPrivate::createProperty(QObject *obj, const QString &str, QObject *infoObj) +QQmlProperty QQuickAbstractAnimationPrivate::createProperty(QObject *obj, const QString &str, QObject *infoObj, QString *errorMessage) { QQmlProperty prop(obj, str, qmlContext(infoObj)); if (!prop.isValid()) { - qmlInfo(infoObj) << QQuickAbstractAnimation::tr("Cannot animate non-existent property \"%1\"").arg(str); + const QString message = QQuickAbstractAnimation::tr("Cannot animate non-existent property \"%1\"").arg(str); + if (errorMessage) + *errorMessage = message; + else + qmlInfo(infoObj) << message; return QQmlProperty(); } else if (!prop.isWritable()) { - qmlInfo(infoObj) << QQuickAbstractAnimation::tr("Cannot animate read-only property \"%1\"").arg(str); + const QString message = QQuickAbstractAnimation::tr("Cannot animate read-only property \"%1\"").arg(str); + if (errorMessage) + *errorMessage = message; + else + qmlInfo(infoObj) << message; return QQmlProperty(); } return prop; @@ -2584,18 +2592,28 @@ QQuickStateActions QQuickPropertyAnimation::createTransitionActions(QQuickStateA if (defaultTarget && targets.isEmpty()) targets << defaultTarget; + bool usingDefaultProperties = false; if (props.isEmpty() && !d->defaultProperties.isEmpty()) { props << d->defaultProperties.split(QLatin1Char(',')); + usingDefaultProperties = true; } bool hasExplicit = false; //an explicit animation has been specified if (d->toIsDefined) { + QVector<QString> errorMessages; + bool successfullyCreatedDefaultProperty = false; + for (int i = 0; i < props.count(); ++i) { for (int j = 0; j < targets.count(); ++j) { QQuickStateAction myAction; - myAction.property = d->createProperty(targets.at(j), props.at(i), this); + QString errorMessage; + const QString propertyName = props.at(i); + myAction.property = d->createProperty(targets.at(j), propertyName, this, &errorMessage); if (myAction.property.isValid()) { + if (usingDefaultProperties) + successfullyCreatedDefaultProperty = true; + if (d->fromIsDefined) { myAction.fromValue = d->from; d->convertVariant(myAction.fromValue, d->interpolatorType ? d->interpolatorType : myAction.property.propertyType()); @@ -2612,9 +2630,16 @@ QQuickStateActions QQuickPropertyAnimation::createTransitionActions(QQuickStateA break; //### any chance there could be multiples? } } + } else { + errorMessages.append(errorMessage); } } } + + if (!successfullyCreatedDefaultProperty) { + foreach (const QString &errorMessage, errorMessages) + qmlInfo(this) << errorMessage; + } } if (!hasExplicit) diff --git a/src/quick/util/qquickanimation_p_p.h b/src/quick/util/qquickanimation_p_p.h index b40e198cc1..a5960f5696 100644 --- a/src/quick/util/qquickanimation_p_p.h +++ b/src/quick/util/qquickanimation_p_p.h @@ -193,7 +193,7 @@ public: QQuickAnimationGroup *group; QAbstractAnimationJob* animationInstance; - static QQmlProperty createProperty(QObject *obj, const QString &str, QObject *infoObj); + static QQmlProperty createProperty(QObject *obj, const QString &str, QObject *infoObj, QString *errorMessage = Q_NULLPTR); }; class QQuickPauseAnimationPrivate : public QQuickAbstractAnimationPrivate diff --git a/src/quick/util/qquickanimatorcontroller.cpp b/src/quick/util/qquickanimatorcontroller.cpp index cfb6037d14..74930fb373 100644 --- a/src/quick/util/qquickanimatorcontroller.cpp +++ b/src/quick/util/qquickanimatorcontroller.cpp @@ -140,6 +140,11 @@ static void qquick_initialize_helper(QAbstractAnimationJob *job, QQuickAnimatorC { if (job->isRenderThreadJob()) { QQuickAnimatorJob *j = static_cast<QQuickAnimatorJob *>(job); + // Note: since a QQuickAnimatorJob::m_target is a QPointer, + // if m_target is destroyed between the time it was set + // as the target of the animator job and before this step, + // (e.g a Loader being set inactive just after starting the animator) + // we are sure it will be NULL and won't be dangling around if (!j->target()) { return; } else if (c->m_deletedSinceLastFrame.contains(j->target())) { diff --git a/src/quick/util/qquickanimatorjob_p.h b/src/quick/util/qquickanimatorjob_p.h index 82c9da1d2e..35057d6278 100644 --- a/src/quick/util/qquickanimatorjob_p.h +++ b/src/quick/util/qquickanimatorjob_p.h @@ -152,7 +152,7 @@ protected: QQuickAnimatorJob(); void debugAnimation(QDebug d) const Q_DECL_OVERRIDE; - QQuickItem *m_target; + QPointer<QQuickItem> m_target; QQuickAnimatorController *m_controller; qreal m_from; |