aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/imports/controls/doc/snippets/qtquickcontrols2-tooltip-slider.qml8
-rw-r--r--src/quicktemplates2/qquickcontainer.cpp40
-rw-r--r--src/quicktemplates2/qquickcontainer_p.h2
-rw-r--r--src/quicktemplates2/qquickcontainer_p_p.h1
-rw-r--r--src/quicktemplates2/qquickdialogbuttonbox.cpp4
-rw-r--r--src/quicktemplates2/qquicktooltip.cpp2
-rw-r--r--tests/auto/controls/data/tst_container.qml30
-rw-r--r--tests/auto/controls/data/tst_pageindicator.qml36
-rw-r--r--tests/auto/controls/data/tst_tooltip.qml31
9 files changed, 122 insertions, 32 deletions
diff --git a/src/imports/controls/doc/snippets/qtquickcontrols2-tooltip-slider.qml b/src/imports/controls/doc/snippets/qtquickcontrols2-tooltip-slider.qml
index de872300..9e5d991a 100644
--- a/src/imports/controls/doc/snippets/qtquickcontrols2-tooltip-slider.qml
+++ b/src/imports/controls/doc/snippets/qtquickcontrols2-tooltip-slider.qml
@@ -1,7 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: http://www.qt.io/licensing/
+** Contact: https://www.qt.io/licensing/
**
** This file is part of the documentation of the Qt Toolkit.
**
@@ -11,8 +11,8 @@
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see http://www.qt.io/terms-conditions. For further
-** information use the contact form at http://www.qt.io/contact-us.
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
**
** GNU Free Documentation License Usage
** Alternatively, this file may be used under the terms of the GNU Free
@@ -20,7 +20,7 @@
** Foundation and appearing in the file included in the packaging of
** this file. Please review the following information to ensure
** the GNU Free Documentation License version 1.3 requirements
-** will be met: http://www.gnu.org/copyleft/fdl.html.
+** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/quicktemplates2/qquickcontainer.cpp b/src/quicktemplates2/qquickcontainer.cpp
index a62de655..07fe04d2 100644
--- a/src/quicktemplates2/qquickcontainer.cpp
+++ b/src/quicktemplates2/qquickcontainer.cpp
@@ -324,6 +324,24 @@ void QQuickContainerPrivate::removeItem(int index, QQuickItem *item)
updatingCurrent = false;
}
+void QQuickContainerPrivate::reorderItems()
+{
+ Q_Q(QQuickContainer);
+ if (!contentItem)
+ return;
+
+ QList<QQuickItem *> siblings = effectiveContentItem(contentItem)->childItems();
+
+ int to = 0;
+ for (int i = 0; i < siblings.count(); ++i) {
+ QQuickItem* sibling = siblings.at(i);
+ if (QQuickItemPrivate::get(sibling)->isTransparentForPositioner())
+ continue;
+ int index = contentModel->indexOf(sibling, nullptr);
+ q->moveItem(index, to++);
+ }
+}
+
void QQuickContainerPrivate::_q_currentIndexChanged()
{
Q_Q(QQuickContainer);
@@ -347,18 +365,11 @@ void QQuickContainerPrivate::itemParentChanged(QQuickItem *item, QQuickItem *par
void QQuickContainerPrivate::itemSiblingOrderChanged(QQuickItem *)
{
- // reorder the restacked items (eg. by a Repeater)
- Q_Q(QQuickContainer);
- QList<QQuickItem *> siblings = effectiveContentItem(contentItem)->childItems();
+ if (!componentComplete)
+ return;
- int to = 0;
- for (int i = 0; i < siblings.count(); ++i) {
- QQuickItem* sibling = siblings.at(i);
- if (QQuickItemPrivate::get(sibling)->isTransparentForPositioner())
- continue;
- int index = contentModel->indexOf(sibling, nullptr);
- q->moveItem(index, to++);
- }
+ // reorder the restacked items (eg. by a Repeater)
+ reorderItems();
}
void QQuickContainerPrivate::itemDestroyed(QQuickItem *item)
@@ -737,6 +748,13 @@ QQuickItem *QQuickContainer::currentItem() const
return itemAt(d->currentIndex);
}
+void QQuickContainer::componentComplete()
+{
+ Q_D(QQuickContainer);
+ QQuickControl::componentComplete();
+ d->reorderItems();
+}
+
void QQuickContainer::itemChange(ItemChange change, const ItemChangeData &data)
{
Q_D(QQuickContainer);
diff --git a/src/quicktemplates2/qquickcontainer_p.h b/src/quicktemplates2/qquickcontainer_p.h
index 5ac585c2..d8773684 100644
--- a/src/quicktemplates2/qquickcontainer_p.h
+++ b/src/quicktemplates2/qquickcontainer_p.h
@@ -100,6 +100,8 @@ Q_SIGNALS:
protected:
QQuickContainer(QQuickContainerPrivate &dd, QQuickItem *parent);
+ void componentComplete() override;
+
void itemChange(ItemChange change, const ItemChangeData &data) override;
void contentItemChange(QQuickItem *newItem, QQuickItem *oldItem) override;
diff --git a/src/quicktemplates2/qquickcontainer_p_p.h b/src/quicktemplates2/qquickcontainer_p_p.h
index 54fc5c60..7791b69c 100644
--- a/src/quicktemplates2/qquickcontainer_p_p.h
+++ b/src/quicktemplates2/qquickcontainer_p_p.h
@@ -74,6 +74,7 @@ public:
void insertItem(int index, QQuickItem *item);
void moveItem(int from, int to, QQuickItem *item);
void removeItem(int index, QQuickItem *item);
+ void reorderItems();
void _q_currentIndexChanged();
diff --git a/src/quicktemplates2/qquickdialogbuttonbox.cpp b/src/quicktemplates2/qquickdialogbuttonbox.cpp
index 7c2f17c4..45924139 100644
--- a/src/quicktemplates2/qquickdialogbuttonbox.cpp
+++ b/src/quicktemplates2/qquickdialogbuttonbox.cpp
@@ -238,8 +238,8 @@ void QQuickDialogButtonBoxPrivate::updateLayout()
const int valign = alignment & Qt::AlignVertical_Mask;
QVector<QQuickAbstractButton *> buttons;
- const qreal maxItemWidth = (contentItem->width() - qMax(0, count - 1) * spacing) / count;
- const qreal maxItemHeight = contentItem->height();
+ const qreal maxItemWidth = ((contentItem ? contentItem->width() : q->availableWidth()) - qMax(0, count - 1) * spacing) / count;
+ const qreal maxItemHeight = contentItem ? contentItem->height() : q->availableHeight();
for (int i = 0; i < count; ++i) {
QQuickItem *item = q->itemAt(i);
diff --git a/src/quicktemplates2/qquicktooltip.cpp b/src/quicktemplates2/qquicktooltip.cpp
index 1aeb9914..f0bc6ffc 100644
--- a/src/quicktemplates2/qquicktooltip.cpp
+++ b/src/quicktemplates2/qquicktooltip.cpp
@@ -36,6 +36,7 @@
#include "qquicktooltip_p.h"
#include "qquickpopup_p_p.h"
+#include "qquickpopupitem_p_p.h"
#include "qquickcontrol_p_p.h"
#include <QtCore/qbasictimer.h>
@@ -172,6 +173,7 @@ QQuickToolTip::QQuickToolTip(QQuickItem *parent)
Q_D(QQuickToolTip);
d->allowVerticalFlip = true;
d->allowHorizontalFlip = true;
+ d->popupItem->setHoverEnabled(false); // QTBUG-63644
}
/*!
diff --git a/tests/auto/controls/data/tst_container.qml b/tests/auto/controls/data/tst_container.qml
index 94f22ad2..c5e74eeb 100644
--- a/tests/auto/controls/data/tst_container.qml
+++ b/tests/auto/controls/data/tst_container.qml
@@ -128,7 +128,7 @@ TestCase {
}
Component {
- id: repeaterContainer
+ id: repeaterContainer1
Container {
id: container
Item { objectName: "0" }
@@ -143,9 +143,33 @@ TestCase {
}
}
+ Component {
+ id: repeaterContainer2
+ Container {
+ id: container
+ contentItem: Item {
+ Repeater {
+ model: container.contentModel
+ }
+ Rectangle { objectName: "extra" }
+ }
+ Rectangle { objectName: "0" }
+ Rectangle { objectName: "1" }
+ Rectangle { objectName: "2" }
+ Rectangle { objectName: "3" }
+ }
+ }
+
+ function test_repeater_data() {
+ return [
+ { tag: "1", component: repeaterContainer1 },
+ { tag: "2", component: repeaterContainer2 }
+ ]
+ }
+
// don't crash (QTBUG-61310)
- function test_repeater() {
- var control = createTemporaryObject(repeaterContainer)
+ function test_repeater(data) {
+ var control = createTemporaryObject(data.component)
verify(control)
compare(control.itemAt(0).objectName, "0")
diff --git a/tests/auto/controls/data/tst_pageindicator.qml b/tests/auto/controls/data/tst_pageindicator.qml
index f3151882..dc411e45 100644
--- a/tests/auto/controls/data/tst_pageindicator.qml
+++ b/tests/auto/controls/data/tst_pageindicator.qml
@@ -122,18 +122,30 @@ TestCase {
// test also clicking outside delegates => the nearest should be selected
for (var i = 0; i < control.count; ++i) {
var child = control.contentItem.children[i]
- for (var x = -2; x <= child.width + 2; ++x) {
- for (var y = -2; y <= child.height + 2; ++y) {
- control.currentIndex = -1
- compare(control.currentIndex, -1)
-
- var pos = control.mapFromItem(child, x, y)
- if (data.touch)
- touch.press(0, control, pos.x, pos.y).commit().release(0, control, pos.x, pos.y).commit()
- else
- mouseClick(control, pos.x, pos.y, Qt.LeftButton)
- compare(control.currentIndex, i)
- }
+
+ var points = [
+ Qt.point(child.width / 2, -2), // top
+ Qt.point(-2, child.height / 2), // left
+ Qt.point(child.width + 2, child.height / 2), // right
+ Qt.point(child.width / 2, child.height + 2), // bottom
+
+ Qt.point(-2, -2), // top-left
+ Qt.point(child.width + 2, -2), // top-right
+ Qt.point(-2, child.height + 2), // bottom-left
+ Qt.point(child.width + 2, child.height + 2), // bottom-right
+ ]
+
+ for (var j = 0; j < points.length; ++j) {
+ control.currentIndex = -1
+ compare(control.currentIndex, -1)
+
+ var point = points[j]
+ var pos = control.mapFromItem(child, x, y)
+ if (data.touch)
+ touch.press(0, control, pos.x, pos.y).commit().release(0, control, pos.x, pos.y).commit()
+ else
+ mouseClick(control, pos.x, pos.y, Qt.LeftButton)
+ compare(control.currentIndex, i)
}
}
}
diff --git a/tests/auto/controls/data/tst_tooltip.qml b/tests/auto/controls/data/tst_tooltip.qml
index bd46fabd..e7cc6787 100644
--- a/tests/auto/controls/data/tst_tooltip.qml
+++ b/tests/auto/controls/data/tst_tooltip.qml
@@ -298,4 +298,35 @@ TestCase {
keyPress(Qt.Key_A)
compare(shortcutActivatedSpy.count, 1)
}
+
+ Component {
+ id: hoverComponent
+ MouseArea {
+ id: hoverArea
+ property alias tooltip: tooltip
+ hoverEnabled: true
+ width: testCase.width
+ height: testCase.height
+ ToolTip {
+ id: tooltip
+ x: 10; y: 10
+ width: 10; height: 10
+ visible: hoverArea.containsMouse
+ }
+ }
+ }
+
+ // QTBUG-63644
+ function test_hover() {
+ var root = createTemporaryObject(hoverComponent, testCase)
+ verify(root)
+
+ var tooltip = root.tooltip
+ verify(tooltip)
+
+ for (var pos = 0; pos <= 25; pos += 5) {
+ mouseMove(root, pos, pos)
+ verify(tooltip.visible)
+ }
+ }
}