aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qquickmenu/data
diff options
context:
space:
mode:
authorMitch Curtis <mitch.curtis@qt.io>2018-04-10 17:40:07 +0200
committerMitch Curtis <mitch.curtis@qt.io>2018-09-05 14:57:22 +0000
commitd5cb26bc56a3b6f6e99c88654d4f7a65f43551ac (patch)
tree614cfe06c0cb5ae35202e7e9e57cb1170fb0eff0 /tests/auto/qquickmenu/data
parent65374a95a33a677740f6e6b25c424b4a4b466b3f (diff)
Menu: ensure the correct delegates are used when created via Component
Don't add items until we're complete, as the delegate could change in the meantime. Instead, add them to contentData and create them when we're complete. Task-number: QTBUG-67559 Change-Id: I5f42129f49de861ff5f15d0069daeda0b4e5017c Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io>
Diffstat (limited to 'tests/auto/qquickmenu/data')
-rw-r--r--tests/auto/qquickmenu/data/delegateFromSeparateComponent.qml107
1 files changed, 107 insertions, 0 deletions
diff --git a/tests/auto/qquickmenu/data/delegateFromSeparateComponent.qml b/tests/auto/qquickmenu/data/delegateFromSeparateComponent.qml
new file mode 100644
index 00000000..48176d37
--- /dev/null
+++ b/tests/auto/qquickmenu/data/delegateFromSeparateComponent.qml
@@ -0,0 +1,107 @@
+/****************************************************************************
+**
+** 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 QtQuick 2.10
+import QtQuick.Controls 2.3
+
+ApplicationWindow {
+ width: 800
+ height: 800
+
+ property alias menu: menu
+
+ Component {
+ id: menuItemComponent
+
+ MenuItem {
+ contentItem: Text {
+ text: parent.text
+ color: "blue"
+ }
+ background: Rectangle {
+ color: "#00ff00"
+ }
+ }
+ }
+
+ Menu {
+ id: menu
+ title: "Root Menu"
+
+ Action {
+ text: "Action Item 1"
+ }
+ Menu {
+ title: "Sub-menu"
+ delegate: menuItemComponent
+
+ Action {
+ text: "Sub-menu Action Item 1"
+ }
+ Menu {
+ title: "Sub-sub-menu"
+ delegate: menuItemComponent
+
+ Action {
+ text: "Sub-sub-menu Action Item 1"
+ }
+ }
+ Action {
+ text: "Sub-menu Action Item 2"
+ }
+ }
+ Action {
+ text: "Action Item 2"
+ }
+
+ delegate: menuItemComponent
+ visible: true
+ }
+}