From a5be4ae50c40f938ca8660296362fc06cc8273b1 Mon Sep 17 00:00:00 2001 From: Konstantin Ritt Date: Mon, 26 Aug 2019 17:59:22 +0300 Subject: Fix timer events handling if the timer event's timerId isn't recognized, make sure control passes to the base class Change-Id: If5988dbf4ccda6a9887805961b439f93640f71ea Reviewed-by: Mitch Curtis --- src/quicktemplates2/qquickmenu.cpp | 2 ++ src/quicktemplates2/qquicktooltip.cpp | 6 +++++- 2 files changed, 7 insertions(+), 1 deletion(-) (limited to 'src/quicktemplates2') diff --git a/src/quicktemplates2/qquickmenu.cpp b/src/quicktemplates2/qquickmenu.cpp index 82cc063f..67e2d806 100644 --- a/src/quicktemplates2/qquickmenu.cpp +++ b/src/quicktemplates2/qquickmenu.cpp @@ -1487,7 +1487,9 @@ void QQuickMenu::timerEvent(QTimerEvent *event) if (QQuickMenu *subMenu = d->currentSubMenu()) subMenu->open(); d->stopHoverTimer(); + return; } + QQuickPopup::timerEvent(event); } QFont QQuickMenu::defaultFont() const diff --git a/src/quicktemplates2/qquicktooltip.cpp b/src/quicktemplates2/qquicktooltip.cpp index ddf434a2..c1271dab 100644 --- a/src/quicktemplates2/qquicktooltip.cpp +++ b/src/quicktemplates2/qquicktooltip.cpp @@ -327,10 +327,14 @@ void QQuickToolTip::timerEvent(QTimerEvent *event) if (event->timerId() == d->timeoutTimer.timerId()) { d->stopTimeout(); QQuickPopup::setVisible(false); - } else if (event->timerId() == d->delayTimer.timerId()) { + return; + } + if (event->timerId() == d->delayTimer.timerId()) { d->stopDelay(); QQuickPopup::setVisible(true); + return; } + QQuickPopup::timerEvent(event); } #if QT_CONFIG(accessibility) -- cgit v1.2.3 From 44a522445c94583e8d8502b9da3de217b6f075d5 Mon Sep 17 00:00:00 2001 From: Konstantin Ritt Date: Mon, 26 Aug 2019 18:17:20 +0300 Subject: QQuickOverlay: micro optimization for disabled multitouch support avoid checking every press event to be one of touch events type when touch events are not delivered at all Change-Id: I1ed91fa124608d8a006cf2f5256ad68294dd465f Reviewed-by: Mitch Curtis --- src/quicktemplates2/qquickoverlay.cpp | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) (limited to 'src/quicktemplates2') diff --git a/src/quicktemplates2/qquickoverlay.cpp b/src/quicktemplates2/qquickoverlay.cpp index cf72c8a6..3f358706 100644 --- a/src/quicktemplates2/qquickoverlay.cpp +++ b/src/quicktemplates2/qquickoverlay.cpp @@ -126,11 +126,6 @@ bool QQuickOverlayPrivate::startDrag(QEvent *event, const QPointF &pos) return false; } -static bool isTouchEvent(QEvent *event) -{ - return event->type() == QEvent::TouchBegin || event->type() == QEvent::TouchUpdate || event->type() == QEvent::TouchEnd; -} - bool QQuickOverlayPrivate::handlePress(QQuickItem *source, QEvent *event, QQuickPopup *target) { if (target) { @@ -139,7 +134,18 @@ bool QQuickOverlayPrivate::handlePress(QQuickItem *source, QEvent *event, QQuick return true; } return false; - } else if (!mouseGrabberPopup || isTouchEvent(event)) { + } + + switch (event->type()) { + default: { + if (mouseGrabberPopup) + break; +#if QT_CONFIG(quicktemplates2_multitouch) + Q_FALLTHROUGH(); + case QEvent::TouchBegin: + case QEvent::TouchUpdate: + case QEvent::TouchEnd: +#endif // allow non-modal popups to close themselves, // and non-dimming modal popups to block the event const auto popups = stackingOrderPopups(); @@ -149,6 +155,8 @@ bool QQuickOverlayPrivate::handlePress(QQuickItem *source, QEvent *event, QQuick return true; } } + break; + } } event->ignore(); -- cgit v1.2.3 From d41362ed752031fdd798e4838b3a56fbb2717f3f Mon Sep 17 00:00:00 2001 From: Konstantin Ritt Date: Wed, 11 Sep 2019 20:54:25 +0300 Subject: TextArea: correctly resize background when there is no flickable Change-Id: Idaf385d12ca9388c0bb0b3f8a47c8e75c620b7eb Reviewed-by: Mitch Curtis --- src/quicktemplates2/qquicktextarea.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src/quicktemplates2') diff --git a/src/quicktemplates2/qquicktextarea.cpp b/src/quicktemplates2/qquicktextarea.cpp index 95bf5bb1..e24844d8 100644 --- a/src/quicktemplates2/qquicktextarea.cpp +++ b/src/quicktemplates2/qquicktextarea.cpp @@ -369,6 +369,8 @@ void QQuickTextAreaPrivate::detachFlickable() QObjectPrivate::disconnect(flickable, &QQuickFlickable::contentHeightChanged, this, &QQuickTextAreaPrivate::resizeFlickableControl); flickable = nullptr; + + resizeBackground(); } void QQuickTextAreaPrivate::ensureCursorVisible() @@ -437,7 +439,10 @@ void QQuickTextAreaPrivate::itemGeometryChanged(QQuickItem *item, QQuickGeometry Q_UNUSED(change); Q_UNUSED(diff); - resizeFlickableControl(); + if (flickable) + resizeFlickableControl(); + else + resizeBackground(); } qreal QQuickTextAreaPrivate::getImplicitWidth() const -- cgit v1.2.3 From a89c3bc67ea6c76bfc89d64f235ebf5cb4b0fca4 Mon Sep 17 00:00:00 2001 From: Konstantin Ritt Date: Wed, 11 Sep 2019 16:39:47 +0000 Subject: Revert "QQuickTextArea: prevent changing size of background recursively" This reverts commit da06da57002b64cf4bcde0ca708b3275a5f919ae. Reason for revert: the change removes symptoms leaving a cause unfixed Change-Id: I0a91409230c521da73ed53e2a00a4ccd8dca7335 Reviewed-by: Mitch Curtis --- src/quicktemplates2/qquicktextarea.cpp | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) (limited to 'src/quicktemplates2') diff --git a/src/quicktemplates2/qquicktextarea.cpp b/src/quicktemplates2/qquicktextarea.cpp index e24844d8..7fdc8f0a 100644 --- a/src/quicktemplates2/qquicktextarea.cpp +++ b/src/quicktemplates2/qquicktextarea.cpp @@ -517,11 +517,8 @@ void QQuickTextAreaPrivate::executeBackground(bool complete) if (!background || complete) quickBeginDeferred(q, backgroundName(), background); - if (complete) { + if (complete) quickCompleteDeferred(q, backgroundName(), background); - if (background) - QQuickControlPrivate::addImplicitSizeListener(background, this, QQuickControlPrivate::ImplicitSizeChanges | QQuickItemPrivate::Geometry); - } } void QQuickTextAreaPrivate::itemImplicitWidthChanged(QQuickItem *item) @@ -641,10 +638,9 @@ void QQuickTextArea::setBackground(QQuickItem *background) d->extra.value().hasBackgroundWidth = p->widthValid; d->extra.value().hasBackgroundHeight = p->heightValid; } - if (isComponentComplete()) { + if (isComponentComplete()) d->resizeBackground(); - QQuickControlPrivate::addImplicitSizeListener(background, d, QQuickControlPrivate::ImplicitSizeChanges | QQuickItemPrivate::Geometry); - } + QQuickControlPrivate::addImplicitSizeListener(background, d, QQuickControlPrivate::ImplicitSizeChanges | QQuickItemPrivate::Geometry); } if (!qFuzzyCompare(oldImplicitBackgroundWidth, implicitBackgroundWidth())) -- cgit v1.2.3 From 6815f353e5a73c0dcf39fbfc91c6a2c1b0784324 Mon Sep 17 00:00:00 2001 From: Konstantin Ritt Date: Wed, 11 Sep 2019 21:54:53 +0300 Subject: TextArea: prevent changing size of background recursively When the x/y position of background depends on the height/width of background and these values are not constant, the if statement in the method resizeBackground() will always pass. And since `resizingBackground` guard wasn't checked, any geometry change will always call resizeBackground() and then call themself recursively (via the change listener), that means the height/width of background will always be reset, no matter what value you set. Another part of the issue was in determining the extra bits too late: in case the background gets parented by the flickable, the new child caused the flickable to re-calculate its metrics and thus resize the background *prior* to remembering if it has w/h set. As a side effect, this fix also brings the possibility to reset previously set w/h to get the default background sizing behavior. Inspired by da06da57002b64cf4bcde0ca708b3275a5f919ae [ChangeLog][QtQuick][QQuickTextArea] prevent changing size of background recursively in construction Fixes: QTBUG-76369 Change-Id: Ide51ec1ebab63605ae3bfcc10a76a28be960ef36 Reviewed-by: Mitch Curtis --- src/quicktemplates2/qquicktextarea.cpp | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) (limited to 'src/quicktemplates2') diff --git a/src/quicktemplates2/qquicktextarea.cpp b/src/quicktemplates2/qquicktextarea.cpp index 7fdc8f0a..f7b8969c 100644 --- a/src/quicktemplates2/qquicktextarea.cpp +++ b/src/quicktemplates2/qquicktextarea.cpp @@ -435,9 +435,16 @@ void QQuickTextAreaPrivate::resizeFlickableContent() void QQuickTextAreaPrivate::itemGeometryChanged(QQuickItem *item, QQuickGeometryChange change, const QRectF &diff) { - Q_UNUSED(item); - Q_UNUSED(change); Q_UNUSED(diff); + if (!resizingBackground && item == background) { + QQuickItemPrivate *p = QQuickItemPrivate::get(item); + // Only set hasBackgroundWidth/Height if it was a width/height change, + // otherwise we're prevented from setting a width/height in the future. + if (change.widthChange()) + extra.value().hasBackgroundWidth = p->widthValid; + if (change.heightChange()) + extra.value().hasBackgroundHeight = p->heightValid; + } if (flickable) resizeFlickableControl(); @@ -627,17 +634,17 @@ void QQuickTextArea::setBackground(QQuickItem *background) d->background = background; if (background) { + QQuickItemPrivate *p = QQuickItemPrivate::get(background); + if (p->widthValid || p->heightValid) { + d->extra.value().hasBackgroundWidth = p->widthValid; + d->extra.value().hasBackgroundHeight = p->heightValid; + } if (d->flickable) background->setParentItem(d->flickable); else background->setParentItem(this); if (qFuzzyIsNull(background->z())) background->setZ(-1); - QQuickItemPrivate *p = QQuickItemPrivate::get(background); - if (p->widthValid || p->heightValid) { - d->extra.value().hasBackgroundWidth = p->widthValid; - d->extra.value().hasBackgroundHeight = p->heightValid; - } if (isComponentComplete()) d->resizeBackground(); QQuickControlPrivate::addImplicitSizeListener(background, d, QQuickControlPrivate::ImplicitSizeChanges | QQuickItemPrivate::Geometry); -- cgit v1.2.3