aboutsummaryrefslogtreecommitdiffstats
path: root/tests/manual
diff options
context:
space:
mode:
authorJ-P Nurmi <jpnurmi@qt.io>2016-10-07 17:20:24 +0200
committerJ-P Nurmi <jpnurmi@qt.io>2016-10-07 17:24:19 +0200
commita3b706531b98c64137acaebf26756828cd43a2a0 (patch)
treeb04490213d60519b8a0c90f9c166eef862ed185b /tests/manual
parent2f4a059881dbec289d86abc7456b42d5eec77ceb (diff)
parentc2b7e55af43518ae1898eddf8611ef617149ca8a (diff)
Merge remote-tracking branch 'origin/5.7' into 5.8
Conflicts: src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-progressbar-disabled.qml src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-progressbar-normal.qml src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-radiobutton-checked.qml src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-radiobutton-disabled.qml src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-radiobutton-focused.qml src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-radiobutton-normal.qml src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-rangeslider-disabled.qml src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-rangeslider-first-handle-focused.qml src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-rangeslider-normal.qml src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-rangeslider-second-handle-focused.qml src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-rangeslider-second-handle.qml src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-slider-disabled.qml src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-slider-focused.qml src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-slider-normal.qml src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-tabbar-explicit.qml src/quicktemplates2/qquickmenu.cpp tests/auto/controls/data/tst_buttongroup.qml tests/auto/controls/data/tst_swipedelegate.qml Change-Id: Ib6042a0ad716f557927e7412d17ea8957d06c015
Diffstat (limited to 'tests/manual')
-rw-r--r--tests/manual/gifs/data/qtquickcontrols2-checkbox.qml8
-rw-r--r--tests/manual/gifs/data/qtquickcontrols2-checkdelegate-tristate.qml81
-rw-r--r--tests/manual/gifs/data/qtquickcontrols2-progressbar-indeterminate.qml57
-rw-r--r--tests/manual/gifs/data/qtquickcontrols2-progressbar.qml71
-rw-r--r--tests/manual/gifs/data/qtquickcontrols2-radiobutton.qml73
-rw-r--r--tests/manual/gifs/data/qtquickcontrols2-scrollbar.qml70
-rw-r--r--tests/manual/gifs/data/qtquickcontrols2-scrollindicator.qml67
-rw-r--r--tests/manual/gifs/data/qtquickcontrols2-slider-snap.qml79
-rw-r--r--tests/manual/gifs/tst_gifs.cpp233
-rw-r--r--tests/manual/manual.pro1
-rw-r--r--tests/manual/screenshots/qtquickcontrols2.conf2
-rw-r--r--tests/manual/screenshots/screenshots.cpp62
-rw-r--r--tests/manual/screenshots/screenshots.pro13
-rw-r--r--tests/manual/screenshots/screenshots.qml164
14 files changed, 947 insertions, 34 deletions
diff --git a/tests/manual/gifs/data/qtquickcontrols2-checkbox.qml b/tests/manual/gifs/data/qtquickcontrols2-checkbox.qml
index ef53721d..3195c1c9 100644
--- a/tests/manual/gifs/data/qtquickcontrols2-checkbox.qml
+++ b/tests/manual/gifs/data/qtquickcontrols2-checkbox.qml
@@ -48,8 +48,8 @@ Window {
height: column.implicitHeight
visible: true
- property alias second: second
- property alias third: third
+ property alias control2: control2
+ property alias control3: control3
ColumnLayout {
id: column
@@ -60,11 +60,11 @@ Window {
text: qsTr("First")
}
CheckBox {
- id: second
+ id: control2
text: qsTr("Second")
}
CheckBox {
- id: third
+ id: control3
checked: true
text: qsTr("Third")
}
diff --git a/tests/manual/gifs/data/qtquickcontrols2-checkdelegate-tristate.qml b/tests/manual/gifs/data/qtquickcontrols2-checkdelegate-tristate.qml
new file mode 100644
index 00000000..eddb71d5
--- /dev/null
+++ b/tests/manual/gifs/data/qtquickcontrols2-checkdelegate-tristate.qml
@@ -0,0 +1,81 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 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.7
+import QtQuick.Controls 2.0
+import QtQuick.Layouts 1.1
+import QtQuick.Window 2.0
+
+Window {
+ id: window
+ width: 170
+ height: column.implicitHeight
+ visible: true
+
+ property alias english: english
+ property alias norwegian: norwegian
+
+ ColumnLayout {
+ id: column
+ anchors.fill: parent
+
+ CheckDelegate {
+ text: qsTr("Languages")
+ checkState: english.checked && norwegian.checked
+ ? Qt.Checked : (english.checked || norwegian.checked) ? Qt.PartiallyChecked : Qt.Unchecked
+ tristate: true
+ Layout.fillWidth: true
+ }
+ CheckDelegate {
+ id: english
+ text: qsTr("English")
+ checked: true
+ leftPadding: indicator.width + 14
+ Layout.fillWidth: true
+ }
+ CheckDelegate {
+ id: norwegian
+ text: qsTr("Norwegian")
+ checked: true
+ leftPadding: indicator.width + 14
+ Layout.fillWidth: true
+ }
+ }
+}
diff --git a/tests/manual/gifs/data/qtquickcontrols2-progressbar-indeterminate.qml b/tests/manual/gifs/data/qtquickcontrols2-progressbar-indeterminate.qml
new file mode 100644
index 00000000..0785b279
--- /dev/null
+++ b/tests/manual/gifs/data/qtquickcontrols2-progressbar-indeterminate.qml
@@ -0,0 +1,57 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 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.7
+import QtQuick.Window 2.0
+import QtQuick.Controls 2.0
+
+Window {
+ width: progressBar.implicitWidth
+ height: 64
+ visible: true
+
+ property alias progressBar: progressBar
+
+ ProgressBar {
+ id: progressBar
+ indeterminate: true
+ anchors.centerIn: parent
+ }
+}
diff --git a/tests/manual/gifs/data/qtquickcontrols2-progressbar.qml b/tests/manual/gifs/data/qtquickcontrols2-progressbar.qml
new file mode 100644
index 00000000..13d5075d
--- /dev/null
+++ b/tests/manual/gifs/data/qtquickcontrols2-progressbar.qml
@@ -0,0 +1,71 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 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.7
+import QtQuick.Window 2.0
+import QtQuick.Controls 2.0
+
+Window {
+ width: progressBar.implicitWidth
+ height: 64
+ visible: true
+
+ property alias progressBar: progressBar
+
+ ProgressBar {
+ id: progressBar
+ value: 0.5
+ anchors.centerIn: parent
+
+ Timer {
+ running: true
+ interval: 500
+ onTriggered: animation.start()
+ }
+
+ NumberAnimation {
+ id: animation
+ target: progressBar
+ property: "value"
+ to: 1
+ duration: 2000
+ }
+ }
+}
diff --git a/tests/manual/gifs/data/qtquickcontrols2-radiobutton.qml b/tests/manual/gifs/data/qtquickcontrols2-radiobutton.qml
new file mode 100644
index 00000000..576668f3
--- /dev/null
+++ b/tests/manual/gifs/data/qtquickcontrols2-radiobutton.qml
@@ -0,0 +1,73 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 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 QtQuick.Controls 2.0
+import QtQuick.Layouts 1.1
+import QtQuick.Window 2.0
+
+Window {
+ width: column.implicitWidth
+ height: column.implicitHeight
+ visible: true
+
+ property alias control1: control1
+ property alias control2: control2
+ property alias control3: control3
+
+ ColumnLayout {
+ id: column
+ anchors.centerIn: parent
+
+ RadioButton {
+ id: control1
+ text: qsTr("First")
+ checked: true
+ }
+ RadioButton {
+ id: control2
+ text: qsTr("Second")
+ }
+ RadioButton {
+ id: control3
+ text: qsTr("Third")
+ }
+ }
+}
diff --git a/tests/manual/gifs/data/qtquickcontrols2-scrollbar.qml b/tests/manual/gifs/data/qtquickcontrols2-scrollbar.qml
new file mode 100644
index 00000000..ce198685
--- /dev/null
+++ b/tests/manual/gifs/data/qtquickcontrols2-scrollbar.qml
@@ -0,0 +1,70 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 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 QtQuick.Window 2.0
+import QtQuick.Controls 2.0
+
+Window {
+ width: 100
+ height: 120
+ visible: true
+ color: "#eeeeee"
+
+ property alias scrollBar: scrollBar
+
+ ListView {
+ anchors.fill: parent
+
+ ScrollBar.vertical: ScrollBar {
+ id: scrollBar
+ active: true
+ }
+
+ model: 10
+ delegate: Label {
+ text: qsTr("Item %1").arg(index + 1)
+ width: 100
+ height: 40
+ leftPadding: 10
+ verticalAlignment: Text.AlignVCenter
+ }
+ }
+}
diff --git a/tests/manual/gifs/data/qtquickcontrols2-scrollindicator.qml b/tests/manual/gifs/data/qtquickcontrols2-scrollindicator.qml
new file mode 100644
index 00000000..091e5250
--- /dev/null
+++ b/tests/manual/gifs/data/qtquickcontrols2-scrollindicator.qml
@@ -0,0 +1,67 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 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 QtQuick.Window 2.0
+import QtQuick.Controls 2.0
+
+Window {
+ width: 100
+ height: 120
+ visible: true
+ color: "#eeeeee"
+
+ ListView {
+ anchors.fill: parent
+
+ ScrollIndicator.vertical: ScrollIndicator {
+ active: true
+ }
+
+ model: 10
+ delegate: Label {
+ text: qsTr("Item %1").arg(index + 1)
+ width: 100
+ height: 40
+ leftPadding: 10
+ verticalAlignment: Text.AlignVCenter
+ }
+ }
+}
diff --git a/tests/manual/gifs/data/qtquickcontrols2-slider-snap.qml b/tests/manual/gifs/data/qtquickcontrols2-slider-snap.qml
new file mode 100644
index 00000000..aa2351fc
--- /dev/null
+++ b/tests/manual/gifs/data/qtquickcontrols2-slider-snap.qml
@@ -0,0 +1,79 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 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.7
+import QtQuick.Window 2.0
+import QtQuick.Controls 2.0
+
+Window {
+ width: slider.implicitWidth
+ height: slider.implicitHeight
+ visible: true
+
+ property alias slider: slider
+
+ Slider {
+ id: slider
+ stepSize: 0.2
+ anchors.centerIn: parent
+
+ Rectangle {
+ anchors.fill: slider.handle
+ radius: width / 2
+ color: slider.pressed ? "#aa666666" : "transparent"
+ }
+
+ contentItem: Item {
+ Repeater {
+ id: repeater
+ model: 6
+
+ Rectangle {
+ x: ((slider.contentItem.width - slider.handle.width) * (index / (repeater.count - 1)))
+ - width / 2 + slider.handle.width / 2
+ y: parent.height
+ width: 1
+ height: 4
+ color: "#888"
+ }
+ }
+ }
+ }
+}
diff --git a/tests/manual/gifs/tst_gifs.cpp b/tests/manual/gifs/tst_gifs.cpp
index 2eebc180..9de401cb 100644
--- a/tests/manual/gifs/tst_gifs.cpp
+++ b/tests/manual/gifs/tst_gifs.cpp
@@ -51,6 +51,8 @@ private slots:
void tumblerWrap();
void slider();
+ void sliderSnap_data();
+ void sliderSnap();
void rangeSlider();
void busyIndicator();
void switchGif();
@@ -65,8 +67,14 @@ private slots:
void delegates();
void dial_data();
void dial();
- void checkBox();
- void checkBoxTriState();
+ void scrollBar();
+ void scrollIndicator();
+ void progressBar_data();
+ void progressBar();
+ void triState_data();
+ void triState();
+ void checkables_data();
+ void checkables();
private:
void moveSmoothly(QQuickWindow *window, const QPoint &from, const QPoint &to, int movements,
@@ -97,8 +105,8 @@ void tst_Gifs::moveSmoothly(QQuickWindow *window, const QPoint &from, const QPoi
int yDifference = to.y() - from.y();
for (int movement = 0; movement < movements; ++movement) {
QPoint pos = QPoint(
- from.x() + curve.valueForProgress(movement / qreal(qAbs(xDifference))) * xDifference,
- from.y() + curve.valueForProgress(movement / qreal(qAbs(yDifference))) * yDifference);
+ from.x() + qRound(curve.valueForProgress(movement / qreal(qAbs(xDifference))) * xDifference),
+ from.y() + qRound(curve.valueForProgress(movement / qreal(qAbs(yDifference))) * yDifference));
QTest::mouseMove(window, pos, movementDelay);
}
}
@@ -236,6 +244,58 @@ void tst_Gifs::slider()
gifRecorder.waitForFinish();
}
+void tst_Gifs::sliderSnap_data()
+{
+ QTest::addColumn<QString>("gifBaseName");
+ QTest::addColumn<int>("snapMode");
+ QTest::newRow("NoSnap") << "qtquickcontrols2-slider-nosnap" << 0;
+ QTest::newRow("SnapAlways") << "qtquickcontrols2-slider-snapalways" << 1;
+ QTest::newRow("SnapOnRelease") << "qtquickcontrols2-slider-snaponrelease" << 2;
+}
+
+void tst_Gifs::sliderSnap()
+{
+ QFETCH(QString, gifBaseName);
+ QFETCH(int, snapMode);
+
+ GifRecorder gifRecorder;
+ gifRecorder.setDataDirPath(dataDirPath);
+ gifRecorder.setOutputDir(outputDir);
+ gifRecorder.setRecordingDuration(8);
+ gifRecorder.setHighQuality(true);
+ gifRecorder.setQmlFileName("qtquickcontrols2-slider-snap.qml");
+ gifRecorder.setOutputFileBaseName(gifBaseName);
+
+ gifRecorder.start();
+
+ QQuickWindow *window = gifRecorder.window();
+ QQuickItem *slider = window->property("slider").value<QQuickItem*>();
+ QVERIFY(slider);
+ QVERIFY(slider->setProperty("snapMode", QVariant(snapMode)));
+ QCOMPARE(slider->property("snapMode").toInt(), snapMode);
+ QQuickItem *handle = slider->property("handle").value<QQuickItem*>();
+ QVERIFY(handle);
+
+ const QPoint startPos(slider->property("leftPadding").toReal(), slider->height() / 2);
+ const int trackWidth = slider->property("availableWidth").toReal();
+
+ QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, startPos, 200);
+ QPoint pos1 = startPos + QPoint(trackWidth * 0.3, 0);
+ moveSmoothly(window, startPos, pos1, pos1.x() - startPos.x(), QEasingCurve::OutQuint, 30);
+ QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, pos1, 0);
+
+ QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, startPos, 400);
+ const QPoint pos2 = startPos + QPoint(trackWidth * 0.6, 0);
+ moveSmoothly(window, pos1, pos2, pos2.x() - pos1.x(), QEasingCurve::OutQuint, 30);
+ QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, pos2, 0);
+
+ QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, pos2, 400);
+ moveSmoothly(window, pos2, startPos, qAbs(startPos.x() - pos2.x()) / 2, QEasingCurve::OutQuint, 30);
+ QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, startPos, 0);
+
+ gifRecorder.waitForFinish();
+}
+
void tst_Gifs::rangeSlider()
{
GifRecorder gifRecorder;
@@ -612,41 +672,61 @@ void tst_Gifs::dial()
gifRecorder.waitForFinish();
}
-void tst_Gifs::checkBox()
+void tst_Gifs::checkables_data()
+{
+ QTest::addColumn<QString>("name");
+ QTest::addColumn<QVector<int> >("pressIndices");
+
+ QTest::newRow("checkbox") << "checkbox" << (QVector<int>() << 1 << 2 << 2 << 1);
+ QTest::newRow("radiobutton") << "radiobutton" << (QVector<int>() << 1 << 2 << 1 << 0);
+}
+
+void tst_Gifs::checkables()
{
+ QFETCH(QString, name);
+ QFETCH(QVector<int>, pressIndices);
+
GifRecorder gifRecorder;
gifRecorder.setDataDirPath(dataDirPath);
gifRecorder.setOutputDir(outputDir);
- gifRecorder.setRecordingDuration(5);
- gifRecorder.setQmlFileName("qtquickcontrols2-checkbox.qml");
+ gifRecorder.setRecordingDuration(6);
+ gifRecorder.setQmlFileName(QString::fromLatin1("qtquickcontrols2-%1.qml").arg(name));
gifRecorder.start();
QQuickWindow *window = gifRecorder.window();
- QQuickItem *second = window->property("second").value<QQuickItem*>();
- QVERIFY(second);
- QQuickItem *third = window->property("third").value<QQuickItem*>();
- QVERIFY(third);
-
- QTest::mouseClick(window, Qt::LeftButton, Qt::NoModifier,
- second->mapToScene(QPointF(second->width() / 2, second->height() / 2)).toPoint(), 400);
- QTest::mouseClick(window, Qt::LeftButton, Qt::NoModifier,
- third->mapToScene(QPointF(third->width() / 2, third->height() / 2)).toPoint(), 800);
- QTest::mouseClick(window, Qt::LeftButton, Qt::NoModifier,
- third->mapToScene(QPointF(third->width() / 2, third->height() / 2)).toPoint(), 800);
- QTest::mouseClick(window, Qt::LeftButton, Qt::NoModifier,
- second->mapToScene(QPointF(second->width() / 2, second->height() / 2)).toPoint(), 800);
+
+ for (int i = 0; i < pressIndices.size(); ++i) {
+ const int pressIndex = pressIndices.at(i);
+ const char *controlId = qPrintable(QString::fromLatin1("control%1").arg(pressIndex + 1));
+ QQuickItem *control = window->property(controlId).value<QQuickItem*>();
+ QVERIFY(control);
+
+ const QPoint pos = control->mapToScene(QPointF(control->width() / 2, control->height() / 2)).toPoint();
+ QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, pos, 800);
+ QTest::mouseClick(window, Qt::LeftButton, Qt::NoModifier, pos, 300);
+ }
gifRecorder.waitForFinish();
}
-void tst_Gifs::checkBoxTriState()
+void tst_Gifs::triState_data()
+{
+ QTest::addColumn<QString>("name");
+
+ QTest::newRow("checkbox-tristate") << "checkbox-tristate";
+ QTest::newRow("checkdelegate-tristate") << "checkdelegate-tristate";
+}
+
+void tst_Gifs::triState()
{
+ QFETCH(QString, name);
+
GifRecorder gifRecorder;
gifRecorder.setDataDirPath(dataDirPath);
gifRecorder.setOutputDir(outputDir);
gifRecorder.setRecordingDuration(6);
- gifRecorder.setQmlFileName("qtquickcontrols2-checkbox-tristate.qml");
+ gifRecorder.setQmlFileName(QString::fromLatin1("qtquickcontrols2-%1.qml").arg(name));
gifRecorder.start();
@@ -656,15 +736,108 @@ void tst_Gifs::checkBoxTriState()
QQuickItem *norwegian = window->property("norwegian").value<QQuickItem*>();
QVERIFY(norwegian);
- QTest::mouseClick(window, Qt::LeftButton, Qt::NoModifier,
- english->mapToScene(QPointF(english->width() / 2, english->height() / 2)).toPoint(), 1000);
- QTest::mouseClick(window, Qt::LeftButton, Qt::NoModifier,
- norwegian->mapToScene(QPointF(norwegian->width() / 2, norwegian->height() / 2)).toPoint(), 1000);
- QTest::mouseClick(window, Qt::LeftButton, Qt::NoModifier,
- norwegian->mapToScene(QPointF(norwegian->width() / 2, norwegian->height() / 2)).toPoint(), 1000);
- QTest::mouseClick(window, Qt::LeftButton, Qt::NoModifier,
- english->mapToScene(QPointF(english->width() / 2, english->height() / 2)).toPoint(), 1000);
+ const QPoint englishCenter = english->mapToScene(
+ QPointF(english->width() / 2, english->height() / 2)).toPoint();
+ QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, englishCenter, 1000);
+ QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, englishCenter, 300);
+
+ const QPoint norwegianCenter = norwegian->mapToScene(
+ QPointF(norwegian->width() / 2, norwegian->height() / 2)).toPoint();
+ QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, norwegianCenter, 1000);
+ QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, norwegianCenter, 300);
+
+ QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, norwegianCenter, 1000);
+ QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, norwegianCenter, 300);
+
+ QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, englishCenter, 1000);
+ QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, englishCenter, 300);
+
+ gifRecorder.waitForFinish();
+}
+
+void tst_Gifs::scrollBar()
+{
+ GifRecorder gifRecorder;
+ gifRecorder.setDataDirPath(dataDirPath);
+ gifRecorder.setOutputDir(outputDir);
+ gifRecorder.setRecordingDuration(6);
+ gifRecorder.setQmlFileName("qtquickcontrols2-scrollbar.qml");
+
+ gifRecorder.start();
+
+ QQuickWindow *window = gifRecorder.window();
+ QQuickItem *scrollBar = window->property("scrollBar").value<QQuickItem*>();
+ QVERIFY(scrollBar);
+
+ // Flick in the center of the screen to show that there's a scroll bar.
+ const QPoint lhsWindowBottom = QPoint(0, window->height() - 1);
+ QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, lhsWindowBottom, 100);
+ QTest::mouseMove(window, lhsWindowBottom - QPoint(0, 10), 30);
+ QTest::mouseMove(window, lhsWindowBottom - QPoint(0, 30), 30);
+ QTest::mouseMove(window, lhsWindowBottom - QPoint(0, 60), 30);
+ QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, lhsWindowBottom - QPoint(0, 100), 30);
+
+ // Scroll with the scroll bar.
+ const QPoint rhsWindowBottom = QPoint(window->width() - 1, window->height() - 1);
+ QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, rhsWindowBottom, 2000);
+ const QPoint rhsWindowTop = QPoint(window->width() - 1, 1);
+ moveSmoothly(window, rhsWindowBottom, rhsWindowTop,
+ qAbs(rhsWindowTop.y() - rhsWindowBottom.y()), QEasingCurve::InCubic, 10);
+ QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, rhsWindowTop, 20);
+
+ gifRecorder.waitForFinish();
+}
+void tst_Gifs::scrollIndicator()
+{
+ GifRecorder gifRecorder;
+ gifRecorder.setDataDirPath(dataDirPath);
+ gifRecorder.setOutputDir(outputDir);
+ gifRecorder.setRecordingDuration(6);
+ gifRecorder.setQmlFileName("qtquickcontrols2-scrollindicator.qml");
+
+ gifRecorder.start();
+
+ // Flick in the center of the screen to show that there's a scroll indicator.
+ QQuickWindow *window = gifRecorder.window();
+ const QPoint windowBottom = QPoint(0, window->height() - 1);
+ QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, windowBottom, 100);
+ QTest::mouseMove(window, windowBottom - QPoint(0, 10), 30);
+ QTest::mouseMove(window, windowBottom - QPoint(0, 30), 30);
+ QTest::mouseMove(window, windowBottom - QPoint(0, 60), 30);
+ QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, windowBottom - QPoint(0, 100), 30);
+
+ // Scroll back down.
+ const QPoint windowTop = QPoint(0, 0);
+ QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, windowTop, 2000);
+ QTest::mouseMove(window, windowTop + QPoint(0, 10), 30);
+ QTest::mouseMove(window, windowTop + QPoint(0, 30), 30);
+ QTest::mouseMove(window, windowTop + QPoint(0, 60), 30);
+ QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, windowTop + QPoint(0, 100), 30);
+
+ gifRecorder.waitForFinish();
+}
+
+void tst_Gifs::progressBar_data()
+{
+ QTest::addColumn<bool>("indeterminate");
+
+ QTest::newRow("indeterminate:false") << false;
+ QTest::newRow("indeterminate:true") << true;
+}
+
+void tst_Gifs::progressBar()
+{
+ QFETCH(bool, indeterminate);
+
+ GifRecorder gifRecorder;
+ gifRecorder.setDataDirPath(dataDirPath);
+ gifRecorder.setOutputDir(outputDir);
+ gifRecorder.setRecordingDuration(4);
+ gifRecorder.setQmlFileName(QString::fromLatin1("qtquickcontrols2-progressbar%1").arg(
+ indeterminate ? QLatin1String("-indeterminate.qml") : QLatin1String(".qml")));
+
+ gifRecorder.start();
gifRecorder.waitForFinish();
}
diff --git a/tests/manual/manual.pro b/tests/manual/manual.pro
index bbc1e881..d81ea32f 100644
--- a/tests/manual/manual.pro
+++ b/tests/manual/manual.pro
@@ -3,6 +3,7 @@ SUBDIRS += \
buttons \
gifs \
fonts \
+ screenshots \
styles \
testbench
diff --git a/tests/manual/screenshots/qtquickcontrols2.conf b/tests/manual/screenshots/qtquickcontrols2.conf
new file mode 100644
index 00000000..b6c7c87e
--- /dev/null
+++ b/tests/manual/screenshots/qtquickcontrols2.conf
@@ -0,0 +1,2 @@
+[Controls]
+Style=Material
diff --git a/tests/manual/screenshots/screenshots.cpp b/tests/manual/screenshots/screenshots.cpp
new file mode 100644
index 00000000..0c14ead3
--- /dev/null
+++ b/tests/manual/screenshots/screenshots.cpp
@@ -0,0 +1,62 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 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$
+**
+****************************************************************************/
+
+#include <QGuiApplication>
+#include <QQmlApplicationEngine>
+#include <QQmlContext>
+#include <QFileInfo>
+#include <QDir>
+
+int main(int argc, char *argv[])
+{
+ QGuiApplication app(argc, argv);
+
+ QQmlApplicationEngine engine;
+ const QUrl snippetsDir = QUrl::fromLocalFile(SNIPPETS_DIR);
+ Q_ASSERT(snippetsDir.isValid() && QFileInfo(snippetsDir.toLocalFile()).exists());
+ engine.rootContext()->setContextProperty("snippetsDir", snippetsDir);
+ engine.rootContext()->setContextProperty("screenshotsDir", QUrl::fromLocalFile(QDir::currentPath()));
+ engine.rootContext()->setContextProperty("screenshotsDirStr", QDir::currentPath());
+ engine.load(QUrl("qrc:/screenshots.qml"));
+ if (engine.rootObjects().isEmpty())
+ return -1;
+
+ return app.exec();
+}
diff --git a/tests/manual/screenshots/screenshots.pro b/tests/manual/screenshots/screenshots.pro
new file mode 100644
index 00000000..5894888f
--- /dev/null
+++ b/tests/manual/screenshots/screenshots.pro
@@ -0,0 +1,13 @@
+TEMPLATE = app
+TARGET = screenshots
+QT += quick widgets
+
+DEFINES += SNIPPETS_DIR=\\\"$$PWD/../../../src/imports/controls/doc/snippets\\\"
+message($$DEFINES)
+
+SOURCES += \
+ screenshots.cpp
+
+RESOURCES += \
+ screenshots.qml \
+ qtquickcontrols2.conf
diff --git a/tests/manual/screenshots/screenshots.qml b/tests/manual/screenshots/screenshots.qml
new file mode 100644
index 00000000..afe7368b
--- /dev/null
+++ b/tests/manual/screenshots/screenshots.qml
@@ -0,0 +1,164 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 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 QtQuick.Layouts 1.3
+import QtQuick.Controls 2.0
+import Qt.labs.folderlistmodel 2.1
+
+ApplicationWindow {
+ id: window
+ title: "Qt Quick Controls 2 - Screenshots"
+ visible: true
+ width: Math.max(600, loader.implicitWidth)
+ height: Math.max(600, loader.implicitHeight)
+
+ property string currentFilePath
+ property string lastSavePath
+
+ Shortcut {
+ sequence: "Ctrl+Q"
+ onActivated: Qt.quit()
+ }
+
+ header: ToolBar {
+ RowLayout {
+ anchors.fill: parent
+
+ ToolButton {
+ text: "Choose Snippet"
+ focusPolicy: Qt.NoFocus
+ onClicked: snippetDrawer.open()
+ }
+ }
+ }
+
+ Drawer {
+ id: snippetDrawer
+ width: window.width / 2
+ height: window.height
+
+ ListView {
+ id: snippetsListView
+ anchors.fill: parent
+ model: FolderListModel {
+ folder: snippetsDir
+ nameFilters: ["*.qml"]
+ showDirs: false
+ }
+ delegate: ItemDelegate {
+ width: parent.width
+ text: fileName
+ focusPolicy: Qt.NoFocus
+
+ readonly property string baseName: fileBaseName
+
+ contentItem: Label {
+ text: parent.text
+ elide: Text.ElideLeft
+ }
+ onClicked: {
+ snippetsListView.currentIndex = index;
+ loader.source = "file:///" + filePath;
+ currentFilePath = filePath;
+ snippetDrawer.close();
+ }
+ }
+ }
+ }
+
+ Loader {
+ id: loader
+ anchors.centerIn: parent
+ }
+
+ ToolTip {
+ id: saveResultToolTip
+ x: window.contentItem.width / 2 - width / 2
+ y: window.contentItem.height - height - 20
+ timeout: 3000
+ }
+
+ footer: ToolBar {
+ RowLayout {
+ anchors.fill: parent
+
+ ToolButton {
+ text: "Open Output Folder"
+ focusPolicy: Qt.NoFocus
+ onClicked: Qt.openUrlExternally(screenshotsDir)
+ }
+
+ ToolButton {
+ text: "Open Last Screenshot"
+ focusPolicy: Qt.NoFocus
+ enabled: lastSavePath.length > 0
+ onClicked: Qt.openUrlExternally(lastSavePath)
+ }
+
+ Item {
+ Layout.fillWidth: true
+ }
+
+ ToolButton {
+ text: "Take Screenshot"
+ focusPolicy: Qt.NoFocus
+ enabled: loader.status === Loader.Ready
+ onClicked: {
+ if (!loader.item)
+ return;
+
+ var grabSuccessful = loader.grabToImage(function(result) {
+ var savePath = screenshotsDirStr + "/" + snippetsListView.currentItem.baseName + ".png";
+ if (result.saveToFile(savePath)) {
+ saveResultToolTip.text = "Successfully saved screenshot to output folder";
+ lastSavePath = savePath;
+ } else {
+ saveResultToolTip.text = "Failed to save screenshot";
+ }
+ })
+ if (!grabSuccessful)
+ saveResultToolTip.text = "Failed to grab image";
+ saveResultToolTip.open();
+ }
+ }
+ }
+ }
+}