From 19976fd5db1f2fb4925831c5f7a708c090e4a70e Mon Sep 17 00:00:00 2001 From: Mitch Curtis Date: Mon, 11 Nov 2019 13:44:22 +0100 Subject: SwipeView: fix issue where child items couldn't get focus Set the focus property of the contentItem (ListView) to the focus property of the SwipeView itself. Change-Id: Ic410f7fb8db9fbb758b956dfe07e1b4265f5f687 Fixes: QTBUG-62401 Reviewed-by: Richard Moe Gustavsen --- tests/auto/controls/data/tst_swipeview.qml | 49 ++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) (limited to 'tests/auto') diff --git a/tests/auto/controls/data/tst_swipeview.qml b/tests/auto/controls/data/tst_swipeview.qml index 38af37f7..5775491c 100644 --- a/tests/auto/controls/data/tst_swipeview.qml +++ b/tests/auto/controls/data/tst_swipeview.qml @@ -574,4 +574,53 @@ TestCase { compare(control.itemAt(i).x, 0) } } + + Component { + id: focusSwipeViewComponent + + SwipeView { + id: swipeView + anchors.fill: parent + focus: true + + property int pressCount + property int releaseCount + property int rectanglePressCount + property int rectangleReleaseCount + + Rectangle { + focus: true + + Keys.onPressed: ++swipeView.rectanglePressCount + Keys.onReleased: ++swipeView.rectangleReleaseCount + } + + Keys.onPressed: ++pressCount + Keys.onReleased: ++releaseCount + } + } + + function test_focus() { + if (Qt.styleHints.tabFocusBehavior !== Qt.TabFocusAllControls) + skip("This platform only allows tab focus for text controls") + + var control = createTemporaryObject(focusSwipeViewComponent, testCase) + verify(control) + compare(control.focus, true) + compare(control.contentItem.focus, true) + compare(control.itemAt(0).focus, true) + compare(control.itemAt(0).activeFocus, true) + + keyPress(Qt.Key_A) + compare(control.pressCount, 1) + compare(control.releaseCount, 0) + compare(control.rectanglePressCount, 1) + compare(control.rectangleReleaseCount, 0) + + keyRelease(Qt.Key_A) + compare(control.pressCount, 1) + compare(control.releaseCount, 1) + compare(control.rectanglePressCount, 1) + compare(control.rectangleReleaseCount, 1) + } } -- cgit v1.2.3 From 2193e9938e98af39a16f5035789c555f2574020b Mon Sep 17 00:00:00 2001 From: Mitch Curtis Date: Mon, 11 Nov 2019 12:49:44 +0100 Subject: Make ToolTips wrap Otherwise the text will go outside the window. Change-Id: I3d50a195b1ee6c9b5d49952ef6c49d17c61372fa Fixes: QTBUG-62350 Reviewed-by: Richard Moe Gustavsen --- tests/auto/controls/data/tst_tooltip.qml | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'tests/auto') diff --git a/tests/auto/controls/data/tst_tooltip.qml b/tests/auto/controls/data/tst_tooltip.qml index 70579c70..d98a7cc8 100644 --- a/tests/auto/controls/data/tst_tooltip.qml +++ b/tests/auto/controls/data/tst_tooltip.qml @@ -421,4 +421,26 @@ TestCase { compare(button2.down, false) tryCompare(button2.ToolTip, "visible", false) } + + Component { + id: wrapComponent + + Item { + ToolTip.text: "This is some very very very very very very very very very very very very" + + " very very very very very very very very very very very very very very" + + " very very very very very very very very very very very very long text" + } + } + + // QTBUG-62350 + function test_wrap() { + var item = createTemporaryObject(wrapComponent, testCase) + verify(item) + + // Avoid "cannot find window to popup in" warning that can occur if it's made visible too early. + item.ToolTip.visible = true + tryCompare(item.ToolTip.toolTip, "opened", true) + compare(item.ToolTip.toolTip.contentItem.wrapMode, Text.Wrap) + verify(item.ToolTip.toolTip.contentItem.width < item.ToolTip.toolTip.contentItem.implicitWidth) + } } -- cgit v1.2.3