summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/quicktemplates2/qquickcontainer.cpp25
-rw-r--r--src/quicktemplates2/qquickcontainer_p_p.h2
-rw-r--r--src/quicktemplates2/qquickmenu.cpp99
-rw-r--r--src/quicktemplates2/qquickmenu_p_p.h3
-rw-r--r--src/quicktemplates2/qquickmenubar.cpp49
-rw-r--r--src/quicktemplates2/qquickmenubar_p.h1
-rw-r--r--src/quicktemplates2/qquickmenubar_p_p.h4
-rw-r--r--src/quicktemplates2/qquickpopuppositioner.cpp2
-rw-r--r--tests/auto/qquickmenu/data/instantiator.qml76
-rw-r--r--tests/auto/qquickmenu/data/instantiatorWithItemsBeforeAndAfter.qml88
-rw-r--r--tests/auto/qquickmenu/data/repeaterWithItemsBeforeAndAfter.qml88
-rw-r--r--tests/auto/qquickmenu/qquickmenu.pro1
-rw-r--r--tests/auto/qquickmenu/tst_qquickmenu.cpp201
-rw-r--r--tests/auto/qquickmenubar/qquickmenubar.pro1
-rw-r--r--tests/auto/qquickmenubar/tst_qquickmenubar.cpp101
-rw-r--r--tests/auto/qquickpopup/tst_qquickpopup.cpp4
-rw-r--r--tests/auto/shared/menuutil.h61
17 files changed, 36 insertions, 770 deletions
diff --git a/src/quicktemplates2/qquickcontainer.cpp b/src/quicktemplates2/qquickcontainer.cpp
index 8217a3ff..c4af6151 100644
--- a/src/quicktemplates2/qquickcontainer.cpp
+++ b/src/quicktemplates2/qquickcontainer.cpp
@@ -336,21 +336,6 @@ void QQuickContainerPrivate::reorderItems()
}
}
-// Helper function needed for derived classes such as QQuickMenuBarPrivate.
-void QQuickContainerPrivate::addObject(QObject *obj)
-{
- Q_Q(QQuickContainer);
- QQuickItem *item = qobject_cast<QQuickItem *>(obj);
- if (item) {
- if (QQuickItemPrivate::get(item)->isTransparentForPositioner())
- item->setParentItem(effectiveContentItem(contentItem));
- else if (contentModel->indexOf(item, nullptr) == -1)
- q->addItem(item);
- } else {
- contentData.append(obj);
- }
-}
-
void QQuickContainerPrivate::_q_currentIndexChanged()
{
Q_Q(QQuickContainer);
@@ -394,7 +379,15 @@ void QQuickContainerPrivate::contentData_append(QQmlListProperty<QObject> *prop,
{
QQuickContainer *q = static_cast<QQuickContainer *>(prop->object);
QQuickContainerPrivate *p = QQuickContainerPrivate::get(q);
- p->addObject(obj);
+ QQuickItem *item = qobject_cast<QQuickItem *>(obj);
+ if (item) {
+ if (QQuickItemPrivate::get(item)->isTransparentForPositioner())
+ item->setParentItem(effectiveContentItem(p->contentItem));
+ else if (p->contentModel->indexOf(item, nullptr) == -1)
+ q->addItem(item);
+ } else {
+ p->contentData.append(obj);
+ }
}
int QQuickContainerPrivate::contentData_count(QQmlListProperty<QObject> *prop)
diff --git a/src/quicktemplates2/qquickcontainer_p_p.h b/src/quicktemplates2/qquickcontainer_p_p.h
index 5ddf298a..16e9c9f6 100644
--- a/src/quicktemplates2/qquickcontainer_p_p.h
+++ b/src/quicktemplates2/qquickcontainer_p_p.h
@@ -73,8 +73,6 @@ public:
void removeItem(int index, QQuickItem *item);
void reorderItems();
- void addObject(QObject *obj);
-
void _q_currentIndexChanged();
void itemChildAdded(QQuickItem *item, QQuickItem *child) override;
diff --git a/src/quicktemplates2/qquickmenu.cpp b/src/quicktemplates2/qquickmenu.cpp
index 42059e7f..f52405c9 100644
--- a/src/quicktemplates2/qquickmenu.cpp
+++ b/src/quicktemplates2/qquickmenu.cpp
@@ -43,7 +43,6 @@
#include "qquickpopuppositioner_p_p.h"
#include "qquickaction_p.h"
-#include <QtCore/qloggingcategory.h>
#include <QtGui/qevent.h>
#include <QtGui/qcursor.h>
#include <QtGui/qpa/qplatformintegration.h>
@@ -55,8 +54,6 @@
#include <QtQml/private/qv4variantobject_p.h>
#include <QtQml/private/qv4qobjectwrapper_p.h>
#include <QtQml/private/qqmlobjectmodel_p.h>
-#include <QtQml/private/qqmlinstantiator_p.h>
-#include <QtQml/private/qqmlinstantiator_p_p.h>
#include <QtQuick/private/qquickitem_p.h>
#include <QtQuick/private/qquickitemchangelistener_p.h>
#include <QtQuick/private/qquickitemview_p.h>
@@ -68,8 +65,6 @@ QT_BEGIN_NAMESPACE
// copied from qfusionstyle.cpp
static const int SUBMENU_DELAY = 225;
-Q_LOGGING_CATEGORY(qlcQQuickMenu, "qt.quick.controls.menu")
-
/*!
\qmltype Menu
\inherits Popup
@@ -256,67 +251,6 @@ void QQuickMenuPrivate::removeItem(int index, QQuickItem *item)
}
}
-void QQuickMenuPrivate::createAndAppendItem(QObject *object)
-{
- Q_Q(QQuickMenu);
- QQuickItem *item = qobject_cast<QQuickItem *>(object);
- if (!item) {
- if (QQuickAction *action = qobject_cast<QQuickAction *>(object))
- item = createItem(action);
- else if (QQuickMenu *menu = qobject_cast<QQuickMenu *>(object))
- item = createItem(menu);
- }
-
- if (item) {
- if (QQuickItemPrivate::get(item)->isTransparentForPositioner()) {
- QQuickItemPrivate::get(item)->addItemChangeListener(this, QQuickItemPrivate::SiblingOrder);
- item->setParentItem(contentItem);
- } else if (contentModel->indexOf(item, nullptr) == -1) {
- q->addItem(item);
- }
- } else {
- contentData.append(object);
- }
-}
-
-void QQuickMenuPrivate::recreateItems()
-{
- // removeItem() will remove stuff from contentData, so we have to make a copy of it.
- const auto originalContentData = contentData;
-
- qCDebug(qlcQQuickMenu) << "removing items so that we can recreate them:";
- QSet<QObject*> instantiatedObjects;
- for (int i = 0; i < contentModel->count(); ) {
- QQuickItem *item = itemAt(i);
- QQmlInstantiator *instantiator = qobject_cast<QQmlInstantiator*>(item->parent());
- if (instantiator) {
- // Don't try to recreate items owned by an instantiator.
- qCDebug(qlcQQuickMenu) << "- item" << item << "at index" << i << "with parent"
- << item->parent() << "was instantiated by Instantiator; ignoring";
- instantiatedObjects.insert(item);
- ++i;
- } else {
- qCDebug(qlcQQuickMenu) << "- removing item" << item << "at index" << i << "with parent" << item->parent();
- removeItem(0, item);
- }
- }
-
- qCDebug(qlcQQuickMenu) << "recreating items:";
- for (QObject *object : originalContentData) {
- QQmlInstantiator *instantiator = qobject_cast<QQmlInstantiator*>(object);
- // Instantiators are part of our contentData. If this particular object is an Instantiator,
- // let it recreate its own items, otherwise strange things happen (the items are culled).
- if (instantiator) {
- qCDebug(qlcQQuickMenu) << "- contentData object" << object << "is an Instantiator;"
- << "asking them to regenerate their own items";
- QQmlInstantiatorPrivate::get(instantiator)->regenerate();
- } else if (!instantiatedObjects.contains(object)) {
- qCDebug(qlcQQuickMenu) << "- creating MenuItem for contentData object" << object;
- createAndAppendItem(object);
- }
- }
-}
-
QQuickItem *QQuickMenuPrivate::beginCreateItem()
{
Q_Q(QQuickMenu);
@@ -389,7 +323,6 @@ void QQuickMenuPrivate::resizeItems()
void QQuickMenuPrivate::itemChildAdded(QQuickItem *, QQuickItem *child)
{
// add dynamically reparented items (eg. by a Repeater)
- qCDebug(qlcQQuickMenu) << "item child added" << child;
if (!QQuickItemPrivate::get(child)->isTransparentForPositioner() && !contentData.contains(child))
insertItem(contentModel->count(), child);
}
@@ -397,7 +330,6 @@ void QQuickMenuPrivate::itemChildAdded(QQuickItem *, QQuickItem *child)
void QQuickMenuPrivate::itemParentChanged(QQuickItem *item, QQuickItem *parent)
{
// remove dynamically unparented items (eg. by a Repeater)
- qCDebug(qlcQQuickMenu) << "parent of item" << item << "changed to" << parent;
if (!parent)
removeItem(contentModel->indexOf(item, nullptr), item);
}
@@ -408,8 +340,6 @@ void QQuickMenuPrivate::itemSiblingOrderChanged(QQuickItem *)
Q_Q(QQuickMenu);
QList<QQuickItem *> siblings = contentItem->childItems();
- qCDebug(qlcQQuickMenu) << "item sibling order changed";
-
int to = 0;
for (int i = 0; i < siblings.count(); ++i) {
QQuickItem* sibling = siblings.at(i);
@@ -422,7 +352,6 @@ void QQuickMenuPrivate::itemSiblingOrderChanged(QQuickItem *)
void QQuickMenuPrivate::itemDestroyed(QQuickItem *item)
{
- qCDebug(qlcQQuickMenu) << "item child destroyed" << item;
QQuickPopupPrivate::itemDestroyed(item);
int index = contentModel->indexOf(item, nullptr);
if (index != -1)
@@ -697,18 +626,24 @@ void QQuickMenuPrivate::contentData_append(QQmlListProperty<QObject> *prop, QObj
QQuickMenu *q = qobject_cast<QQuickMenu *>(prop->object);
QQuickMenuPrivate *p = QQuickMenuPrivate::get(q);
- if (!p->complete) {
- qCDebug(qlcQQuickMenu) << "appending object" << obj
- << "to contentData, but delaying MenuItem creation (if necessary) until we're completed";
- // Don't add items until we're complete, as the delegate could change in the meantime.
- // We'll add it to contentData and create it when we're complete.
- p->contentData.append(obj);
- return;
+ QQuickItem *item = qobject_cast<QQuickItem *>(obj);
+ if (!item) {
+ if (QQuickAction *action = qobject_cast<QQuickAction *>(obj))
+ item = p->createItem(action);
+ else if (QQuickMenu *menu = qobject_cast<QQuickMenu *>(obj))
+ item = p->createItem(menu);
}
- qCDebug(qlcQQuickMenu) << "appending object" << obj
- << "to contentData and creating MenuItem for it if necessary";
- p->createAndAppendItem(obj);
+ if (item) {
+ if (QQuickItemPrivate::get(item)->isTransparentForPositioner()) {
+ QQuickItemPrivate::get(item)->addItemChangeListener(p, QQuickItemPrivate::SiblingOrder);
+ item->setParentItem(p->contentItem);
+ } else if (p->contentModel->indexOf(item, nullptr) == -1) {
+ q->addItem(item);
+ }
+ } else {
+ p->contentData.append(obj);
+ }
}
int QQuickMenuPrivate::contentData_count(QQmlListProperty<QObject> *prop)
@@ -1421,7 +1356,7 @@ void QQuickMenu::componentComplete()
{
Q_D(QQuickMenu);
QQuickPopup::componentComplete();
- d->recreateItems();
+ d->resizeItems();
}
void QQuickMenu::contentItemChange(QQuickItem *newItem, QQuickItem *oldItem)
diff --git a/src/quicktemplates2/qquickmenu_p_p.h b/src/quicktemplates2/qquickmenu_p_p.h
index c0bb2702..6146b960 100644
--- a/src/quicktemplates2/qquickmenu_p_p.h
+++ b/src/quicktemplates2/qquickmenu_p_p.h
@@ -78,9 +78,6 @@ public:
void moveItem(int from, int to);
void removeItem(int index, QQuickItem *item);
- void createAndAppendItem(QObject *object);
- void recreateItems();
-
QQuickItem *beginCreateItem();
void completeCreateItem();
diff --git a/src/quicktemplates2/qquickmenubar.cpp b/src/quicktemplates2/qquickmenubar.cpp
index 9be9ee09..6016e70d 100644
--- a/src/quicktemplates2/qquickmenubar.cpp
+++ b/src/quicktemplates2/qquickmenubar.cpp
@@ -76,26 +76,7 @@ QT_BEGIN_NAMESPACE
{Focus Management in Qt Quick Controls 2}
*/
-void QQuickMenuBarPrivate::createItems()
-{
- // removeItem() will remove stuff from contentData, so we have to make a copy of it.
- const auto originalContentData = QQuickContainerPrivate::contentData;
- // Sanity check that there aren't any items we don't know about.
- Q_ASSERT(contentModel->count() == 0);
-
- for (QObject *object : originalContentData) {
- if (QQuickMenu *menu = qobject_cast<QQuickMenu *>(object)) {
- // It's a QQuickMenu; create a QQuickMenuBarItem for it.
- QQuickItem *menuItem = createItem(menu);
- addObject(menuItem);
- } else if (qobject_cast<QQuickMenuBarItem *>(object)) {
- addObject(object);
- }
- // If it's neither, skip it because we don't care about it.
- }
-}
-
-QQuickItem *QQuickMenuBarPrivate::beginCreateItem(QQuickMenu *menu)
+QQuickItem *QQuickMenuBarPrivate::beginCreateItem()
{
Q_Q(QQuickMenuBar);
if (!delegate)
@@ -115,8 +96,6 @@ QQuickItem *QQuickMenuBarPrivate::beginCreateItem(QQuickMenu *menu)
return nullptr;
}
- if (QQuickMenuBarItem *menuBarItem = qobject_cast<QQuickMenuBarItem *>(item))
- menuBarItem->setMenu(menu);
item->setParentItem(q);
QQml_setParent_noEvent(item, q);
@@ -133,7 +112,9 @@ void QQuickMenuBarPrivate::completeCreateItem()
QQuickItem *QQuickMenuBarPrivate::createItem(QQuickMenu *menu)
{
- QQuickItem *item = beginCreateItem(menu);
+ QQuickItem *item = beginCreateItem();
+ if (QQuickMenuBarItem *menuBarItem = qobject_cast<QQuickMenuBarItem *>(item))
+ menuBarItem->setMenu(menu);
completeCreateItem();
return item;
}
@@ -273,18 +254,9 @@ void QQuickMenuBarPrivate::itemImplicitHeightChanged(QQuickItem *item)
void QQuickMenuBarPrivate::contentData_append(QQmlListProperty<QObject> *prop, QObject *obj)
{
QQuickMenuBar *menuBar = static_cast<QQuickMenuBar *>(prop->object);
- QQuickMenuBarPrivate *menuBarPrivate = QQuickMenuBarPrivate::get(menuBar);
- if (!menuBarPrivate->componentComplete) {
- // Don't add items until we're complete, as the delegate could change in the meantime.
- // We'll add it to contentData and create it when we're complete.
- menuBarPrivate->QQuickContainerPrivate::contentData.append(obj);
- return;
- }
-
- if (QQuickMenu *menu = qobject_cast<QQuickMenu *>(obj)) {
- QQuickItem *menuItem = menuBarPrivate->createItem(menu);
- menuBarPrivate->addObject(menuItem);
- }
+ if (QQuickMenu *menu = qobject_cast<QQuickMenu *>(obj))
+ obj = QQuickMenuBarPrivate::get(menuBar)->createItem(menu);
+ QQuickContainerPrivate::contentData_append(prop, obj);
}
void QQuickMenuBarPrivate::menus_append(QQmlListProperty<QQuickMenu> *prop, QQuickMenu *obj)
@@ -482,13 +454,6 @@ QQmlListProperty<QObject> QQuickMenuBarPrivate::contentData()
QQuickContainerPrivate::contentData_clear);
}
-void QQuickMenuBar::componentComplete()
-{
- Q_D(QQuickMenuBar);
- QQuickContainer::componentComplete();
- d->createItems();
-}
-
bool QQuickMenuBar::eventFilter(QObject *object, QEvent *event)
{
return QObject::eventFilter(object, event);
diff --git a/src/quicktemplates2/qquickmenubar_p.h b/src/quicktemplates2/qquickmenubar_p.h
index 983bb578..af37d0f2 100644
--- a/src/quicktemplates2/qquickmenubar_p.h
+++ b/src/quicktemplates2/qquickmenubar_p.h
@@ -81,7 +81,6 @@ Q_SIGNALS:
void menusChanged();
protected:
- void componentComplete() override;
bool eventFilter(QObject *object, QEvent *event) override;
void keyPressEvent(QKeyEvent *event) override;
void keyReleaseEvent(QKeyEvent *event) override;
diff --git a/src/quicktemplates2/qquickmenubar_p_p.h b/src/quicktemplates2/qquickmenubar_p_p.h
index 8623ef43..75fbed73 100644
--- a/src/quicktemplates2/qquickmenubar_p_p.h
+++ b/src/quicktemplates2/qquickmenubar_p_p.h
@@ -69,9 +69,7 @@ public:
QQmlListProperty<QQuickMenu> menus();
QQmlListProperty<QObject> contentData();
- void createItems();
-
- QQuickItem *beginCreateItem(QQuickMenu *menu);
+ QQuickItem *beginCreateItem();
void completeCreateItem();
QQuickItem *createItem(QQuickMenu *menu);
diff --git a/src/quicktemplates2/qquickpopuppositioner.cpp b/src/quicktemplates2/qquickpopuppositioner.cpp
index ebd8ff29..69a57674 100644
--- a/src/quicktemplates2/qquickpopuppositioner.cpp
+++ b/src/quicktemplates2/qquickpopuppositioner.cpp
@@ -300,7 +300,7 @@ void QQuickPopupPositioner::addAncestorListeners(QQuickItem *item)
QQuickItem *p = item;
while (p) {
- QQuickItemPrivate::get(p)->updateOrAddItemChangeListener(this, AncestorChangeTypes);
+ QQuickItemPrivate::get(p)->addItemChangeListener(this, AncestorChangeTypes);
p = p->parentItem();
}
}
diff --git a/tests/auto/qquickmenu/data/instantiator.qml b/tests/auto/qquickmenu/data/instantiator.qml
deleted file mode 100644
index 270266c3..00000000
--- a/tests/auto/qquickmenu/data/instantiator.qml
+++ /dev/null
@@ -1,76 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2018 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 QtQml 2.11
-import QtQuick 2.11
-import QtQuick.Controls 2.4
-
-ApplicationWindow {
- width: 200
- height: 200
-
- property alias menu: menu
-
- Menu {
- id: menu
-
- Instantiator {
- model: ["A", "B"]
-
- MenuItem {
- objectName: text
- text: modelData
- }
-
- onObjectAdded: menu.insertItem(index, object)
- onObjectRemoved: menu.removeItem(object)
- }
- }
-}
diff --git a/tests/auto/qquickmenu/data/instantiatorWithItemsBeforeAndAfter.qml b/tests/auto/qquickmenu/data/instantiatorWithItemsBeforeAndAfter.qml
deleted file mode 100644
index 9f3ef430..00000000
--- a/tests/auto/qquickmenu/data/instantiatorWithItemsBeforeAndAfter.qml
+++ /dev/null
@@ -1,88 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2018 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 QtQml 2.11
-import QtQuick 2.11
-import QtQuick.Controls 2.4
-
-ApplicationWindow {
- width: 200
- height: 200
-
- property alias menu: menu
-
- Menu {
- id: menu
-
- MenuItem {
- objectName: text
- text: "Before"
- }
-
- Instantiator {
- model: ["Instantiated #1", "Instantiated #2"]
-
- MenuItem {
- objectName: text
- text: modelData
- }
-
- // We want our items to be added after the "Before" MenuItem,
- // so we have to insert items at the index after it.
- onObjectAdded: menu.insertItem(1 + index, object)
- onObjectRemoved: menu.removeItem(object)
- }
-
- MenuItem {
- objectName: text
- text: "After"
- }
- }
-}
diff --git a/tests/auto/qquickmenu/data/repeaterWithItemsBeforeAndAfter.qml b/tests/auto/qquickmenu/data/repeaterWithItemsBeforeAndAfter.qml
deleted file mode 100644
index 46ed8856..00000000
--- a/tests/auto/qquickmenu/data/repeaterWithItemsBeforeAndAfter.qml
+++ /dev/null
@@ -1,88 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2018 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 QtQml 2.11
-import QtQuick 2.11
-import QtQuick.Controls 2.4
-
-ApplicationWindow {
- width: 200
- height: 200
-
- property alias menu: menu
-
- Menu {
- id: menu
-
- MenuItem {
- objectName: text
- text: "Before"
- }
-
- Repeater {
- model: ["Repeater Item #1", "Repeater Item #2"]
-
- MenuItem {
- objectName: text
- text: modelData
- }
-
- // We want our items to be added after the "Before" MenuItem,
- // so we have to insert items at the index after it.
- onItemAdded: menu.insertItem(1 + index, item)
- onItemRemoved: menu.removeItem(item)
- }
-
- MenuItem {
- objectName: text
- text: "After"
- }
- }
-}
diff --git a/tests/auto/qquickmenu/qquickmenu.pro b/tests/auto/qquickmenu/qquickmenu.pro
index 7e1080b9..ee539842 100644
--- a/tests/auto/qquickmenu/qquickmenu.pro
+++ b/tests/auto/qquickmenu/qquickmenu.pro
@@ -1,6 +1,5 @@
CONFIG += testcase
TARGET = tst_qquickmenu
-HEADERS += ../shared/menuutil.h
SOURCES += tst_qquickmenu.cpp
macos:CONFIG -= app_bundle
diff --git a/tests/auto/qquickmenu/tst_qquickmenu.cpp b/tests/auto/qquickmenu/tst_qquickmenu.cpp
index 2f6d5049..b46b8781 100644
--- a/tests/auto/qquickmenu/tst_qquickmenu.cpp
+++ b/tests/auto/qquickmenu/tst_qquickmenu.cpp
@@ -43,8 +43,6 @@
#include <QtQml/qqmlcontext.h>
#include <QtQuick/qquickview.h>
#include <QtQuick/private/qquickitem_p.h>
-#include <QtQuick/private/qquicklistview_p.h>
-#include "../shared/menuutil.h"
#include "../shared/util.h"
#include "../shared/visualtestutil.h"
@@ -75,7 +73,6 @@ private slots:
void addItem();
void menuSeparator();
void repeater();
- void repeaterWithItemsBeforeAndAfter();
void order();
void popup();
void actions();
@@ -89,9 +86,6 @@ private slots:
void addRemoveSubMenus();
void scrollable_data();
void scrollable();
- void delegateFromSeparateComponent();
- void instantiator();
- void instantiatorWithItemsBeforeAndAfter();
};
void tst_QQuickMenu::defaults()
@@ -151,7 +145,6 @@ void tst_QQuickMenu::mouse()
menu->open();
QVERIFY(menu->isVisible());
QVERIFY(window->overlay()->childItems().contains(menu->contentItem()->parentItem()));
- waitForMenuListViewPolish(menu);
QQuickItem *firstItem = menu->itemAt(0);
QSignalSpy clickedSpy(firstItem, SIGNAL(clicked()));
@@ -275,8 +268,6 @@ void tst_QQuickMenu::contextMenuKeyboard()
QCOMPARE(visibleSpy.count(), 1);
QVERIFY(menu->isVisible());
QVERIFY(window->overlay()->childItems().contains(menu->contentItem()->parentItem()));
- waitForMenuListViewPolish(menu);
-
QVERIFY(!firstItem->hasActiveFocus());
QVERIFY(!firstItem->property("highlighted").toBool());
QCOMPARE(menu->currentIndex(), -1);
@@ -592,7 +583,7 @@ void tst_QQuickMenu::repeater()
for (int i = 0; i < count; ++i) {
QQuickItem *item = menu->itemAt(i);
- QVERIFY2(item, qPrintable(QString::fromLatin1("Expected item to be at index %1").arg(i)));
+ QVERIFY(item);
QCOMPARE(item->property("idx").toInt(), i);
QQuickItem *repeaterItem = nullptr;
@@ -616,35 +607,6 @@ void tst_QQuickMenu::repeater()
}
}
-void tst_QQuickMenu::repeaterWithItemsBeforeAndAfter()
-{
- QQuickApplicationHelper helper(this, QLatin1String("repeaterWithItemsBeforeAndAfter.qml"));
-
- QQuickApplicationWindow *window = helper.appWindow;
- window->show();
- window->requestActivate();
- QVERIFY(QTest::qWaitForWindowActive(window));
- QVERIFY(QGuiApplication::focusWindow() == window);
- centerOnScreen(window);
- moveMouseAway(window);
-
- QQuickMenu *menu = window->property("menu").value<QQuickMenu*>();
- menu->open();
- QVERIFY(menu->isVisible());
- waitForMenuListViewPolish(menu);
-
- QStringList expectedItemTexts;
- expectedItemTexts << QLatin1String("Before") << QLatin1String("Repeater Item #1")
- << QLatin1String("Repeater Item #2") << QLatin1String("After");
-
- for (int i = 0; i < expectedItemTexts.size(); ++i) {
- const QString expectedText = expectedItemTexts.at(i);
- QQuickMenuItem *menuItem = qobject_cast<QQuickMenuItem*>(menu->itemAt(i));
- QVERIFY(menuItem);
- QCOMPARE(menuItem->text(), expectedText);
- }
-}
-
void tst_QQuickMenu::order()
{
QQuickApplicationHelper helper(this, QLatin1String("order.qml"));
@@ -972,7 +934,6 @@ void tst_QQuickMenu::subMenuMouse()
QVERIFY(!subMenu1->isVisible());
QVERIFY(!subMenu2->isVisible());
QVERIFY(!subSubMenu1->isVisible());
- waitForMenuListViewPolish(mainMenu);
// open the sub-menu with mouse click
QQuickMenuItem *subMenu1Item = qobject_cast<QQuickMenuItem *>(mainMenu->itemAt(1));
@@ -983,7 +944,6 @@ void tst_QQuickMenu::subMenuMouse()
QVERIFY(subMenu1->isVisible());
QVERIFY(!subMenu2->isVisible());
QVERIFY(!subSubMenu1->isVisible());
- waitForMenuListViewPolish(subMenu1);
// open the cascading sub-sub-menu with mouse hover
QQuickMenuItem *subSubMenu1Item = qobject_cast<QQuickMenuItem *>(subMenu1->itemAt(2));
@@ -994,7 +954,6 @@ void tst_QQuickMenu::subMenuMouse()
QVERIFY(subMenu1->isVisible());
QVERIFY(!subMenu2->isVisible());
QVERIFY(!subSubMenu1->isVisible());
- QVERIFY(subSubMenu1Item->isHovered());
if (cascade)
QTRY_VERIFY(subSubMenu1->isVisible());
@@ -1014,7 +973,6 @@ void tst_QQuickMenu::subMenuMouse()
QVERIFY(subMenu1->isVisible());
QVERIFY(!subMenu2->isVisible());
QVERIFY(!subSubMenu1->isVisible());
- QVERIFY(subSubMenu1Item->isHovered());
if (cascade)
QTRY_VERIFY(subSubMenu1->isVisible());
@@ -1241,7 +1199,6 @@ void tst_QQuickMenu::subMenuPosition()
QVERIFY(!subMenu1->isVisible());
QVERIFY(!subMenu2->isVisible());
QVERIFY(!subSubMenu1->isVisible());
- waitForMenuListViewPolish(mainMenu);
// open the sub-menu (never flips)
QQuickMenuItem *subMenu1Item = qobject_cast<QQuickMenuItem *>(mainMenu->itemAt(1));
@@ -1376,165 +1333,9 @@ void tst_QQuickMenu::scrollable()
QVERIFY(menu->isVisible());
QQuickItem *contentItem = menu->contentItem();
- // Can only be scrollable if it exceeds the height of the window.
- QTRY_VERIFY(contentItem->property("contentHeight").toReal() > window->height());
QCOMPARE(contentItem->property("interactive").toBool(), true);
}
-// QTBUG-67559
-// Test that Actions and MenuItems declared as children of a Menu have the
-// correct delegate when it is declared outside of the Menu as a Component.
-void tst_QQuickMenu::delegateFromSeparateComponent()
-{
- QQuickApplicationHelper helper(this, QLatin1String("delegateFromSeparateComponent.qml"));
- QQuickWindow *window = helper.window;
- window->show();
- QVERIFY(QTest::qWaitForWindowActive(window));
-
- const QColor green = QColor::fromRgb(0x00ff00);
-
- QQuickMenu *menu = window->property("menu").value<QQuickMenu*>();
- QVERIFY(menu);
-
- // "Action Item 1"
- QQuickMenuItem *actionItem1 = qobject_cast<QQuickMenuItem*>(menu->itemAt(0));
- QVERIFY(actionItem1);
- QCOMPARE(actionItem1->text(), QLatin1String("Action Item 1"));
-
- QQuickItem *actionItem1Bg = actionItem1->property("background").value<QQuickItem*>();
- QVERIFY(actionItem1Bg);
- QCOMPARE(actionItem1Bg->property("color").value<QColor>(), green);
-
- // "Sub-menu"
- QQuickMenuItem *subMenuItem = qobject_cast<QQuickMenuItem*>(menu->itemAt(1));
- QVERIFY(subMenuItem);
- QCOMPARE(subMenuItem->text(), QLatin1String("Sub-menu"));
-
- QQuickItem *subMenuItemBg = subMenuItem->property("background").value<QQuickItem*>();
- QVERIFY(subMenuItemBg);
- QCOMPARE(subMenuItemBg->property("color").value<QColor>(), green);
-
- QQuickMenu *subMenu = subMenuItem->subMenu();
- QVERIFY(subMenu);
-
- // "Sub-menu Action Item 1"
- QQuickMenuItem *subMenuActionItem1 = qobject_cast<QQuickMenuItem*>(subMenu->itemAt(0));
- QVERIFY(subMenuActionItem1);
- QCOMPARE(subMenuActionItem1->text(), QLatin1String("Sub-menu Action Item 1"));
-
- QQuickItem *subMenuActionItem1Bg = subMenuActionItem1->property("background").value<QQuickItem*>();
- QVERIFY(subMenuActionItem1Bg);
- QCOMPARE(subMenuActionItem1Bg->property("color").value<QColor>(), green);
-
- // "Sub-sub-menu"
- QQuickMenuItem *subSubMenuItem = qobject_cast<QQuickMenuItem*>(subMenu->itemAt(1));
- QVERIFY(subSubMenuItem);
- QCOMPARE(subSubMenuItem->text(), QLatin1String("Sub-sub-menu"));
-
- QQuickItem *subSubMenuItemBg = subSubMenuItem->property("background").value<QQuickItem*>();
- QVERIFY(subSubMenuItemBg);
- QCOMPARE(subSubMenuItemBg->property("color").value<QColor>(), green);
-
- QQuickMenu *subSubMenu = subSubMenuItem->subMenu();
- QVERIFY(subSubMenu);
-
- // "Sub-sub-menu Action Item 1"
- QQuickMenuItem *subSubMenuActionItem1 = qobject_cast<QQuickMenuItem*>(subSubMenu->itemAt(0));
- QVERIFY(subSubMenuActionItem1);
- QCOMPARE(subSubMenuActionItem1->text(), QLatin1String("Sub-sub-menu Action Item 1"));
-
- QQuickItem *subSubMenuActionItem1Bg = subSubMenuActionItem1->property("background").value<QQuickItem*>();
- QVERIFY(subSubMenuActionItem1Bg);
- QCOMPARE(subSubMenuActionItem1Bg->property("color").value<QColor>(), green);
-
- // "Sub-menu Action Item 2"
- QQuickMenuItem *subMenuActionItem2 = qobject_cast<QQuickMenuItem*>(subMenu->itemAt(2));
- QVERIFY(subMenuActionItem2);
- QCOMPARE(subMenuActionItem2->text(), QLatin1String("Sub-menu Action Item 2"));
-
- QQuickItem *subMenuActionItem2Bg = subMenuActionItem2->property("background").value<QQuickItem*>();
- QVERIFY(subMenuActionItem2Bg);
- QCOMPARE(subMenuActionItem2Bg->property("color").value<QColor>(), green);
-
- // "Action Item 2"
- QQuickMenuItem *actionItem2 = qobject_cast<QQuickMenuItem*>(menu->itemAt(2));
- QVERIFY(actionItem2);
- QCOMPARE(actionItem2->text(), QLatin1String("Action Item 2"));
-
- QQuickItem *actionItem2Bg = actionItem2->property("background").value<QQuickItem*>();
- QVERIFY(actionItem2Bg);
- QCOMPARE(actionItem2Bg->property("color").value<QColor>(), green);
-}
-
-void tst_QQuickMenu::instantiator()
-{
- if (QGuiApplication::styleHints()->tabFocusBehavior() != Qt::TabFocusAllControls)
- QSKIP("This platform only allows tab focus for text controls");
-
- QQuickApplicationHelper helper(this, QLatin1String("instantiator.qml"));
-
- QQuickApplicationWindow *window = helper.appWindow;
- window->show();
- window->requestActivate();
- QVERIFY(QTest::qWaitForWindowActive(window));
- QVERIFY(QGuiApplication::focusWindow() == window);
- centerOnScreen(window);
- moveMouseAway(window);
-
- QQuickMenu *menu = window->property("menu").value<QQuickMenu*>();
- menu->open();
- QVERIFY(menu->isVisible());
- waitForMenuListViewPolish(menu);
- menu->setFocus(true);
-
- // Highlight the first item.
- QQuickMenuItem *firstItem = qobject_cast<QQuickMenuItem *>(menu->itemAt(0));
- QVERIFY(firstItem);
- QTest::keyClick(window, Qt::Key_Tab);
- QVERIFY(firstItem->hasActiveFocus());
- QVERIFY(firstItem->hasVisualFocus());
- QVERIFY(firstItem->isHighlighted());
- QTRY_VERIFY(!QQuickItemPrivate::get(firstItem)->culled);
-
- // Highlight the second item.
- QQuickMenuItem *secondItem = qobject_cast<QQuickMenuItem *>(menu->itemAt(1));
- QVERIFY(secondItem);
- QTest::keyClick(window, Qt::Key_Down);
- QVERIFY(secondItem->hasActiveFocus());
- QVERIFY(secondItem->hasVisualFocus());
- QVERIFY(secondItem->isHighlighted());
- QVERIFY(!QQuickItemPrivate::get(secondItem)->culled);
-}
-
-void tst_QQuickMenu::instantiatorWithItemsBeforeAndAfter()
-{
- QQuickApplicationHelper helper(this, QLatin1String("instantiatorWithItemsBeforeAndAfter.qml"));
-
- QQuickApplicationWindow *window = helper.appWindow;
- window->show();
- window->requestActivate();
- QVERIFY(QTest::qWaitForWindowActive(window));
- QVERIFY(QGuiApplication::focusWindow() == window);
- centerOnScreen(window);
- moveMouseAway(window);
-
- QQuickMenu *menu = window->property("menu").value<QQuickMenu*>();
- menu->open();
- QVERIFY(menu->isVisible());
- waitForMenuListViewPolish(menu);
-
- QStringList expectedItemTexts;
- expectedItemTexts << QLatin1String("Before") << QLatin1String("Instantiated #1")
- << QLatin1String("Instantiated #2") << QLatin1String("After");
-
- for (int i = 0; i < expectedItemTexts.size(); ++i) {
- const QString expectedText = expectedItemTexts.at(i);
- QQuickMenuItem *menuItem = qobject_cast<QQuickMenuItem*>(menu->itemAt(i));
- QVERIFY(menuItem);
- QCOMPARE(menuItem->text(), expectedText);
- }
-}
-
QTEST_MAIN(tst_QQuickMenu)
#include "tst_qquickmenu.moc"
diff --git a/tests/auto/qquickmenubar/qquickmenubar.pro b/tests/auto/qquickmenubar/qquickmenubar.pro
index d2f28e47..b7d41f0f 100644
--- a/tests/auto/qquickmenubar/qquickmenubar.pro
+++ b/tests/auto/qquickmenubar/qquickmenubar.pro
@@ -1,6 +1,5 @@
CONFIG += testcase
TARGET = tst_qquickmenubar
-HEADERS += ../shared/menuutil.h
SOURCES += tst_qquickmenubar.cpp
macos:CONFIG -= app_bundle
diff --git a/tests/auto/qquickmenubar/tst_qquickmenubar.cpp b/tests/auto/qquickmenubar/tst_qquickmenubar.cpp
index 70d487a9..19d67eac 100644
--- a/tests/auto/qquickmenubar/tst_qquickmenubar.cpp
+++ b/tests/auto/qquickmenubar/tst_qquickmenubar.cpp
@@ -36,17 +36,13 @@
#include <QtTest>
#include <QtQml>
-#include <QtQuick/private/qquicklistview_p.h>
-#include "../shared/menuutil.h"
#include "../shared/util.h"
#include "../shared/visualtestutil.h"
#include "../shared/qtest_quickcontrols.h"
#include <QtQuickTemplates2/private/qquickapplicationwindow_p.h>
#include <QtQuickTemplates2/private/qquickmenu_p.h>
-#include <QtQuickTemplates2/private/qquickmenu_p_p.h>
#include <QtQuickTemplates2/private/qquickmenubar_p.h>
-#include <QtQuickTemplates2/private/qquickmenubar_p_p.h>
#include <QtQuickTemplates2/private/qquickmenubaritem_p.h>
#include <QtQuickTemplates2/private/qquickmenuitem_p.h>
@@ -64,8 +60,6 @@ private slots:
void keys();
void mnemonics();
void addRemove();
- void delegateFromSeparateComponent();
- void openTwice();
};
void tst_qquickmenubar::delegate()
@@ -110,13 +104,6 @@ void tst_qquickmenubar::mouse()
QQuickMenuBarItem *viewMenuBarItem = qobject_cast<QQuickMenuBarItem *>(viewMenuBarMenu->parentItem());
QQuickMenuBarItem *helpMenuBarItem = qobject_cast<QQuickMenuBarItem *>(helpMenuBarMenu->parentItem());
QVERIFY(fileMenuBarItem && editMenuBarItem && viewMenuBarItem && helpMenuBarItem);
- // Something about postponing delegate creation to component completion
- // means that the fileMenuBarItem->isHighlighted() check below fails occasionally.
- // Give it a chance to sort itself out before sending move events.
- QQuickMenuBarPrivate *menuBarPrivate = QQuickMenuBarPrivate::get(menuBar);
- menuBar->polish();
- QVERIFY(menuBarPrivate->polishScheduled);
- QTRY_VERIFY(!menuBarPrivate->polishScheduled);
// highlight a menubar item
QTest::mouseMove(window.data(), fileMenuBarItem->mapToScene(QPointF(fileMenuBarItem->width() / 2, fileMenuBarItem->height() / 2)).toPoint());
@@ -159,7 +146,6 @@ void tst_qquickmenubar::mouse()
QVERIFY(helpMenuBarMenu->isVisible());
QTRY_VERIFY(!editMenuBarMenu->isVisible());
QTRY_VERIFY(helpMenuBarMenu->isOpened());
- waitForMenuListViewPolish(helpMenuBarMenu);
// trigger a menu item to close the menu
QQuickMenuItem *aboutMenuItem = qobject_cast<QQuickMenuItem *>(helpMenuBarMenu->itemAt(0));
@@ -181,7 +167,6 @@ void tst_qquickmenubar::mouse()
QVERIFY(viewMenuBarItem->isHighlighted());
QVERIFY(viewMenuBarMenu->isVisible());
QTRY_VERIFY(viewMenuBarMenu->isOpened());
- waitForMenuListViewPolish(viewMenuBarMenu);
// trigger a menu item to open a sub-menu
QQuickMenuItem *alignmentSubMenuItem = qobject_cast<QQuickMenuItem *>(viewMenuBarMenu->itemAt(0));
@@ -192,7 +177,6 @@ void tst_qquickmenubar::mouse()
QVERIFY(viewMenuBarMenu->isVisible());
QVERIFY(alignmentSubMenu->isVisible());
QTRY_VERIFY(alignmentSubMenu->isOpened());
- waitForMenuListViewPolish(alignmentSubMenu);
// trigger a menu item to open a sub-sub-menu
QQuickMenuItem *verticalSubMenuItem = qobject_cast<QQuickMenuItem *>(alignmentSubMenu->itemAt(1));
@@ -204,7 +188,6 @@ void tst_qquickmenubar::mouse()
QVERIFY(alignmentSubMenu->isVisible());
QVERIFY(verticalSubMenu->isVisible());
QTRY_VERIFY(verticalSubMenu->isOpened());
- waitForMenuListViewPolish(verticalSubMenu);
// trigger a menu item to close the whole chain of menus
QQuickMenuItem *centerMenuItem = qobject_cast<QQuickMenuItem *>(verticalSubMenu->itemAt(1));
@@ -581,90 +564,6 @@ void tst_qquickmenubar::addRemove()
QVERIFY(menuBarItem1.isNull());
}
-// QTBUG-67559
-// Test that Menus declared as children of a MenuBar have the
-// correct delegate when it is declared outside of the MenuBar as a Component.
-void tst_qquickmenubar::delegateFromSeparateComponent()
-{
- QQuickApplicationHelper helper(this, QLatin1String("delegateFromSeparateComponent.qml"));
- QQuickWindow *window = helper.window;
- window->show();
- QVERIFY(QTest::qWaitForWindowActive(window));
-
- const QColor green = QColor::fromRgb(0x00ff00);
-
- QQuickMenuBar *menuBar = window->property("menuBar").value<QQuickMenuBar*>();
- QVERIFY(menuBar);
-
- QQuickMenu *menu = qobject_cast<QQuickMenu*>(menuBar->menuAt(0));
- QVERIFY(menu);
-
- QQuickMenuBarItem *menuBarItem = qobject_cast<QQuickMenuBarItem *>(menu->parentItem());
- QVERIFY(menuBarItem);
-
- QQuickItem *menuBarItemBg = menuBarItem->property("background").value<QQuickItem*>();
- QVERIFY(menuBarItemBg);
- QCOMPARE(menuBarItemBg->property("color").value<QColor>(), green);
-}
-
-void tst_qquickmenubar::openTwice()
-{
- if ((QGuiApplication::platformName() == QLatin1String("offscreen"))
- || (QGuiApplication::platformName() == QLatin1String("minimal")))
- QSKIP("Mouse highlight not functional on offscreen/minimal platforms");
-
- QQmlApplicationEngine engine(testFileUrl("menubar.qml"));
-
- QScopedPointer<QQuickApplicationWindow> window(qobject_cast<QQuickApplicationWindow *>(engine.rootObjects().value(0)));
- QVERIFY(window);
- QVERIFY(QTest::qWaitForWindowActive(window.data()));
-
- centerOnScreen(window.data());
-
- QQuickMenuBar *menuBar = window->property("header").value<QQuickMenuBar *>();
- QVERIFY(menuBar);
-
- QQuickMenu *fileMenuBarMenu = menuBar->menuAt(0);
- QVERIFY(fileMenuBarMenu);
-
- QQuickMenuBarItem *fileMenuBarItem = qobject_cast<QQuickMenuBarItem *>(fileMenuBarMenu->parentItem());
- QVERIFY(fileMenuBarItem);
- QQuickMenuBarPrivate *menuBarPrivate = QQuickMenuBarPrivate::get(menuBar);
- menuBar->polish();
- QVERIFY(menuBarPrivate->polishScheduled);
- QTRY_VERIFY(!menuBarPrivate->polishScheduled);
-
- // Open a menu.
- QTest::mouseClick(window.data(), Qt::LeftButton, Qt::NoModifier,
- fileMenuBarItem->mapToScene(QPointF(fileMenuBarItem->width() / 2, fileMenuBarItem->height() / 2)).toPoint());
- QVERIFY(fileMenuBarItem->isHighlighted());
- QVERIFY(fileMenuBarMenu->isVisible());
- QTRY_VERIFY(fileMenuBarMenu->isOpened());
- waitForMenuListViewPolish(fileMenuBarMenu);
-
- // Click on an item to close the menu.
- QQuickMenuItem *openMenuItem = qobject_cast<QQuickMenuItem *>(fileMenuBarMenu->itemAt(0));
- QVERIFY(openMenuItem);
- QTest::mouseClick(window.data(), Qt::LeftButton, Qt::NoModifier,
- openMenuItem->mapToScene(QPointF(openMenuItem->width() / 2, openMenuItem->height() / 2)).toPoint());
- QVERIFY(!fileMenuBarItem->isHighlighted());
- QTRY_VERIFY(!fileMenuBarMenu->isVisible());
-
- // Re-open the menu. It should open with one click of the QQuickMenuBarItem.
- QTest::mouseClick(window.data(), Qt::LeftButton, Qt::NoModifier,
- fileMenuBarItem->mapToScene(QPointF(fileMenuBarItem->width() / 2, fileMenuBarItem->height() / 2)).toPoint());
- QVERIFY(fileMenuBarItem->isHighlighted());
- QVERIFY(fileMenuBarMenu->isVisible());
- QTRY_VERIFY(fileMenuBarMenu->isOpened());
- waitForMenuListViewPolish(fileMenuBarMenu);
-
- // Click on an item to close the menu.
- QTest::mouseClick(window.data(), Qt::LeftButton, Qt::NoModifier,
- openMenuItem->mapToScene(QPointF(openMenuItem->width() / 2, openMenuItem->height() / 2)).toPoint());
- QVERIFY(!fileMenuBarItem->isHighlighted());
- QTRY_VERIFY(!fileMenuBarMenu->isVisible());
-}
-
QTEST_QUICKCONTROLS_MAIN(tst_qquickmenubar)
#include "tst_qquickmenubar.moc"
diff --git a/tests/auto/qquickpopup/tst_qquickpopup.cpp b/tests/auto/qquickpopup/tst_qquickpopup.cpp
index 6c860d6e..9230116b 100644
--- a/tests/auto/qquickpopup/tst_qquickpopup.cpp
+++ b/tests/auto/qquickpopup/tst_qquickpopup.cpp
@@ -36,7 +36,6 @@
#include <QtTest/qtest.h>
#include <QtTest/qsignalspy.h>
-#include "../shared/menuutil.h"
#include "../shared/util.h"
#include "../shared/visualtestutil.h"
#include "../shared/qtest_quickcontrols.h"
@@ -859,7 +858,6 @@ void tst_QQuickPopup::grabber()
menu->open();
QTRY_COMPARE(menu->isOpened(), true);
- waitForMenuListViewPolish(menu);
QCOMPARE(popup->isVisible(), false);
QCOMPARE(combo->isVisible(), false);
@@ -882,7 +880,6 @@ void tst_QQuickPopup::grabber()
menu->open();
QTRY_COMPARE(menu->isOpened(), true);
- waitForMenuListViewPolish(menu);
QCOMPARE(popup->isVisible(), false);
QCOMPARE(combo->isVisible(), false);
@@ -974,7 +971,6 @@ void tst_QQuickPopup::closeOnEscapeWithNestedPopups()
QQuickPopup *optionsMenu = window->findChild<QQuickPopup*>("optionsMenu");
QVERIFY(optionsMenu);
QTRY_VERIFY(optionsMenu->isVisible());
- waitForMenuListViewPolish(optionsMenu);
QQuickItem *settingsMenuItem = window->findChild<QQuickItem*>("settingsMenuItem");
QVERIFY(settingsMenuItem);
diff --git a/tests/auto/shared/menuutil.h b/tests/auto/shared/menuutil.h
deleted file mode 100644
index 067b7e55..00000000
--- a/tests/auto/shared/menuutil.h
+++ /dev/null
@@ -1,61 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2018 The Qt Company Ltd.
-** Contact: http://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL3$
-** 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 http://www.qt.io/terms-conditions. For further
-** information use the contact form at http://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPLv3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or later as published by the Free
-** Software Foundation and appearing in the file LICENSE.GPL included in
-** the packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 2.0 requirements will be
-** met: http://www.gnu.org/licenses/gpl-2.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QQUICKMENUTUTIL_H
-#define QQUICKMENUTUTIL_H
-
-#include <QtQuick/private/qquickitem_p.h>
-#include <QtQuick/private/qquicklistview_p.h>
-
-/*
- QQuickMenuPrivate::insertItem() culls newly added items to ensure
- that they don't show up when they shouldn't, but now that QQuickMenu
- postpones item creation until after component completion (QTBUG-67559),
- the culled flag being set means that mouse events don't get delivered
- to menu items (see the culled check in QQuickWindowPrivate::pointerTargets()).
-
- ListView unculls the items in FxViewItem::setVisible(), and waiting until
- polishes are finished is a reliable way of ensuring that that happens
- before we send mouse events.
-*/
-#define waitForMenuListViewPolish(menu) \
-{ \
- const auto listView = qobject_cast<QQuickListView*>((menu)->contentItem()); \
- Q_ASSERT(listView); \
- QTRY_COMPARE(QQuickItemPrivate::get(listView)->polishScheduled, false); \
-}
-
-#endif // QQUICKMENUTUTIL_H