From 4f6f82bb5dd2ac5d64c1f5c22f6fd3e524662f98 Mon Sep 17 00:00:00 2001 From: Mitch Curtis Date: Sun, 2 Apr 2017 09:22:44 +0200 Subject: Doc: mention that standardButtons is ordered according to platform This was mentioned in the detailed description of DialogButtonBox, but could easily be missed by users looking at Dialog's standardButtons documentation, because that doesn't mention DialogButtonBox. Change-Id: If3229589e24992d3071388a044246906e739a918 Reviewed-by: J-P Nurmi --- src/quicktemplates2/qquickdialog.cpp | 2 ++ src/quicktemplates2/qquickdialogbuttonbox.cpp | 2 ++ 2 files changed, 4 insertions(+) diff --git a/src/quicktemplates2/qquickdialog.cpp b/src/quicktemplates2/qquickdialog.cpp index fbb612b3..3ac99caa 100644 --- a/src/quicktemplates2/qquickdialog.cpp +++ b/src/quicktemplates2/qquickdialog.cpp @@ -257,6 +257,8 @@ void QQuickDialog::setFooter(QQuickItem *footer) \snippet qtquickcontrols2-dialog.qml 1 + The buttons will be positioned in the appropriate order for the user's platform. + Possible flags: \value Dialog.Ok An "OK" button defined with the \c AcceptRole. \value Dialog.Open An "Open" button defined with the \c AcceptRole. diff --git a/src/quicktemplates2/qquickdialogbuttonbox.cpp b/src/quicktemplates2/qquickdialogbuttonbox.cpp index f1971635..386577da 100644 --- a/src/quicktemplates2/qquickdialogbuttonbox.cpp +++ b/src/quicktemplates2/qquickdialogbuttonbox.cpp @@ -437,6 +437,8 @@ void QQuickDialogButtonBox::resetAlignment() \snippet qtquickcontrols2-dialogbuttonbox.qml 1 + The buttons will be positioned in the appropriate order for the user's platform. + Possible flags: \value DialogButtonBox.Ok An "OK" button defined with the \c AcceptRole. \value DialogButtonBox.Open An "Open" button defined with the \c AcceptRole. -- cgit v1.2.3 From 8d1ad7261d265972af1e837a7d07c91164694abb Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Thu, 30 Mar 2017 08:16:31 +0200 Subject: Doc: merge controls & styles columns in the version table The version table added in c9cd624 looked fine in locally generated docs, but it seems to get a bit too wide in the online snapshots (the table becomes horizontally scrollable). => Merge the controls and styles columns that all have the same version. Change-Id: Icb8387f95211ddee030cb410594adc9a6fad5c97 Reviewed-by: Mitch Curtis --- src/imports/controls/doc/src/qtquickcontrols2-index.qdoc | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/imports/controls/doc/src/qtquickcontrols2-index.qdoc b/src/imports/controls/doc/src/qtquickcontrols2-index.qdoc index fdc49855..5fa2980a 100644 --- a/src/imports/controls/doc/src/qtquickcontrols2-index.qdoc +++ b/src/imports/controls/doc/src/qtquickcontrols2-index.qdoc @@ -71,35 +71,31 @@ \li \c Qt \li \l {Qt Quick QML Types}{\c QtQuick} \li \l {Qt Quick Controls 2 QML Types}{\c QtQuick.Controls},\br - \l {Qt Quick Templates 2 QML Types}{\c QtQuick.Templates}, - \li \l {Material Style}{\c QtQuick.Controls.Material},\br - \l {Universal Style}{\c QtQuick.Controls.Universal} + \l {Material Style}{\c QtQuick.Controls.Material},\br + \l {Universal Style}{\c QtQuick.Controls.Universal},\br + \l {Qt Quick Templates 2 QML Types}{\c QtQuick.Templates} \li \l {Qt Labs Calendar QML Types}{\c Qt.labs.calendar},\br \l {Qt Labs Platform QML Types}{\c Qt.labs.platform} \row \li 5.7 \li 2.7 \li 2.0 - \li 2.0 \li 1.0 \row \li 5.8 \li 2.8 \li 2.1 - \li 2.1 \li 1.0 \row \li 5.9 \li 2.9 \li 2.2 - \li 2.2 \li 1.0 \row \li ... \li ... \li ... \li ... - \li ... \endtable \section1 Important Concepts in Qt Quick Controls 2 -- cgit v1.2.3 From 07805c738d66838c372b2533cf5bfaf21663be58 Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Thu, 30 Mar 2017 09:12:41 +0200 Subject: Doc: add style screenshots on the index page To make it more clear what the controls are and how they look. Change-Id: I6ce9a56a1692d90900952be798d7b254bc067dbb Reviewed-by: Mitch Curtis --- .../controls/doc/src/qtquickcontrols2-index.qdoc | 30 ++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/src/imports/controls/doc/src/qtquickcontrols2-index.qdoc b/src/imports/controls/doc/src/qtquickcontrols2-index.qdoc index 5fa2980a..7307333e 100644 --- a/src/imports/controls/doc/src/qtquickcontrols2-index.qdoc +++ b/src/imports/controls/doc/src/qtquickcontrols2-index.qdoc @@ -35,6 +35,36 @@ to build complete interfaces in Qt Quick. The module was introduced in Qt 5.7. + Qt Quick Controls 2 comes with a selection customizable styles. + See \l {Styling Qt Quick Controls 2} for more details. + + \raw HTML + + + + + + + + + + + +
+ + Default + + + + Material + + + + Universal + +
DefaultMaterialUniversal
+ \endraw + \section1 Prerequisites The \l{Qt Quick Controls 2 QML Types}{QML types} can be imported into your -- cgit v1.2.3 From 1c4b2b146548bcf26cdd4fe1e1a0c2871fcfddc6 Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Thu, 30 Mar 2017 09:13:49 +0200 Subject: Doc: replace "released" with "introduced" on the index page To use the same "was introduced in Qt 5.7" phrasing already used at the top of the page. Change-Id: I3736a1c3e87aa91e7fa3b8a41370f4b2252e793d Reviewed-by: Mitch Curtis --- src/imports/controls/doc/src/qtquickcontrols2-index.qdoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/imports/controls/doc/src/qtquickcontrols2-index.qdoc b/src/imports/controls/doc/src/qtquickcontrols2-index.qdoc index 7307333e..34e548a3 100644 --- a/src/imports/controls/doc/src/qtquickcontrols2-index.qdoc +++ b/src/imports/controls/doc/src/qtquickcontrols2-index.qdoc @@ -92,7 +92,7 @@ \section1 Versions - Qt Quick Controls 2.0 was released in Qt 5.7. Subsequent minor Qt releases + Qt Quick Controls 2.0 was introduced in Qt 5.7. Subsequent minor Qt releases increment the import version of the Qt Quick Controls 2 modules by one. The experimental Qt Labs modules use import version 1.0. -- cgit v1.2.3 From e049719c9c18959572676dfaeccc4ad68e031958 Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Mon, 3 Apr 2017 11:47:56 +0200 Subject: Doc: add missing Popup::aboutToShow() and aboutToHide() signals The signals have been there since the first release. The docs were just missing. Change-Id: I5f5340859136b8924832da4ddb2a18d4a812cca3 Task-numer: QTBUG-59400 Reviewed-by: Mitch Curtis --- src/quicktemplates2/qquickpopup.cpp | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/quicktemplates2/qquickpopup.cpp b/src/quicktemplates2/qquickpopup.cpp index 9cdb194e..f4751261 100644 --- a/src/quicktemplates2/qquickpopup.cpp +++ b/src/quicktemplates2/qquickpopup.cpp @@ -176,7 +176,7 @@ QT_BEGIN_NAMESPACE This signal is emitted when the popup is opened. - \sa closed + \sa aboutToShow() */ /*! @@ -184,7 +184,23 @@ QT_BEGIN_NAMESPACE This signal is emitted when the popup is closed. - \sa opened + \sa aboutToHide() +*/ + +/*! + \qmlsignal void QtQuick.Controls::Popup::aboutToShow() + + This signal is emitted when the popup is about to show. + + \sa opened() +*/ + +/*! + \qmlsignal void QtQuick.Controls::Popup::aboutToHide() + + This signal is emitted when the popup is about to hide. + + \sa closed() */ QQuickPopupPrivate::QQuickPopupPrivate() -- cgit v1.2.3 From 377030c2bfb3393dc35939aae8e74ba9cf193799 Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Mon, 3 Apr 2017 16:33:40 +0200 Subject: TextField: make textEdited() available The signal was added in Qt Quick 2.9 and has revision 9. Change-Id: Id1bb0f17ac5d8c9684ab5127782d030b54756e6f Reviewed-by: Mitch Curtis --- src/imports/templates/qtquicktemplates2plugin.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/imports/templates/qtquicktemplates2plugin.cpp b/src/imports/templates/qtquicktemplates2plugin.cpp index 8cc760a8..dd79ac5b 100644 --- a/src/imports/templates/qtquicktemplates2plugin.cpp +++ b/src/imports/templates/qtquicktemplates2plugin.cpp @@ -251,6 +251,7 @@ void QtQuickTemplates2Plugin::registerTypes(const char *uri) // NOTE: register the latest revisions of all template/control base classes to // make revisioned properties available to their subclasses (synced with Qt 5.9) qmlRegisterRevision(uri, 2, 2); + qmlRegisterRevision(uri, 2, 2); } QT_END_NAMESPACE -- cgit v1.2.3 From 29d89645aab7b830c5d56b04f1947fa6b445c620 Mon Sep 17 00:00:00 2001 From: Karol Polak Date: Mon, 3 Apr 2017 22:28:36 +0200 Subject: BusyIndicator: add lacking initialization in material style Random values of the m_elapsed could make the time in updateCurrentTime invalid. Task-number: QTBUG-59911 Change-Id: I8d36f50f01679f56300df9bae00a8d5de6528cc3 Reviewed-by: J-P Nurmi --- src/imports/controls/material/qquickmaterialbusyindicator.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/imports/controls/material/qquickmaterialbusyindicator.cpp b/src/imports/controls/material/qquickmaterialbusyindicator.cpp index 7bc96505..9df8f5d2 100644 --- a/src/imports/controls/material/qquickmaterialbusyindicator.cpp +++ b/src/imports/controls/material/qquickmaterialbusyindicator.cpp @@ -178,7 +178,7 @@ void QQuickMaterialBusyIndicatorNode::sync(QQuickItem *item) } QQuickMaterialBusyIndicator::QQuickMaterialBusyIndicator(QQuickItem *parent) : - QQuickItem(parent) + QQuickItem(parent), m_elapsed(0), m_color(Qt::black) { setFlag(ItemHasContents); } -- cgit v1.2.3 From 88a62b3b910d09324dbbef3e1e791659ecd6537f Mon Sep 17 00:00:00 2001 From: Karol Polak Date: Tue, 4 Apr 2017 00:44:35 +0200 Subject: QQuickScrollBar: set implicit Cursor as Qt::ArrowCursor Scrollbar over TextArea had Qt::IBeamCursor, although the textarea would not be activated when clicked. Task-number: QTBUG-59629 Change-Id: Ie96ba03360fcfb5872f5bb6345e168c987978aca Reviewed-by: J-P Nurmi --- src/quicktemplates2/qquickscrollbar.cpp | 3 ++ tests/auto/auto.pro | 1 + tests/auto/scrollbar/data/cursor.qml | 70 +++++++++++++++++++++++++++ tests/auto/scrollbar/scrollbar.pro | 14 ++++++ tests/auto/scrollbar/tst_scrollbar.cpp | 85 +++++++++++++++++++++++++++++++++ 5 files changed, 173 insertions(+) create mode 100644 tests/auto/scrollbar/data/cursor.qml create mode 100644 tests/auto/scrollbar/scrollbar.pro create mode 100644 tests/auto/scrollbar/tst_scrollbar.cpp diff --git a/src/quicktemplates2/qquickscrollbar.cpp b/src/quicktemplates2/qquickscrollbar.cpp index 3dcb720a..8f4337ae 100644 --- a/src/quicktemplates2/qquickscrollbar.cpp +++ b/src/quicktemplates2/qquickscrollbar.cpp @@ -274,6 +274,9 @@ QQuickScrollBar::QQuickScrollBar(QQuickItem *parent) { setKeepMouseGrab(true); setAcceptedMouseButtons(Qt::LeftButton); +#if QT_CONFIG(cursor) + setCursor(Qt::ArrowCursor); +#endif } QQuickScrollBarAttached *QQuickScrollBar::qmlAttachedProperties(QObject *object) diff --git a/tests/auto/auto.pro b/tests/auto/auto.pro index 4dabf06f..6741296a 100644 --- a/tests/auto/auto.pro +++ b/tests/auto/auto.pro @@ -17,6 +17,7 @@ SUBDIRS += \ qquickuniversalstyleconf \ revisions \ sanity \ + scrollbar \ snippets # QTBUG-50295 diff --git a/tests/auto/scrollbar/data/cursor.qml b/tests/auto/scrollbar/data/cursor.qml new file mode 100644 index 00000000..01dcd2ae --- /dev/null +++ b/tests/auto/scrollbar/data/cursor.qml @@ -0,0 +1,70 @@ +/**************************************************************************** +** +** 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.6 +import QtQuick.Controls 2.0 + +ApplicationWindow { + width: 400 + height: 400 + + property alias textArea: textArea + property alias scrollBar: scrollBar + + Flickable { + anchors.fill: parent + TextArea.flickable: TextArea { + id: textArea + } + ScrollBar.vertical: ScrollBar { + id: scrollBar + } + } +} diff --git a/tests/auto/scrollbar/scrollbar.pro b/tests/auto/scrollbar/scrollbar.pro new file mode 100644 index 00000000..03e11d44 --- /dev/null +++ b/tests/auto/scrollbar/scrollbar.pro @@ -0,0 +1,14 @@ +CONFIG += testcase +TARGET = tst_scrollbar +SOURCES += tst_scrollbar.cpp + +macos:CONFIG -= app_bundle + +QT += core-private gui-private qml-private quick-private testlib quicktemplates2-private + +include (../shared/util.pri) + +TESTDATA = data/* + +OTHER_FILES += \ + data/*.qml diff --git a/tests/auto/scrollbar/tst_scrollbar.cpp b/tests/auto/scrollbar/tst_scrollbar.cpp new file mode 100644 index 00000000..741a6edc --- /dev/null +++ b/tests/auto/scrollbar/tst_scrollbar.cpp @@ -0,0 +1,85 @@ +/**************************************************************************** +** +** Copyright (C) 2017 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:LGPL3$ +** 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 http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include "../shared/visualtestutil.h" + +#include +#include +#include + +using namespace QQuickVisualTestUtil; + +class tst_scrollbar : public QQmlDataTest +{ + Q_OBJECT + +private slots: + void cursorShape(); +}; + +// QTBUG-59629 +void tst_scrollbar::cursorShape() +{ + // Ensure that the mouse cursor has the correct shape when over a scrollbar + // which is itself over a text area with IBeamCursor. + QQuickApplicationHelper helper(this, QStringLiteral("cursor.qml")); + QQuickApplicationWindow *window = helper.appWindow; + window->show(); + QVERIFY(QTest::qWaitForWindowExposed(window)); + + QQuickScrollBar *scrollBar = helper.appWindow->property("scrollBar").value(); + QVERIFY(scrollBar); + + QQuickTextArea *textArea = helper.appWindow->property("textArea").value(); + QVERIFY(textArea); + + textArea->setText(QString("\n").repeated(100)); + + const QPoint textAreaPos(window->width() / 2, window->height() / 2); + QTest::mouseMove(window, textAreaPos); + QCOMPARE(window->cursor().shape(), textArea->cursor().shape()); + + const QPoint scrollBarPos(window->width() - scrollBar->width() / 2, window->height() / 2); + QTest::mouseMove(window, scrollBarPos); + QVERIFY(scrollBar->isActive()); + QCOMPARE(window->cursor().shape(), scrollBar->cursor().shape()); + QCOMPARE(scrollBar->cursor().shape(), Qt::CursorShape::ArrowCursor); +} + +QTEST_MAIN(tst_scrollbar) + +#include "tst_scrollbar.moc" -- cgit v1.2.3 From c7e98f4cb9717dcf267f23bf2e8ca57cdc874b84 Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Mon, 3 Apr 2017 19:56:04 +0200 Subject: StackView: resolve relative URLs to the caller Task-number: QTBUG-59309 Change-Id: I3c19d55431dd4831c4510acb5ef0e9fffa8f478f Reviewed-by: Mitch Curtis --- src/quicktemplates2/qquickstackview_p.cpp | 17 +++++++++++++---- src/quicktemplates2/qquickstackview_p_p.h | 3 ++- tests/auto/controls/data/tst_stackview.qml | 9 +++++++++ 3 files changed, 24 insertions(+), 5 deletions(-) diff --git a/src/quicktemplates2/qquickstackview_p.cpp b/src/quicktemplates2/qquickstackview_p.cpp index c6f9291d..3c983d6b 100644 --- a/src/quicktemplates2/qquickstackview_p.cpp +++ b/src/quicktemplates2/qquickstackview_p.cpp @@ -93,6 +93,7 @@ static bool initProperties(QQuickStackElement *element, const QV4::Value &props, QList QQuickStackViewPrivate::parseElements(int from, QQmlV4Function *args, QStringList *errors) { QV4::ExecutionEngine *v4 = args->v4engine(); + QQmlContextData *context = v4->callingQmlContext(); QV4::Scope scope(v4); QList elements; @@ -105,7 +106,7 @@ QList QQuickStackViewPrivate::parseElements(int from, QQml for (int j = 0; j < len; ++j) { QString error; QV4::ScopedValue value(scope, array->getIndexed(j)); - QQuickStackElement *element = createElement(value, &error); + QQuickStackElement *element = createElement(value, context, &error); if (element) { if (j < len - 1) { QV4::ScopedValue props(scope, array->getIndexed(j + 1)); @@ -119,7 +120,7 @@ QList QQuickStackViewPrivate::parseElements(int from, QQml } } else { QString error; - QQuickStackElement *element = createElement(arg, &error); + QQuickStackElement *element = createElement(arg, context, &error); if (element) { if (i < argc - 1) { QV4::ScopedValue props(scope, (*args)[i + 1]); @@ -153,11 +154,19 @@ QQuickStackElement *QQuickStackViewPrivate::findElement(const QV4::Value &value) return nullptr; } -QQuickStackElement *QQuickStackViewPrivate::createElement(const QV4::Value &value, QString *error) +static QString resolvedUrl(const QString &str, QQmlContextData *context) +{ + QUrl url(str); + if (url.isRelative()) + return context->resolvedUrl(url).toString(); + return str; +} + +QQuickStackElement *QQuickStackViewPrivate::createElement(const QV4::Value &value, QQmlContextData *context, QString *error) { Q_Q(QQuickStackView); if (const QV4::String *s = value.as()) - return QQuickStackElement::fromString(s->toQString(), q, error); + return QQuickStackElement::fromString(resolvedUrl(s->toQString(), context), q, error); if (const QV4::QObjectWrapper *o = value.as()) return QQuickStackElement::fromObject(o->object(), q, error); return nullptr; diff --git a/src/quicktemplates2/qquickstackview_p_p.h b/src/quicktemplates2/qquickstackview_p_p.h index 26d741f8..81ca9164 100644 --- a/src/quicktemplates2/qquickstackview_p_p.h +++ b/src/quicktemplates2/qquickstackview_p_p.h @@ -57,6 +57,7 @@ QT_BEGIN_NAMESPACE +class QQmlContextData; class QQuickStackElement; struct QQuickStackTransition; @@ -79,7 +80,7 @@ public: QList parseElements(int from, QQmlV4Function *args, QStringList *errors); QQuickStackElement *findElement(QQuickItem *item) const; QQuickStackElement *findElement(const QV4::Value &value) const; - QQuickStackElement *createElement(const QV4::Value &value, QString *error); + QQuickStackElement *createElement(const QV4::Value &value, QQmlContextData *context, QString *error); bool pushElements(const QList &elements); bool pushElement(QQuickStackElement *element); bool popElements(QQuickStackElement *element); diff --git a/tests/auto/controls/data/tst_stackview.qml b/tests/auto/controls/data/tst_stackview.qml index c56a04de..37bd5222 100644 --- a/tests/auto/controls/data/tst_stackview.qml +++ b/tests/auto/controls/data/tst_stackview.qml @@ -1101,4 +1101,13 @@ TestCase { control.destroy() } + + function test_resolve() { + var control = createTemporaryObject(stackView, testCase) + verify(control) + + var item = control.push("TestItem.qml") + compare(control.depth, 1) + verify(item) + } } -- cgit v1.2.3 From ab34a0e545230db1a865af918d5a9c2ed6553224 Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Tue, 4 Apr 2017 10:47:50 +0200 Subject: tst_combobox: use larger window test_down() needs to place the popup below the combobox button to be able to test its pressed and down states while the popup is open. On some high DPI displays (Chromebook Pixel) the popup did not fit fully below, but got pushed partly over the button. Consequently, mouse presses went to the popup instead of the button and the test failed. Change-Id: I03e5768e00cf1eaf6d704a16ffe2b8d1705021b2 Reviewed-by: Mitch Curtis --- tests/auto/controls/data/tst_combobox.qml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/auto/controls/data/tst_combobox.qml b/tests/auto/controls/data/tst_combobox.qml index fb4dc57c..05eb2de1 100644 --- a/tests/auto/controls/data/tst_combobox.qml +++ b/tests/auto/controls/data/tst_combobox.qml @@ -55,8 +55,8 @@ import QtQuick.Controls 2.2 TestCase { id: testCase - width: 200 - height: 200 + width: 400 + height: 400 visible: true when: windowShown name: "ComboBox" @@ -724,6 +724,8 @@ TestCase { compare(downSpy.count, 3) compare(pressedSpy.count, 2) + compare(control.popup.y, control.height) + control.down = false compare(control.down, false) compare(downSpy.count, 4) -- cgit v1.2.3 From 0704f76d4793929b79a1fefd6c9f83ac69e70307 Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Tue, 4 Apr 2017 16:06:59 +0200 Subject: Rename tst_scrollbar to tst_cursor This test was added in 88a62b3 that fixed the scrollbar cursor. It was not possible to test in QML, so a separate C++ test was added. It was noticed that most interactive controls have the exact same issue, so we want to utilize the same test for testing the cursors of all relevant controls. Change-Id: I7c307de9f72760b0993007246beb3357a1b5ec2b Reviewed-by: Mitch Curtis --- .gitignore | 1 + tests/auto/auto.pro | 2 +- tests/auto/cursor/cursor.pro | 14 ++++++ tests/auto/cursor/data/scrollbar.qml | 70 ++++++++++++++++++++++++++++ tests/auto/cursor/tst_cursor.cpp | 85 ++++++++++++++++++++++++++++++++++ tests/auto/scrollbar/data/cursor.qml | 70 ---------------------------- tests/auto/scrollbar/scrollbar.pro | 14 ------ tests/auto/scrollbar/tst_scrollbar.cpp | 85 ---------------------------------- 8 files changed, 171 insertions(+), 170 deletions(-) create mode 100644 tests/auto/cursor/cursor.pro create mode 100644 tests/auto/cursor/data/scrollbar.qml create mode 100644 tests/auto/cursor/tst_cursor.cpp delete mode 100644 tests/auto/scrollbar/data/cursor.qml delete mode 100644 tests/auto/scrollbar/scrollbar.pro delete mode 100644 tests/auto/scrollbar/tst_scrollbar.cpp diff --git a/.gitignore b/.gitignore index b60a0dbb..3d119373 100644 --- a/.gitignore +++ b/.gitignore @@ -32,6 +32,7 @@ /tests/auto/controls/default/tst_default /tests/auto/controls/material/tst_material /tests/auto/controls/universal/tst_universal +/tests/auto/cursor/tst_cursor /tests/auto/drawer/tst_drawer /tests/auto/focus/tst_focus /tests/auto/menu/tst_menu diff --git a/tests/auto/auto.pro b/tests/auto/auto.pro index 6741296a..a04615d6 100644 --- a/tests/auto/auto.pro +++ b/tests/auto/auto.pro @@ -4,6 +4,7 @@ SUBDIRS += \ applicationwindow \ calendar \ controls \ + cursor \ drawer \ menu \ platform \ @@ -17,7 +18,6 @@ SUBDIRS += \ qquickuniversalstyleconf \ revisions \ sanity \ - scrollbar \ snippets # QTBUG-50295 diff --git a/tests/auto/cursor/cursor.pro b/tests/auto/cursor/cursor.pro new file mode 100644 index 00000000..4948e943 --- /dev/null +++ b/tests/auto/cursor/cursor.pro @@ -0,0 +1,14 @@ +CONFIG += testcase +TARGET = tst_cursor +SOURCES += tst_cursor.cpp + +macos:CONFIG -= app_bundle + +QT += core-private gui-private qml-private quick-private testlib quicktemplates2-private + +include (../shared/util.pri) + +TESTDATA = data/* + +OTHER_FILES += \ + data/*.qml diff --git a/tests/auto/cursor/data/scrollbar.qml b/tests/auto/cursor/data/scrollbar.qml new file mode 100644 index 00000000..01dcd2ae --- /dev/null +++ b/tests/auto/cursor/data/scrollbar.qml @@ -0,0 +1,70 @@ +/**************************************************************************** +** +** 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.6 +import QtQuick.Controls 2.0 + +ApplicationWindow { + width: 400 + height: 400 + + property alias textArea: textArea + property alias scrollBar: scrollBar + + Flickable { + anchors.fill: parent + TextArea.flickable: TextArea { + id: textArea + } + ScrollBar.vertical: ScrollBar { + id: scrollBar + } + } +} diff --git a/tests/auto/cursor/tst_cursor.cpp b/tests/auto/cursor/tst_cursor.cpp new file mode 100644 index 00000000..dafb3159 --- /dev/null +++ b/tests/auto/cursor/tst_cursor.cpp @@ -0,0 +1,85 @@ +/**************************************************************************** +** +** Copyright (C) 2017 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:LGPL3$ +** 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 http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include "../shared/visualtestutil.h" + +#include +#include +#include + +using namespace QQuickVisualTestUtil; + +class tst_cursor : public QQmlDataTest +{ + Q_OBJECT + +private slots: + void scrollBar(); +}; + +// QTBUG-59629 +void tst_cursor::scrollBar() +{ + // Ensure that the mouse cursor has the correct shape when over a scrollbar + // which is itself over a text area with IBeamCursor. + QQuickApplicationHelper helper(this, QStringLiteral("scrollbar.qml")); + QQuickApplicationWindow *window = helper.appWindow; + window->show(); + QVERIFY(QTest::qWaitForWindowExposed(window)); + + QQuickScrollBar *scrollBar = helper.appWindow->property("scrollBar").value(); + QVERIFY(scrollBar); + + QQuickTextArea *textArea = helper.appWindow->property("textArea").value(); + QVERIFY(textArea); + + textArea->setText(QString("\n").repeated(100)); + + const QPoint textAreaPos(window->width() / 2, window->height() / 2); + QTest::mouseMove(window, textAreaPos); + QCOMPARE(window->cursor().shape(), textArea->cursor().shape()); + + const QPoint scrollBarPos(window->width() - scrollBar->width() / 2, window->height() / 2); + QTest::mouseMove(window, scrollBarPos); + QVERIFY(scrollBar->isActive()); + QCOMPARE(window->cursor().shape(), scrollBar->cursor().shape()); + QCOMPARE(scrollBar->cursor().shape(), Qt::CursorShape::ArrowCursor); +} + +QTEST_MAIN(tst_cursor) + +#include "tst_cursor.moc" diff --git a/tests/auto/scrollbar/data/cursor.qml b/tests/auto/scrollbar/data/cursor.qml deleted file mode 100644 index 01dcd2ae..00000000 --- a/tests/auto/scrollbar/data/cursor.qml +++ /dev/null @@ -1,70 +0,0 @@ -/**************************************************************************** -** -** 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.6 -import QtQuick.Controls 2.0 - -ApplicationWindow { - width: 400 - height: 400 - - property alias textArea: textArea - property alias scrollBar: scrollBar - - Flickable { - anchors.fill: parent - TextArea.flickable: TextArea { - id: textArea - } - ScrollBar.vertical: ScrollBar { - id: scrollBar - } - } -} diff --git a/tests/auto/scrollbar/scrollbar.pro b/tests/auto/scrollbar/scrollbar.pro deleted file mode 100644 index 03e11d44..00000000 --- a/tests/auto/scrollbar/scrollbar.pro +++ /dev/null @@ -1,14 +0,0 @@ -CONFIG += testcase -TARGET = tst_scrollbar -SOURCES += tst_scrollbar.cpp - -macos:CONFIG -= app_bundle - -QT += core-private gui-private qml-private quick-private testlib quicktemplates2-private - -include (../shared/util.pri) - -TESTDATA = data/* - -OTHER_FILES += \ - data/*.qml diff --git a/tests/auto/scrollbar/tst_scrollbar.cpp b/tests/auto/scrollbar/tst_scrollbar.cpp deleted file mode 100644 index 741a6edc..00000000 --- a/tests/auto/scrollbar/tst_scrollbar.cpp +++ /dev/null @@ -1,85 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 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:LGPL3$ -** 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 http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPLv3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or later as published by the Free -** Software Foundation and appearing in the file LICENSE.GPL included in -** the packaging of this file. Please review the following information to -** ensure the GNU General Public License version 2.0 requirements will be -** met: http://www.gnu.org/licenses/gpl-2.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include "../shared/visualtestutil.h" - -#include -#include -#include - -using namespace QQuickVisualTestUtil; - -class tst_scrollbar : public QQmlDataTest -{ - Q_OBJECT - -private slots: - void cursorShape(); -}; - -// QTBUG-59629 -void tst_scrollbar::cursorShape() -{ - // Ensure that the mouse cursor has the correct shape when over a scrollbar - // which is itself over a text area with IBeamCursor. - QQuickApplicationHelper helper(this, QStringLiteral("cursor.qml")); - QQuickApplicationWindow *window = helper.appWindow; - window->show(); - QVERIFY(QTest::qWaitForWindowExposed(window)); - - QQuickScrollBar *scrollBar = helper.appWindow->property("scrollBar").value(); - QVERIFY(scrollBar); - - QQuickTextArea *textArea = helper.appWindow->property("textArea").value(); - QVERIFY(textArea); - - textArea->setText(QString("\n").repeated(100)); - - const QPoint textAreaPos(window->width() / 2, window->height() / 2); - QTest::mouseMove(window, textAreaPos); - QCOMPARE(window->cursor().shape(), textArea->cursor().shape()); - - const QPoint scrollBarPos(window->width() - scrollBar->width() / 2, window->height() / 2); - QTest::mouseMove(window, scrollBarPos); - QVERIFY(scrollBar->isActive()); - QCOMPARE(window->cursor().shape(), scrollBar->cursor().shape()); - QCOMPARE(scrollBar->cursor().shape(), Qt::CursorShape::ArrowCursor); -} - -QTEST_MAIN(tst_scrollbar) - -#include "tst_scrollbar.moc" -- cgit v1.2.3 From ed64115cbf11a758a9cacd2bd34f3af5603f73b7 Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Tue, 4 Apr 2017 16:18:39 +0200 Subject: Set explicit cursors on all interactive controls For example, if you have a floating button on top of a text editor, hovering the button must change the cursor from the editor's ibeam cursor to an arrow cursor. This applies to all interactive controls that call setAcceptedMouseButtons(). If a control blocks mouse events, it should not use some random cursor from another control underneath. Task-number: QTBUG-59629 Change-Id: I8a6ae306bbc76a9b22377361cb19cf9c3a872d31 Reviewed-by: Mitch Curtis --- src/imports/calendar/qquickmonthgrid.cpp | 3 + src/quicktemplates2/qquickabstractbutton.cpp | 6 ++ src/quicktemplates2/qquickcombobox.cpp | 12 +++ src/quicktemplates2/qquickdial.cpp | 3 + src/quicktemplates2/qquickoverlay.cpp | 3 + src/quicktemplates2/qquickpage.cpp | 3 + src/quicktemplates2/qquickpageindicator.cpp | 12 ++- src/quicktemplates2/qquickpane.cpp | 6 ++ src/quicktemplates2/qquickrangeslider.cpp | 5 +- src/quicktemplates2/qquickscrollbar.cpp | 13 ++- src/quicktemplates2/qquickslider.cpp | 3 + src/quicktemplates2/qquickspinbox.cpp | 17 ++++ tests/auto/cursor/data/buttons.qml | 104 ++++++++++++++++++++++++ tests/auto/cursor/data/containers.qml | 77 ++++++++++++++++++ tests/auto/cursor/data/editable.qml | 72 +++++++++++++++++ tests/auto/cursor/data/pageindicator.qml | 62 +++++++++++++++ tests/auto/cursor/data/sliders.qml | 71 +++++++++++++++++ tests/auto/cursor/tst_cursor.cpp | 114 ++++++++++++++++++++++++++- 18 files changed, 581 insertions(+), 5 deletions(-) create mode 100644 tests/auto/cursor/data/buttons.qml create mode 100644 tests/auto/cursor/data/containers.qml create mode 100644 tests/auto/cursor/data/editable.qml create mode 100644 tests/auto/cursor/data/pageindicator.qml create mode 100644 tests/auto/cursor/data/sliders.qml diff --git a/src/imports/calendar/qquickmonthgrid.cpp b/src/imports/calendar/qquickmonthgrid.cpp index 5eb0798c..9621f49a 100644 --- a/src/imports/calendar/qquickmonthgrid.cpp +++ b/src/imports/calendar/qquickmonthgrid.cpp @@ -195,6 +195,9 @@ QQuickMonthGrid::QQuickMonthGrid(QQuickItem *parent) : setFlag(ItemIsFocusScope); setActiveFocusOnTab(true); setAcceptedMouseButtons(Qt::LeftButton); +#if QT_CONFIG(cursor) + setCursor(Qt::ArrowCursor); +#endif d->model = new QQuickMonthModel(this); d->source = QVariant::fromValue(d->model); diff --git a/src/quicktemplates2/qquickabstractbutton.cpp b/src/quicktemplates2/qquickabstractbutton.cpp index 225ab9ab..7c2ced66 100644 --- a/src/quicktemplates2/qquickabstractbutton.cpp +++ b/src/quicktemplates2/qquickabstractbutton.cpp @@ -308,6 +308,9 @@ QQuickAbstractButton::QQuickAbstractButton(QQuickItem *parent) setActiveFocusOnTab(true); setFocusPolicy(Qt::StrongFocus); setAcceptedMouseButtons(Qt::LeftButton); +#if QT_CONFIG(cursor) + setCursor(Qt::ArrowCursor); +#endif } QQuickAbstractButton::QQuickAbstractButton(QQuickAbstractButtonPrivate &dd, QQuickItem *parent) @@ -316,6 +319,9 @@ QQuickAbstractButton::QQuickAbstractButton(QQuickAbstractButtonPrivate &dd, QQui setActiveFocusOnTab(true); setFocusPolicy(Qt::StrongFocus); setAcceptedMouseButtons(Qt::LeftButton); +#if QT_CONFIG(cursor) + setCursor(Qt::ArrowCursor); +#endif } QQuickAbstractButton::~QQuickAbstractButton() diff --git a/src/quicktemplates2/qquickcombobox.cpp b/src/quicktemplates2/qquickcombobox.cpp index 786db55b..85c577b4 100644 --- a/src/quicktemplates2/qquickcombobox.cpp +++ b/src/quicktemplates2/qquickcombobox.cpp @@ -628,6 +628,9 @@ QQuickComboBox::QQuickComboBox(QQuickItem *parent) setFocusPolicy(Qt::StrongFocus); setFlag(QQuickItem::ItemIsFocusScope); setAcceptedMouseButtons(Qt::LeftButton); +#if QT_CONFIG(cursor) + setCursor(Qt::ArrowCursor); +#endif setInputMethodHints(Qt::ImhNoPredictiveText); } @@ -737,12 +740,18 @@ void QQuickComboBox::setEditable(bool editable) QObjectPrivate::connect(input, &QQuickTextInput::textChanged, d, &QQuickComboBoxPrivate::updateEditText); QObjectPrivate::connect(input, &QQuickTextInput::accepted, d, &QQuickComboBoxPrivate::acceptInput); } +#if QT_CONFIG(cursor) + d->contentItem->setCursor(Qt::IBeamCursor); +#endif } else { d->contentItem->removeEventFilter(this); if (QQuickTextInput *input = qobject_cast(d->contentItem)) { QObjectPrivate::disconnect(input, &QQuickTextInput::textChanged, d, &QQuickComboBoxPrivate::updateEditText); QObjectPrivate::disconnect(input, &QQuickTextInput::accepted, d, &QQuickComboBoxPrivate::acceptInput); } +#if QT_CONFIG(cursor) + d->contentItem->unsetCursor(); +#endif } } @@ -1542,6 +1551,9 @@ void QQuickComboBox::contentItemChange(QQuickItem *newItem, QQuickItem *oldItem) connect(newInput, &QQuickTextInput::inputMethodComposingChanged, this, &QQuickComboBox::inputMethodComposingChanged); connect(newInput, &QQuickTextInput::acceptableInputChanged, this, &QQuickComboBox::acceptableInputChanged); } +#if QT_CONFIG(cursor) + newItem->setCursor(Qt::IBeamCursor); +#endif } } diff --git a/src/quicktemplates2/qquickdial.cpp b/src/quicktemplates2/qquickdial.cpp index 24a8df01..c7fbdc80 100644 --- a/src/quicktemplates2/qquickdial.cpp +++ b/src/quicktemplates2/qquickdial.cpp @@ -260,6 +260,9 @@ QQuickDial::QQuickDial(QQuickItem *parent) { setActiveFocusOnTab(true); setAcceptedMouseButtons(Qt::LeftButton); +#if QT_CONFIG(cursor) + setCursor(Qt::ArrowCursor); +#endif } /*! diff --git a/src/quicktemplates2/qquickoverlay.cpp b/src/quicktemplates2/qquickoverlay.cpp index c72979ae..d31186cd 100644 --- a/src/quicktemplates2/qquickoverlay.cpp +++ b/src/quicktemplates2/qquickoverlay.cpp @@ -97,6 +97,9 @@ static QQuickItem *createDimmer(QQmlComponent *component, QQuickPopup *popup, QQ item->setZ(popup->z()); if (popup->isModal()) { item->setAcceptedMouseButtons(Qt::AllButtons); +#if QT_CONFIG(cursor) + item->setCursor(Qt::ArrowCursor); +#endif #if QT_CONFIG(quicktemplates2_hover) // TODO: switch to QStyleHints::useHoverEffects in Qt 5.8 item->setAcceptHoverEvents(true); diff --git a/src/quicktemplates2/qquickpage.cpp b/src/quicktemplates2/qquickpage.cpp index 701916b6..6b0b3a38 100644 --- a/src/quicktemplates2/qquickpage.cpp +++ b/src/quicktemplates2/qquickpage.cpp @@ -117,6 +117,9 @@ QQuickPage::QQuickPage(QQuickItem *parent) Q_D(QQuickPage); setFlag(ItemIsFocusScope); setAcceptedMouseButtons(Qt::AllButtons); +#if QT_CONFIG(cursor) + setCursor(Qt::ArrowCursor); +#endif d->layout.reset(new QQuickPageLayout(this)); } diff --git a/src/quicktemplates2/qquickpageindicator.cpp b/src/quicktemplates2/qquickpageindicator.cpp index 92b6c0c0..b4c9c14c 100644 --- a/src/quicktemplates2/qquickpageindicator.cpp +++ b/src/quicktemplates2/qquickpageindicator.cpp @@ -247,7 +247,17 @@ void QQuickPageIndicator::setInteractive(bool interactive) return; d->interactive = interactive; - setAcceptedMouseButtons(interactive ? Qt::LeftButton : Qt::NoButton); + if (interactive) { + setAcceptedMouseButtons(Qt::LeftButton); +#if QT_CONFIG(cursor) + setCursor(Qt::ArrowCursor); +#endif + } else { + setAcceptedMouseButtons(Qt::NoButton); +#if QT_CONFIG(cursor) + unsetCursor(); +#endif + } emit interactiveChanged(); } diff --git a/src/quicktemplates2/qquickpane.cpp b/src/quicktemplates2/qquickpane.cpp index 6cb81316..efa85e0c 100644 --- a/src/quicktemplates2/qquickpane.cpp +++ b/src/quicktemplates2/qquickpane.cpp @@ -123,6 +123,9 @@ QQuickPane::QQuickPane(QQuickItem *parent) { setFlag(QQuickItem::ItemIsFocusScope); setAcceptedMouseButtons(Qt::AllButtons); +#if QT_CONFIG(cursor) + setCursor(Qt::ArrowCursor); +#endif } QQuickPane::QQuickPane(QQuickPanePrivate &dd, QQuickItem *parent) @@ -130,6 +133,9 @@ QQuickPane::QQuickPane(QQuickPanePrivate &dd, QQuickItem *parent) { setFlag(QQuickItem::ItemIsFocusScope); setAcceptedMouseButtons(Qt::AllButtons); +#if QT_CONFIG(cursor) + setCursor(Qt::ArrowCursor); +#endif } /*! diff --git a/src/quicktemplates2/qquickrangeslider.cpp b/src/quicktemplates2/qquickrangeslider.cpp index 1c74f9ee..2d3c464f 100644 --- a/src/quicktemplates2/qquickrangeslider.cpp +++ b/src/quicktemplates2/qquickrangeslider.cpp @@ -521,8 +521,11 @@ QQuickRangeSlider::QQuickRangeSlider(QQuickItem *parent) d->first = new QQuickRangeSliderNode(0.0, this); d->second = new QQuickRangeSliderNode(1.0, this); - setAcceptedMouseButtons(Qt::LeftButton); setFlag(QQuickItem::ItemIsFocusScope); + setAcceptedMouseButtons(Qt::LeftButton); +#if QT_CONFIG(cursor) + setCursor(Qt::ArrowCursor); +#endif } /*! diff --git a/src/quicktemplates2/qquickscrollbar.cpp b/src/quicktemplates2/qquickscrollbar.cpp index 8f4337ae..cb5c0001 100644 --- a/src/quicktemplates2/qquickscrollbar.cpp +++ b/src/quicktemplates2/qquickscrollbar.cpp @@ -196,9 +196,18 @@ void QQuickScrollBarPrivate::setInteractive(bool enabled) return; interactive = enabled; - q->setAcceptedMouseButtons(interactive ? Qt::LeftButton : Qt::NoButton); - if (!interactive) + if (interactive) { + q->setAcceptedMouseButtons(Qt::LeftButton); +#if QT_CONFIG(cursor) + q->setCursor(Qt::ArrowCursor); +#endif + } else { + q->setAcceptedMouseButtons(Qt::NoButton); +#if QT_CONFIG(cursor) + q->unsetCursor(); +#endif q->ungrabMouse(); + } emit q->interactiveChanged(); } diff --git a/src/quicktemplates2/qquickslider.cpp b/src/quicktemplates2/qquickslider.cpp index 266f883f..fbf9755d 100644 --- a/src/quicktemplates2/qquickslider.cpp +++ b/src/quicktemplates2/qquickslider.cpp @@ -243,6 +243,9 @@ QQuickSlider::QQuickSlider(QQuickItem *parent) setActiveFocusOnTab(true); setFocusPolicy(Qt::StrongFocus); setAcceptedMouseButtons(Qt::LeftButton); +#if QT_CONFIG(cursor) + setCursor(Qt::ArrowCursor); +#endif } /*! diff --git a/src/quicktemplates2/qquickspinbox.cpp b/src/quicktemplates2/qquickspinbox.cpp index 657102c3..b70366ea 100644 --- a/src/quicktemplates2/qquickspinbox.cpp +++ b/src/quicktemplates2/qquickspinbox.cpp @@ -351,6 +351,9 @@ QQuickSpinBox::QQuickSpinBox(QQuickItem *parent) setFlag(ItemIsFocusScope); setFiltersChildMouseEvents(true); setAcceptedMouseButtons(Qt::LeftButton); +#if QT_CONFIG(cursor) + setCursor(Qt::ArrowCursor); +#endif } /*! @@ -470,6 +473,15 @@ void QQuickSpinBox::setEditable(bool editable) if (d->editable == editable) return; +#if QT_CONFIG(cursor) + if (d->contentItem) { + if (editable) + d->contentItem->setCursor(Qt::IBeamCursor); + else + d->contentItem->unsetCursor(); + } +#endif + d->editable = editable; emit editableChanged(); } @@ -905,11 +917,16 @@ void QQuickSpinBox::itemChange(ItemChange change, const ItemChangeData &value) void QQuickSpinBox::contentItemChange(QQuickItem *newItem, QQuickItem *oldItem) { + Q_D(QQuickSpinBox); if (QQuickTextInput *oldInput = qobject_cast(oldItem)) disconnect(oldInput, &QQuickTextInput::inputMethodComposingChanged, this, &QQuickSpinBox::inputMethodComposingChanged); if (newItem) { newItem->setActiveFocusOnTab(true); +#if QT_CONFIG(cursor) + if (d->editable) + newItem->setCursor(Qt::IBeamCursor); +#endif if (QQuickTextInput *newInput = qobject_cast(newItem)) connect(newInput, &QQuickTextInput::inputMethodComposingChanged, this, &QQuickSpinBox::inputMethodComposingChanged); diff --git a/tests/auto/cursor/data/buttons.qml b/tests/auto/cursor/data/buttons.qml new file mode 100644 index 00000000..21226ef5 --- /dev/null +++ b/tests/auto/cursor/data/buttons.qml @@ -0,0 +1,104 @@ +/**************************************************************************** +** +** 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.6 +import QtQuick.Controls 2.2 + +MouseArea { + width: column.width + height: column.height + cursorShape: Qt.ForbiddenCursor + + Column { + id: column + padding: 10 + spacing: 10 + + Button { + text: "Button" + } + CheckBox { + text: "CheckBox" + } + CheckDelegate { + text: "CheckDelegate" + } + ItemDelegate { + text: "ItemDelegate" + } + MenuItem { + text: "MenuItem" + } + RadioButton { + text: "RadioButton" + } + RadioDelegate { + text: "RadioDelegate" + } + RoundButton { + text: "X" + } + SwipeDelegate { + text: "SwipeDelegate" + } + Switch { + text: "Switch" + } + SwitchDelegate { + text: "SwitchDelegate" + } + TabButton { + text: "TabButton" + } + ToolButton { + text: "ToolButton" + } + } +} diff --git a/tests/auto/cursor/data/containers.qml b/tests/auto/cursor/data/containers.qml new file mode 100644 index 00000000..09fbbc18 --- /dev/null +++ b/tests/auto/cursor/data/containers.qml @@ -0,0 +1,77 @@ +/**************************************************************************** +** +** 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.6 +import QtQuick.Controls 2.2 + +MouseArea { + width: column.width + height: column.height + cursorShape: Qt.ForbiddenCursor + + Column { + id: column + padding: 10 + spacing: 10 + + Page { + width: 200 + height: 20 + } + Pane { + width: 200 + height: 20 + } + ToolBar { + width: 200 + height: 20 + } + } +} diff --git a/tests/auto/cursor/data/editable.qml b/tests/auto/cursor/data/editable.qml new file mode 100644 index 00000000..1956889b --- /dev/null +++ b/tests/auto/cursor/data/editable.qml @@ -0,0 +1,72 @@ +/**************************************************************************** +** +** 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.6 +import QtQuick.Controls 2.2 + +MouseArea { + width: column.width + height: column.height + cursorShape: Qt.ForbiddenCursor + + Column { + id: column + padding: 10 + spacing: 10 + + ComboBox { + editable: true + model: "ComboBox" + } + SpinBox { + editable: true + } + } +} diff --git a/tests/auto/cursor/data/pageindicator.qml b/tests/auto/cursor/data/pageindicator.qml new file mode 100644 index 00000000..1e550a78 --- /dev/null +++ b/tests/auto/cursor/data/pageindicator.qml @@ -0,0 +1,62 @@ +/**************************************************************************** +** +** 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.6 +import QtQuick.Controls 2.2 + +MouseArea { + width: 200 + height: 200 + cursorShape: Qt.ForbiddenCursor + + PageIndicator { + anchors.centerIn: parent + } +} diff --git a/tests/auto/cursor/data/sliders.qml b/tests/auto/cursor/data/sliders.qml new file mode 100644 index 00000000..408e8947 --- /dev/null +++ b/tests/auto/cursor/data/sliders.qml @@ -0,0 +1,71 @@ +/**************************************************************************** +** +** 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.6 +import QtQuick.Controls 2.2 + +MouseArea { + width: column.width + height: column.height + cursorShape: Qt.ForbiddenCursor + + Column { + id: column + padding: 10 + spacing: 10 + + Dial { + } + Slider { + } + RangeSlider { + } + } +} diff --git a/tests/auto/cursor/tst_cursor.cpp b/tests/auto/cursor/tst_cursor.cpp index dafb3159..6256112d 100644 --- a/tests/auto/cursor/tst_cursor.cpp +++ b/tests/auto/cursor/tst_cursor.cpp @@ -37,7 +37,10 @@ #include #include "../shared/visualtestutil.h" +#include #include +#include +#include #include #include @@ -48,9 +51,114 @@ class tst_cursor : public QQmlDataTest Q_OBJECT private slots: + void controls_data(); + void controls(); + void editable(); + void pageIndicator(); void scrollBar(); }; +void tst_cursor::controls_data() +{ + QTest::addColumn("testFile"); + + QTest::newRow("buttons") << "buttons.qml"; + QTest::newRow("containers") << "containers.qml"; + QTest::newRow("sliders") << "sliders.qml"; +} + +void tst_cursor::controls() +{ + QFETCH(QString, testFile); + + QQuickView view(testFileUrl(testFile)); + view.show(); + QVERIFY(QTest::qWaitForWindowActive(&view)); + + QQuickItem *mouseArea = view.rootObject(); + QVERIFY(mouseArea); + QCOMPARE(mouseArea->cursor().shape(), Qt::ForbiddenCursor); + + QQuickItem *column = mouseArea->childItems().value(0); + QVERIFY(column); + + const auto controls = column->childItems(); + for (QQuickItem *control : controls) { + QCOMPARE(control->cursor().shape(), Qt::ArrowCursor); + + QTest::mouseMove(&view, control->mapToScene(QPointF(-1, -1)).toPoint()); + QCOMPARE(view.cursor().shape(), Qt::ForbiddenCursor); + + QTest::mouseMove(&view, control->mapToScene(QPointF(0, 0)).toPoint()); + QCOMPARE(view.cursor().shape(), Qt::ArrowCursor); + + QTest::mouseMove(&view, control->mapToScene(QPointF(control->width() + 1, control->height() + 1)).toPoint()); + QCOMPARE(view.cursor().shape(), Qt::ForbiddenCursor); + } +} + +void tst_cursor::editable() +{ + QQuickView view(testFileUrl("editable.qml")); + view.show(); + QVERIFY(QTest::qWaitForWindowActive(&view)); + + QQuickItem *mouseArea = view.rootObject(); + QVERIFY(mouseArea); + QCOMPARE(mouseArea->cursor().shape(), Qt::ForbiddenCursor); + + QQuickItem *column = mouseArea->childItems().value(0); + QVERIFY(column); + + const auto children = column->childItems(); + for (QQuickItem *child : children) { + QQuickControl *control = qobject_cast(child); + QVERIFY(control); + QCOMPARE(control->cursor().shape(), Qt::ArrowCursor); + QCOMPARE(control->contentItem()->cursor().shape(), Qt::IBeamCursor); + + QTest::mouseMove(&view, control->mapToScene(QPointF(-1, -1)).toPoint()); + QCOMPARE(view.cursor().shape(), Qt::ForbiddenCursor); + + QTest::mouseMove(&view, control->mapToScene(QPointF(control->width() / 2, control->height() / 2)).toPoint()); + QCOMPARE(view.cursor().shape(), Qt::IBeamCursor); + + control->setProperty("editable", false); + QCOMPARE(control->cursor().shape(), Qt::ArrowCursor); + QCOMPARE(control->contentItem()->cursor().shape(), Qt::ArrowCursor); + QCOMPARE(view.cursor().shape(), Qt::ArrowCursor); + + QTest::mouseMove(&view, control->mapToScene(QPointF(control->width() + 1, control->height() + 1)).toPoint()); + QCOMPARE(view.cursor().shape(), Qt::ForbiddenCursor); + } +} + +void tst_cursor::pageIndicator() +{ + QQuickView view(testFileUrl("pageindicator.qml")); + view.show(); + QVERIFY(QTest::qWaitForWindowActive(&view)); + + QQuickItem *mouseArea = view.rootObject(); + QVERIFY(mouseArea); + QCOMPARE(mouseArea->cursor().shape(), Qt::ForbiddenCursor); + + QQuickPageIndicator *indicator = qobject_cast(mouseArea->childItems().value(0)); + QVERIFY(indicator); + + QTest::mouseMove(&view, indicator->mapToScene(QPointF(-1, -1)).toPoint()); + QCOMPARE(view.cursor().shape(), Qt::ForbiddenCursor); + + QTest::mouseMove(&view, indicator->mapToScene(QPointF(0, 0)).toPoint()); + QCOMPARE(view.cursor().shape(), Qt::ForbiddenCursor); + + indicator->setInteractive(true); + QCOMPARE(view.cursor().shape(), Qt::ArrowCursor); + + QTest::mouseMove(&view, indicator->mapToScene(QPointF(indicator->width() + 1, indicator->height() + 1)).toPoint()); + QCOMPARE(view.cursor().shape(), Qt::ForbiddenCursor); +} + // QTBUG-59629 void tst_cursor::scrollBar() { @@ -59,7 +167,7 @@ void tst_cursor::scrollBar() QQuickApplicationHelper helper(this, QStringLiteral("scrollbar.qml")); QQuickApplicationWindow *window = helper.appWindow; window->show(); - QVERIFY(QTest::qWaitForWindowExposed(window)); + QVERIFY(QTest::qWaitForWindowActive(window)); QQuickScrollBar *scrollBar = helper.appWindow->property("scrollBar").value(); QVERIFY(scrollBar); @@ -72,12 +180,16 @@ void tst_cursor::scrollBar() const QPoint textAreaPos(window->width() / 2, window->height() / 2); QTest::mouseMove(window, textAreaPos); QCOMPARE(window->cursor().shape(), textArea->cursor().shape()); + QCOMPARE(textArea->cursor().shape(), Qt::CursorShape::IBeamCursor); const QPoint scrollBarPos(window->width() - scrollBar->width() / 2, window->height() / 2); QTest::mouseMove(window, scrollBarPos); QVERIFY(scrollBar->isActive()); QCOMPARE(window->cursor().shape(), scrollBar->cursor().shape()); QCOMPARE(scrollBar->cursor().shape(), Qt::CursorShape::ArrowCursor); + + scrollBar->setInteractive(false); + QCOMPARE(window->cursor().shape(), textArea->cursor().shape()); } QTEST_MAIN(tst_cursor) -- cgit v1.2.3 From f5890e07ca8172b05ce8305c65b42531acdb629b Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Tue, 4 Apr 2017 15:32:23 +0200 Subject: auto tests: utilize TestCase::fuzzyCompare() Change-Id: I9c3f7997a14bd1824663c7521061c4ee43d6380e Reviewed-by: Mitch Curtis --- tests/auto/controls/data/tst_rangeslider.qml | 24 ++++++++++-------------- tests/auto/controls/data/tst_slider.qml | 24 ++++++++++-------------- 2 files changed, 20 insertions(+), 28 deletions(-) diff --git a/tests/auto/controls/data/tst_rangeslider.qml b/tests/auto/controls/data/tst_rangeslider.qml index cde81981..c25b7e0f 100644 --- a/tests/auto/controls/data/tst_rangeslider.qml +++ b/tests/auto/controls/data/tst_rangeslider.qml @@ -792,9 +792,7 @@ TestCase { control.first.value = 0 control.second.value = data.to - function sliderCompare(left, right) { - return Math.abs(left - right) < 0.05 - } + var fuzz = 0.05 mousePress(control, control.first.handle.x, control.first.handle.y) compare(control.first.pressed, true) @@ -803,13 +801,13 @@ TestCase { mouseMove(control, control.leftPadding + 0.15 * (control.availableWidth + control.first.handle.width / 2)) compare(control.first.pressed, true) - verify(sliderCompare(control.first.value, data.values[1])) - verify(sliderCompare(control.first.position, data.positions[1])) + fuzzyCompare(control.first.value, data.values[1], fuzz) + fuzzyCompare(control.first.position, data.positions[1], fuzz) mouseRelease(control, control.leftPadding + 0.15 * (control.availableWidth + control.first.handle.width / 2)) compare(control.first.pressed, false) - verify(sliderCompare(control.first.value, data.values[2])) - verify(sliderCompare(control.first.position, data.positions[2])) + fuzzyCompare(control.first.value, data.values[2], fuzz) + fuzzyCompare(control.first.position, data.positions[2], fuzz) } function test_snapMode_touch_data() { @@ -823,9 +821,7 @@ TestCase { control.first.value = 0 control.second.value = data.to - function sliderCompare(left, right) { - return Math.abs(left - right) < 0.05 - } + var fuzz = 0.05 var touch = touchEvent(control) touch.press(0, control, control.first.handle.x, control.first.handle.y).commit() @@ -835,13 +831,13 @@ TestCase { touch.move(0, control, control.leftPadding + 0.15 * (control.availableWidth + control.first.handle.width / 2)).commit() compare(control.first.pressed, true) - verify(sliderCompare(control.first.value, data.values[1])) - verify(sliderCompare(control.first.position, data.positions[1])) + fuzzyCompare(control.first.value, data.values[1], fuzz) + fuzzyCompare(control.first.position, data.positions[1], fuzz) touch.release(0, control, control.leftPadding + 0.15 * (control.availableWidth + control.first.handle.width / 2)).commit() compare(control.first.pressed, false) - verify(sliderCompare(control.first.value, data.values[2])) - verify(sliderCompare(control.first.position, data.positions[2])) + fuzzyCompare(control.first.value, data.values[2], fuzz) + fuzzyCompare(control.first.position, data.positions[2], fuzz) } function test_focus() { diff --git a/tests/auto/controls/data/tst_slider.qml b/tests/auto/controls/data/tst_slider.qml index c647b666..40bb389d 100644 --- a/tests/auto/controls/data/tst_slider.qml +++ b/tests/auto/controls/data/tst_slider.qml @@ -664,9 +664,7 @@ TestCase { var control = createTemporaryObject(slider, testCase, {live: false, snapMode: data.snapMode, from: data.from, to: data.to, stepSize: 0.2}) verify(control) - function sliderCompare(left, right) { - return Math.abs(left - right) < 0.05 - } + var fuzz = 0.05 mousePress(control, control.leftPadding) compare(control.value, data.values[0]) @@ -674,12 +672,12 @@ TestCase { mouseMove(control, control.leftPadding + 0.15 * (control.availableWidth + control.handle.width / 2)) - verify(sliderCompare(control.value, data.values[1])) - verify(sliderCompare(control.position, data.positions[1])) + fuzzyCompare(control.value, data.values[1], fuzz) + fuzzyCompare(control.position, data.positions[1], fuzz) mouseRelease(control, control.leftPadding + 0.15 * (control.availableWidth + control.handle.width / 2)) - verify(sliderCompare(control.value, data.values[2])) - verify(sliderCompare(control.position, data.positions[2])) + fuzzyCompare(control.value, data.values[2], fuzz) + fuzzyCompare(control.position, data.positions[2], fuzz) } function test_snapMode_touch_data() { @@ -690,9 +688,7 @@ TestCase { var control = createTemporaryObject(slider, testCase, {live: false, snapMode: data.snapMode, from: data.from, to: data.to, stepSize: 0.2}) verify(control) - function sliderCompare(left, right) { - return Math.abs(left - right) < 0.05 - } + var fuzz = 0.05 var touch = touchEvent(control) touch.press(0, control, control.leftPadding).commit() @@ -701,12 +697,12 @@ TestCase { touch.move(0, control, control.leftPadding + 0.15 * (control.availableWidth + control.handle.width / 2)).commit() - verify(sliderCompare(control.value, data.values[1])) - verify(sliderCompare(control.position, data.positions[1])) + fuzzyCompare(control.value, data.values[1], fuzz) + fuzzyCompare(control.position, data.positions[1], fuzz) touch.release(0, control, control.leftPadding + 0.15 * (control.availableWidth + control.handle.width / 2)).commit() - verify(sliderCompare(control.value, data.values[2])) - verify(sliderCompare(control.position, data.positions[2])) + fuzzyCompare(control.value, data.values[2], fuzz) + fuzzyCompare(control.position, data.positions[2], fuzz) } function test_wheel_data() { -- cgit v1.2.3 From 1cf6abc8ba5547f12352467db8ce1c3d09921960 Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Tue, 4 Apr 2017 17:41:14 +0200 Subject: Slider: react immediately when using a mouse The initial drag threshold is a necessary evil on touch to avoid conflicting with flickables, but leads to bad experience (QTBUG-47081) when using a mouse. Now that we have separate mouse and touch handling, we can apply immediate moves when using a mouse, but keep the old behavior on touch. Changing the behavior is simple, but auto tests need quite many tweaks so RangeSlider and Dial will be done separate follow up changes. [ChangeLog][Important Behavior Changes] Sliders and Dials now react immediately when using a mouse. Now the initial drag threshold applies only on touch, to avoid conflicting with flickables. Task-number: QTBUG-59920 Change-Id: Ifc1e6ed74c7894c3c854c975dff5238278827590 Reviewed-by: Mitch Curtis --- src/quicktemplates2/qquickslider.cpp | 6 +++--- tests/auto/controls/data/tst_slider.qml | 30 +++++++++++++++--------------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/quicktemplates2/qquickslider.cpp b/src/quicktemplates2/qquickslider.cpp index fbf9755d..77e5856c 100644 --- a/src/quicktemplates2/qquickslider.cpp +++ b/src/quicktemplates2/qquickslider.cpp @@ -194,8 +194,6 @@ void QQuickSliderPrivate::handlePress(const QPointF &point) void QQuickSliderPrivate::handleMove(const QPointF &point) { Q_Q(QQuickSlider); - if (!q->keepMouseGrab() && !q->keepTouchGrab()) - return; const qreal oldPos = position; qreal pos = positionAt(point); if (snapMode == QQuickSlider::SnapAlways) @@ -621,6 +619,7 @@ void QQuickSlider::mousePressEvent(QMouseEvent *event) Q_D(QQuickSlider); QQuickControl::mousePressEvent(event); d->handlePress(event->localPos()); + d->handleMove(event->localPos()); } void QQuickSlider::mouseMoveEvent(QMouseEvent *event) @@ -675,7 +674,8 @@ void QQuickSlider::touchEvent(QTouchEvent *event) else setKeepTouchGrab(QQuickWindowPrivate::dragOverThreshold(point.pos().y() - d->pressPoint.y(), Qt::YAxis, &point)); } - d->handleMove(point.pos()); + if (keepTouchGrab()) + d->handleMove(point.pos()); } break; diff --git a/tests/auto/controls/data/tst_slider.qml b/tests/auto/controls/data/tst_slider.qml index 40bb389d..b02e77d0 100644 --- a/tests/auto/controls/data/tst_slider.qml +++ b/tests/auto/controls/data/tst_slider.qml @@ -229,7 +229,7 @@ TestCase { var movedSpy = signalSpy.createObject(control, {target: control, signalName: "moved"}) verify(movedSpy.valid) - mousePress(control, 0, 0, Qt.LeftButton) + mousePress(control, 0, control.height, Qt.LeftButton) compare(pressedSpy.count, ++pressedCount) compare(movedSpy.count, movedCount) compare(control.pressed, true) @@ -258,17 +258,17 @@ TestCase { compare(control.value, 0.5) compare(control.position, 0.5) - mousePress(control, control.width, control.height, Qt.LeftButton) + mousePress(control, control.width, 0, Qt.LeftButton) compare(pressedSpy.count, ++pressedCount) - compare(movedSpy.count, movedCount) + compare(movedSpy.count, ++movedCount) compare(control.pressed, true) - compare(control.value, 0.5) - compare(control.position, 0.5) + compare(control.value, data.live ? 1.0 : 0.5) + compare(control.position, 1.0) // maximum on the right in horizontal vs. at the top in vertical mouseMove(control, control.width * 2, -control.height, 0) compare(pressedSpy.count, pressedCount) - compare(movedSpy.count, ++movedCount) + compare(movedSpy.count, movedCount) compare(control.pressed, true) compare(control.value, data.live ? 1.0 : 0.5) compare(control.position, 1.0) @@ -617,8 +617,8 @@ TestCase { compare(pressedSpy.count, 3) compare(control.pressed, true) compare(control.value, 0.0) - compare(control.position, 0.0) - compare(control.visualPosition, 1.0) + compare(control.position, 1.0) + compare(control.visualPosition, 0.0) mouseMove(control, control.leftPadding + control.availableWidth * 0.5, control.height * 0.5, 0) compare(pressedSpy.count, 3) @@ -642,22 +642,22 @@ TestCase { compare(control.visualPosition, 0.5) } - function test_snapMode_data() { + function test_snapMode_data(immediate) { return [ { tag: "NoSnap", snapMode: Slider.NoSnap, from: 0, to: 2, values: [0, 0, 0.25], positions: [0, 0.1, 0.1] }, { tag: "SnapAlways (0..2)", snapMode: Slider.SnapAlways, from: 0, to: 2, values: [0.0, 0.0, 0.2], positions: [0.0, 0.1, 0.1] }, { tag: "SnapAlways (1..3)", snapMode: Slider.SnapAlways, from: 1, to: 3, values: [1.0, 1.0, 1.2], positions: [0.0, 0.1, 0.1] }, - { tag: "SnapAlways (-1..1)", snapMode: Slider.SnapAlways, from: -1, to: 1, values: [0.0, 0.0, -0.8], positions: [0.5, 0.1, 0.1] }, - { tag: "SnapAlways (1..-1)", snapMode: Slider.SnapAlways, from: 1, to: -1, values: [0.0, 0.0, 0.8], positions: [0.5, 0.1, 0.1] }, + { tag: "SnapAlways (-1..1)", snapMode: Slider.SnapAlways, from: -1, to: 1, values: [0.0, 0.0, -0.8], positions: [immediate ? 0.0 : 0.5, 0.1, 0.1] }, + { tag: "SnapAlways (1..-1)", snapMode: Slider.SnapAlways, from: 1, to: -1, values: [0.0, 0.0, 0.8], positions: [immediate ? 0.0 : 0.5, 0.1, 0.1] }, { tag: "SnapOnRelease (0..2)", snapMode: Slider.SnapOnRelease, from: 0, to: 2, values: [0.0, 0.0, 0.2], positions: [0.0, 0.1, 0.1] }, { tag: "SnapOnRelease (1..3)", snapMode: Slider.SnapOnRelease, from: 1, to: 3, values: [1.0, 1.0, 1.2], positions: [0.0, 0.1, 0.1] }, - { tag: "SnapOnRelease (-1..1)", snapMode: Slider.SnapOnRelease, from: -1, to: 1, values: [0.0, 0.0, -0.8], positions: [0.5, 0.1, 0.1] }, - { tag: "SnapOnRelease (1..-1)", snapMode: Slider.SnapOnRelease, from: 1, to: -1, values: [0.0, 0.0, 0.8], positions: [0.5, 0.1, 0.1] } + { tag: "SnapOnRelease (-1..1)", snapMode: Slider.SnapOnRelease, from: -1, to: 1, values: [0.0, 0.0, -0.8], positions: [immediate ? 0.0 : 0.5, 0.1, 0.1] }, + { tag: "SnapOnRelease (1..-1)", snapMode: Slider.SnapOnRelease, from: 1, to: -1, values: [0.0, 0.0, 0.8], positions: [immediate ? 0.0 : 0.5, 0.1, 0.1] } ] } function test_snapMode_mouse_data() { - return test_snapMode_data() + return test_snapMode_data(true) } function test_snapMode_mouse(data) { @@ -681,7 +681,7 @@ TestCase { } function test_snapMode_touch_data() { - return test_snapMode_data() + return test_snapMode_data(false) } function test_snapMode_touch(data) { -- cgit v1.2.3 From 790cf8d3b4078dc1bbc1afb338f1bf197598c4d0 Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Tue, 4 Apr 2017 17:44:58 +0200 Subject: Dial: react immediately when using a mouse The initial drag threshold is a necessary evil on touch to avoid conflicting with flickables, but leads to bad experience (QTBUG-47081) when using a mouse. Now that we have separate mouse and touch handling, we can apply immediate moves when using a mouse, but keep the old behavior on touch. Task-number: QTBUG-59920 Change-Id: I097cbdaed4933c0d907097b75f15ba16dcf615b1 Reviewed-by: Mitch Curtis --- src/quicktemplates2/qquickdial.cpp | 6 +++--- tests/auto/controls/data/tst_dial.qml | 14 +++++++------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/quicktemplates2/qquickdial.cpp b/src/quicktemplates2/qquickdial.cpp index c7fbdc80..5b98992b 100644 --- a/src/quicktemplates2/qquickdial.cpp +++ b/src/quicktemplates2/qquickdial.cpp @@ -207,8 +207,6 @@ void QQuickDialPrivate::handlePress(const QPointF &point) void QQuickDialPrivate::handleMove(const QPointF &point) { Q_Q(QQuickDial); - if (!q->keepMouseGrab() && !q->keepTouchGrab()) - return; const qreal oldPos = position; qreal pos = positionAt(point); if (snapMode == QQuickDial::SnapAlways) @@ -651,6 +649,7 @@ void QQuickDial::mousePressEvent(QMouseEvent *event) Q_D(QQuickDial); QQuickControl::mousePressEvent(event); d->handlePress(event->localPos()); + d->handleMove(event->localPos()); } void QQuickDial::mouseMoveEvent(QMouseEvent *event) @@ -711,7 +710,8 @@ void QQuickDial::touchEvent(QTouchEvent *event) setKeepTouchGrab(overYDragThreshold); } } - d->handleMove(point.pos()); + if (keepTouchGrab()) + d->handleMove(point.pos()); } break; diff --git a/tests/auto/controls/data/tst_dial.qml b/tests/auto/controls/data/tst_dial.qml index 98c3a002..3b20e91d 100644 --- a/tests/auto/controls/data/tst_dial.qml +++ b/tests/auto/controls/data/tst_dial.qml @@ -465,7 +465,7 @@ TestCase { compare(dial.value, dial.to); } - function test_snapMode_data() { + function test_snapMode_data(immediate) { return [ { tag: "NoSnap", snapMode: Slider.NoSnap, from: 0, to: 2, values: [0, 0, 1], positions: [0, 0.5, 0.5] }, { tag: "SnapAlways (0..2)", snapMode: Slider.SnapAlways, from: 0, to: 2, values: [0.0, 0.0, 1.0], positions: [0.0, 0.5, 0.5] }, @@ -474,13 +474,13 @@ TestCase { { tag: "SnapAlways (1..-1)", snapMode: Slider.SnapAlways, from: 1, to: -1, values: [1.0, 1.0, 0.0], positions: [0.0, 0.5, 0.5] }, { tag: "SnapOnRelease (0..2)", snapMode: Slider.SnapOnRelease, from: 0, to: 2, values: [0.0, 0.0, 1.0], positions: [0.0, 0.5, 0.5] }, { tag: "SnapOnRelease (1..3)", snapMode: Slider.SnapOnRelease, from: 1, to: 3, values: [1.0, 1.0, 2.0], positions: [0.0, 0.5, 0.5] }, - { tag: "SnapOnRelease (-1..1)", snapMode: Slider.SnapOnRelease, from: -1, to: 1, values: [0.0, 0.0, 0.0], positions: [0.5, 0.5, 0.5] }, + { tag: "SnapOnRelease (-1..1)", snapMode: Slider.SnapOnRelease, from: -1, to: 1, values: [0.0, 0.0, 0.0], positions: [immediate ? 0.0 : 0.5, 0.5, 0.5] }, { tag: "SnapOnRelease (1..-1)", snapMode: Slider.SnapOnRelease, from: 1, to: -1, values: [1.0, 1.0, 0.0], positions: [0.0, 0.5, 0.5] } ] } function test_snapMode_mouse_data() { - return test_snapMode_data() + return test_snapMode_data(true) } function test_snapMode_mouse(data) { @@ -492,11 +492,11 @@ TestCase { dial.to = data.to; dial.stepSize = 0.2; - var fuzz = 0.05; + var fuzz = 0.055; mousePress(dial, dial.width * 0.25, dial.height * 0.75); - compare(dial.value, data.values[0]); - compare(dial.position, data.positions[0]); + fuzzyCompare(dial.value, data.values[0], fuzz); + fuzzyCompare(dial.position, data.positions[0], fuzz); mouseMove(dial, dial.width * 0.5, dial.height * 0.25); fuzzyCompare(dial.value, data.values[1], fuzz); @@ -508,7 +508,7 @@ TestCase { } function test_snapMode_touch_data() { - return test_snapMode_data() + return test_snapMode_data(false) } function test_snapMode_touch(data) { -- cgit v1.2.3 From 4a37f67ec820cf9a972218d4244fc160a3697453 Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Tue, 4 Apr 2017 18:11:51 +0200 Subject: RangeSlider: react immediately when using a mouse The initial drag threshold is a necessary evil on touch to avoid conflicting with flickables, but leads to bad experience (QTBUG-47081) when using a mouse. Now that we have separate mouse and touch handling, we can apply immediate moves when using a mouse, but keep the old behavior on touch. Task-number: QTBUG-59920 Change-Id: Ida36eed1f59a30173e3a2c53b55e044a87c98d8b Reviewed-by: Mitch Curtis --- src/quicktemplates2/qquickrangeslider.cpp | 6 +++--- tests/auto/controls/data/tst_rangeslider.qml | 29 ++++++++++++++-------------- 2 files changed, 18 insertions(+), 17 deletions(-) diff --git a/src/quicktemplates2/qquickrangeslider.cpp b/src/quicktemplates2/qquickrangeslider.cpp index 2d3c464f..1c530c7c 100644 --- a/src/quicktemplates2/qquickrangeslider.cpp +++ b/src/quicktemplates2/qquickrangeslider.cpp @@ -456,8 +456,6 @@ void QQuickRangeSliderPrivate::handlePress(const QPointF &point, int touchId) void QQuickRangeSliderPrivate::handleMove(const QPointF &point, int touchId) { Q_Q(QQuickRangeSlider); - if (!q->keepMouseGrab() && !q->keepTouchGrab()) - return; QQuickRangeSliderNode *pressedNode = QQuickRangeSliderPrivate::pressedNode(touchId); if (pressedNode) { qreal pos = positionAt(q, pressedNode->handle(), point); @@ -953,6 +951,7 @@ void QQuickRangeSlider::mousePressEvent(QMouseEvent *event) Q_D(QQuickRangeSlider); QQuickControl::mousePressEvent(event); d->handlePress(event->localPos()); + d->handleMove(event->localPos()); } void QQuickRangeSlider::mouseMoveEvent(QMouseEvent *event) @@ -965,7 +964,8 @@ void QQuickRangeSlider::mouseMoveEvent(QMouseEvent *event) else setKeepMouseGrab(QQuickWindowPrivate::dragOverThreshold(event->localPos().y() - d->pressPoint.y(), Qt::YAxis, event)); } - d->handleMove(event->localPos()); + if (keepMouseGrab()) + d->handleMove(event->localPos()); } void QQuickRangeSlider::mouseReleaseEvent(QMouseEvent *event) diff --git a/tests/auto/controls/data/tst_rangeslider.qml b/tests/auto/controls/data/tst_rangeslider.qml index c25b7e0f..2cd83b89 100644 --- a/tests/auto/controls/data/tst_rangeslider.qml +++ b/tests/auto/controls/data/tst_rangeslider.qml @@ -287,7 +287,7 @@ TestCase { var secondPressedSpy = signalSpy.createObject(control, {target: control.second, signalName: "pressedChanged"}) verify(secondPressedSpy.valid) - mousePress(control, control.width * 0.25, control.height * 0.75, Qt.LeftButton) + mousePress(control, control.leftPadding, control.height - control.bottomPadding, Qt.LeftButton) compare(firstPressedSpy.count, 1) compare(secondPressedSpy.count, 0) compare(control.first.pressed, true) @@ -297,7 +297,7 @@ TestCase { compare(control.second.value, 1.0) compare(control.second.position, 1.0) - mouseRelease(control, control.width * 0.25, control.height * 0.75, Qt.LeftButton) + mouseRelease(control, control.leftPadding, control.height - control.bottomPadding, Qt.LeftButton) compare(firstPressedSpy.count, 2) compare(secondPressedSpy.count, 0) compare(control.first.pressed, false) @@ -307,7 +307,7 @@ TestCase { compare(control.second.value, 1.0) compare(control.second.position, 1.0) - mousePress(control, control.width * 0.75, control.height * 0.25, Qt.LeftButton) + mousePress(control, control.width - control.rightPadding, control.topPadding, Qt.LeftButton) compare(firstPressedSpy.count, 2) compare(secondPressedSpy.count, 1) compare(control.first.pressed, false) @@ -317,7 +317,7 @@ TestCase { compare(control.second.value, 1.0) compare(control.second.position, 1.0) - mouseRelease(control, control.width * 0.75, control.height * 0.25, Qt.LeftButton) + mouseRelease(control, control.width - control.rightPadding, control.topPadding, Qt.LeftButton) compare(firstPressedSpy.count, 2) compare(secondPressedSpy.count, 2) compare(control.first.pressed, false) @@ -347,7 +347,7 @@ TestCase { compare(control.second.value, 1.0) compare(control.second.position, 1.0) - mousePress(control, control.first.handle.x, control.first.handle.y, Qt.LeftButton) + mousePress(control, control.leftPadding, control.height - control.bottomPadding, Qt.LeftButton) compare(firstPressedSpy.count, 5) compare(secondPressedSpy.count, 2) compare(control.first.pressed, true) @@ -738,7 +738,8 @@ TestCase { control.first.value = 0 control.locale = Qt.locale("ar_EG") - mousePress(control, control.first.handle.x, control.first.handle.y, Qt.LeftButton) + mousePress(control, control.first.handle.x + control.first.handle.width / 2, + control.first.handle.y + control.first.handle.height / 2, Qt.LeftButton) compare(firstPressedSpy.count, 3) compare(control.first.pressed, true) compare(control.first.value, 0.0) @@ -767,22 +768,22 @@ TestCase { compare(control.first.visualPosition, 0.5) } - function test_snapMode_data() { + function test_snapMode_data(immediate) { return [ { tag: "NoSnap", snapMode: RangeSlider.NoSnap, from: 0, to: 2, values: [0, 0, 0.25], positions: [0, 0.1, 0.1] }, { tag: "SnapAlways (0..2)", snapMode: RangeSlider.SnapAlways, from: 0, to: 2, values: [0.0, 0.0, 0.2], positions: [0.0, 0.1, 0.1] }, { tag: "SnapAlways (1..3)", snapMode: RangeSlider.SnapAlways, from: 1, to: 3, values: [1.0, 1.0, 1.2], positions: [0.0, 0.1, 0.1] }, - { tag: "SnapAlways (-1..1)", snapMode: RangeSlider.SnapAlways, from: -1, to: 1, values: [0.0, 0.0, -0.8], positions: [0.5, 0.1, 0.1] }, - { tag: "SnapAlways (1..-1)", snapMode: RangeSlider.SnapAlways, from: 1, to: -1, values: [0.0, 0.0, 0.8], positions: [0.5, 0.1, 0.1] }, + { tag: "SnapAlways (-1..1)", snapMode: RangeSlider.SnapAlways, from: -1, to: 1, values: [0.0, 0.0, -0.8], positions: [immediate ? 0.0 : 0.5, 0.1, 0.1] }, + { tag: "SnapAlways (1..-1)", snapMode: RangeSlider.SnapAlways, from: 1, to: -1, values: [0.0, 0.0, 0.8], positions: [immediate ? 0.0 : 0.5, 0.1, 0.1] }, { tag: "SnapOnRelease (0..2)", snapMode: RangeSlider.SnapOnRelease, from: 0, to: 2, values: [0.0, 0.0, 0.2], positions: [0.0, 0.1, 0.1] }, { tag: "SnapOnRelease (1..3)", snapMode: RangeSlider.SnapOnRelease, from: 1, to: 3, values: [1.0, 1.0, 1.2], positions: [0.0, 0.1, 0.1] }, - { tag: "SnapOnRelease (-1..1)", snapMode: RangeSlider.SnapOnRelease, from: -1, to: 1, values: [0.0, 0.0, -0.8], positions: [0.5, 0.1, 0.1] }, - { tag: "SnapOnRelease (1..-1)", snapMode: RangeSlider.SnapOnRelease, from: 1, to: -1, values: [0.0, 0.0, 0.8], positions: [0.5, 0.1, 0.1] } + { tag: "SnapOnRelease (-1..1)", snapMode: RangeSlider.SnapOnRelease, from: -1, to: 1, values: [0.0, 0.0, -0.8], positions: [immediate ? 0.0 : 0.5, 0.1, 0.1] }, + { tag: "SnapOnRelease (1..-1)", snapMode: RangeSlider.SnapOnRelease, from: 1, to: -1, values: [0.0, 0.0, 0.8], positions: [immediate ? 0.0 : 0.5, 0.1, 0.1] } ] } function test_snapMode_mouse_data() { - return test_snapMode_data() + return test_snapMode_data(true) } function test_snapMode_mouse(data) { @@ -794,7 +795,7 @@ TestCase { var fuzz = 0.05 - mousePress(control, control.first.handle.x, control.first.handle.y) + mousePress(control, control.leftPadding) compare(control.first.pressed, true) compare(control.first.value, data.values[0]) compare(control.first.position, data.positions[0]) @@ -811,7 +812,7 @@ TestCase { } function test_snapMode_touch_data() { - return test_snapMode_data() + return test_snapMode_data(false) } function test_snapMode_touch(data) { -- cgit v1.2.3 From 920ca0adb8ca3b0f5a4a2c576420ef1f5f420320 Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Wed, 5 Apr 2017 19:19:44 +0200 Subject: Doc: highlight the Wearable Demo on the index page Change-Id: Ib7eb50df859ea598aac806dbd44f150f2b77e4e1 Reviewed-by: Mitch Curtis --- src/imports/controls/doc/src/qtquickcontrols2-index.qdoc | 1 + 1 file changed, 1 insertion(+) diff --git a/src/imports/controls/doc/src/qtquickcontrols2-index.qdoc b/src/imports/controls/doc/src/qtquickcontrols2-index.qdoc index 34e548a3..056c4ec3 100644 --- a/src/imports/controls/doc/src/qtquickcontrols2-index.qdoc +++ b/src/imports/controls/doc/src/qtquickcontrols2-index.qdoc @@ -155,6 +155,7 @@ \li \l{Qt Quick Controls 2 - Gallery}{Gallery} \li \l{Qt Quick Controls 2 - Chat Tutorial}{Chat Tutorial} \li \l{Qt Quick Controls 2 - Text Editor}{Text Editor} + \li \l{Qt Quick Controls 2 - Wearable Demo}{Wearable Demo} \li \l{Qt Quick Controls 2 Examples}{All Examples} \endlist -- cgit v1.2.3 From d453cc9ec7efd23479368a9b08cc3d3f0753b57a Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Wed, 5 Apr 2017 19:57:18 +0200 Subject: QQuickTabBar: add missing Q_REVISION() for contentWidth/HeightChanged() Missed in 24acfcaf. Change-Id: I11c87a21d7d29befec5784eff1961a6feb5ea24b Reviewed-by: Mitch Curtis --- src/quicktemplates2/qquicktabbar_p.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/quicktemplates2/qquicktabbar_p.h b/src/quicktemplates2/qquicktabbar_p.h index bc228346..0ffd53d5 100644 --- a/src/quicktemplates2/qquicktabbar_p.h +++ b/src/quicktemplates2/qquicktabbar_p.h @@ -83,8 +83,8 @@ public: Q_SIGNALS: void positionChanged(); - void contentWidthChanged(); - void contentHeightChanged(); + Q_REVISION(2) void contentWidthChanged(); + Q_REVISION(2) void contentHeightChanged(); protected: void updatePolish() override; -- cgit v1.2.3 From 1414f2fcce6bcd3f02c571a371d999aff8814a74 Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Thu, 6 Apr 2017 09:45:46 +0200 Subject: Gallery: handle Back shortcut on mobile Menus, dialogs, and drawers already handle it out of the box, but for page/stack navigation we need an explicit shortcut. Change-Id: Iad3e05f0fc31dbd66e3b1aa9286f8ef076fcff0d Task-number: QTBUG-58105 Reviewed-by: Mitch Curtis --- examples/quickcontrols2/gallery/gallery.qml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/quickcontrols2/gallery/gallery.qml b/examples/quickcontrols2/gallery/gallery.qml index ed5171df..c077f6c5 100644 --- a/examples/quickcontrols2/gallery/gallery.qml +++ b/examples/quickcontrols2/gallery/gallery.qml @@ -48,7 +48,7 @@ ** ****************************************************************************/ -import QtQuick 2.6 +import QtQuick 2.9 import QtQuick.Layouts 1.3 import QtQuick.Controls 2.2 import QtQuick.Controls.Material 2.1 @@ -68,7 +68,7 @@ ApplicationWindow { } Shortcut { - sequence: "Esc" + sequences: ["Esc", "Back"] enabled: stackView.depth > 1 onActivated: { stackView.pop() -- cgit v1.2.3 From f8224c9c9e3dfc1fd4cc3bff915e7e2d1c411d05 Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Thu, 6 Apr 2017 11:16:55 +0200 Subject: Gallery: handle Menu shortcut on mobile Change-Id: Ie7ad814b3999791801c60776777c6a736db1c093 Reviewed-by: Mitch Curtis --- examples/quickcontrols2/gallery/gallery.qml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/examples/quickcontrols2/gallery/gallery.qml b/examples/quickcontrols2/gallery/gallery.qml index c077f6c5..9f253ab3 100644 --- a/examples/quickcontrols2/gallery/gallery.qml +++ b/examples/quickcontrols2/gallery/gallery.qml @@ -76,6 +76,11 @@ ApplicationWindow { } } + Shortcut { + sequence: "Menu" + onActivated: optionsMenu.open() + } + header: ToolBar { Material.foreground: "white" -- cgit v1.2.3