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 | |
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')
-rw-r--r-- | src/quick/handlers/qquickpointhandler.cpp | 4 | ||||
-rw-r--r-- | src/quick/handlers/qquicktaphandler.cpp | 19 | ||||
-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 |
9 files changed, 65 insertions, 42 deletions
diff --git a/src/quick/handlers/qquickpointhandler.cpp b/src/quick/handlers/qquickpointhandler.cpp index 6d6ba07f5c..30f62332ba 100644 --- a/src/quick/handlers/qquickpointhandler.cpp +++ b/src/quick/handlers/qquickpointhandler.cpp @@ -59,8 +59,8 @@ QT_BEGIN_NAMESPACE occurs within the bounds of the \l {PointerHandler::parent}, and no sibling PointHandler within the same \l {PointerHandler::parent} has yet acquired a passive grab on that point, and if the other - constraints such as \l[QML]{SinglePointHandler::acceptedButtons}, - \l {PointerDeviceHandler::acceptedDevices} etc. are satisfied, it's + constraints such as \l {PointerDeviceHandler::acceptedButtons}{acceptedButtons}, \l {PointerDeviceHandler::acceptedDevices}{acceptedDevices} etc. + are satisfied, it's eligible, and the PointHandler then acquires a passive grab. In this way, the \l {PointerHandler::parent} acts like an exclusive group: there can be multiple instances of PointHandler, and the diff --git a/src/quick/handlers/qquicktaphandler.cpp b/src/quick/handlers/qquicktaphandler.cpp index b4b6bd574e..081645da71 100644 --- a/src/quick/handlers/qquicktaphandler.cpp +++ b/src/quick/handlers/qquicktaphandler.cpp @@ -230,7 +230,7 @@ void QQuickTapHandler::timerEvent(QTimerEvent *event) will not take the exclusive grab, but merely a passive grab. \value TapHandler.WithinBounds - If the event point leaves the bounds of the \l parent Item, the tap + If the event point leaves the bounds of the \c parent Item, the tap gesture is canceled. The TapHandler will take the exclusive grab on press, but will release the grab as soon as the boundary constraint is no longer satisfied. @@ -238,7 +238,7 @@ void QQuickTapHandler::timerEvent(QTimerEvent *event) \value TapHandler.ReleaseWithinBounds At the time of release (the mouse button is released or the finger is lifted), if the event point is outside the bounds of the - \l parent Item, a tap gesture is not recognized. This corresponds to + \c parent Item, a tap gesture is not recognized. This corresponds to typical behavior for button widgets: you can cancel a click by dragging outside the button, and you can also change your mind by dragging back inside the button before release. Note that it's @@ -383,7 +383,7 @@ void QQuickTapHandler::updateTimeHeld() /*! \qmlsignal QtQuick::TapHandler::tapped - This signal is emitted each time the \l parent Item is tapped. + This signal is emitted each time the \c parent Item is tapped. That is, if you press and release a touchpoint or button within a time period less than \l longPressThreshold, while any movement does not exceed @@ -395,7 +395,7 @@ void QQuickTapHandler::updateTimeHeld() \qmlsignal QtQuick::TapHandler::singleTapped \since 5.11 - This signal is emitted when the \l parent Item is tapped once. + This signal is emitted when the \c parent Item is tapped once. After an amount of time greater than QStyleHints::mouseDoubleClickInterval, it can be tapped again; but if the time until the next tap is less, \l tapCount will increase. @@ -405,7 +405,7 @@ void QQuickTapHandler::updateTimeHeld() \qmlsignal QtQuick::TapHandler::doubleTapped \since 5.11 - This signal is emitted when the \l parent Item is tapped twice within a + This signal is emitted when the \c parent Item is tapped twice within a short span of time (QStyleHints::mouseDoubleClickInterval) and distance (QPlatformTheme::MouseDoubleClickDistance or QPlatformTheme::TouchDoubleTapDistance). This signal always occurs after @@ -415,11 +415,18 @@ void QQuickTapHandler::updateTimeHeld() /*! \qmlsignal QtQuick::TapHandler::longPressed - This signal is emitted when the \l parent Item is pressed and held for a + This signal is emitted when the \c parent Item is pressed and held for a time period greater than \l longPressThreshold. That is, if you press and hold a touchpoint or button, while any movement does not exceed the drag threshold, then the \c longPressed signal will be emitted at the time that \l timeHeld exceeds \l longPressThreshold. */ +/*! + \qmlsignal QtQuick::TapHandler::tapCountChanged + + This signal is emitted when the \c parent Item is tapped once or more (within + a specified time and distance span) and when the present \c tapCount differs + from the previous \c tapCount. +*/ QT_END_NAMESPACE 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); |