aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTarja Sundqvist <tarja.sundqvist@qt.io>2023-03-23 16:00:22 +0200
committerTarja Sundqvist <tarja.sundqvist@qt.io>2023-03-23 16:00:22 +0200
commit5e31cdc9dda940aee38cf8de4ddbbeb2c0cebfc7 (patch)
tree010b48a0a96c33852012f614043e6e881c1b2bf6
parent3a657dc092bea4d21f281368b0caad01e1aa6e32 (diff)
parentedb18d6101e8bb9dd265330dbe019722181d7577 (diff)
Merge remote-tracking branch 'origin/tqtc/lts-5.15.9' into tqtc/lts-5.15-opensourcev5.15.9-lts-lgpl
-rw-r--r--.qmake.conf2
-rw-r--r--src/quicktemplates2/qquickabstractbutton.cpp35
-rw-r--r--src/quicktemplates2/qquickabstractbutton_p_p.h2
-rw-r--r--src/quicktemplates2/qquickaction.cpp2
-rw-r--r--src/quicktemplates2/qquickswipeview.cpp1
-rw-r--r--tests/auto/controls/data/tst_abstractbutton.qml49
-rw-r--r--tests/auto/controls/data/tst_action.qml33
-rw-r--r--tests/auto/controls/data/tst_swipeview.qml63
-rw-r--r--tests/auto/controls/data/tst_switch.qml23
9 files changed, 202 insertions, 8 deletions
diff --git a/.qmake.conf b/.qmake.conf
index 6546557b..aee6e65e 100644
--- a/.qmake.conf
+++ b/.qmake.conf
@@ -5,4 +5,4 @@ DEFINES += QT_NO_FOREACH QT_NO_JAVA_STYLE_ITERATORS QT_NO_LINKED_LIST
QQC2_SOURCE_TREE = $$PWD
-MODULE_VERSION = 5.15.8
+MODULE_VERSION = 5.15.9
diff --git a/src/quicktemplates2/qquickabstractbutton.cpp b/src/quicktemplates2/qquickabstractbutton.cpp
index 950e4e09..20cf59c1 100644
--- a/src/quicktemplates2/qquickabstractbutton.cpp
+++ b/src/quicktemplates2/qquickabstractbutton.cpp
@@ -215,8 +215,20 @@ bool QQuickAbstractButtonPrivate::acceptKeyClick(Qt::Key key) const
bool QQuickAbstractButtonPrivate::isPressAndHoldConnected()
{
Q_Q(QQuickAbstractButton);
- const auto signal = &QQuickAbstractButton::pressAndHold;
- const QMetaMethod method = QMetaMethod::fromSignal(signal);
+ static const QMetaMethod method = [&]() {
+ const auto signal = &QQuickAbstractButton::pressAndHold;
+ return QMetaMethod::fromSignal(signal);
+ }();
+ return q->isSignalConnected(method);
+}
+
+bool QQuickAbstractButtonPrivate::isDoubleClickConnected()
+{
+ Q_Q(QQuickAbstractButton);
+ static const QMetaMethod method = [&]() {
+ const auto signal = &QQuickAbstractButton::doubleClicked;
+ return QMetaMethod::fromSignal(signal);
+ }();
return q->isSignalConnected(method);
}
@@ -387,6 +399,17 @@ void QQuickAbstractButtonPrivate::itemImplicitHeightChanged(QQuickItem *item)
emit q->implicitIndicatorHeightChanged();
}
+void QQuickAbstractButtonPrivate::itemDestroyed(QQuickItem *item)
+{
+ Q_Q(QQuickAbstractButton);
+ QQuickControlPrivate::itemDestroyed(item);
+ if (item == indicator) {
+ indicator = nullptr;
+ emit q->implicitIndicatorWidthChanged();
+ emit q->implicitIndicatorHeightChanged();
+ }
+}
+
QQuickAbstractButton *QQuickAbstractButtonPrivate::findCheckedButton() const
{
Q_Q(const QQuickAbstractButton);
@@ -1086,9 +1109,11 @@ void QQuickAbstractButton::mousePressEvent(QMouseEvent *event)
void QQuickAbstractButton::mouseDoubleClickEvent(QMouseEvent *event)
{
Q_D(QQuickAbstractButton);
- QQuickControl::mouseDoubleClickEvent(event);
- emit doubleClicked();
- d->wasDoubleClick = true;
+ if (d->isDoubleClickConnected()) {
+ QQuickControl::mouseDoubleClickEvent(event);
+ emit doubleClicked();
+ d->wasDoubleClick = true;
+ }
}
void QQuickAbstractButton::timerEvent(QTimerEvent *event)
diff --git a/src/quicktemplates2/qquickabstractbutton_p_p.h b/src/quicktemplates2/qquickabstractbutton_p_p.h
index 9291c1a8..907790dc 100644
--- a/src/quicktemplates2/qquickabstractbutton_p_p.h
+++ b/src/quicktemplates2/qquickabstractbutton_p_p.h
@@ -80,6 +80,7 @@ public:
virtual bool acceptKeyClick(Qt::Key key) const;
bool isPressAndHoldConnected();
+ bool isDoubleClickConnected();
void startPressAndHold();
void stopPressAndHold();
@@ -109,6 +110,7 @@ public:
void itemImplicitWidthChanged(QQuickItem *item) override;
void itemImplicitHeightChanged(QQuickItem *item) override;
+ void itemDestroyed(QQuickItem *item) override;
// copied from qabstractbutton.cpp
static const int AUTO_REPEAT_DELAY = 300;
diff --git a/src/quicktemplates2/qquickaction.cpp b/src/quicktemplates2/qquickaction.cpp
index 2041e774..8610cdfa 100644
--- a/src/quicktemplates2/qquickaction.cpp
+++ b/src/quicktemplates2/qquickaction.cpp
@@ -145,7 +145,7 @@ int QQuickActionPrivate::ShortcutEntry::shortcutId() const
void QQuickActionPrivate::ShortcutEntry::grab(const QKeySequence &shortcut, bool enabled)
{
- if (shortcut.isEmpty())
+ if (shortcut.isEmpty() || m_shortcutId)
return;
Qt::ShortcutContext context = Qt::WindowShortcut; // TODO
diff --git a/src/quicktemplates2/qquickswipeview.cpp b/src/quicktemplates2/qquickswipeview.cpp
index dab20b93..98d4d22b 100644
--- a/src/quicktemplates2/qquickswipeview.cpp
+++ b/src/quicktemplates2/qquickswipeview.cpp
@@ -310,7 +310,6 @@ void QQuickSwipeView::geometryChanged(const QRectF &newGeometry, const QRectF &o
void QQuickSwipeView::itemAdded(int index, QQuickItem *item)
{
Q_D(QQuickSwipeView);
- QQuickItemPrivate::get(item)->setCulled(true); // QTBUG-51078, QTBUG-51669
if (isComponentComplete())
item->setSize(QSizeF(d->contentItem->width(), d->contentItem->height()));
QQuickSwipeViewAttached *attached = qobject_cast<QQuickSwipeViewAttached *>(qmlAttachedPropertiesObject<QQuickSwipeView>(item));
diff --git a/tests/auto/controls/data/tst_abstractbutton.qml b/tests/auto/controls/data/tst_abstractbutton.qml
index da5642cc..6181e526 100644
--- a/tests/auto/controls/data/tst_abstractbutton.qml
+++ b/tests/auto/controls/data/tst_abstractbutton.qml
@@ -910,4 +910,53 @@ TestCase {
compare(clickedSpy.count, 1)
compare(doubleClickedSpy.count, 1)
}
+
+ // It should be possible to quickly click a button whose doubleClicked signal
+ // is not connected to anything.
+ function test_fastClick() {
+ let control = createTemporaryObject(button, testCase, { text: "Hello" })
+ verify(control)
+
+ let pressedSpy = signalSpy.createObject(control, { target: control, signalName: "pressed" })
+ verify(pressedSpy.valid)
+
+ let releasedSpy = signalSpy.createObject(control, { target: control, signalName: "released" })
+ verify(releasedSpy.valid)
+
+ let clickedSpy = signalSpy.createObject(control, { target: control, signalName: "clicked" })
+ verify(clickedSpy.valid)
+
+ // Can't listen to doubleClicked because it would cause it to be emitted.
+ // We instead just check that clicked is emitted twice.
+
+ mouseDoubleClickSequence(control)
+ compare(pressedSpy.count, 2)
+ compare(releasedSpy.count, 2)
+ compare(clickedSpy.count, 2)
+
+ let touch = touchEvent(control)
+ touch.press(0, control)
+ touch.commit()
+ compare(pressedSpy.count, 3)
+ compare(releasedSpy.count, 2)
+ compare(clickedSpy.count, 2)
+
+ touch.release(0, control)
+ touch.commit()
+ compare(pressedSpy.count, 3)
+ compare(releasedSpy.count, 3)
+ compare(clickedSpy.count, 3)
+
+ touch.press(0, control)
+ touch.commit()
+ compare(pressedSpy.count, 4)
+ compare(releasedSpy.count, 3)
+ compare(clickedSpy.count, 3)
+
+ touch.release(0, control)
+ touch.commit()
+ compare(pressedSpy.count, 4)
+ compare(releasedSpy.count, 4)
+ compare(clickedSpy.count, 4)
+ }
}
diff --git a/tests/auto/controls/data/tst_action.qml b/tests/auto/controls/data/tst_action.qml
index 0e41b7f3..7ed4aa11 100644
--- a/tests/auto/controls/data/tst_action.qml
+++ b/tests/auto/controls/data/tst_action.qml
@@ -194,4 +194,37 @@ TestCase {
verify(container)
compare(container.indirect.nativeText, container.direct.nativeText);
}
+
+ Component {
+ id: shortcutCleanup
+ Item {
+ property alias page: page
+ property alias action: action
+ property alias menu: menu
+ Item {
+ id: page
+ Action {
+ id: action
+ text: "action"
+ shortcut: "Insert"
+ }
+ Menu {
+ id: menu
+ MenuItem { action: action }
+ }
+ }
+ }
+ }
+
+ function test_shortcutCleanup() {
+ {
+ var container = createTemporaryObject(shortcutCleanup, testCase);
+ verify(container)
+ container.action.shortcut = "Delete"
+ container.menu.open()
+ container.page.destroy()
+ tryVerify(function() { return !container.page })
+ }
+ keyClick(Qt.Key_Delete, Qt.NoModifier)
+ }
}
diff --git a/tests/auto/controls/data/tst_swipeview.qml b/tests/auto/controls/data/tst_swipeview.qml
index 5775491c..07d0cc0c 100644
--- a/tests/auto/controls/data/tst_swipeview.qml
+++ b/tests/auto/controls/data/tst_swipeview.qml
@@ -623,4 +623,67 @@ TestCase {
compare(control.rectanglePressCount, 1)
compare(control.rectangleReleaseCount, 1)
}
+
+ // We have a particular customer who came up with this hack to make SwipeView wrap around at the end.
+ // It's not advisible, and perhaps the test can be removed when we add a bool wrap property.
+ Component {
+ id: pathViewWorkaroundComponent
+
+ SwipeView {
+ id: swipeView
+ anchors.left: parent.left
+ width: 100
+ height: 100
+ clip: true
+ Repeater {
+ id: repeater
+ objectName: "peter"
+ delegate: Rectangle {
+ id: rect
+ color: "#ffff00"
+ border.color: "black"
+ width: 100
+ height: 100
+ Text {
+ anchors.verticalCenter: parent.verticalCenter
+ anchors.horizontalCenter: parent.horizontalCenter
+ font.pixelSize: 24
+ text: model.index
+ }
+ }
+ }
+ contentItem: PathView {
+ id: pathview
+
+ preferredHighlightBegin: 0.5
+ preferredHighlightEnd: 0.5
+ model: swipeView.contentModel
+
+ path: Path {
+ id: path
+ startX: (swipeView.width / 2 * -1) * (swipeView.count - 1)
+ startY: swipeView.height / 2
+ PathLine {
+ relativeX: swipeView.width * swipeView.count
+ relativeY: 0
+ }
+ }
+ }
+ }
+ }
+
+ function test_child_pathview() {
+ const control = createTemporaryObject(pathViewWorkaroundComponent, testCase)
+ verify(control)
+ const repeater = control.children[0].children[0]
+ const spy = signalSpy.createObject(repeater, {target: repeater, signalName: "itemAdded"})
+ repeater.model = 1
+ tryCompare(spy, "count", 1)
+ const rect = repeater.itemAt(0)
+ tryCompare(rect, "visible", true)
+ if (Qt.platform.pluginName === "offscreen")
+ skip("grabImage() is not functional on the offscreen platform (QTBUG-63185)")
+ var image = grabImage(control)
+ compare(image.pixel(3, 3), "#ffff00")
+ }
}
diff --git a/tests/auto/controls/data/tst_switch.qml b/tests/auto/controls/data/tst_switch.qml
index b3fab41c..10b6baa0 100644
--- a/tests/auto/controls/data/tst_switch.qml
+++ b/tests/auto/controls/data/tst_switch.qml
@@ -608,4 +608,27 @@ TestCase {
mouseClick(control.indicator)
verify(control.activeFocus)
}
+
+ Component {
+ id: deletionOrder1
+ Item {
+ Image { id: innerImage }
+ Switch { indicator: innerImage }
+ }
+ }
+
+ Component {
+ id: deletionOrder2
+ Item {
+ Switch { indicator: innerImage }
+ Image { id: innerImage }
+ }
+ }
+
+ function test_deletionOrder() {
+ var control1 = createTemporaryObject(deletionOrder1, testCase)
+ verify(control1)
+ var control2 = createTemporaryObject(deletionOrder2, testCase)
+ verify(control2)
+ }
}