diff options
author | Ulf Hermann <ulf.hermann@qt.io> | 2019-03-13 10:48:24 +0000 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2019-03-13 10:48:24 +0000 |
commit | 44fbf97533e297b0871150b7b8689fe7a641ad51 (patch) | |
tree | 3fa693a3c98c50df0f277377a96e39c5d86e002b /src/quick/items | |
parent | ca66d4fc23706a0f4ecfc4031f37cdd19facd836 (diff) | |
parent | 76be4abbbcfb2fbb14ce532413e0895198e7f0f1 (diff) |
Merge "Merge remote-tracking branch 'origin/5.12' into 5.13" into refs/staging/5.13
Diffstat (limited to 'src/quick/items')
-rw-r--r-- | src/quick/items/qquickevents.cpp | 7 | ||||
-rw-r--r-- | src/quick/items/qquickflickable.cpp | 4 | ||||
-rw-r--r-- | src/quick/items/qquickitemgrabresult.cpp | 6 | ||||
-rw-r--r-- | src/quick/items/qquicktableview.cpp | 15 | ||||
-rw-r--r-- | src/quick/items/qquicktext.cpp | 4 | ||||
-rw-r--r-- | src/quick/items/qquicktextnodeengine.cpp | 18 | ||||
-rw-r--r-- | src/quick/items/qquickwindow.cpp | 30 |
7 files changed, 50 insertions, 34 deletions
diff --git a/src/quick/items/qquickevents.cpp b/src/quick/items/qquickevents.cpp index 2eaab164a0..c43eab6b8a 100644 --- a/src/quick/items/qquickevents.cpp +++ b/src/quick/items/qquickevents.cpp @@ -864,8 +864,11 @@ void QQuickEventPoint::setGrabberItem(QQuickItem *grabber) QQuickWindowPrivate *windowPriv = QQuickWindowPrivate::get(grabber->window()); windowPriv->sendUngrabEvent(oldGrabberItem, windowPriv->isDeliveringTouchAsMouse()); } - for (QPointer<QQuickPointerHandler> passiveGrabber : m_passiveGrabbers) - passiveGrabber->onGrabChanged(passiveGrabber, OverrideGrabPassive, this); + if (grabber) { + for (QPointer<QQuickPointerHandler> passiveGrabber : m_passiveGrabbers) + if (passiveGrabber) + passiveGrabber->onGrabChanged(passiveGrabber, OverrideGrabPassive, this); + } } } diff --git a/src/quick/items/qquickflickable.cpp b/src/quick/items/qquickflickable.cpp index cf882e8c9e..d6dddc3f1c 100644 --- a/src/quick/items/qquickflickable.cpp +++ b/src/quick/items/qquickflickable.cpp @@ -786,7 +786,7 @@ void QQuickFlickable::setContentX(qreal pos) d->hData.vTime = d->timeline.time(); if (isMoving() || isFlicking()) movementEnding(true, false); - if (-pos != d->hData.move.value()) + if (!qFuzzyCompare(-pos, d->hData.move.value())) d->hData.move.setValue(-pos); } @@ -804,7 +804,7 @@ void QQuickFlickable::setContentY(qreal pos) d->vData.vTime = d->timeline.time(); if (isMoving() || isFlicking()) movementEnding(false, true); - if (-pos != d->vData.move.value()) + if (!qFuzzyCompare(-pos, d->vData.move.value())) d->vData.move.setValue(-pos); } diff --git a/src/quick/items/qquickitemgrabresult.cpp b/src/quick/items/qquickitemgrabresult.cpp index b45cb09c4b..f298803c7f 100644 --- a/src/quick/items/qquickitemgrabresult.cpp +++ b/src/quick/items/qquickitemgrabresult.cpp @@ -226,10 +226,12 @@ bool QQuickItemGrabResult::event(QEvent *e) Q_D(QQuickItemGrabResult); if (e->type() == Event_Grab_Completed) { // JS callback - if (d->qmlEngine && d->callback.isCallable()) + if (d->qmlEngine && d->callback.isCallable()) { d->callback.call(QJSValueList() << d->qmlEngine->newQObject(this)); - else + deleteLater(); + } else { Q_EMIT ready(); + } return true; } return QObject::event(e); diff --git a/src/quick/items/qquicktableview.cpp b/src/quick/items/qquicktableview.cpp index 675208d75c..ac3397d2a9 100644 --- a/src/quick/items/qquicktableview.cpp +++ b/src/quick/items/qquicktableview.cpp @@ -133,7 +133,7 @@ width, unless the \l columnWidthProvider property is explicitly set. Once the column width is found, all other items in the same column are resized to this width, even if new items that are flicked in later have larger - \c implicitWidth. Setting an explicit \l width on an item is ignored and + \c implicitWidth. Setting an explicit \c width on an item is ignored and overwritten. \note The calculated width of a column is discarded when it is flicked out @@ -265,9 +265,10 @@ applies to \c row and \c column. Properties of the model are also available depending upon the type of \l {qml-data-models}{Data Model}. - A delegate should specify its size using \l implicitWidth and \l implicitHeight. - The TableView lays out the items based on that information. Explicit \l width or - \l height settings are ignored and overwritten. + A delegate should specify its size using \l [QML]{Item::implicitWidth}{implicitWidth} and + \l [QML]{Item::implicitHeight}{implicitHeight}. + The TableView lays out the items based on that information. Explicit width or + height settings are ignored and overwritten. \note Delegates are instantiated as needed and may be destroyed at any time. They are also reused if the \l reuseItems property is set to \c true. You @@ -289,7 +290,7 @@ /*! \qmlproperty real QtQuick::TableView::contentWidth - This property holds the width of the \l contentView, which is also + This property holds the width of the \l view, which is also the width of the table (including margins). As a TableView cannot always know the exact width of the table without loading all columns in the model, the \c contentWidth is usually an estimated width based on @@ -307,7 +308,7 @@ /*! \qmlproperty real QtQuick::TableView::contentHeight - This property holds the height of the \l contentView, which is also + This property holds the height of the \l view, which is also the height of the table (including margins). As a TableView cannot always know the exact height of the table without loading all rows in the model, the \c contentHeight is usually an estimated height @@ -328,7 +329,7 @@ Responding to changes in the model are batched so that they are handled only once per frame. This means the TableView delays showing any changes while a script is being run. The same is also true when changing - properties such as \l rowSpacing or \l leftMargin. + properties such as \l rowSpacing or \l {Item::anchors.leftMargin}{leftMargin}. This method forces the TableView to immediately update the layout so that any recent changes take effect. diff --git a/src/quick/items/qquicktext.cpp b/src/quick/items/qquicktext.cpp index 9e447d40ac..73b151168e 100644 --- a/src/quick/items/qquicktext.cpp +++ b/src/quick/items/qquicktext.cpp @@ -442,7 +442,7 @@ void QQuickTextPrivate::updateSize() if (internalWidthUpdate) return; - extra->doc->setPageSize(QSizeF()); + extra->doc->setPageSize(QSizeF(q->width(), -1)); if (q->widthValid() && (wrapMode != QQuickText::NoWrap || extra->doc->idealWidth() < availableWidth())) extra->doc->setTextWidth(availableWidth()); else @@ -1247,7 +1247,7 @@ void QQuickTextPrivate::ensureDoc() if (!extra.isAllocated() || !extra->doc) { Q_Q(QQuickText); extra.value().doc = new QQuickTextDocumentWithImageResources(q); - extra->doc->setPageSize(QSizeF(0, 0)); + extra->doc->setPageSize(QSizeF(q->width(), -1)); extra->doc->setDocumentMargin(0); extra->doc->setBaseUrl(q->baseUrl()); qmlobject_connect(extra->doc, QQuickTextDocumentWithImageResources, SIGNAL(imagesLoaded()), diff --git a/src/quick/items/qquicktextnodeengine.cpp b/src/quick/items/qquicktextnodeengine.cpp index d84932b8d0..a1b5eb1faf 100644 --- a/src/quick/items/qquicktextnodeengine.cpp +++ b/src/quick/items/qquicktextnodeengine.cpp @@ -967,9 +967,14 @@ void QQuickTextNodeEngine::addTextBlock(QTextDocument *textDocument, const QText QVarLengthArray<QTextLayout::FormatRange> colorChanges; mergeFormats(block.layout(), &colorChanges); - QPointF blockPosition = textDocument->documentLayout()->blockBoundingRect(block).topLeft() + position; + const QTextCharFormat charFormat = block.charFormat(); + const QRectF blockBoundingRect = textDocument->documentLayout()->blockBoundingRect(block).translated(position); + + if (charFormat.background().style() != Qt::NoBrush) + m_backgrounds.append(qMakePair(blockBoundingRect, charFormat.background().color())); + if (QTextList *textList = block.textList()) { - QPointF pos = blockPosition; + QPointF pos = blockBoundingRect.topLeft(); QTextLayout *layout = block.layout(); if (layout->lineCount() > 0) { QTextLine firstLine = layout->lineAt(0); @@ -982,7 +987,6 @@ void QQuickTextNodeEngine::addTextBlock(QTextDocument *textDocument, const QText if (block.textDirection() == Qt::RightToLeft) pos.rx() += textRect.width(); - const QTextCharFormat charFormat = block.charFormat(); QFont font(charFormat.font()); QFontMetricsF fontMetrics(font); QTextListFormat listFormat = textList->format(); @@ -1043,11 +1047,11 @@ void QQuickTextNodeEngine::addTextBlock(QTextDocument *textDocument, const QText int fontHeight = fontMetrics.descent() + fontMetrics.ascent(); int valign = charFormat.verticalAlignment(); if (valign == QTextCharFormat::AlignSuperScript) - setPosition(QPointF(blockPosition.x(), blockPosition.y() - fontHeight / 2)); + setPosition(QPointF(blockBoundingRect.x(), blockBoundingRect.y() - fontHeight / 2)); else if (valign == QTextCharFormat::AlignSubScript) - setPosition(QPointF(blockPosition.x(), blockPosition.y() + fontHeight / 6)); + setPosition(QPointF(blockBoundingRect.x(), blockBoundingRect.y() + fontHeight / 6)); else - setPosition(blockPosition); + setPosition(blockBoundingRect.topLeft()); if (text.contains(QChar::ObjectReplacementCharacter)) { QTextFrame *frame = qobject_cast<QTextFrame *>(textDocument->objectForFormat(charFormat)); @@ -1101,7 +1105,7 @@ void QQuickTextNodeEngine::addTextBlock(QTextDocument *textDocument, const QText #if QT_CONFIG(im) if (preeditLength >= 0 && textPos <= block.position() + preeditPosition) { - setPosition(blockPosition); + setPosition(blockBoundingRect.topLeft()); textPos = block.position() + preeditPosition; QTextLine line = block.layout()->lineForTextPosition(preeditPosition); if (!currentLine().isValid() diff --git a/src/quick/items/qquickwindow.cpp b/src/quick/items/qquickwindow.cpp index 2305a22cf7..d448d74b99 100644 --- a/src/quick/items/qquickwindow.cpp +++ b/src/quick/items/qquickwindow.cpp @@ -1613,7 +1613,9 @@ bool QQuickWindow::event(QEvent *e) bool accepted = enter->isAccepted(); bool delivered = d->deliverHoverEvent(d->contentItem, enter->windowPos(), d->lastMousePosition, QGuiApplication::keyboardModifiers(), 0L, accepted); + d->lastMousePosition = enter->windowPos(); enter->setAccepted(accepted); + d->updateCursor(mapFromGlobal(QCursor::pos())); return delivered; } break; @@ -2535,18 +2537,22 @@ bool QQuickWindowPrivate::deliverPressOrReleaseEvent(QQuickPointerEvent *event, int pointCount = event->pointCount(); QVector<QQuickItem *> targetItems; bool isTouchEvent = (event->asPointerTouchEvent() != nullptr); - if (isTouchEvent && event->isPressEvent() && isDeliveringTouchAsMouse() && - pointerEventInstance(touchMouseDevice)->pointById(touchMouseId)->grabberPointerHandler()) { - // When a second point is pressed, if the first point's existing - // grabber was a pointer handler while a filtering parent is filtering - // the same first point _as mouse_: we're starting over with delivery, - // so we need to allow the second point to now be sent as a synth-mouse - // instead of the first one, so that filtering parents (maybe even the - // same one) can get a chance to see the second touchpoint as a - // synth-mouse and perhaps grab it. Ideally we would always do this - // when a new touchpoint is pressed, but this compromise fixes - // QTBUG-70998 and avoids breaking tst_FlickableInterop::touchDragSliderAndFlickable - cancelTouchMouseSynthesis(); + if (isTouchEvent && event->isPressEvent() && isDeliveringTouchAsMouse()) { + if (const QQuickEventPoint *point = pointerEventInstance(touchMouseDevice)->pointById(touchMouseId)) { + // When a second point is pressed, if the first point's existing + // grabber was a pointer handler while a filtering parent is filtering + // the same first point _as mouse_: we're starting over with delivery, + // so we need to allow the second point to now be sent as a synth-mouse + // instead of the first one, so that filtering parents (maybe even the + // same one) can get a chance to see the second touchpoint as a + // synth-mouse and perhaps grab it. Ideally we would always do this + // when a new touchpoint is pressed, but this compromise fixes + // QTBUG-70998 and avoids breaking tst_FlickableInterop::touchDragSliderAndFlickable + if (point->grabberPointerHandler()) + cancelTouchMouseSynthesis(); + } else { + qCWarning(DBG_TOUCH_TARGET) << "during delivery of touch press, synth-mouse ID" << touchMouseId << "is missing from" << event; + } } for (int i = 0; i < pointCount; ++i) { auto point = event->point(i); |