diff options
author | J-P Nurmi <jpnurmi@qt.io> | 2017-11-06 20:32:26 +0100 |
---|---|---|
committer | J-P Nurmi <jpnurmi@qt.io> | 2017-11-06 20:32:26 +0100 |
commit | 501d45012f746d843e0144c78202297a577758bc (patch) | |
tree | 5c2b125327d49e3495b5f47995d93fb4215acbb4 /tests | |
parent | 9e1b044afa994cdd77fd256cea78cd144e804d76 (diff) | |
parent | 442843db6f5dce6b594448d43b380c9b884a7c91 (diff) |
Merge remote-tracking branch 'origin/5.10' into dev
Conflicts:
src/quickcontrols2/qquickchecklabel.cpp
src/quickcontrols2/qquickchecklabel_p.h
src/quickcontrols2/qquickmnemoniclabel_p.h
src/quicktemplates2/qquickbuttongroup_p.h
src/quicktemplates2/qquickspinbox.cpp
src/quicktemplates2/qquickswipedelegate.cpp
Change-Id: I1278b78dcaf25be5698f34751193b83dc951eb3c
Diffstat (limited to 'tests')
24 files changed, 355 insertions, 61 deletions
diff --git a/tests/auto/controls/data/tst_abstractbutton.qml b/tests/auto/controls/data/tst_abstractbutton.qml index f4a89367..f71a3725 100644 --- a/tests/auto/controls/data/tst_abstractbutton.qml +++ b/tests/auto/controls/data/tst_abstractbutton.qml @@ -410,7 +410,7 @@ TestCase { verify(control) control.text = "&Hello" - compare(control.text, "Hello") // ### TODO: visualize mnemonics + compare(control.text, "&Hello") var clickSpy = signalSpy.createObject(control, {target: control, signalName: "clicked"}) verify(clickSpy.valid) @@ -427,7 +427,7 @@ TestCase { compare(clickSpy.count, 2) control.text = "Te&st" - compare(control.text, "Test") // ### TODO: visualize mnemonics + compare(control.text, "Te&st") keyClick(Qt.Key_H, Qt.AltModifier) compare(clickSpy.count, 2) diff --git a/tests/auto/controls/data/tst_container.qml b/tests/auto/controls/data/tst_container.qml index 94f22ad2..c5e74eeb 100644 --- a/tests/auto/controls/data/tst_container.qml +++ b/tests/auto/controls/data/tst_container.qml @@ -128,7 +128,7 @@ TestCase { } Component { - id: repeaterContainer + id: repeaterContainer1 Container { id: container Item { objectName: "0" } @@ -143,9 +143,33 @@ TestCase { } } + Component { + id: repeaterContainer2 + Container { + id: container + contentItem: Item { + Repeater { + model: container.contentModel + } + Rectangle { objectName: "extra" } + } + Rectangle { objectName: "0" } + Rectangle { objectName: "1" } + Rectangle { objectName: "2" } + Rectangle { objectName: "3" } + } + } + + function test_repeater_data() { + return [ + { tag: "1", component: repeaterContainer1 }, + { tag: "2", component: repeaterContainer2 } + ] + } + // don't crash (QTBUG-61310) - function test_repeater() { - var control = createTemporaryObject(repeaterContainer) + function test_repeater(data) { + var control = createTemporaryObject(data.component) verify(control) compare(control.itemAt(0).objectName, "0") diff --git a/tests/auto/controls/data/tst_pageindicator.qml b/tests/auto/controls/data/tst_pageindicator.qml index f3151882..dc411e45 100644 --- a/tests/auto/controls/data/tst_pageindicator.qml +++ b/tests/auto/controls/data/tst_pageindicator.qml @@ -122,18 +122,30 @@ TestCase { // test also clicking outside delegates => the nearest should be selected for (var i = 0; i < control.count; ++i) { var child = control.contentItem.children[i] - for (var x = -2; x <= child.width + 2; ++x) { - for (var y = -2; y <= child.height + 2; ++y) { - control.currentIndex = -1 - compare(control.currentIndex, -1) - - var pos = control.mapFromItem(child, x, y) - if (data.touch) - touch.press(0, control, pos.x, pos.y).commit().release(0, control, pos.x, pos.y).commit() - else - mouseClick(control, pos.x, pos.y, Qt.LeftButton) - compare(control.currentIndex, i) - } + + var points = [ + Qt.point(child.width / 2, -2), // top + Qt.point(-2, child.height / 2), // left + Qt.point(child.width + 2, child.height / 2), // right + Qt.point(child.width / 2, child.height + 2), // bottom + + Qt.point(-2, -2), // top-left + Qt.point(child.width + 2, -2), // top-right + Qt.point(-2, child.height + 2), // bottom-left + Qt.point(child.width + 2, child.height + 2), // bottom-right + ] + + for (var j = 0; j < points.length; ++j) { + control.currentIndex = -1 + compare(control.currentIndex, -1) + + var point = points[j] + var pos = control.mapFromItem(child, x, y) + if (data.touch) + touch.press(0, control, pos.x, pos.y).commit().release(0, control, pos.x, pos.y).commit() + else + mouseClick(control, pos.x, pos.y, Qt.LeftButton) + compare(control.currentIndex, i) } } } diff --git a/tests/auto/controls/data/tst_scrollbar.qml b/tests/auto/controls/data/tst_scrollbar.qml index a8d33cea..90fe9468 100644 --- a/tests/auto/controls/data/tst_scrollbar.qml +++ b/tests/auto/controls/data/tst_scrollbar.qml @@ -704,7 +704,7 @@ TestCase { } function test_overshoot() { - var container = flickable.createObject(testCase) + var container = createTemporaryObject(flickable, testCase) verify(container) waitForRendering(container) @@ -733,8 +733,6 @@ TestCase { horizontal.position = 0.8 compare(horizontal.contentItem.x, horizontal.leftPadding + 0.8 * horizontal.availableWidth) compare(horizontal.contentItem.width, 0.2 * horizontal.availableWidth) - - container.destroy() } function test_orientation() { diff --git a/tests/auto/controls/data/tst_spinbox.qml b/tests/auto/controls/data/tst_spinbox.qml index a1d1b7ba..9568da1a 100644 --- a/tests/auto/controls/data/tst_spinbox.qml +++ b/tests/auto/controls/data/tst_spinbox.qml @@ -367,6 +367,9 @@ TestCase { var control = createTemporaryObject(spinBox, testCase) verify(control) + var valueModifiedSpy = signalSpy.createObject(control, {target: control, signalName: "valueModified"}) + verify(valueModifiedSpy.valid) + control.contentItem.forceActiveFocus() compare(control.contentItem.activeFocus, true) @@ -375,6 +378,7 @@ TestCase { keyClick(Qt.Key_5) keyClick(Qt.Key_Return) compare(control.value, 0) + compare(valueModifiedSpy.count, 0) control.editable = true compare(control.editable, true) @@ -382,6 +386,7 @@ TestCase { keyClick(Qt.Key_5) keyClick(Qt.Key_Return) compare(control.value, 5) + compare(valueModifiedSpy.count, 1) } function test_wheel_data() { diff --git a/tests/auto/controls/data/tst_textfield.qml b/tests/auto/controls/data/tst_textfield.qml index 6a40f053..0fee7363 100644 --- a/tests/auto/controls/data/tst_textfield.qml +++ b/tests/auto/controls/data/tst_textfield.qml @@ -420,4 +420,19 @@ TestCase { mouseClick(control, rect.x + rect.width / 2, rect.y + rect.height / 2) compare(control.selectedText, "Qt Quick Controls 2 TextArea") } + + // QTBUG-64048 + function test_rightClick() { + var control = createTemporaryObject(textField, testCase, {text: "TextField", selectByMouse: true}) + verify(control) + + control.selectAll() + compare(control.selectedText, "TextField") + + mouseClick(control, control.width / 2, control.height / 2, Qt.RightButton) + compare(control.selectedText, "TextField") + + mouseClick(control, control.width / 2, control.height / 2, Qt.LeftButton | Qt.RightButton) + compare(control.selectedText, "") + } } diff --git a/tests/auto/controls/data/tst_tooltip.qml b/tests/auto/controls/data/tst_tooltip.qml index bd46fabd..e7cc6787 100644 --- a/tests/auto/controls/data/tst_tooltip.qml +++ b/tests/auto/controls/data/tst_tooltip.qml @@ -298,4 +298,35 @@ TestCase { keyPress(Qt.Key_A) compare(shortcutActivatedSpy.count, 1) } + + Component { + id: hoverComponent + MouseArea { + id: hoverArea + property alias tooltip: tooltip + hoverEnabled: true + width: testCase.width + height: testCase.height + ToolTip { + id: tooltip + x: 10; y: 10 + width: 10; height: 10 + visible: hoverArea.containsMouse + } + } + } + + // QTBUG-63644 + function test_hover() { + var root = createTemporaryObject(hoverComponent, testCase) + verify(root) + + var tooltip = root.tooltip + verify(tooltip) + + for (var pos = 0; pos <= 25; pos += 5) { + mouseMove(root, pos, pos) + verify(tooltip.visible) + } + } } diff --git a/tests/auto/qquickapplicationwindow/data/clearfocusondestruction.qml b/tests/auto/qquickapplicationwindow/data/clearfocusondestruction.qml index 3589439e..a992e0be 100644 --- a/tests/auto/qquickapplicationwindow/data/clearfocusondestruction.qml +++ b/tests/auto/qquickapplicationwindow/data/clearfocusondestruction.qml @@ -1,12 +1,22 @@ /**************************************************************************** ** ** Copyright (C) 2017 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ +** Contact: https://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: +** 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 diff --git a/tests/auto/qquickdrawer/BLACKLIST b/tests/auto/qquickdrawer/BLACKLIST deleted file mode 100644 index b302c76b..00000000 --- a/tests/auto/qquickdrawer/BLACKLIST +++ /dev/null @@ -1,14 +0,0 @@ -# See qtbase/src/testlib/qtestblacklist.cpp for format - -# https://bugreports.qt.io/browse/QTBUG-62628 -[multiple] -* - -[touch] -* - -[multiTouch] -* - -[grabber] -* diff --git a/tests/auto/qquickiconimage/data/imageProvider.qml b/tests/auto/qquickiconimage/data/imageProvider.qml new file mode 100644 index 00000000..0d7d3033 --- /dev/null +++ b/tests/auto/qquickiconimage/data/imageProvider.qml @@ -0,0 +1,9 @@ +import QtQuick 2.10 +import QtQuick.Controls 2.3 +import QtQuick.Controls.impl 2.3 +import QtQuick.Templates 2.3 as T + +IconLabel { + icon.color: "transparent" + icon.source: "image://provider/red" +} diff --git a/tests/auto/qquickiconimage/tst_qquickiconimage.cpp b/tests/auto/qquickiconimage/tst_qquickiconimage.cpp index 4e4afb13..77b860a2 100644 --- a/tests/auto/qquickiconimage/tst_qquickiconimage.cpp +++ b/tests/auto/qquickiconimage/tst_qquickiconimage.cpp @@ -35,6 +35,7 @@ #include <QtQml/qqmlfileselector.h> #include <QtQuick/qquickitem.h> #include <QtQuick/qquickview.h> +#include <QtQuick/qquickimageprovider.h> #include <QtQuick/qquickitemgrabresult.h> #include <QtQuick/private/qquickimage_p.h> #include <QtQuickControls2/private/qquickiconimage_p.h> @@ -67,6 +68,7 @@ private slots: void svgSourceBindingSourceSize(); void color(); void fileSelectors(); + void imageProvider(); private: void setTheme(); @@ -480,6 +482,43 @@ void tst_qquickiconimage::fileSelectors() QCOMPARE(iconImageWindowGrab.pixelColor(iconImageWindowGrab.width() / 2, iconImageWindowGrab.height() / 2), QColor(Qt::blue)); } +class TestImageProvider : public QQuickImageProvider +{ +public: + TestImageProvider() : QQuickImageProvider(QQuickImageProvider::Pixmap) { } + + QPixmap requestPixmap(const QString &id, QSize *size, const QSize &requestedSize) + { + QSize defaultSize(32, 32); + if (size) + *size = defaultSize; + + QPixmap pixmap(requestedSize.width() > 0 ? requestedSize.width() : defaultSize.width(), + requestedSize.height() > 0 ? requestedSize.height() : defaultSize.height()); + pixmap.fill(QColor(id).rgba()); + return pixmap; + } +}; + +// don't crash (QTBUG-63959) +void tst_qquickiconimage::imageProvider() +{ + QQuickView view; + view.engine()->addImageProvider("provider", new TestImageProvider); + view.setSource(testFileUrl("imageProvider.qml")); + QCOMPARE(view.status(), QQuickView::Ready); + view.show(); + view.requestActivate(); + QVERIFY(QTest::qWaitForWindowActive(&view)); + + QQuickIconImage *iconImage = qobject_cast<QQuickIconImage*>(view.rootObject()->findChild<QQuickIconImage *>()); + QVERIFY(iconImage); + + QImage image = grabItemToImage(iconImage); + QVERIFY(!image.isNull()); + QCOMPARE(image.pixelColor(image.width() / 2, image.height() / 2), QColor(Qt::red)); +} + int main(int argc, char *argv[]) { QGuiApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); diff --git a/tests/auto/qquickpopup/BLACKLIST b/tests/auto/qquickpopup/BLACKLIST deleted file mode 100644 index 47795a8b..00000000 --- a/tests/auto/qquickpopup/BLACKLIST +++ /dev/null @@ -1,10 +0,0 @@ -[overlay] -# QTBUG-62668 -* - -[closePolicy] -# QTBUG-62668 -* - - - diff --git a/tests/auto/sanity/tst_sanity.cpp b/tests/auto/sanity/tst_sanity.cpp index 25e118e3..f6e1c78b 100644 --- a/tests/auto/sanity/tst_sanity.cpp +++ b/tests/auto/sanity/tst_sanity.cpp @@ -139,7 +139,7 @@ private: void tst_Sanity::initTestCase() { QDirIterator it(QQC2_IMPORT_PATH, QStringList() << "*.qml" << "*.js", QDir::Files, QDirIterator::Subdirectories); - const QStringList excludeDirs = QStringList() << QStringLiteral("snippets") << QStringLiteral("designer"); + const QStringList excludeDirs = QStringList() << QStringLiteral("snippets") << QStringLiteral("designer") << QStringLiteral("Sketch"); while (it.hasNext()) { it.next(); QFileInfo info = it.fileInfo(); @@ -280,9 +280,12 @@ static void addTestRows(QQmlEngine *engine, const QString &sourcePath, const QSt if (QFile::exists(filePath)) { QTest::newRow(qPrintable(name)) << QUrl::fromLocalFile(filePath); break; - } else if (QFile::exists(QQmlFile::urlToLocalFileOrQrc(filePath))) { - QTest::newRow(qPrintable(name)) << QUrl(filePath); - break; + } else { + filePath = QQmlFile::urlToLocalFileOrQrc(filePath); + if (!filePath.isEmpty() && QFile::exists(filePath)) { + QTest::newRow(qPrintable(name)) << QUrl(filePath); + break; + } } } } @@ -313,7 +316,7 @@ void tst_Sanity::attachedObjects_data() { QTest::addColumn<QUrl>("url"); addTestRows(&engine, "calendar", "Qt/labs/calendar"); - addTestRows(&engine, "controls", "QtQuick/Controls.2", QStringList() << "CheckIndicator" << "RadioIndicator" << "SwitchIndicator"); + addTestRows(&engine, "controls", "QtQuick/Controls.2"); addTestRows(&engine, "controls/fusion", "QtQuick/Controls.2", QStringList() << "CheckIndicator" << "RadioIndicator" << "SliderGroove" << "SliderHandle" << "SwitchIndicator"); addTestRows(&engine, "controls/material", "QtQuick/Controls.2/Material", QStringList() << "Ripple" << "SliderHandle" << "CheckIndicator" << "RadioIndicator" << "SwitchIndicator" << "BoxShadow" << "ElevationEffect" << "CursorDelegate"); addTestRows(&engine, "controls/universal", "QtQuick/Controls.2/Universal", QStringList() << "CheckIndicator" << "RadioIndicator" << "SwitchIndicator"); diff --git a/tests/auto/snippets/tst_snippets.cpp b/tests/auto/snippets/tst_snippets.cpp index 852c98e9..107759ce 100644 --- a/tests/auto/snippets/tst_snippets.cpp +++ b/tests/auto/snippets/tst_snippets.cpp @@ -103,8 +103,8 @@ void tst_Snippets::verify() QUrl url = QUrl::fromLocalFile(input); component.loadUrl(url); - QObject *root = component.create(); - QVERIFY(root); + QScopedPointer<QObject> root(component.create()); + QVERIFY2(!root.isNull(), qPrintable(component.errorString())); QCOMPARE(component.status(), QQmlComponent::Ready); QVERIFY(component.errors().isEmpty()); @@ -132,10 +132,10 @@ void tst_Snippets::verify() output.insert(index, "-" + applicationStyle.toLower()); } - QQuickWindow *window = qobject_cast<QQuickWindow *>(root); + QQuickWindow *window = qobject_cast<QQuickWindow *>(root.data()); if (!window) { QQuickView *view = new QQuickView; - view->setContent(url, &component, root); + view->setContent(url, &component, root.data()); window = view; } diff --git a/tests/benchmarks/creationtime/tst_creationtime.cpp b/tests/benchmarks/creationtime/tst_creationtime.cpp index c584b9a5..1d300b1c 100644 --- a/tests/benchmarks/creationtime/tst_creationtime.cpp +++ b/tests/benchmarks/creationtime/tst_creationtime.cpp @@ -131,7 +131,7 @@ void tst_CreationTime::controls() void tst_CreationTime::controls_data() { QTest::addColumn<QUrl>("url"); - addTestRows(&engine, "controls", "QtQuick/Controls.2", QStringList() << "ApplicationWindow" << "CheckIndicator" << "RadioIndicator" << "SwitchIndicator"); + addTestRows(&engine, "controls", "QtQuick/Controls.2", QStringList() << "ApplicationWindow"); } void tst_CreationTime::fusion() diff --git a/tests/benchmarks/objectcount/tst_objectcount.cpp b/tests/benchmarks/objectcount/tst_objectcount.cpp index 748cc1c1..fcb6be5b 100644 --- a/tests/benchmarks/objectcount/tst_objectcount.cpp +++ b/tests/benchmarks/objectcount/tst_objectcount.cpp @@ -126,7 +126,7 @@ static void addTestRows(QQmlEngine *engine, const QString &sourcePath, const QSt static void initTestRows(QQmlEngine *engine) { - addTestRows(engine, "controls", "QtQuick/Controls.2", QStringList() << "CheckIndicator" << "RadioIndicator" << "SwitchIndicator"); + addTestRows(engine, "controls", "QtQuick/Controls.2"); addTestRows(engine, "controls/fusion", "QtQuick/Controls.2/Fusion", QStringList() << "ButtonPanel" << "CheckIndicator" << "RadioIndicator" << "SliderGroove" << "SliderHandle" << "SwitchIndicator"); addTestRows(engine, "controls/imagine", "QtQuick/Controls.2/Imagine"); addTestRows(engine, "controls/material", "QtQuick/Controls.2/Material", QStringList() << "Ripple" << "SliderHandle" << "CheckIndicator" << "RadioIndicator" << "SwitchIndicator" << "BoxShadow" << "ElevationEffect" << "CursorDelegate"); diff --git a/tests/manual/manual.pro b/tests/manual/manual.pro index d81ea32f..d23b4494 100644 --- a/tests/manual/manual.pro +++ b/tests/manual/manual.pro @@ -7,4 +7,6 @@ SUBDIRS += \ styles \ testbench +qtConfig(systemtrayicon): SUBDIRS += systemtrayicon + qtHaveModule(widgets): SUBDIRS += viewinqwidget diff --git a/tests/manual/systemtrayicon/images/qt_logo_green_256.png b/tests/manual/systemtrayicon/images/qt_logo_green_256.png Binary files differnew file mode 100644 index 00000000..92243fd5 --- /dev/null +++ b/tests/manual/systemtrayicon/images/qt_logo_green_256.png diff --git a/tests/manual/systemtrayicon/systemtrayicon.cpp b/tests/manual/systemtrayicon/systemtrayicon.cpp new file mode 100644 index 00000000..1866a269 --- /dev/null +++ b/tests/manual/systemtrayicon/systemtrayicon.cpp @@ -0,0 +1,64 @@ +/**************************************************************************** +** +** Copyright (C) 2017 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$ +** +****************************************************************************/ + +#include <QGuiApplication> +#include <QQmlApplicationEngine> + +int main(int argc, char *argv[]) +{ + QGuiApplication app(argc, argv); + + QQmlApplicationEngine engine; + engine.load(QUrl("qrc:/files/systemtrayicon.qml")); + if (engine.rootObjects().isEmpty()) + return -1; + + return app.exec(); +} diff --git a/tests/manual/systemtrayicon/systemtrayicon.pro b/tests/manual/systemtrayicon/systemtrayicon.pro new file mode 100644 index 00000000..24b9caa0 --- /dev/null +++ b/tests/manual/systemtrayicon/systemtrayicon.pro @@ -0,0 +1,9 @@ +TEMPLATE = app +TARGET = systemtrayicon +QT += quick quickcontrols2 + +SOURCES += \ + systemtrayicon.cpp + +RESOURCES += \ + systemtrayicon.qrc diff --git a/tests/manual/systemtrayicon/systemtrayicon.qml b/tests/manual/systemtrayicon/systemtrayicon.qml new file mode 100644 index 00000000..8431ab30 --- /dev/null +++ b/tests/manual/systemtrayicon/systemtrayicon.qml @@ -0,0 +1,89 @@ +/**************************************************************************** +** +** Copyright (C) 2017 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 +import Qt.labs.platform 1.0 + +ApplicationWindow { + id: window + + visible: true + title: "Qt Quick Controls 2 - System Tray Icon" + + MenuBar { + id: menuBar + + Menu { + id: fileMenu + title: qsTr("File") + + MenuItem { + id : quitItem + text : "Quit" + onTriggered: Qt.quit() + } + } + } + + SystemTrayIcon { + visible: true + iconSource: "qrc:/files/images/qt_logo_green_256.png" + + menu: Menu { + MenuItem { + text: qsTr("Quit") + onTriggered: Qt.quit() + } + } + + onActivated: console.log("Activated") + } +} diff --git a/tests/manual/systemtrayicon/systemtrayicon.qrc b/tests/manual/systemtrayicon/systemtrayicon.qrc new file mode 100644 index 00000000..656476d9 --- /dev/null +++ b/tests/manual/systemtrayicon/systemtrayicon.qrc @@ -0,0 +1,6 @@ +<RCC> + <qresource prefix="/files"> + <file>systemtrayicon.qml</file> + <file>images/qt_logo_green_256.png</file> + </qresource> +</RCC> diff --git a/tests/manual/viewinqwidget/main.cpp b/tests/manual/viewinqwidget/main.cpp index c7050bc1..80cbb415 100644 --- a/tests/manual/viewinqwidget/main.cpp +++ b/tests/manual/viewinqwidget/main.cpp @@ -39,6 +39,7 @@ #include <QVBoxLayout> #include <QDebug> #include <QDesktopWidget> +#include <QDir> #include <QGroupBox> #include <QQmlApplicationEngine> #include <QQmlError> @@ -66,8 +67,9 @@ int main(int argc, char *argv[]) } hLayout->addWidget(groupBox); - const QUrl gallerySource(QLatin1String("qrc:/gallery.qml")); - QQmlApplicationEngine engine(gallerySource); + const QString gallerySource = + QDir::cleanPath(QLatin1String(SRCDIR"../../../examples/quickcontrols2/gallery/gallery.qml")); + QQmlApplicationEngine engine(QUrl::fromLocalFile(gallerySource)); QObject *root = engine.rootObjects().value(0, nullptr); if (!root || !root->isWindowType()) { qWarning() << "Load error" << gallerySource; diff --git a/tests/manual/viewinqwidget/viewinqwidget.pro b/tests/manual/viewinqwidget/viewinqwidget.pro index 9b7cba00..649829d4 100644 --- a/tests/manual/viewinqwidget/viewinqwidget.pro +++ b/tests/manual/viewinqwidget/viewinqwidget.pro @@ -2,5 +2,5 @@ QT += qml quick widgets quickwidgets TARGET = viewinqwidget SOURCES += $$PWD/main.cpp OTHER_FILES += main.qml -RESOURCES += viewinqwidget.qrc \ - ../../../examples/controls/gallery/gallery.qrc +RESOURCES += viewinqwidget.qrc +DEFINES += SRCDIR=\\\"$$PWD/\\\" |