aboutsummaryrefslogtreecommitdiffstats
path: root/tests/manual
diff options
context:
space:
mode:
authorMitch Curtis <mitch.curtis@theqtcompany.com>2015-11-16 16:06:07 +0100
committerJ-P Nurmi <jpnurmi@theqtcompany.com>2015-12-02 16:16:31 +0000
commitb185fc1ac02d4887d2b187a4043b1fdedb95305e (patch)
tree9650c29786a86d7272541702d59cfa285216f7f0 /tests/manual
parent5823d6230f5b1fbbd27c3b00b334e062a21b3d65 (diff)
Add Menu
An item-based menu derived from QQuickPanel. Eventually we'd like to make Panel itself a QQuickItem, as it makes both the implementation and the actual usage of Menu a lot easier. Change-Id: Ic1bf2a05ab98d9e17824c402ed8326ef65d26c69 Reviewed-by: J-P Nurmi <jpnurmi@theqtcompany.com>
Diffstat (limited to 'tests/manual')
-rw-r--r--tests/manual/gifs/data/qtlabscontrols-menu.qml75
-rw-r--r--tests/manual/gifs/tst_gifs.cpp34
-rw-r--r--tests/manual/testbench/main.qml17
3 files changed, 126 insertions, 0 deletions
diff --git a/tests/manual/gifs/data/qtlabscontrols-menu.qml b/tests/manual/gifs/data/qtlabscontrols-menu.qml
new file mode 100644
index 00000000..65cd3563
--- /dev/null
+++ b/tests/manual/gifs/data/qtlabscontrols-menu.qml
@@ -0,0 +1,75 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 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:BSD$
+** 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.6
+import Qt.labs.controls 1.0
+
+// TODO: restore and finish https://codereview.qt-project.org/#/c/123948/
+ApplicationWindow {
+ width: menu.contentItem.width + 20
+ height: menu.contentItem.height + fileButton.height + 20
+
+ property alias fileButton: fileButton
+ property alias menu: menu
+
+ Button {
+ id: fileButton
+ text: "File"
+ onClicked: menu.show()
+ x: 10
+ y: 10
+ }
+ Menu {
+ id: menu
+ // TODO
+ contentItem.x: fileButton.x
+ contentItem.y: fileButton.y + fileButton.height
+
+ MenuItem {
+ text: "New..."
+ }
+ MenuItem {
+ text: "Open..."
+ }
+ MenuItem {
+ text: "Save"
+ }
+ }
+}
diff --git a/tests/manual/gifs/tst_gifs.cpp b/tests/manual/gifs/tst_gifs.cpp
index 5ae15e79..bd0cc61f 100644
--- a/tests/manual/gifs/tst_gifs.cpp
+++ b/tests/manual/gifs/tst_gifs.cpp
@@ -56,6 +56,7 @@ private slots:
void switchGif();
void button();
void tabBar();
+ void menu();
private:
void moveSmoothly(QQuickWindow *window, const QPoint &from, const QPoint &to, int movements,
@@ -338,6 +339,39 @@ void tst_Gifs::tabBar()
gifRecorder.waitForFinish();
}
+void tst_Gifs::menu()
+{
+ const QString qmlFileName = QStringLiteral("qtlabscontrols-menu.qml");
+
+ GifRecorder gifRecorder;
+ gifRecorder.setDataDirPath(dataDirPath);
+ gifRecorder.setOutputDir(outputDir);
+ gifRecorder.setRecordingDuration(3);
+ gifRecorder.setQmlFileName(qmlFileName);
+ gifRecorder.setHighQuality(true);
+
+ gifRecorder.start();
+
+ QQuickWindow *window = gifRecorder.window();
+ const QQuickItem *fileButton = window->property("fileButton").value<QQuickItem*>();
+ QVERIFY(fileButton);
+
+ const QPoint fileButtonCenter = fileButton->mapToScene(QPointF(fileButton->width() / 2, fileButton->height() / 2)).toPoint();
+ QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, fileButtonCenter, 0);
+ QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, fileButtonCenter, 200);
+
+ const QObject *menu = window->property("menu").value<QObject*>();
+ QVERIFY(menu);
+ const QQuickItem *menuContentItem = menu->property("contentItem").value<QQuickItem*>();
+ QVERIFY(menuContentItem);
+
+ const QPoint lastItemPos = menuContentItem->mapToScene(QPointF(menuContentItem->width() / 2, menuContentItem->height() - 10)).toPoint();
+ QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, lastItemPos, 1000);
+ QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, lastItemPos, 300);
+
+ gifRecorder.waitForFinish();
+}
+
QTEST_MAIN(tst_Gifs)
#include "tst_gifs.moc"
diff --git a/tests/manual/testbench/main.qml b/tests/manual/testbench/main.qml
index 6f842c9c..b375a098 100644
--- a/tests/manual/testbench/main.qml
+++ b/tests/manual/testbench/main.qml
@@ -62,6 +62,7 @@ ApplicationWindow {
ToolButton {
text: "Normal"
+ onClicked: menu.visible ? menu.hide() : menu.show()
}
ToolButton {
text: "Pressed"
@@ -97,6 +98,22 @@ ApplicationWindow {
}
}
+ Menu {
+ id: menu
+ contentItem.x: 1
+ contentItem.y: header.height
+
+ MenuItem {
+ text: "Option 1"
+ }
+ MenuItem {
+ text: "Option 2"
+ }
+ MenuItem {
+ text: "Option 3"
+ }
+ }
+
Flickable {
anchors.fill: parent
topMargin: 30