From 9e454f556b73c06d935a8059b4374d67655db047 Mon Sep 17 00:00:00 2001 From: Mitch Curtis Date: Thu, 6 Oct 2016 12:29:41 +0200 Subject: ScrollBar: replace PNGs with GIFs Change-Id: I0c0f23b88c0ce36d43bc31321371508ec63c2903 Task-number: QTBUG-55904 Reviewed-by: J-P Nurmi --- .../doc/images/qtquickcontrols2-scrollbar.gif | Bin 0 -> 32067 bytes .../doc/images/qtquickcontrols2-scrollbar.png | Bin 680 -> 0 bytes .../doc/src/qtquickcontrols2-indicators.qdoc | 2 +- src/quicktemplates2/qquickscrollbar.cpp | 4 +- .../gifs/data/qtquickcontrols2-scrollbar.qml | 70 +++++++++++++++++++++ tests/manual/gifs/tst_gifs.cpp | 34 ++++++++++ 6 files changed, 107 insertions(+), 3 deletions(-) create mode 100644 src/imports/controls/doc/images/qtquickcontrols2-scrollbar.gif delete mode 100644 src/imports/controls/doc/images/qtquickcontrols2-scrollbar.png create mode 100644 tests/manual/gifs/data/qtquickcontrols2-scrollbar.qml diff --git a/src/imports/controls/doc/images/qtquickcontrols2-scrollbar.gif b/src/imports/controls/doc/images/qtquickcontrols2-scrollbar.gif new file mode 100644 index 00000000..ed3ab607 Binary files /dev/null and b/src/imports/controls/doc/images/qtquickcontrols2-scrollbar.gif differ diff --git a/src/imports/controls/doc/images/qtquickcontrols2-scrollbar.png b/src/imports/controls/doc/images/qtquickcontrols2-scrollbar.png deleted file mode 100644 index b1abafb5..00000000 Binary files a/src/imports/controls/doc/images/qtquickcontrols2-scrollbar.png and /dev/null differ diff --git a/src/imports/controls/doc/src/qtquickcontrols2-indicators.qdoc b/src/imports/controls/doc/src/qtquickcontrols2-indicators.qdoc index 010ff444..47e6be82 100644 --- a/src/imports/controls/doc/src/qtquickcontrols2-indicators.qdoc +++ b/src/imports/controls/doc/src/qtquickcontrols2-indicators.qdoc @@ -54,7 +54,7 @@ \section1 ScrollBar Control - \image qtquickcontrols2-scrollbar.png + \image qtquickcontrols2-scrollbar.gif \l ScrollBar is an interactive bar that indicates the current scroll position, and can be used to scroll to a specific position in a diff --git a/src/quicktemplates2/qquickscrollbar.cpp b/src/quicktemplates2/qquickscrollbar.cpp index c2506c3c..19f7aea4 100644 --- a/src/quicktemplates2/qquickscrollbar.cpp +++ b/src/quicktemplates2/qquickscrollbar.cpp @@ -52,12 +52,12 @@ QT_BEGIN_NAMESPACE \ingroup qtquickcontrols2-indicators \brief An interactive scroll bar control. + \image qtquickcontrols2-scrollbar.gif + ScrollBar is an interactive bar that can be used to scroll to a specific position. A scroll bar can be either \l vertical or \l horizontal, and can be attached to any \l Flickable, such as \l ListView and \l GridView. - \image qtquickcontrols2-scrollbar.png - \code Flickable { // ... 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/tst_gifs.cpp b/tests/manual/gifs/tst_gifs.cpp index 27234e63..e6fa9d61 100644 --- a/tests/manual/gifs/tst_gifs.cpp +++ b/tests/manual/gifs/tst_gifs.cpp @@ -67,6 +67,7 @@ private slots: void dial(); void checkBox(); void checkBoxTriState(); + void scrollBar(); private: void moveSmoothly(QQuickWindow *window, const QPoint &from, const QPoint &to, int movements, @@ -665,6 +666,39 @@ void tst_Gifs::checkBoxTriState() 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(); + 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(); +} + QTEST_MAIN(tst_Gifs) #include "tst_gifs.moc" -- cgit v1.2.3