From da7f7af244e5f1f61ef7060b62b2e5c8d240701f Mon Sep 17 00:00:00 2001
From: Mitch Curtis
Date: Wed, 16 Oct 2019 15:18:36 +0200
Subject: Fix assertion failure when hiding a SplitView with only one item
Check for -1 when calling handleIndexForSplitIndex().
Change-Id: I81021b64265ace0c47269ea54e538a2725c84b79
Fixes: QTBUG-79270
Reviewed-by: Richard Moe Gustavsen
---
src/quicktemplates2/qquicksplitview.cpp | 12 ++++++++----
tests/auto/controls/data/tst_splitview.qml | 16 ++++++++++++++++
2 files changed, 24 insertions(+), 4 deletions(-)
diff --git a/src/quicktemplates2/qquicksplitview.cpp b/src/quicktemplates2/qquicksplitview.cpp
index 75cd9674..108dbe07 100644
--- a/src/quicktemplates2/qquicksplitview.cpp
+++ b/src/quicktemplates2/qquicksplitview.cpp
@@ -849,6 +849,8 @@ QQuickSplitViewPrivate::EffectiveSizeData QQuickSplitViewPrivate::effectiveSizeD
int QQuickSplitViewPrivate::handleIndexForSplitIndex(int splitIndex) const
{
+ // If it's the first and only item in the view, it doesn't have a handle,
+ // so return -1: splitIndex (0) - 1.
// If it's the last item in the view, it doesn't have a handle, so use
// the handle for the previous item.
return splitIndex == contentModel->count() - 1 ? splitIndex - 1 : splitIndex;
@@ -1016,11 +1018,13 @@ void QQuickSplitViewPrivate::itemVisibilityChanged(QQuickItem *item)
// of the corresponding handle (if one exists).
const int handleIndex = handleIndexForSplitIndex(itemIndex);
- QQuickItem *handleItem = m_handleItems.at(handleIndex);
- handleItem->setVisible(item->isVisible());
+ if (handleIndex != -1) {
+ QQuickItem *handleItem = m_handleItems.at(handleIndex);
+ handleItem->setVisible(item->isVisible());
- qCDebug(qlcQQuickSplitView) << "set visible property of handle item"
- << handleItem << "at index" << handleIndex << "to" << item->isVisible();
+ qCDebug(qlcQQuickSplitView) << "set visible property of handle item"
+ << handleItem << "at index" << handleIndex << "to" << item->isVisible();
+ }
updateHandleVisibilities();
updateFillIndex();
diff --git a/tests/auto/controls/data/tst_splitview.qml b/tests/auto/controls/data/tst_splitview.qml
index a03c09a0..bd36e898 100644
--- a/tests/auto/controls/data/tst_splitview.qml
+++ b/tests/auto/controls/data/tst_splitview.qml
@@ -1958,4 +1958,20 @@ TestCase {
mouseRelease(targetHandle, -100, targetHandle.height / 2, Qt.LeftButton)
verify(!control.resizing)
}
+
+ Component {
+ id: oneItemComponent
+
+ SplitView {
+ Item {}
+ }
+ }
+
+ // QTBUG-79270
+ function test_hideSplitViewWithOneItem() {
+ var control = createTemporaryObject(oneItemComponent, testCase)
+ verify(control)
+ // Shouldn't be an assertion failure.
+ control.visible = false
+ }
}
--
cgit v1.2.3
From 78569ded1a6b9b660416bfc1208efecdfb1bdd51 Mon Sep 17 00:00:00 2001
From: Mitch Curtis
Date: Wed, 23 Oct 2019 13:37:02 +0200
Subject: Fix tst_qquickpopup failure on Windows 7 MinGW
Change-Id: I42b6a7050886f795e267893aa5eeaaf7a5841971
Fixes: QTBUG-79370
Reviewed-by: Volker Hilsheimer
---
tests/auto/qquickpopup/tst_qquickpopup.cpp | 2 ++
1 file changed, 2 insertions(+)
diff --git a/tests/auto/qquickpopup/tst_qquickpopup.cpp b/tests/auto/qquickpopup/tst_qquickpopup.cpp
index 8a8cd143..c36edd6d 100644
--- a/tests/auto/qquickpopup/tst_qquickpopup.cpp
+++ b/tests/auto/qquickpopup/tst_qquickpopup.cpp
@@ -904,6 +904,8 @@ void tst_QQuickPopup::cursorShape()
// which is itself over an item with a different shape.
QQuickApplicationHelper helper(this, QStringLiteral("cursor.qml"));
QQuickApplicationWindow *window = helper.appWindow;
+ centerOnScreen(window);
+ moveMouseAway(window);
window->show();
QVERIFY(QTest::qWaitForWindowExposed(window));
--
cgit v1.2.3
From 66de71b26a6c3b5be308c1a92287b6490164ae72 Mon Sep 17 00:00:00 2001
From: Wang Chuan
Date: Tue, 8 Oct 2019 17:50:25 +0800
Subject: QQuickMenuBar: let MenuBarItem lose highlight when Menu is dismissed
When adding new MenuBarItem to MenuBar, MenuBar will first check the
Menu pointer in MenuBarItem and then connect the Menu's signal [aboutToHide]
to MenuBar's slot [onMenuAboutToHide] to unhighlight the MenuBarItem.
In case of adding dynamic Menu, this operation will be performed before
setting new Menu to MenuBarItem. So the Menu pointer in MenuBarItem is
null, and the connection will not be performed.
[ChangeLog][Controls][QQuickMenuBar] Fixed issue with dynamically menu bar
items not losing their highlight when their menu was dismissed.
Fixes: QTBUG-77306
Change-Id: Ibe987462505f65747b4290b3c206e9dfbcbbef57
Reviewed-by: Mitch Curtis
---
src/quicktemplates2/qquickmenubar.cpp | 8 +-
src/quicktemplates2/qquickmenubar_p_p.h | 2 +-
.../data/checkHighlightWhenDismissed.qml | 93 ++++++++++++++++++++++
tests/auto/qquickmenubar/tst_qquickmenubar.cpp | 58 ++++++++++++++
4 files changed, 156 insertions(+), 5 deletions(-)
create mode 100644 tests/auto/qquickmenubar/data/checkHighlightWhenDismissed.qml
diff --git a/src/quicktemplates2/qquickmenubar.cpp b/src/quicktemplates2/qquickmenubar.cpp
index 1761d999..f909193f 100644
--- a/src/quicktemplates2/qquickmenubar.cpp
+++ b/src/quicktemplates2/qquickmenubar.cpp
@@ -76,7 +76,7 @@ QT_BEGIN_NAMESPACE
{Focus Management in Qt Quick Controls}
*/
-QQuickItem *QQuickMenuBarPrivate::beginCreateItem()
+QQuickItem *QQuickMenuBarPrivate::beginCreateItem(QQuickMenu *menu)
{
Q_Q(QQuickMenuBar);
if (!delegate)
@@ -96,6 +96,8 @@ QQuickItem *QQuickMenuBarPrivate::beginCreateItem()
return nullptr;
}
+ if (QQuickMenuBarItem *menuBarItem = qobject_cast(item))
+ menuBarItem->setMenu(menu);
item->setParentItem(q);
QQml_setParent_noEvent(item, q);
@@ -112,9 +114,7 @@ void QQuickMenuBarPrivate::completeCreateItem()
QQuickItem *QQuickMenuBarPrivate::createItem(QQuickMenu *menu)
{
- QQuickItem *item = beginCreateItem();
- if (QQuickMenuBarItem *menuBarItem = qobject_cast(item))
- menuBarItem->setMenu(menu);
+ QQuickItem *item = beginCreateItem(menu);
completeCreateItem();
return item;
}
diff --git a/src/quicktemplates2/qquickmenubar_p_p.h b/src/quicktemplates2/qquickmenubar_p_p.h
index 75fbed73..c214962b 100644
--- a/src/quicktemplates2/qquickmenubar_p_p.h
+++ b/src/quicktemplates2/qquickmenubar_p_p.h
@@ -69,7 +69,7 @@ public:
QQmlListProperty menus();
QQmlListProperty contentData();
- QQuickItem *beginCreateItem();
+ QQuickItem *beginCreateItem(QQuickMenu *menu);
void completeCreateItem();
QQuickItem *createItem(QQuickMenu *menu);
diff --git a/tests/auto/qquickmenubar/data/checkHighlightWhenDismissed.qml b/tests/auto/qquickmenubar/data/checkHighlightWhenDismissed.qml
new file mode 100644
index 00000000..072fa6b1
--- /dev/null
+++ b/tests/auto/qquickmenubar/data/checkHighlightWhenDismissed.qml
@@ -0,0 +1,93 @@
+/****************************************************************************
+**
+** Copyright (C) 2019 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** 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 https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** BSD License Usage
+** Alternatively, you may use this file under the terms of the BSD license
+** as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.13
+import QtQuick.Controls 2.13
+
+ApplicationWindow {
+ width: 300
+ height: 300
+ visible: true
+ MenuBar {
+ id: mb
+ objectName: "menuBar"
+ width: parent.width
+ Menu {
+ title: "StaticMenu"
+ MenuItem {
+ text: "Cut"
+ }
+ MenuItem {
+ text: "Copy"
+ }
+ MenuItem {
+ text: "Paste"
+ }
+ }
+ }
+ Component {
+ id: cmp
+ Menu {
+ title: "DynamicMenu"
+ MenuItem {
+ text: "Cut"
+ }
+ MenuItem {
+ text: "Copy"
+ }
+ MenuItem {
+ text: "Paste"
+ }
+ }
+ }
+ Component.onCompleted: {
+ mb.addMenu(cmp.createObject(mb))
+ }
+}
diff --git a/tests/auto/qquickmenubar/tst_qquickmenubar.cpp b/tests/auto/qquickmenubar/tst_qquickmenubar.cpp
index 9a22d26f..2fb1a02b 100644
--- a/tests/auto/qquickmenubar/tst_qquickmenubar.cpp
+++ b/tests/auto/qquickmenubar/tst_qquickmenubar.cpp
@@ -60,6 +60,7 @@ private slots:
void keys();
void mnemonics();
void addRemove();
+ void checkHighlightWhenMenuDismissed();
};
void tst_qquickmenubar::delegate()
@@ -564,6 +565,63 @@ void tst_qquickmenubar::addRemove()
QVERIFY(menuBarItem1.isNull());
}
+void tst_qquickmenubar::checkHighlightWhenMenuDismissed()
+{
+ if ((QGuiApplication::platformName() == QLatin1String("offscreen"))
+ || (QGuiApplication::platformName() == QLatin1String("minimal")))
+ QSKIP("Mouse highlight not functional on offscreen/minimal platforms");
+
+ QQmlApplicationEngine engine(testFileUrl("checkHighlightWhenDismissed.qml"));
+ QScopedPointer window(qobject_cast(engine.rootObjects().value(0)));
+ QVERIFY(window);
+
+ centerOnScreen(window.data());
+ moveMouseAway(window.data());
+ QVERIFY(QTest::qWaitForWindowActive(window.data()));
+
+ QQuickMenuBar *menuBar = window->findChild("menuBar");
+ QVERIFY(menuBar);
+
+ QQuickMenu *staticMenu = menuBar->menuAt(0);
+ QQuickMenu *dynamicMenu = menuBar->menuAt(1);
+ QVERIFY(staticMenu && dynamicMenu);
+ QQuickMenuBarItem *staticMenuBarItem = qobject_cast(staticMenu->parentItem());
+ QQuickMenuBarItem *dynamicMenuBarItem = qobject_cast(dynamicMenu->parentItem());
+ QVERIFY(staticMenuBarItem && dynamicMenuBarItem);
+
+ // highlight the static MenuBarItem and open the menu
+ QTest::mouseMove(window.data(), staticMenuBarItem->mapToScene(
+ QPointF(staticMenuBarItem->width() / 2, staticMenuBarItem->height() / 2)).toPoint());
+ QTest::mouseClick(window.data(), Qt::LeftButton, Qt::NoModifier,
+ staticMenuBarItem->mapToScene(QPointF(staticMenuBarItem->width() / 2, staticMenuBarItem->height() / 2)).toPoint());
+ QCOMPARE(staticMenuBarItem->isHighlighted(), true);
+ QCOMPARE(staticMenu->isVisible(), true);
+ QTRY_COMPARE(staticMenu->isOpened(), true);
+
+ // click a menu item to dismiss the menu and unhighlight the static MenuBarItem
+ QQuickMenuItem *menuItem = qobject_cast(staticMenu->itemAt(0));
+ QVERIFY(menuItem);
+ QTest::mouseClick(window.data(), Qt::LeftButton, Qt::NoModifier,
+ menuItem->mapToScene(QPointF(menuItem->width() / 2, menuItem->height() / 2)).toPoint());
+ QCOMPARE(staticMenuBarItem->isHighlighted(), false);
+
+ // highlight the dynamic MenuBarItem and open the menu
+ QTest::mouseMove(window.data(), dynamicMenuBarItem->mapToScene(
+ QPointF(dynamicMenuBarItem->width() / 2, dynamicMenuBarItem->height() / 2)).toPoint());
+ QTest::mouseClick(window.data(), Qt::LeftButton, Qt::NoModifier,
+ dynamicMenuBarItem->mapToScene(QPointF(dynamicMenuBarItem->width() / 2, dynamicMenuBarItem->height() / 2)).toPoint());
+ QCOMPARE(dynamicMenuBarItem->isHighlighted(), true);
+ QCOMPARE(dynamicMenu->isVisible(), true);
+ QTRY_COMPARE(dynamicMenu->isOpened(), true);
+
+ // click a menu item to dismiss the menu and unhighlight the dynamic MenuBarItem
+ menuItem = qobject_cast(dynamicMenu->itemAt(0));
+ QVERIFY(menuItem);
+ QTest::mouseClick(window.data(), Qt::LeftButton, Qt::NoModifier,
+ menuItem->mapToScene(QPointF(menuItem->width() / 2, menuItem->height() / 2)).toPoint());
+ QCOMPARE(dynamicMenuBarItem->isHighlighted(), false);
+}
+
QTEST_QUICKCONTROLS_MAIN(tst_qquickmenubar)
#include "tst_qquickmenubar.moc"
--
cgit v1.2.3
From e748ad35b5a8574287d93d9110bbbed3ab6a593e Mon Sep 17 00:00:00 2001
From: Mitch Curtis
Date: Thu, 24 Oct 2019 10:58:00 +0200
Subject: texteditor: update links in html file
Change-Id: I7e3bd670039d181fb562967c5e9d3830f63d46a3
Reviewed-by: Alexandru Croitor
---
examples/quickcontrols2/texteditor/texteditor.html | 15 +++++++--------
1 file changed, 7 insertions(+), 8 deletions(-)
diff --git a/examples/quickcontrols2/texteditor/texteditor.html b/examples/quickcontrols2/texteditor/texteditor.html
index 1310da42..41705f85 100644
--- a/examples/quickcontrols2/texteditor/texteditor.html
+++ b/examples/quickcontrols2/texteditor/texteditor.html
@@ -31,14 +31,13 @@
-
- - Menu - provides a QML API for native platform menu popups.
- - MenuBar - provides a QML API for native platform menubars.
- - MenuItem - provides a QML API for native platform menu items.
- - FileDialog - provides a QML API for native platform file dialogs.
- - FontDialog - provides a QML API for native platform font dialogs.
- - ColorDialog - provides a QML API for native platform color dialogs.
- - MessageDialog - provides a QML API for native platform message dialogs.
+ - Menu - provides a QML API for native platform menu popups.
+ - MenuBar - provides a QML API for native platform menubars.
+ - MenuItem - provides a QML API for native platform menu items.
+ - FileDialog - provides a QML API for native platform file dialogs.
+ - FontDialog - provides a QML API for native platform font dialogs.
+ - ColorDialog - provides a QML API for native platform color dialogs.
+ - MessageDialog - provides a QML API for native platform message dialogs.