From 99264fcfb98c01040a1edccba70ce7c268c41de4 Mon Sep 17 00:00:00 2001 From: Antti Kokko Date: Thu, 4 Jan 2018 13:31:04 +0200 Subject: Add changes file for Qt 5.9.4 Change-Id: I03415ed1c96190aeb69bb7371068464684080776 Reviewed-by: Mitch Curtis --- dist/changes-5.9.4 | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 dist/changes-5.9.4 diff --git a/dist/changes-5.9.4 b/dist/changes-5.9.4 new file mode 100644 index 00000000..3ac6f4a5 --- /dev/null +++ b/dist/changes-5.9.4 @@ -0,0 +1,63 @@ +Qt 5.9.4 is a bug-fix release. It maintains both forward and backward +compatibility (source and binary) with Qt 5.9.0. + +For more details, refer to the online documentation included in this +distribution. The documentation is also available online: + +http://doc.qt.io/qt-5/index.html + +The Qt version 5.9 series is binary compatible with the 5.8.x series. +Applications compiled for 5.8 will continue to run with 5.9. + +Some of the changes listed in this file include issue tracking numbers +corresponding to tasks in the Qt Bug Tracker: + +https://bugreports.qt.io/ + +Each of these identifiers can be entered in the bug tracker to obtain more +information about a particular change. + +**************************************************************************** +* Important Behavior Changes * +**************************************************************************** + + - As a fix to QTBUG-50992, execution of delegates, such as contentItem and + background, is deferred until the construction of a control is complete, + or a delegate is accessed. Consequently, if a delegate is replaced with + a custom delegate, the default delegate is not created. Previously, when + a default delegate was replaced by a custom delegate, the default + delegate was nevertheless created and destroyed during the construction + of the control. + +**************************************************************************** +* Controls * +**************************************************************************** + + - [QTBUG-64548] Fixed shortcuts in QQuickWidget + + - [QTBUG-65016] Fixed QQuickStyle::setFallbackStyle() in static builds + + - [QTBUG-50992] Fixed a bug which caused delegates of customized controls + to often be "destroyed during incubation" when asynchronously incubated + by item views or asynchronous loaders. + + - BusyIndicator: + * [QTBUG-62874] Fixed busy animation in QQuickWidget + + - ProgressBar: + * [QTBUG-62874] Fixed indeterminate animation in QQuickWidget + + - StackView: + * [QTBUG-65084] Fixed to not block touch events. + + - SwipeView: + * [QTBUG-62110] Fixed slow swiping in large views + + - ToolButton: + * [QTBUG-65052] Fixed round ripple for square buttons in the Material style + + - Tumbler: + * [QTBUG-65165] Made currentIndex animations take a constant amount of + time (1 second) regardless of how many items are in the model. This + prevents Tumblers with large amounts of items from scrolling too + slowly when changing the currentIndex. -- cgit v1.2.3 From 96e16e3501c23bc97e2a60cc78e57aaff7177019 Mon Sep 17 00:00:00 2001 From: Mitch Curtis Date: Wed, 17 Jan 2018 12:24:10 +0100 Subject: Tumbler: qualify references to visibleItemCount with "control" This code currently works, but we prefer to use control. to access properties directly. A similar patch was done for the styles that were available in 5.9. Change-Id: Iff12162464daa6b10fa8d3f322e0e61632713d08 Reviewed-by: J-P Nurmi --- src/imports/controls/fusion/Tumbler.qml | 2 +- src/imports/controls/imagine/Tumbler.qml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/imports/controls/fusion/Tumbler.qml b/src/imports/controls/fusion/Tumbler.qml index d53b6845..66e8906b 100644 --- a/src/imports/controls/fusion/Tumbler.qml +++ b/src/imports/controls/fusion/Tumbler.qml @@ -50,7 +50,7 @@ T.Tumbler { text: modelData color: control.palette.windowText font: control.font - opacity: (1.0 - Math.abs(Tumbler.displacement) / (visibleItemCount / 2)) * (control.enabled ? 1 : 0.6) + opacity: (1.0 - Math.abs(Tumbler.displacement) / (control.visibleItemCount / 2)) * (control.enabled ? 1 : 0.6) horizontalAlignment: Text.AlignHCenter verticalAlignment: Text.AlignVCenter } diff --git a/src/imports/controls/imagine/Tumbler.qml b/src/imports/controls/imagine/Tumbler.qml index 17f6c562..d3d7b574 100644 --- a/src/imports/controls/imagine/Tumbler.qml +++ b/src/imports/controls/imagine/Tumbler.qml @@ -50,7 +50,7 @@ T.Tumbler { text: modelData font: control.font color: control.palette.text - opacity: (1.0 - Math.abs(Tumbler.displacement) / (visibleItemCount / 2)) * (control.enabled ? 1 : 0.6) + opacity: (1.0 - Math.abs(Tumbler.displacement) / (control.visibleItemCount / 2)) * (control.enabled ? 1 : 0.6) horizontalAlignment: Text.AlignHCenter verticalAlignment: Text.AlignVCenter } -- cgit v1.2.3 From da7d894deb4cc36155ade5e6a1ebecc3262363f8 Mon Sep 17 00:00:00 2001 From: Mitch Curtis Date: Tue, 16 Jan 2018 15:22:40 +0100 Subject: Make Tumbler compatible with deferred execution Now that the contentItem is created at a different stage, we have to shuffle some code around and add some null checks. Task-number: QTBUG-50992 Change-Id: I34d3a9ea9cb9ab54008a1015b37b1666538c085e Reviewed-by: J-P Nurmi --- src/quickcontrols2/qquicktumblerview.cpp | 9 +- src/quicktemplates2/qquicktumbler.cpp | 189 ++++++++++++++++--------- src/quicktemplates2/qquicktumbler_p.h | 1 - src/quicktemplates2/qquicktumbler_p_p.h | 29 ++++ tests/auto/controls/data/TumblerListView.qml | 12 +- tests/auto/controls/data/TumblerPathView.qml | 11 +- tests/auto/controls/data/tst_tumbler.qml | 21 ++- tests/auto/customization/tst_customization.cpp | 2 +- 8 files changed, 198 insertions(+), 76 deletions(-) diff --git a/src/quickcontrols2/qquicktumblerview.cpp b/src/quickcontrols2/qquicktumblerview.cpp index e8f0c364..4469810c 100644 --- a/src/quickcontrols2/qquicktumblerview.cpp +++ b/src/quickcontrols2/qquicktumblerview.cpp @@ -173,14 +173,19 @@ void QQuickTumblerView::createView() m_listView->setParentItem(this); m_listView->setSnapMode(QQuickListView::SnapToItem); m_listView->setHighlightRangeMode(QQuickListView::StrictlyEnforceRange); - m_listView->setHighlightMoveDuration(1000); m_listView->setClip(true); - m_listView->setDelegate(m_delegate); // Give the view a size. updateView(); // Set the model. updateModel(); + + // Set these after the model is set so that the currentItem animation + // happens instantly on startup/after switching models. If we set them too early, + // the view animates any potential currentIndex change over one second, + // which we don't want when the contentItem has just been created. + m_listView->setDelegate(m_delegate); + m_listView->setHighlightMoveDuration(1000); } } } diff --git a/src/quicktemplates2/qquicktumbler.cpp b/src/quicktemplates2/qquicktumbler.cpp index 3429f1f4..241a5fc3 100644 --- a/src/quicktemplates2/qquicktumbler.cpp +++ b/src/quicktemplates2/qquicktumbler.cpp @@ -119,6 +119,11 @@ namespace { */ QQuickItem *QQuickTumblerPrivate::determineViewType(QQuickItem *contentItem) { + if (!contentItem) { + resetViewData(); + return nullptr; + } + if (contentItem->inherits("QQuickPathView")) { view = contentItem; viewContentItem = contentItem; @@ -139,6 +144,7 @@ QQuickItem *QQuickTumblerPrivate::determineViewType(QQuickItem *contentItem) } resetViewData(); + viewContentItemType = UnsupportedContentItemType; return nullptr; } @@ -146,7 +152,7 @@ void QQuickTumblerPrivate::resetViewData() { view = nullptr; viewContentItem = nullptr; - viewContentItemType = UnsupportedContentItemType; + viewContentItemType = NoContentItem; } QList QQuickTumblerPrivate::viewContentItemChildItems() const @@ -484,8 +490,6 @@ void QQuickTumbler::componentComplete() { Q_D(QQuickTumbler); QQuickControl::componentComplete(); - d->_q_updateItemHeights(); - d->_q_updateItemWidths(); if (!d->view) { // Force the view to be created. @@ -493,6 +497,17 @@ void QQuickTumbler::componentComplete() // Determine the type of view for attached properties, etc. d->setupViewData(d->contentItem); } + + // If there was no contentItem or it was of an unsupported type, + // we don't have anything else to do. + if (!d->view) + return; + + // Update item heights after we've populated the model, + // otherwise ignoreSignals will cause these functions to return early. + d->_q_updateItemHeights(); + d->_q_updateItemWidths(); + d->_q_onViewCountChanged(); } void QQuickTumbler::contentItemChange(QQuickItem *newItem, QQuickItem *oldItem) @@ -511,6 +526,9 @@ void QQuickTumbler::contentItemChange(QQuickItem *newItem, QQuickItem *oldItem) // Make sure we use the new content item and not the current one, as that won't // be changed until after contentItemChange() has finished. d->setupViewData(newItem); + + d->_q_updateItemHeights(); + d->_q_updateItemWidths(); } } } @@ -545,6 +563,9 @@ void QQuickTumblerPrivate::setupViewData(QQuickItem *newControlContentItem) determineViewType(newControlContentItem); + if (viewContentItemType == QQuickTumblerPrivate::NoContentItem) + return; + if (viewContentItemType == QQuickTumblerPrivate::UnsupportedContentItemType) { qWarning() << "Tumbler: contentItem must contain either a PathView or a ListView"; return; @@ -561,6 +582,16 @@ void QQuickTumblerPrivate::setupViewData(QQuickItem *newControlContentItem) // Sync the view's currentIndex with ours. syncCurrentIndex(); + + const auto items = viewContentItemChildItems(); + for (QQuickItem *childItem : items) { + QQuickTumblerAttached *attached = qobject_cast( + qmlAttachedPropertiesObject(childItem, false)); + if (attached) { + QQuickTumblerAttachedPrivate *attachedPrivate = QQuickTumblerAttachedPrivate::get(attached); + attachedPrivate->viewDataSetUp(); + } + } } void QQuickTumblerPrivate::syncCurrentIndex() @@ -568,17 +599,27 @@ void QQuickTumblerPrivate::syncCurrentIndex() const int actualViewIndex = view->property("currentIndex").toInt(); Q_Q(QQuickTumbler); + const bool isPendingCurrentIndex = pendingCurrentIndex != -1; + const int indexToSet = isPendingCurrentIndex ? pendingCurrentIndex : currentIndex; + // Nothing to do. - if (actualViewIndex == currentIndex) + if (actualViewIndex == indexToSet) { + pendingCurrentIndex = -1; return; + } // PathView likes to use 0 as currentIndex for empty models, but we use -1 for that. if (q->count() == 0 && actualViewIndex == 0) return; ignoreCurrentIndexChanges = true; - view->setProperty("currentIndex", currentIndex); + view->setProperty("currentIndex", QVariant(indexToSet)); ignoreCurrentIndexChanges = false; + + if (view->property("currentIndex").toInt() == indexToSet) + pendingCurrentIndex = -1; + else if (isPendingCurrentIndex) + q->polish(); } void QQuickTumblerPrivate::setCount(int newCount) @@ -629,11 +670,17 @@ void QQuickTumblerPrivate::setWrap(bool shouldWrap, bool isExplicit) ignoreCurrentIndexChanges = false; - // The view should have been created now, so we can start determining its type, etc. - // If the delegates use attached properties, this will have already been called, - // in which case it will return early. If the delegate doesn't use attached properties, - // we need to call it here. - setupViewData(contentItem); + // If isComponentComplete() is true, we require a contentItem. If it's not + // true, it might not have been created yet, so we wait until + // componentComplete() is called. + // + // When the contentItem (usually QQuickTumblerView) has been created, we + // can start determining its type, etc. If the delegates use attached + // properties, this will have already been called, in which case it will + // return early. If the delegate doesn't use attached properties, we need + // to call it here. + if (q->isComponentComplete() || contentItem) + setupViewData(contentItem); q->setCurrentIndex(oldCurrentIndex); } @@ -668,6 +715,10 @@ void QQuickTumbler::updatePolish() { Q_D(QQuickTumbler); if (d->pendingCurrentIndex != -1) { + // Update our count, as ignoreSignals might have been true + // when _q_onViewCountChanged() was last called. + d->setCount(d->view->property("count").toInt()); + // If the count is still 0, it's not going to happen. if (d->count == 0) { d->pendingCurrentIndex = -1; @@ -689,53 +740,34 @@ void QQuickTumbler::updatePolish() } } -class QQuickTumblerAttachedPrivate : public QObjectPrivate, public QQuickItemChangeListener +QQuickTumblerAttachedPrivate::QQuickTumblerAttachedPrivate() + : tumbler(nullptr), + index(-1), + displacement(0) { - Q_DECLARE_PUBLIC(QQuickTumblerAttached) -public: - QQuickTumblerAttachedPrivate() - : tumbler(nullptr), - index(-1), - displacement(0) - { - } - - void init(QQuickItem *delegateItem) - { - if (!delegateItem->parentItem()) { - qWarning() << "Tumbler: attached properties must be accessed through a delegate item that has a parent"; - return; - } - - QVariant indexContextProperty = qmlContext(delegateItem)->contextProperty(QStringLiteral("index")); - if (!indexContextProperty.isValid()) { - qWarning() << "Tumbler: attempting to access attached property on item without an \"index\" property"; - return; - } - - index = indexContextProperty.toInt(); +} - QQuickItem *parentItem = delegateItem; - while ((parentItem = parentItem->parentItem())) { - if ((tumbler = qobject_cast(parentItem))) - break; - } +void QQuickTumblerAttachedPrivate::init(QQuickItem *delegateItem) +{ + if (!delegateItem->parentItem()) { + qWarning() << "Tumbler: attached properties must be accessed through a delegate item that has a parent"; + return; } - void itemGeometryChanged(QQuickItem *item, QQuickGeometryChange change, const QRectF &diff) override; - void itemChildAdded(QQuickItem *, QQuickItem *) override; - void itemChildRemoved(QQuickItem *, QQuickItem *) override; + QVariant indexContextProperty = qmlContext(delegateItem)->contextProperty(QStringLiteral("index")); + if (!indexContextProperty.isValid()) { + qWarning() << "Tumbler: attempting to access attached property on item without an \"index\" property"; + return; + } - void _q_calculateDisplacement(); - void emitIfDisplacementChanged(qreal oldDisplacement, qreal newDisplacement); + index = indexContextProperty.toInt(); - // The Tumbler that contains the delegate. Required to calculated the displacement. - QPointer tumbler; - // The index of the delegate. Used to calculate the displacement. - int index; - // The displacement for our delegate. - qreal displacement; -}; + QQuickItem *parentItem = delegateItem; + while ((parentItem = parentItem->parentItem())) { + if ((tumbler = qobject_cast(parentItem))) + break; + } +} void QQuickTumblerAttachedPrivate::itemGeometryChanged(QQuickItem *, QQuickGeometryChange, const QRectF &) { @@ -768,9 +800,9 @@ void QQuickTumblerAttachedPrivate::_q_calculateDisplacement() const int previousDisplacement = displacement; displacement = 0; - // Can happen if the attached properties are accessed on the wrong type of item or the tumbler was destroyed. if (!tumbler) { - emitIfDisplacementChanged(previousDisplacement, displacement); + // Can happen if the attached properties are accessed on the wrong type of item or the tumbler was destroyed. + // We don't want to emit the change signal though, as this could cause warnings about Tumbler.tumbler being null. return; } @@ -820,6 +852,28 @@ void QQuickTumblerAttachedPrivate::emitIfDisplacementChanged(qreal oldDisplaceme emit q->displacementChanged(); } +void QQuickTumblerAttachedPrivate::viewDataSetUp() +{ + Q_Q(QQuickTumblerAttached); + QQuickTumblerPrivate *tumblerPrivate = QQuickTumblerPrivate::get(tumbler); + if (!tumblerPrivate->viewContentItem) + return; + + QQuickItemPrivate *viewContentItemPrivate = QQuickItemPrivate::get(tumblerPrivate->viewContentItem); + viewContentItemPrivate->addItemChangeListener(this, QQuickItemPrivate::Geometry | QQuickItemPrivate::Children); + + const char *contentItemSignal = tumblerPrivate->viewContentItemType == QQuickTumblerPrivate::PathViewContentItem + ? SIGNAL(offsetChanged()) : SIGNAL(contentYChanged()); + QObject::connect(tumblerPrivate->view, contentItemSignal, q, SLOT(_q_calculateDisplacement())); + + _q_calculateDisplacement(); +} + +QQuickTumblerAttachedPrivate *QQuickTumblerAttachedPrivate::get(QQuickTumblerAttached *attached) +{ + return attached->d_func(); +} + QQuickTumblerAttached::QQuickTumblerAttached(QObject *parent) : QObject(*(new QQuickTumblerAttachedPrivate), parent) { @@ -839,17 +893,24 @@ QQuickTumblerAttached::QQuickTumblerAttached(QObject *parent) QQuickTumblerPrivate *tumblerPrivate = QQuickTumblerPrivate::get(d->tumbler); tumblerPrivate->setupViewData(tumblerPrivate->contentItem); - if (!tumblerPrivate->viewContentItem) - return; - - QQuickItemPrivate *p = QQuickItemPrivate::get(tumblerPrivate->viewContentItem); - p->addItemChangeListener(d, QQuickItemPrivate::Geometry | QQuickItemPrivate::Children); - - const char *contentItemSignal = tumblerPrivate->viewContentItemType == QQuickTumblerPrivate::PathViewContentItem - ? SIGNAL(offsetChanged()) : SIGNAL(contentYChanged()); - connect(tumblerPrivate->view, contentItemSignal, this, SLOT(_q_calculateDisplacement())); - - d->_q_calculateDisplacement(); + // When creating a custom contentItem with e.g. Component's createObject() function, + // the item is created and *then* assigned to Tumbler's contentItem property, + // meaning that, at this point, the tumbler's contentItem is still its old one, + // as the delegates and their attached objects are created before the contentItem is assigned. + // That's why setupViewData() calls viewDataSetUp() on each attached object: + // we have to be notified whenever the contentItem changes, as otherwise + // we may never end up using the correct view data, and end up calculating incorrect displacements. + + if (delegateItem->parentItem() == tumblerPrivate->viewContentItem) { + // This item belongs to the "new" view, meaning that the tumbler's contentItem + // was probably assigned declaratively. If the contentItem was instead created + // dynamically and then assigned (as mentioned above), these two won't + // be equal and we'll have to wait until viewDataSetUp() is called before + // connecting signals to our slots. Since viewDataSetUp() is only called once + // for each contentItem, and every attached object after the first one that is + // created would miss the chance for it to be called, we call the slot manually here. + d->viewDataSetUp(); + } } } diff --git a/src/quicktemplates2/qquicktumbler_p.h b/src/quicktemplates2/qquicktumbler_p.h index 480ebb23..de7de595 100644 --- a/src/quicktemplates2/qquicktumbler_p.h +++ b/src/quicktemplates2/qquicktumbler_p.h @@ -70,7 +70,6 @@ class Q_QUICKTEMPLATES2_PRIVATE_EXPORT QQuickTumbler : public QQuickControl Q_PROPERTY(bool wrap READ wrap WRITE setWrap RESET resetWrap NOTIFY wrapChanged FINAL REVISION 1) // 2.2 (Qt 5.9) Q_PROPERTY(bool moving READ isMoving NOTIFY movingChanged FINAL REVISION 2) - Q_CLASSINFO("DeferredPropertyNames", "background") public: explicit QQuickTumbler(QQuickItem *parent = nullptr); diff --git a/src/quicktemplates2/qquicktumbler_p_p.h b/src/quicktemplates2/qquicktumbler_p_p.h index 0dcae762..38b0f60d 100644 --- a/src/quicktemplates2/qquicktumbler_p_p.h +++ b/src/quicktemplates2/qquicktumbler_p_p.h @@ -64,6 +64,7 @@ public: ~QQuickTumblerPrivate(); enum ContentItemType { + NoContentItem, UnsupportedContentItemType, PathViewContentItem, ListViewContentItem @@ -109,6 +110,34 @@ public: void itemChildRemoved(QQuickItem *, QQuickItem *) override; }; +class Q_QUICKTEMPLATES2_PRIVATE_EXPORT QQuickTumblerAttachedPrivate : public QObjectPrivate, public QQuickItemChangeListener +{ + Q_DECLARE_PUBLIC(QQuickTumblerAttached) + +public: + QQuickTumblerAttachedPrivate(); + + void init(QQuickItem *delegateItem); + + void itemGeometryChanged(QQuickItem *item, QQuickGeometryChange change, const QRectF &diff) override; + void itemChildAdded(QQuickItem *, QQuickItem *) override; + void itemChildRemoved(QQuickItem *, QQuickItem *) override; + + void _q_calculateDisplacement(); + void emitIfDisplacementChanged(qreal oldDisplacement, qreal newDisplacement); + + void viewDataSetUp(); + + static QQuickTumblerAttachedPrivate *get(QQuickTumblerAttached *attached); + + // The Tumbler that contains the delegate. Required to calculated the displacement. + QPointer tumbler; + // The index of the delegate. Used to calculate the displacement. + int index; + // The displacement for our delegate. + qreal displacement; +}; + QT_END_NAMESPACE #endif // QQUICKTUMBLER_P_P_H diff --git a/tests/auto/controls/data/TumblerListView.qml b/tests/auto/controls/data/TumblerListView.qml index 4e71f471..1248bec0 100644 --- a/tests/auto/controls/data/TumblerListView.qml +++ b/tests/auto/controls/data/TumblerListView.qml @@ -49,15 +49,21 @@ ****************************************************************************/ import QtQuick 2.6 +import QtQuick.Controls 2.2 ListView { anchors.fill: parent - model: parent.model - delegate: parent.delegate - snapMode: ListView.SnapToItem highlightRangeMode: ListView.StrictlyEnforceRange preferredHighlightBegin: height / 2 - (height / parent.visibleItemCount / 2) preferredHighlightEnd: height / 2 + (height / parent.visibleItemCount / 2) clip: true + model: parent.model + delegate: Text { + objectName: text + text: "Custom" + modelData + opacity: 1.0 - Math.abs(Tumbler.displacement) / (Tumbler.tumbler.visibleItemCount / 2) + horizontalAlignment: Text.AlignHCenter + verticalAlignment: Text.AlignVCenter + } } diff --git a/tests/auto/controls/data/TumblerPathView.qml b/tests/auto/controls/data/TumblerPathView.qml index 4f6f653f..7b7cd5f4 100644 --- a/tests/auto/controls/data/TumblerPathView.qml +++ b/tests/auto/controls/data/TumblerPathView.qml @@ -49,16 +49,23 @@ ****************************************************************************/ import QtQuick 2.6 +import QtQuick.Controls 2.2 PathView { id: pathView - model: parent.model - delegate: parent.delegate clip: true pathItemCount: parent.visibleItemCount + 1 preferredHighlightBegin: 0.5 preferredHighlightEnd: 0.5 dragMargin: width / 2 + model: parent.model + delegate: Text { + objectName: text + text: "Custom" + modelData + opacity: 1.0 - Math.abs(Tumbler.displacement) / (Tumbler.tumbler.visibleItemCount / 2) + horizontalAlignment: Text.AlignHCenter + verticalAlignment: Text.AlignVCenter + } path: Path { startX: pathView.width / 2 diff --git a/tests/auto/controls/data/tst_tumbler.qml b/tests/auto/controls/data/tst_tumbler.qml index 825c2489..36808b8f 100644 --- a/tests/auto/controls/data/tst_tumbler.qml +++ b/tests/auto/controls/data/tst_tumbler.qml @@ -287,11 +287,10 @@ TestCase { compare(tumblerView.currentIndex, data.currentIndex); compare(tumblerView.currentItem.text, data.currentIndex.toString()); - var fuzz = 1; if (data.wrap) { - fuzzyCompare(tumblerView.offset, data.currentIndex > 0 ? tumblerView.count - data.currentIndex : 0, fuzz); + tryCompare(tumblerView, "offset", data.currentIndex > 0 ? tumblerView.count - data.currentIndex : 0); } else { - fuzzyCompare(tumblerView.contentY, tumblerDelegateHeight * data.currentIndex - tumblerView.preferredHighlightBegin, fuzz); + tryCompare(tumblerView, "contentY", tumblerDelegateHeight * data.currentIndex - tumblerView.preferredHighlightBegin); } } @@ -680,6 +679,17 @@ TestCase { compare(tumbler.currentIndex, 3); } + function findFirstDelegateWithText(view, text) { + var delegate = null; + var contentItem = view.hasOwnProperty("contentItem") ? view.contentItem : view; + for (var i = 0; i < contentItem.children.length && !delegate; ++i) { + var child = contentItem.children[i]; + if (child.hasOwnProperty("text") && child.text === text) + delegate = child; + } + return delegate; + } + function test_customContentItemAfterConstruction_data() { return [ { tag: "ListView", componentPath: "TumblerListView.qml" }, @@ -705,6 +715,11 @@ TestCase { tumblerView = findView(tumbler); compare(tumblerView.currentIndex, 2); + var delegate = findFirstDelegateWithText(tumblerView, "Custom2"); + verify(delegate); + compare(delegate.height, defaultImplicitDelegateHeight); + tryCompare(delegate.Tumbler, "displacement", 0); + tumblerView.incrementCurrentIndex(); compare(tumblerView.currentIndex, 3); compare(tumbler.currentIndex, 3); diff --git a/tests/auto/customization/tst_customization.cpp b/tests/auto/customization/tst_customization.cpp index 05d95ec8..3010565c 100644 --- a/tests/auto/customization/tst_customization.cpp +++ b/tests/auto/customization/tst_customization.cpp @@ -101,7 +101,7 @@ static const ControlInfo ControlInfos[] = { { "ToolButton", QStringList() << "background" << "contentItem" }, { "ToolSeparator", QStringList() << "background" << "contentItem" }, { "ToolTip", QStringList() << "background" << "contentItem" }, - // { "Tumbler", QStringList() << "background" << "contentItem" } ### TODO: fix and enable deferred execution + { "Tumbler", QStringList() << "background" << "contentItem" } }; class tst_customization : public QQmlDataTest -- cgit v1.2.3 From 6c831d8e8a5007e0309f81f6263562b078046607 Mon Sep 17 00:00:00 2001 From: Mitch Curtis Date: Wed, 17 Jan 2018 10:51:58 +0100 Subject: Tumbler: qualify references to visibleItemCount with "control" This code currently works, but we prefer to use control. to access properties directly. Change-Id: Ieba95bffdd0b0a9b33373524248d0ac06e9f2a3d Reviewed-by: J-P Nurmi --- src/imports/controls/Tumbler.qml | 2 +- src/imports/controls/doc/snippets/qtquickcontrols2-tumbler-custom.qml | 2 +- src/imports/controls/material/Tumbler.qml | 2 +- src/imports/controls/universal/Tumbler.qml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/imports/controls/Tumbler.qml b/src/imports/controls/Tumbler.qml index e9cbf97d..15ad876d 100644 --- a/src/imports/controls/Tumbler.qml +++ b/src/imports/controls/Tumbler.qml @@ -48,7 +48,7 @@ T.Tumbler { text: modelData color: control.visualFocus ? Default.focusColor : Default.textDarkColor font: control.font - opacity: (1.0 - Math.abs(Tumbler.displacement) / (visibleItemCount / 2)) * (control.enabled ? 1 : 0.6) + opacity: (1.0 - Math.abs(Tumbler.displacement) / (control.visibleItemCount / 2)) * (control.enabled ? 1 : 0.6) horizontalAlignment: Text.AlignHCenter verticalAlignment: Text.AlignVCenter } diff --git a/src/imports/controls/doc/snippets/qtquickcontrols2-tumbler-custom.qml b/src/imports/controls/doc/snippets/qtquickcontrols2-tumbler-custom.qml index b3645587..cc37d541 100644 --- a/src/imports/controls/doc/snippets/qtquickcontrols2-tumbler-custom.qml +++ b/src/imports/controls/doc/snippets/qtquickcontrols2-tumbler-custom.qml @@ -56,7 +56,7 @@ Tumbler { font: control.font horizontalAlignment: Text.AlignHCenter verticalAlignment: Text.AlignVCenter - opacity: 1.0 - Math.abs(Tumbler.displacement) / (visibleItemCount / 2) + opacity: 1.0 - Math.abs(Tumbler.displacement) / (control.visibleItemCount / 2) } Rectangle { diff --git a/src/imports/controls/material/Tumbler.qml b/src/imports/controls/material/Tumbler.qml index 76e6124e..97628fc4 100644 --- a/src/imports/controls/material/Tumbler.qml +++ b/src/imports/controls/material/Tumbler.qml @@ -49,7 +49,7 @@ T.Tumbler { text: modelData color: control.Material.foreground font: control.font - opacity: (1.0 - Math.abs(Tumbler.displacement) / (visibleItemCount / 2)) * (control.enabled ? 1 : 0.6) + opacity: (1.0 - Math.abs(Tumbler.displacement) / (control.visibleItemCount / 2)) * (control.enabled ? 1 : 0.6) horizontalAlignment: Text.AlignHCenter verticalAlignment: Text.AlignVCenter } diff --git a/src/imports/controls/universal/Tumbler.qml b/src/imports/controls/universal/Tumbler.qml index 9da9d56e..9972fb4c 100644 --- a/src/imports/controls/universal/Tumbler.qml +++ b/src/imports/controls/universal/Tumbler.qml @@ -50,7 +50,7 @@ T.Tumbler { text: modelData font: control.font color: control.Universal.foreground - opacity: (1.0 - Math.abs(Tumbler.displacement) / (visibleItemCount / 2)) * (control.enabled ? 1 : 0.6) + opacity: (1.0 - Math.abs(Tumbler.displacement) / (control.visibleItemCount / 2)) * (control.enabled ? 1 : 0.6) horizontalAlignment: Text.AlignHCenter verticalAlignment: Text.AlignVCenter } -- cgit v1.2.3 From 8e52c65ac4c5d5140d5e1a6cdb18274f2c6b2108 Mon Sep 17 00:00:00 2001 From: Mitch Curtis Date: Wed, 17 Jan 2018 11:36:23 +0100 Subject: Tumbler: reduce amount of signal-slot connections and change listeners Instead of adding change listeners and signal-slot connections for each attached object, add them once in QQuickTumbler and then notify each attached object all in one go. Change-Id: I6c5e76182c026b24922dcddaeb08ae4b1d4c4c38 Reviewed-by: J-P Nurmi --- src/quicktemplates2/qquicktumbler.cpp | 105 ++++++++------------------------ src/quicktemplates2/qquicktumbler_p.h | 1 + src/quicktemplates2/qquicktumbler_p_p.h | 7 +-- 3 files changed, 28 insertions(+), 85 deletions(-) diff --git a/src/quicktemplates2/qquicktumbler.cpp b/src/quicktemplates2/qquicktumbler.cpp index 241a5fc3..c965095d 100644 --- a/src/quicktemplates2/qquicktumbler.cpp +++ b/src/quicktemplates2/qquicktumbler.cpp @@ -119,6 +119,7 @@ namespace { */ QQuickItem *QQuickTumblerPrivate::determineViewType(QQuickItem *contentItem) { + Q_Q(QQuickTumbler); if (!contentItem) { resetViewData(); return nullptr; @@ -128,11 +129,17 @@ QQuickItem *QQuickTumblerPrivate::determineViewType(QQuickItem *contentItem) view = contentItem; viewContentItem = contentItem; viewContentItemType = PathViewContentItem; + + QObject::connect(view, SIGNAL(offsetChanged()), q, SLOT(_q_calculateAttachedDisplacements())); + return contentItem; } else if (contentItem->inherits("QQuickListView")) { view = contentItem; viewContentItem = qobject_cast(contentItem)->contentItem(); viewContentItemType = ListViewContentItem; + + QObject::connect(view, SIGNAL(contentYChanged()), q, SLOT(_q_calculateAttachedDisplacements())); + return contentItem; } else { const auto childItems = contentItem->childItems(); @@ -234,6 +241,19 @@ void QQuickTumblerPrivate::_q_onViewCountChanged() } } +void QQuickTumblerPrivate::_q_calculateAttachedDisplacements() +{ + const auto items = viewContentItemChildItems(); + for (QQuickItem *childItem : items) { + QQuickTumblerAttached *attached = qobject_cast( + qmlAttachedPropertiesObject(childItem, false)); + if (attached) { + QQuickTumblerAttachedPrivate *attachedPrivate = QQuickTumblerAttachedPrivate::get(attached); + attachedPrivate->_q_calculateDisplacement(); + } + } +} + void QQuickTumblerPrivate::itemChildAdded(QQuickItem *, QQuickItem *) { _q_updateItemWidths(); @@ -550,7 +570,7 @@ void QQuickTumblerPrivate::disconnectFromView() QObject::disconnect(view, SIGNAL(movingChanged()), q, SIGNAL(movingChanged())); QQuickItemPrivate *oldViewContentItemPrivate = QQuickItemPrivate::get(viewContentItem); - oldViewContentItemPrivate->removeItemChangeListener(this, QQuickItemPrivate::Children); + oldViewContentItemPrivate->removeItemChangeListener(this, QQuickItemPrivate::Geometry | QQuickItemPrivate::Children); resetViewData(); } @@ -578,20 +598,12 @@ void QQuickTumblerPrivate::setupViewData(QQuickItem *newControlContentItem) QObject::connect(view, SIGNAL(movingChanged()), q, SIGNAL(movingChanged())); QQuickItemPrivate *viewContentItemPrivate = QQuickItemPrivate::get(viewContentItem); - viewContentItemPrivate->addItemChangeListener(this, QQuickItemPrivate::Children); + viewContentItemPrivate->addItemChangeListener(this, QQuickItemPrivate::Geometry | QQuickItemPrivate::Children); // Sync the view's currentIndex with ours. syncCurrentIndex(); - const auto items = viewContentItemChildItems(); - for (QQuickItem *childItem : items) { - QQuickTumblerAttached *attached = qobject_cast( - qmlAttachedPropertiesObject(childItem, false)); - if (attached) { - QQuickTumblerAttachedPrivate *attachedPrivate = QQuickTumblerAttachedPrivate::get(attached); - attachedPrivate->viewDataSetUp(); - } - } + _q_calculateAttachedDisplacements(); } void QQuickTumblerPrivate::syncCurrentIndex() @@ -769,32 +781,6 @@ void QQuickTumblerAttachedPrivate::init(QQuickItem *delegateItem) } } -void QQuickTumblerAttachedPrivate::itemGeometryChanged(QQuickItem *, QQuickGeometryChange, const QRectF &) -{ - _q_calculateDisplacement(); -} - -void QQuickTumblerAttachedPrivate::itemChildAdded(QQuickItem *, QQuickItem *) -{ - _q_calculateDisplacement(); -} - -void QQuickTumblerAttachedPrivate::itemChildRemoved(QQuickItem *item, QQuickItem *child) -{ - _q_calculateDisplacement(); - - if (parent == child) { - // The child that was removed from the contentItem was the delegate - // that our properties are attached to. If we don't remove the change - // listener, the contentItem will attempt to notify a destroyed - // listener, causing a crash. - - // item is the "actual content item" of Tumbler's contentItem, i.e. a PathView or ListView.contentItem - QQuickItemPrivate *p = QQuickItemPrivate::get(item); - p->removeItemChangeListener(this, QQuickItemPrivate::Geometry | QQuickItemPrivate::Children); - } -} - void QQuickTumblerAttachedPrivate::_q_calculateDisplacement() { const int previousDisplacement = displacement; @@ -852,23 +838,6 @@ void QQuickTumblerAttachedPrivate::emitIfDisplacementChanged(qreal oldDisplaceme emit q->displacementChanged(); } -void QQuickTumblerAttachedPrivate::viewDataSetUp() -{ - Q_Q(QQuickTumblerAttached); - QQuickTumblerPrivate *tumblerPrivate = QQuickTumblerPrivate::get(tumbler); - if (!tumblerPrivate->viewContentItem) - return; - - QQuickItemPrivate *viewContentItemPrivate = QQuickItemPrivate::get(tumblerPrivate->viewContentItem); - viewContentItemPrivate->addItemChangeListener(this, QQuickItemPrivate::Geometry | QQuickItemPrivate::Children); - - const char *contentItemSignal = tumblerPrivate->viewContentItemType == QQuickTumblerPrivate::PathViewContentItem - ? SIGNAL(offsetChanged()) : SIGNAL(contentYChanged()); - QObject::connect(tumblerPrivate->view, contentItemSignal, q, SLOT(_q_calculateDisplacement())); - - _q_calculateDisplacement(); -} - QQuickTumblerAttachedPrivate *QQuickTumblerAttachedPrivate::get(QQuickTumblerAttached *attached) { return attached->d_func(); @@ -893,39 +862,17 @@ QQuickTumblerAttached::QQuickTumblerAttached(QObject *parent) QQuickTumblerPrivate *tumblerPrivate = QQuickTumblerPrivate::get(d->tumbler); tumblerPrivate->setupViewData(tumblerPrivate->contentItem); - // When creating a custom contentItem with e.g. Component's createObject() function, - // the item is created and *then* assigned to Tumbler's contentItem property, - // meaning that, at this point, the tumbler's contentItem is still its old one, - // as the delegates and their attached objects are created before the contentItem is assigned. - // That's why setupViewData() calls viewDataSetUp() on each attached object: - // we have to be notified whenever the contentItem changes, as otherwise - // we may never end up using the correct view data, and end up calculating incorrect displacements. - if (delegateItem->parentItem() == tumblerPrivate->viewContentItem) { // This item belongs to the "new" view, meaning that the tumbler's contentItem - // was probably assigned declaratively. If the contentItem was instead created - // dynamically and then assigned (as mentioned above), these two won't - // be equal and we'll have to wait until viewDataSetUp() is called before - // connecting signals to our slots. Since viewDataSetUp() is only called once - // for each contentItem, and every attached object after the first one that is - // created would miss the chance for it to be called, we call the slot manually here. - d->viewDataSetUp(); + // was probably assigned declaratively. If they're not equal, calling + // _q_calculateDisplacement() would use the old contentItem data, which is bad. + d->_q_calculateDisplacement(); } } } QQuickTumblerAttached::~QQuickTumblerAttached() { - Q_D(QQuickTumblerAttached); - if (!d->tumbler) - return; - - QQuickTumblerPrivate *tumblerPrivate = QQuickTumblerPrivate::get(d->tumbler); - if (!tumblerPrivate->viewContentItem) - return; - - QQuickItemPrivate *viewContentItemPrivate = QQuickItemPrivate::get(tumblerPrivate->viewContentItem); - viewContentItemPrivate->removeItemChangeListener(d, QQuickItemPrivate::Geometry | QQuickItemPrivate::Children); } /*! diff --git a/src/quicktemplates2/qquicktumbler_p.h b/src/quicktemplates2/qquicktumbler_p.h index de7de595..50069cd7 100644 --- a/src/quicktemplates2/qquicktumbler_p.h +++ b/src/quicktemplates2/qquicktumbler_p.h @@ -127,6 +127,7 @@ private: Q_PRIVATE_SLOT(d_func(), void _q_updateItemHeights()) Q_PRIVATE_SLOT(d_func(), void _q_onViewCurrentIndexChanged()) Q_PRIVATE_SLOT(d_func(), void _q_onViewCountChanged()) + Q_PRIVATE_SLOT(d_func(), void _q_calculateAttachedDisplacements()) }; class QQuickTumblerAttachedPrivate; diff --git a/src/quicktemplates2/qquicktumbler_p_p.h b/src/quicktemplates2/qquicktumbler_p_p.h index 38b0f60d..fc38dfcc 100644 --- a/src/quicktemplates2/qquicktumbler_p_p.h +++ b/src/quicktemplates2/qquicktumbler_p_p.h @@ -95,6 +95,7 @@ public: void _q_updateItemWidths(); void _q_onViewCurrentIndexChanged(); void _q_onViewCountChanged(); + void _q_calculateAttachedDisplacements(); void disconnectFromView(); void setupViewData(QQuickItem *newControlContentItem); @@ -119,15 +120,9 @@ public: void init(QQuickItem *delegateItem); - void itemGeometryChanged(QQuickItem *item, QQuickGeometryChange change, const QRectF &diff) override; - void itemChildAdded(QQuickItem *, QQuickItem *) override; - void itemChildRemoved(QQuickItem *, QQuickItem *) override; - void _q_calculateDisplacement(); void emitIfDisplacementChanged(qreal oldDisplacement, qreal newDisplacement); - void viewDataSetUp(); - static QQuickTumblerAttachedPrivate *get(QQuickTumblerAttached *attached); // The Tumbler that contains the delegate. Required to calculated the displacement. -- cgit v1.2.3 From c9cbee192263998bd3a9fe9d1414a4b539b9e4a2 Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Wed, 17 Jan 2018 15:51:18 +0100 Subject: Imagine/SpinBox: cleanup internal IDs for deferred execution Task-number: QTBUG-50992 Change-Id: Iaabd561b2bd009d3db970f370eff6fa717164961 Reviewed-by: Mitch Curtis --- src/imports/controls/imagine/SpinBox.qml | 6 ++---- tests/auto/sanity/BLACKLIST | 2 -- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/src/imports/controls/imagine/SpinBox.qml b/src/imports/controls/imagine/SpinBox.qml index ebadb860..1870148e 100644 --- a/src/imports/controls/imagine/SpinBox.qml +++ b/src/imports/controls/imagine/SpinBox.qml @@ -98,7 +98,6 @@ T.SpinBox { } up.indicator: NinePatchImage { - id: upIndicator x: control.mirrored ? 0 : parent.width - width height: parent.height @@ -106,7 +105,7 @@ T.SpinBox { NinePatchImageSelector on source { states: [ {"up": true}, - {"disabled": !upIndicator.enabled}, + {"disabled": !control.up.indicator.enabled}, {"editable": control.editable}, {"pressed": control.up.pressed}, {"focused": control.activeFocus}, @@ -117,7 +116,6 @@ T.SpinBox { } down.indicator: NinePatchImage { - id: downIndicator x: control.mirrored ? parent.width - width : 0 height: parent.height @@ -125,7 +123,7 @@ T.SpinBox { NinePatchImageSelector on source { states: [ {"down": true}, - {"disabled": !downIndicator.enabled}, + {"disabled": !control.down.indicator.enabled}, {"editable": control.editable}, {"pressed": control.down.pressed}, {"focused": control.activeFocus}, diff --git a/tests/auto/sanity/BLACKLIST b/tests/auto/sanity/BLACKLIST index 94e4fd32..b2038576 100644 --- a/tests/auto/sanity/BLACKLIST +++ b/tests/auto/sanity/BLACKLIST @@ -12,8 +12,6 @@ * [ids:imagine/ProgressBar.qml] * -[ids:imagine/SpinBox.qml] -* [ids:imagine/Switch.qml] * [ids:imagine/SwitchDelegate.qml] -- cgit v1.2.3 From 47168eb73bbe888042a1735e424ae35c9af04e2f Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Wed, 17 Jan 2018 15:52:55 +0100 Subject: Imagine/GroupBox: cleanup internal IDs for deferred execution Task-number: QTBUG-50992 Change-Id: Ied6b4365d03fc1ef3ae3a69667f1cb1fc8cdb9ac Reviewed-by: Mitch Curtis --- src/imports/controls/imagine/GroupBox.qml | 9 ++++----- tests/auto/sanity/BLACKLIST | 2 -- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/src/imports/controls/imagine/GroupBox.qml b/src/imports/controls/imagine/GroupBox.qml index ac09fb16..0049b8b0 100644 --- a/src/imports/controls/imagine/GroupBox.qml +++ b/src/imports/controls/imagine/GroupBox.qml @@ -60,10 +60,10 @@ T.GroupBox { label: Label { width: control.width - topPadding: header.topPadding - leftPadding: header.leftPadding - rightPadding: header.rightPadding - bottomPadding: header.bottomPadding + topPadding: background.topPadding + leftPadding: background.leftPadding + rightPadding: background.rightPadding + bottomPadding: background.bottomPadding text: control.title font: control.font @@ -73,7 +73,6 @@ T.GroupBox { color: control.palette.windowText background: NinePatchImage { - id: header width: parent.width height: parent.height diff --git a/tests/auto/sanity/BLACKLIST b/tests/auto/sanity/BLACKLIST index b2038576..ab9673a7 100644 --- a/tests/auto/sanity/BLACKLIST +++ b/tests/auto/sanity/BLACKLIST @@ -6,8 +6,6 @@ * [ids:imagine/DelayButton.qml] * -[ids:imagine/GroupBox.qml] -* [ids:imagine/ProgressBar.qml] * [ids:imagine/ProgressBar.qml] -- cgit v1.2.3 From 035990f2695e57526e5960b55fdefdaea3299ecb Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Thu, 18 Jan 2018 11:05:36 +0100 Subject: Imagine/BusyIndicator: cleanup internal IDs for deferred execution Task-number: QTBUG-50992 Change-Id: Idee1a13355e36e9221b32cdf9b89b4090dcf87b4 Reviewed-by: Mitch Curtis --- src/imports/controls/imagine/BusyIndicator.qml | 6 +++--- tests/auto/sanity/BLACKLIST | 2 -- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/imports/controls/imagine/BusyIndicator.qml b/src/imports/controls/imagine/BusyIndicator.qml index a1ce3f7b..28585ab1 100644 --- a/src/imports/controls/imagine/BusyIndicator.qml +++ b/src/imports/controls/imagine/BusyIndicator.qml @@ -53,10 +53,10 @@ T.BusyIndicator { bottomPadding: background ? background.bottomPadding : 0 contentItem: AnimatedImage { - playing: control.running opacity: control.running ? 1 : 0 - visible: control.running || animator.running - Behavior on opacity { OpacityAnimator { id: animator; duration: 250 } } + playing: control.running || opacity > 0 + visible: control.running || opacity > 0 + Behavior on opacity { OpacityAnimator { duration: 250 } } source: Imagine.url + "busyindicator-animation" AnimatedImageSelector on source { diff --git a/tests/auto/sanity/BLACKLIST b/tests/auto/sanity/BLACKLIST index ab9673a7..c34a6ebd 100644 --- a/tests/auto/sanity/BLACKLIST +++ b/tests/auto/sanity/BLACKLIST @@ -2,8 +2,6 @@ * [attachedObjects:material/SwitchDelegate.qml] * -[ids:imagine/BusyIndicator.qml] -* [ids:imagine/DelayButton.qml] * [ids:imagine/ProgressBar.qml] -- cgit v1.2.3 From 81ff2b14c317545e6f7b44b722cf057badd1e322 Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Thu, 18 Jan 2018 11:56:38 +0100 Subject: Imagine/ProgressBar: cleanup internal IDs for deferred execution Task-number: QTBUG-50992 Change-Id: I1f31b23f3db23e5582b74b18ed643e8263d99142 Reviewed-by: Mitch Curtis --- src/imports/controls/imagine/ProgressBar.qml | 31 ++++++++++++++-------------- tests/auto/sanity/BLACKLIST | 4 ---- 2 files changed, 16 insertions(+), 19 deletions(-) diff --git a/src/imports/controls/imagine/ProgressBar.qml b/src/imports/controls/imagine/ProgressBar.qml index 89645d3c..e943f188 100644 --- a/src/imports/controls/imagine/ProgressBar.qml +++ b/src/imports/controls/imagine/ProgressBar.qml @@ -58,11 +58,13 @@ T.ProgressBar { implicitHeight: control.indeterminate ? animation.implicitHeight || progress.implicitHeight : progress.implicitHeight scale: control.mirrored ? -1 : 1 - NinePatchImage { - id: progress + readonly property bool hasMask: mask.status !== Image.Null + + readonly property NinePatchImage progress: NinePatchImage { + parent: control.contentItem width: control.position * parent.width height: parent.height - visible: !control.indeterminate && mask.status === Image.Null + visible: !control.indeterminate && !control.contentItem.hasMask source: Imagine.url + "progressbar-progress" NinePatchImageSelector on source { @@ -75,12 +77,12 @@ T.ProgressBar { } } - AnimatedImage { - id: animation + readonly property AnimatedImage animation: AnimatedImage { + parent: control.contentItem width: parent.width height: parent.height playing: control.indeterminate - visible: control.indeterminate && mask.status === Image.Null + visible: control.indeterminate && !control.contentItem.hasMask source: Imagine.url + "progressbar-animation" AnimatedImageSelector on source { @@ -92,10 +94,9 @@ T.ProgressBar { } } - NinePatchImage { - id: mask - width: parent.width - height: parent.height + readonly property NinePatchImage mask: NinePatchImage { + width: control.availableWidth + height: control.availableHeight visible: false source: Imagine.url + "progressbar-mask" @@ -109,15 +110,15 @@ T.ProgressBar { } } - OpacityMask { - id: effect + readonly property OpacityMask effect: OpacityMask { + parent: control.contentItem width: source.width height: source.height - source: control.indeterminate ? animation : progress + source: control.indeterminate ? control.contentItem.animation : control.contentItem.progress maskSource: ShaderEffectSource { - sourceItem: mask - sourceRect: Qt.rect(0, 0, effect.width, effect.height) + sourceItem: control.contentItem.mask + sourceRect: Qt.rect(0, 0, control.contentItem.effect.width, control.contentItem.effect.height) } } } diff --git a/tests/auto/sanity/BLACKLIST b/tests/auto/sanity/BLACKLIST index c34a6ebd..53b27412 100644 --- a/tests/auto/sanity/BLACKLIST +++ b/tests/auto/sanity/BLACKLIST @@ -4,10 +4,6 @@ * [ids:imagine/DelayButton.qml] * -[ids:imagine/ProgressBar.qml] -* -[ids:imagine/ProgressBar.qml] -* [ids:imagine/Switch.qml] * [ids:imagine/SwitchDelegate.qml] -- cgit v1.2.3 From 8244e2e36af2f6923c5be586da37c0facf7152a8 Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Thu, 18 Jan 2018 12:16:48 +0100 Subject: Imagine/DelayButton: cleanup internal IDs for deferred execution Task-number: QTBUG-50992 Change-Id: I5f2708bc0e9f37232b10e2cd6f1c61ab779156e3 Reviewed-by: Mitch Curtis --- src/imports/controls/imagine/DelayButton.qml | 21 ++++++++++----------- tests/auto/sanity/BLACKLIST | 2 -- 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/src/imports/controls/imagine/DelayButton.qml b/src/imports/controls/imagine/DelayButton.qml index 3b2eb8bb..157285f6 100644 --- a/src/imports/controls/imagine/DelayButton.qml +++ b/src/imports/controls/imagine/DelayButton.qml @@ -86,8 +86,8 @@ T.DelayButton { ] } - NinePatchImage { - id: progress + readonly property NinePatchImage progress: NinePatchImage { + parent: control.background width: control.progress * parent.width height: parent.height visible: false @@ -105,10 +105,9 @@ T.DelayButton { } } - NinePatchImage { - id: mask - width: parent.width - height: parent.height + readonly property NinePatchImage mask: NinePatchImage { + width: control.background.width + height: control.background.height visible: false source: Imagine.url + "delaybutton-mask" @@ -124,15 +123,15 @@ T.DelayButton { } } - OpacityMask { - id: effect + readonly property OpacityMask effect: OpacityMask { + parent: control.background width: source.width height: source.height - source: progress + source: control.background.progress maskSource: ShaderEffectSource { - sourceItem: mask - sourceRect: Qt.rect(0, 0, effect.width, effect.height) + sourceItem: control.background.mask + sourceRect: Qt.rect(0, 0, control.background.effect.width, control.background.effect.height) } } } diff --git a/tests/auto/sanity/BLACKLIST b/tests/auto/sanity/BLACKLIST index 53b27412..a595d354 100644 --- a/tests/auto/sanity/BLACKLIST +++ b/tests/auto/sanity/BLACKLIST @@ -2,8 +2,6 @@ * [attachedObjects:material/SwitchDelegate.qml] * -[ids:imagine/DelayButton.qml] -* [ids:imagine/Switch.qml] * [ids:imagine/SwitchDelegate.qml] -- cgit v1.2.3 From 26056b52b182b4452855f54a2c811d64246c434a Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Thu, 18 Jan 2018 12:19:27 +0100 Subject: Imagine/Switch(Delegate): cleanup internal IDs for deferred execution Task-number: QTBUG-50992 Change-Id: I621343bef562b4ed85202a0690a0cccfc0a053c5 Reviewed-by: Mitch Curtis --- src/imports/controls/imagine/Switch.qml | 5 +++-- src/imports/controls/imagine/SwitchDelegate.qml | 5 +++-- tests/auto/sanity/BLACKLIST | 4 ---- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/imports/controls/imagine/Switch.qml b/src/imports/controls/imagine/Switch.qml index 6d69502d..c7cc8ecb 100644 --- a/src/imports/controls/imagine/Switch.qml +++ b/src/imports/controls/imagine/Switch.qml @@ -74,12 +74,13 @@ T.Switch { ] } - NinePatchImage { - id: handle + property NinePatchImage handle: NinePatchImage { readonly property real minPos: parent.leftPadding - leftPadding readonly property real maxPos: parent.width - width + rightPadding - parent.rightPadding readonly property real dragPos: control.visualPosition * parent.width - (width / 2) + parent: control.indicator + x: Math.max(minPos, Math.min(maxPos, control.visualPosition * parent.width - (width / 2))) y: (parent.height - height) / 2 diff --git a/src/imports/controls/imagine/SwitchDelegate.qml b/src/imports/controls/imagine/SwitchDelegate.qml index 0c9bfb15..625595d7 100644 --- a/src/imports/controls/imagine/SwitchDelegate.qml +++ b/src/imports/controls/imagine/SwitchDelegate.qml @@ -81,12 +81,13 @@ T.SwitchDelegate { ] } - NinePatchImage { - id: handle + property NinePatchImage handle: NinePatchImage { readonly property real minPos: parent.leftPadding - leftPadding readonly property real maxPos: parent.width - width + rightPadding - parent.rightPadding readonly property real dragPos: control.visualPosition * parent.width - (width / 2) + parent: control.indicator + x: Math.max(minPos, Math.min(maxPos, control.visualPosition * parent.width - (width / 2))) y: (parent.height - height) / 2 diff --git a/tests/auto/sanity/BLACKLIST b/tests/auto/sanity/BLACKLIST index a595d354..42ad3448 100644 --- a/tests/auto/sanity/BLACKLIST +++ b/tests/auto/sanity/BLACKLIST @@ -2,7 +2,3 @@ * [attachedObjects:material/SwitchDelegate.qml] * -[ids:imagine/Switch.qml] -* -[ids:imagine/SwitchDelegate.qml] -* -- cgit v1.2.3