From 335b1fff26ef0c13e1cd1fe697c70d7b8f1a8139 Mon Sep 17 00:00:00 2001 From: Mitch Curtis Date: Wed, 30 Mar 2016 16:34:15 +0200 Subject: Improve documentation for delegate controls - Add "Delegate Controls" doc page. This will list future delegate controls, such as CheckDelegate, RadioDelegate and SwitchDelegate. - Add GIF for ItemDelegate. Change-Id: If8c66ab2178185f96d190f29ef7815beaa6e8d68 Reviewed-by: Venugopal Shivashankar Reviewed-by: Mitch Curtis --- .../gifs/data/qtquickcontrols-itemdelegate.qml | 64 ++++++++++++++++++++++ tests/manual/gifs/tst_gifs.cpp | 35 ++++++++++++ 2 files changed, 99 insertions(+) create mode 100644 tests/manual/gifs/data/qtquickcontrols-itemdelegate.qml (limited to 'tests') diff --git a/tests/manual/gifs/data/qtquickcontrols-itemdelegate.qml b/tests/manual/gifs/data/qtquickcontrols-itemdelegate.qml new file mode 100644 index 00000000..413cd085 --- /dev/null +++ b/tests/manual/gifs/data/qtquickcontrols-itemdelegate.qml @@ -0,0 +1,64 @@ +/**************************************************************************** +** +** 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 Qt.labs.controls 1.0 + +Window { + width: column.implicitWidth + height: column.implicitHeight + visible: true + + property var delegate: repeater.count > 0 ? repeater.itemAt(0) : null + + Column { + id: column + + Repeater { + id: repeater + model: ["Option 1", "Option 2", "Option 3"] + delegate: ItemDelegate { + checkable: true + text: modelData + } + } + } +} diff --git a/tests/manual/gifs/tst_gifs.cpp b/tests/manual/gifs/tst_gifs.cpp index ed5d2956..bc096ccb 100644 --- a/tests/manual/gifs/tst_gifs.cpp +++ b/tests/manual/gifs/tst_gifs.cpp @@ -60,6 +60,8 @@ private slots: void swipeDelegate_data(); void swipeDelegate(); void swipeDelegateBehind(); + void delegates_data(); + void delegates(); private: void moveSmoothly(QQuickWindow *window, const QPoint &from, const QPoint &to, int movements, @@ -466,6 +468,39 @@ void tst_Gifs::swipeDelegateBehind() gifRecorder.waitForFinish(); } +void tst_Gifs::delegates_data() +{ + QTest::addColumn("name"); + QTest::newRow("ItemDelegate") << "itemdelegate"; +} + +void tst_Gifs::delegates() +{ + QFETCH(QString, name); + + GifRecorder gifRecorder; + gifRecorder.setDataDirPath(dataDirPath); + gifRecorder.setOutputDir(outputDir); + gifRecorder.setRecordingDuration(5); + gifRecorder.setQmlFileName(QString::fromLatin1("qtquickcontrols-%1.qml").arg(name)); + gifRecorder.setHighQuality(true); + + gifRecorder.start(); + + QQuickWindow *window = gifRecorder.window(); + QQuickItem *delegate = window->property("delegate").value(); + QVERIFY(delegate); + + const QPoint delegateCenter(delegate->mapToScene(QPointF(delegate->width() / 2, delegate->height() / 2)).toPoint()); + QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, delegateCenter, 200); + QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, delegateCenter, 400); + + QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, delegateCenter, 1000); + QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, delegateCenter, 400); + + gifRecorder.waitForFinish(); +} + QTEST_MAIN(tst_Gifs) #include "tst_gifs.moc" -- cgit v1.2.3