From f14fa8b42c2d09afbc27209ffc520dfaf6dbc4d7 Mon Sep 17 00:00:00 2001 From: Richard Moe Gustavsen Date: Thu, 14 Feb 2019 14:49:05 +0100 Subject: QQuickScrollView: only forward content size to flickable if set explicit TableView monitors if the application sets an explicit contentWidth/Height, and skips calculating it when that is the case. So be more careful from ScrollView, and don't set it on the flickable if the application did not set it explicitly. By doing it this way, you can now set an explicit contentWidth/Height both in ScrollView and TableView, and it will be respected. Task-number: QTBUG-72536 Change-Id: Ib87fa6958881fccdc47f50133e996484392281b6 Reviewed-by: Shawn Rutledge Reviewed-by: Mitch Curtis --- src/quicktemplates2/qquickscrollview.cpp | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/quicktemplates2/qquickscrollview.cpp b/src/quicktemplates2/qquickscrollview.cpp index 57b0177e..7890a30a 100644 --- a/src/quicktemplates2/qquickscrollview.cpp +++ b/src/quicktemplates2/qquickscrollview.cpp @@ -154,6 +154,7 @@ public: bool wasTouched = false; QQuickFlickable *flickable = nullptr; + bool ownsFlickable = false; }; QList QQuickScrollViewPrivate::contentChildItems() const @@ -174,8 +175,10 @@ QQuickItem *QQuickScrollViewPrivate::getContentItem() QQuickFlickable *QQuickScrollViewPrivate::ensureFlickable(bool content) { Q_Q(QQuickScrollView); - if (!flickable) + if (!flickable) { setFlickable(new QQuickFlickable(q), content); + ownsFlickable = true; + } return flickable; } @@ -563,8 +566,16 @@ void QQuickScrollView::contentSizeChange(const QSizeF &newSize, const QSizeF &ol Q_D(QQuickScrollView); QQuickPane::contentSizeChange(newSize, oldSize); if (d->flickable) { - d->flickable->setContentWidth(newSize.width()); - d->flickable->setContentHeight(newSize.height()); + // Only set the content size on the flickable if we created the + // flickable ourselves. Otherwise we can end up overwriting + // assignments done to those properties by the application. The + // exception is if the application has assigned a content size + // directly to the scrollview, which will then win even if the + // application has assigned something else to the flickable. + if (d->hasContentWidth || d->ownsFlickable) + d->flickable->setContentWidth(newSize.width()); + if (d->hasContentHeight || d->ownsFlickable) + d->flickable->setContentHeight(newSize.height()); } } -- cgit v1.2.3 From 0dfc617e4d089f7513573673d12f9678a88d3081 Mon Sep 17 00:00:00 2001 From: Topi Reinio Date: Mon, 18 Feb 2019 10:20:36 +0100 Subject: Doc: Fix incorrect link to Number.toLocaleString() Task-number: QTBUG-73849 Change-Id: I02b32f55fabc6274a071536234dd485bf4e9bd02 Reviewed-by: Venugopal Shivashankar Reviewed-by: Nico Vertriest --- src/quicktemplates2/qquickspinbox.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/quicktemplates2/qquickspinbox.cpp b/src/quicktemplates2/qquickspinbox.cpp index 7f4f59fa..6af1d8e8 100644 --- a/src/quicktemplates2/qquickspinbox.cpp +++ b/src/quicktemplates2/qquickspinbox.cpp @@ -629,7 +629,8 @@ void QQuickSpinBox::setValidator(QValidator *validator) is the value to be converted, and the optional second argument is the locale that should be used for the conversion, if applicable. - The default implementation does the conversion using \l {QtQml::Locale}{Number.toLocaleString()}: + The default implementation does the conversion using + \l {QtQml::Number::toLocaleString()}{Number.toLocaleString}(): \code textFromValue: function(value, locale) { return Number(value).toLocaleString(locale, 'f', 0); } -- cgit v1.2.3 From 16836da1ae44c11317b9861764ea55cce39eac02 Mon Sep 17 00:00:00 2001 From: Mitch Curtis Date: Tue, 19 Feb 2019 14:22:27 +0100 Subject: Page: fix binding loop When Dialog (which derives from Page) has only its title set, there'd be a binding loop. A simplified version of the call stack: - QQuickPopup::componentComplete - QQuickPopupPrivate::prepareEnterTransition - QQuickItem::setVisible - QQuickPagePrivate::itemVisibilityChanged - QQuickDialog::implicitHeaderWidthChanged - QQmlBinding::expressionChanged <== Dialog.qml's implicitWidth binding - QQmlPropertyData::readProperty - QQuickDialog::implicitHeaderWidth - QQuickPage::implicitHeaderWidth - QQuickItem::implicitWidth <== QQuickPagePrivate::header, aka Label - QQuickTextPrivate::getImplicitWidth - QQuickTextPrivate::updateSize - QQuickTextPrivate::setupTextLayout - QQuickItem::setImplicitSize - QQuickItemPrivate::implicitWidthChanged - QQuickPagePrivate::itemImplicitWidthChanged - QQuickDialog::implicitHeaderWidthChanged - QQmlBinding::expressionChanged - QQmlAbstractBinding::printBindingLoopError Fix the issue by not emitting change signals if we're already in the process of doing so. Change-Id: I37d6fa35b1e70420e436c0e001f55035d7630542 Fixes: QTBUG-66494 Reviewed-by: Frederik Gladhorn --- src/quicktemplates2/qquickpage.cpp | 12 ++++++++++++ src/quicktemplates2/qquickpage_p_p.h | 1 + 2 files changed, 13 insertions(+) diff --git a/src/quicktemplates2/qquickpage.cpp b/src/quicktemplates2/qquickpage.cpp index 56034297..cb90ac48 100644 --- a/src/quicktemplates2/qquickpage.cpp +++ b/src/quicktemplates2/qquickpage.cpp @@ -149,10 +149,12 @@ void QQuickPagePrivate::itemVisibilityChanged(QQuickItem *item) Q_Q(QQuickPage); QQuickPanePrivate::itemVisibilityChanged(item); if (item == header) { + QBoolBlocker signalGuard(emittingImplicitSizeChangedSignals); emit q->implicitHeaderWidthChanged(); emit q->implicitHeaderHeightChanged(); relayout(); } else if (item == footer) { + QBoolBlocker signalGuard(emittingImplicitSizeChangedSignals); emit q->implicitFooterWidthChanged(); emit q->implicitFooterHeightChanged(); relayout(); @@ -163,6 +165,11 @@ void QQuickPagePrivate::itemImplicitWidthChanged(QQuickItem *item) { Q_Q(QQuickPage); QQuickPanePrivate::itemImplicitWidthChanged(item); + + // Avoid binding loops by skipping signal emission if we're already doing it. + if (emittingImplicitSizeChangedSignals) + return; + if (item == header) emit q->implicitHeaderWidthChanged(); else if (item == footer) @@ -173,6 +180,11 @@ void QQuickPagePrivate::itemImplicitHeightChanged(QQuickItem *item) { Q_Q(QQuickPage); QQuickPanePrivate::itemImplicitHeightChanged(item); + + // Avoid binding loops by skipping signal emission if we're already doing it. + if (emittingImplicitSizeChangedSignals) + return; + if (item == header) emit q->implicitHeaderHeightChanged(); else if (item == footer) diff --git a/src/quicktemplates2/qquickpage_p_p.h b/src/quicktemplates2/qquickpage_p_p.h index b7d89ac4..6c8b0371 100644 --- a/src/quicktemplates2/qquickpage_p_p.h +++ b/src/quicktemplates2/qquickpage_p_p.h @@ -71,6 +71,7 @@ public: QString title; QQuickItem *header = nullptr; QQuickItem *footer = nullptr; + bool emittingImplicitSizeChangedSignals = false; }; QT_END_NAMESPACE -- cgit v1.2.3 From feed3b7b8077f2c9bba72c49e249fb96c262d72e Mon Sep 17 00:00:00 2001 From: Mitch Curtis Date: Thu, 1 Nov 2018 10:52:32 +0100 Subject: Drawer: fix infinite positioning loop This fixes the issue where Drawer would try to reposition itself forever, but does not address the fact that it is incorrectly positioned afterwards. Task-number: QTBUG-71290 Change-Id: Ibbd4baa84b66ab446ce3af2ef326f8c50e74216d Reviewed-by: Richard Moe Gustavsen --- src/quicktemplates2/qquickdrawer.cpp | 3 + src/quicktemplates2/qquickpopuppositioner_p_p.h | 1 - tests/auto/qquickdrawer/data/topEdgeScreenEdge.qml | 78 ++++++++++++++++++++++ tests/auto/qquickdrawer/tst_qquickdrawer.cpp | 16 +++++ 4 files changed, 97 insertions(+), 1 deletion(-) create mode 100644 tests/auto/qquickdrawer/data/topEdgeScreenEdge.qml diff --git a/src/quicktemplates2/qquickdrawer.cpp b/src/quicktemplates2/qquickdrawer.cpp index 95b27512..9cc38791 100644 --- a/src/quicktemplates2/qquickdrawer.cpp +++ b/src/quicktemplates2/qquickdrawer.cpp @@ -222,6 +222,9 @@ QQuickPopupPositioner *QQuickDrawerPrivate::getPositioner() void QQuickDrawerPositioner::reposition() { + if (m_positioning) + return; + QQuickDrawer *drawer = static_cast(popup()); QQuickWindow *window = drawer->window(); if (!window) diff --git a/src/quicktemplates2/qquickpopuppositioner_p_p.h b/src/quicktemplates2/qquickpopuppositioner_p_p.h index 6eb990a7..64f57a3f 100644 --- a/src/quicktemplates2/qquickpopuppositioner_p_p.h +++ b/src/quicktemplates2/qquickpopuppositioner_p_p.h @@ -73,7 +73,6 @@ protected: void itemParentChanged(QQuickItem *, QQuickItem *parent) override; void itemChildRemoved(QQuickItem *, QQuickItem *child) override; -private: void removeAncestorListeners(QQuickItem *item); void addAncestorListeners(QQuickItem *item); diff --git a/tests/auto/qquickdrawer/data/topEdgeScreenEdge.qml b/tests/auto/qquickdrawer/data/topEdgeScreenEdge.qml new file mode 100644 index 00000000..02b5a10f --- /dev/null +++ b/tests/auto/qquickdrawer/data/topEdgeScreenEdge.qml @@ -0,0 +1,78 @@ +/**************************************************************************** +** +** Copyright (C) 2018 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.12 +import QtQuick.Controls 2.5 + +ApplicationWindow { + id: window + width: 400 + height: 400 + + property alias drawer: drawer + + header: Rectangle { + color: "red" + height: 40 + } + + Drawer { + id: drawer + width: window.width + height: window.height * 0.2 + parent: window.contentItem + edge: Qt.TopEdge + + Label { + anchors.centerIn: parent + text: "a drawer" + } + } +} diff --git a/tests/auto/qquickdrawer/tst_qquickdrawer.cpp b/tests/auto/qquickdrawer/tst_qquickdrawer.cpp index e3a6ccf2..816f9b67 100644 --- a/tests/auto/qquickdrawer/tst_qquickdrawer.cpp +++ b/tests/auto/qquickdrawer/tst_qquickdrawer.cpp @@ -109,6 +109,8 @@ private slots: void slider_data(); void slider(); + void topEdgeScreenEdge(); + private: struct TouchDeviceDeleter { @@ -1316,6 +1318,20 @@ void tst_QQuickDrawer::slider() QTest::touchEvent(window, touchDevice.data()).release(0, to); } +void tst_QQuickDrawer::topEdgeScreenEdge() +{ + QQuickApplicationHelper helper(this, QStringLiteral("topEdgeScreenEdge.qml")); + QQuickWindow *window = helper.window; + window->show(); + QVERIFY(QTest::qWaitForWindowActive(window)); + + QQuickDrawer *drawer = window->property("drawer").value(); + QVERIFY(drawer); + + QVERIFY(QMetaObject::invokeMethod(drawer, "open")); + QTRY_COMPARE(drawer->position(), 1.0); +} + QTEST_QUICKCONTROLS_MAIN(tst_QQuickDrawer) #include "tst_qquickdrawer.moc" -- cgit v1.2.3 From fa641ab12340fa128668318a1fe7c6a01906f163 Mon Sep 17 00:00:00 2001 From: Mitch Curtis Date: Mon, 18 Feb 2019 17:43:11 +0100 Subject: Add dialogs manual test As with the buttons manual test, there are a lot of possible combinations of dialogs, which makes automated testing very difficult. This test will allow us to see lots of different combinations all at once for a particular style. Change-Id: I42fa5a1e027c9f56bebf859078d3e54fe1902228 Reviewed-by: Frederik Gladhorn --- tests/manual/dialogs/CustomDialog.qml | 74 +++++++++ tests/manual/dialogs/DialogLabel.qml | 60 +++++++ tests/manual/dialogs/Marker.qml | 68 ++++++++ tests/manual/dialogs/dialogs.cpp | 63 ++++++++ tests/manual/dialogs/dialogs.pro | 11 ++ tests/manual/dialogs/dialogs.qml | 247 +++++++++++++++++++++++++++++ tests/manual/dialogs/qtquickcontrols2.conf | 6 + 7 files changed, 529 insertions(+) create mode 100644 tests/manual/dialogs/CustomDialog.qml create mode 100644 tests/manual/dialogs/DialogLabel.qml create mode 100644 tests/manual/dialogs/Marker.qml create mode 100644 tests/manual/dialogs/dialogs.cpp create mode 100644 tests/manual/dialogs/dialogs.pro create mode 100644 tests/manual/dialogs/dialogs.qml create mode 100644 tests/manual/dialogs/qtquickcontrols2.conf diff --git a/tests/manual/dialogs/CustomDialog.qml b/tests/manual/dialogs/CustomDialog.qml new file mode 100644 index 00000000..0e86fbb8 --- /dev/null +++ b/tests/manual/dialogs/CustomDialog.qml @@ -0,0 +1,74 @@ +/**************************************************************************** +** +** Copyright (C) 2019 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.Controls 2.12 + +Dialog { + id: root + x: previousDialog ? previousDialog.x + previousDialog.width + space : 0 + y: previousDialog ? previousDialog.y : 0 + closePolicy: Dialog.NoAutoClose + visible: true + + property Dialog previousDialog + property int space: dialogSpacing + + Marker { + parent: root.footer.contentItem + visible: visualizeDialogButtonBoxContentItem + text: "footer.contentItem" + } + Marker { + parent: root.footer + visible: visualizeDialogButtonBox + text: "footer" + border.color: "red" + } +} diff --git a/tests/manual/dialogs/DialogLabel.qml b/tests/manual/dialogs/DialogLabel.qml new file mode 100644 index 00000000..c4775aea --- /dev/null +++ b/tests/manual/dialogs/DialogLabel.qml @@ -0,0 +1,60 @@ +/**************************************************************************** +** +** Copyright (C) 2019 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.Controls 2.12 + +Label { + x: dialog.x + (dialog.width - width) / 2 + y: dialog.y - height + width: dialog.width + wrapMode: Label.Wrap + + property Dialog dialog +} diff --git a/tests/manual/dialogs/Marker.qml b/tests/manual/dialogs/Marker.qml new file mode 100644 index 00000000..439b50f2 --- /dev/null +++ b/tests/manual/dialogs/Marker.qml @@ -0,0 +1,68 @@ +/**************************************************************************** +** +** Copyright (C) 2019 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.12 + +Rectangle { + anchors.fill: parent + color: "transparent" + border.color: "darkorange" + + property alias text: label.text + + Text { + id: label + font.pixelSize: Qt.application.font.pixelSize * 0.6 + color: parent.border.color + anchors.left: parent.left + anchors.bottom: parent.bottom + anchors.margins: 4 + } +} diff --git a/tests/manual/dialogs/dialogs.cpp b/tests/manual/dialogs/dialogs.cpp new file mode 100644 index 00000000..73faa175 --- /dev/null +++ b/tests/manual/dialogs/dialogs.cpp @@ -0,0 +1,63 @@ +/**************************************************************************** +** +** Copyright (C) 2019 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include + +int main(int argc, char *argv[]) +{ + QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling); + QGuiApplication app(argc, argv); + + QQmlApplicationEngine engine; + engine.load(QUrl("qrc:/dialogs.qml")); + + return app.exec(); +} diff --git a/tests/manual/dialogs/dialogs.pro b/tests/manual/dialogs/dialogs.pro new file mode 100644 index 00000000..4863923f --- /dev/null +++ b/tests/manual/dialogs/dialogs.pro @@ -0,0 +1,11 @@ +TEMPLATE = app +TARGET = dialogs +QT += qml quickcontrols2 + +SOURCES += dialogs.cpp +RESOURCES += \ + qtquickcontrols2.conf \ + dialogs.qml \ + Marker.qml \ + CustomDialog.qml \ + DialogLabel.qml diff --git a/tests/manual/dialogs/dialogs.qml b/tests/manual/dialogs/dialogs.qml new file mode 100644 index 00000000..a3048c34 --- /dev/null +++ b/tests/manual/dialogs/dialogs.qml @@ -0,0 +1,247 @@ +/**************************************************************************** +** +** Copyright (C) 2019 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.12 +import QtQuick.Controls 2.12 +import QtQuick.Layouts 1.12 + +ApplicationWindow { + id: window + width: 1200 + height: 800 + title: "Buttons" + visible: true + + property alias visualizeDialogButtonBoxContentItem: visualizeDialogButtonBoxContentItemMenuItem.checked + property alias visualizeDialogButtonBox: visualizeDialogButtonBoxMenuItem.checked + + property int dialogSpacing: 60 + + header: ToolBar { + RowLayout { + anchors.fill: parent + Item { + Layout.fillWidth: true + } + + ToolButton { + text: "Settings" + onClicked: settingsMenu.open() + + Menu { + id: settingsMenu + width: 400 + + MenuItem { + id: visualizeDialogButtonBoxContentItemMenuItem + text: "Visualize DialogButtonBox contentItem" + checkable: true + } + + MenuItem { + id: visualizeDialogButtonBoxMenuItem + text: "Visualize DialogButtonBox" + checkable: true + } + } + } + } + } + + + DialogLabel { + text: "implicit width" + dialog: dialogImplicitWidthNoButtons + width: 100 + } + CustomDialog { + id: dialogImplicitWidthNoButtons + x: dialogSpacing + y: dialogSpacing + space: 200 + } + + DialogLabel { + text: "title, implicit width" + dialog: dialogImplicitWidthTitleNoButtons + width: 150 + } + CustomDialog { + id: dialogImplicitWidthTitleNoButtons + y: dialogSpacing + title: "Test" + previousDialog: dialogImplicitWidthNoButtons + space: 200 + } + + DialogLabel { + text: "title, fixed width" + dialog: dialogFixedWidthTitleNoButtons + } + CustomDialog { + id: dialogFixedWidthTitleNoButtons + y: dialogSpacing + width: 300 + title: "Test" + previousDialog: dialogImplicitWidthTitleNoButtons + space: 200 + } + + + DialogLabel { + text: "one standard button, implicit width" + dialog: dialogImplicitWidthOneButton + } + CustomDialog { + id: dialogImplicitWidthOneButton + x: dialogSpacing + y: dialogFixedWidthTitleNoButtons.y + dialogFixedWidthTitleNoButtons.height + dialogSpacing + standardButtons: Dialog.Ok + } + + DialogLabel { + text: "two standard buttons, implicit width" + dialog: dialogImplicitWidthTwoButtons + } + CustomDialog { + id: dialogImplicitWidthTwoButtons + standardButtons: Dialog.Ok | Dialog.Cancel + previousDialog: dialogImplicitWidthOneButton + } + + DialogLabel { + text: "three standard buttons, implicit width" + dialog: dialogImplicitWidthThreeButtons + } + CustomDialog { + id: dialogImplicitWidthThreeButtons + standardButtons: Dialog.Apply | Dialog.RestoreDefaults | Dialog.Cancel + previousDialog: dialogImplicitWidthTwoButtons + } + + + DialogLabel { + text: "text, one standard button, implicit width" + dialog: dialogTextImplicitWidthOneButton + } + CustomDialog { + id: dialogTextImplicitWidthOneButton + x: dialogSpacing + y: dialogImplicitWidthThreeButtons.y + dialogImplicitWidthThreeButtons.height + dialogSpacing + standardButtons: Dialog.Ok + + Label { + text: "A Label" + } + } + + DialogLabel { + text: "text, two standard buttons, implicit width" + dialog: dialogTextImplicitWidthTwoButtons + } + CustomDialog { + id: dialogTextImplicitWidthTwoButtons + standardButtons: Dialog.Ok | Dialog.Cancel + previousDialog: dialogTextImplicitWidthOneButton + + Label { + text: "A Label" + } + } + + DialogLabel { + text: "text, three standard buttons, implicit width" + dialog: dialogTextImplicitWidthThreeButtons + } + CustomDialog { + id: dialogTextImplicitWidthThreeButtons + standardButtons: Dialog.Apply | Dialog.RestoreDefaults | Dialog.Cancel + previousDialog: dialogTextImplicitWidthTwoButtons + + Label { + text: "A Label" + } + } + + + DialogLabel { + text: "one standard button, fixed width (300)" + dialog: dialogFixedWidthOneButton + } + CustomDialog { + id: dialogFixedWidthOneButton + x: dialogSpacing + y: dialogTextImplicitWidthThreeButtons.y + dialogTextImplicitWidthThreeButtons.height + dialogSpacing + width: 300 + standardButtons: Dialog.Ok + } + + DialogLabel { + text: "two standard buttons, fixed width (300)" + dialog: dialogFixedWidthTwoButtons + } + CustomDialog { + id: dialogFixedWidthTwoButtons + width: 300 + standardButtons: Dialog.Ok | Dialog.Cancel + previousDialog: dialogFixedWidthOneButton + } + + DialogLabel { + text: "three standard buttons, fixed width (300)" + dialog: dialogFixedWidthThreeButtons + } + CustomDialog { + id: dialogFixedWidthThreeButtons + width: 300 + standardButtons: Dialog.Apply | Dialog.RestoreDefaults | Dialog.Cancel + previousDialog: dialogFixedWidthTwoButtons + } +} diff --git a/tests/manual/dialogs/qtquickcontrols2.conf b/tests/manual/dialogs/qtquickcontrols2.conf new file mode 100644 index 00000000..7ac31807 --- /dev/null +++ b/tests/manual/dialogs/qtquickcontrols2.conf @@ -0,0 +1,6 @@ +[Controls] +Style=Default +;Style=Fusion +;Style=Imagine +;Style=Material +;Style=Universal -- cgit v1.2.3 From 951bfc041f1f43272f73d9cbc47100060c379c0c Mon Sep 17 00:00:00 2001 From: Mitch Curtis Date: Mon, 11 Feb 2019 16:44:20 +0100 Subject: Doc: restructure and fill in Imagine customization section Change-Id: I1b34fe2df28c734395dc2a55340f2a7cb1629692 Reviewed-by: Paul Wicking --- .../controls/doc/src/qtquickcontrols2-imagine.qdoc | 29 +++++++++++++++++----- 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/src/imports/controls/doc/src/qtquickcontrols2-imagine.qdoc b/src/imports/controls/doc/src/qtquickcontrols2-imagine.qdoc index c7ad71cf..2a9f1c5d 100644 --- a/src/imports/controls/doc/src/qtquickcontrols2-imagine.qdoc +++ b/src/imports/controls/doc/src/qtquickcontrols2-imagine.qdoc @@ -2417,10 +2417,10 @@ The \l {https://developers.google.com/speed/webp/}{WebP} and GIF animated image formats are supported by the Imagine style. - \section2 Palette - \section2 Customization + \section3 Path + The Imagine style allows customizing the \l {imagine-path-attached-prop}{path} that is used to do the image asset selection. The path can be specified for any window or item, and it automatically propagates to children in the same manner as @@ -2454,23 +2454,40 @@ \endtable In addition to specifying the path in QML, it is also possible to specify - it via an environment variable or in a configuration file. Attributes - specified in QML take precedence over all other methods. + it via an \l {imagine-customization-environment-variable}{environment variable} + or in a \l {imagine-customization-configuration-file}{configuration file}. + Attributes specified in QML take precedence over all other methods. - \section3 Configuration File + \section4 Configuration File + \target imagine-customization-configuration-file \include qquickimaginestyle.qdocinc conf See \l {Qt Quick Controls 2 Configuration File} for more details about the configuration file. - \section3 Environment Variables + \section4 Environment Variables + \target imagine-customization-environment-variable \include qquickimaginestyle.qdocinc env See \l {Supported Environment Variables in Qt Quick Controls 2} for the full list of supported environment variables. + \section3 Palette + + The Imagine style supports palette customization via the \l {Control::}{palette} + property and the \l {Palette Configuration}{qtquickcontrols2.conf} file. + As with other styles, the exact \l {palette QML Basic Type}{palette roles} + that the Imagine style uses are style-dependent. However, as most of the visual + appearance of controls (for example: backgrounds) are managed through image assets, + only the roles that are typically used for text will have an effect. + + \section3 Font + + Custom fonts can be set via the \l {Control::}{font} property and the + \l {Font Configuration}{configuration} file. + \section2 Dependency The Imagine style must be separately imported to gain access to the -- cgit v1.2.3 From d45d163240fca2fcdec445f1d8622062ad90bdd8 Mon Sep 17 00:00:00 2001 From: Mitch Curtis Date: Tue, 12 Feb 2019 11:16:44 +0100 Subject: Doc: state that negative scales for Popup are not supported This sentence was probably copied from Item's docs. Task-number: QTBUG-73687 Change-Id: If9f7554c78cbc47abc7c9fdabacc8025864b76e0 Reviewed-by: Paul Wicking --- src/quicktemplates2/qquickpopup.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/quicktemplates2/qquickpopup.cpp b/src/quicktemplates2/qquickpopup.cpp index 72e4f042..dd7dede6 100644 --- a/src/quicktemplates2/qquickpopup.cpp +++ b/src/quicktemplates2/qquickpopup.cpp @@ -1972,8 +1972,8 @@ void QQuickPopup::setOpacity(qreal opacity) This property holds the scale factor of the popup. The default value is \c 1.0. A scale of less than \c 1.0 causes the popup to be rendered at a smaller size, - and a scale greater than \c 1.0 renders the popup at a larger size. A negative - scale causes the popup to be mirrored when rendered. + and a scale greater than \c 1.0 renders the popup at a larger size. Negative + scales are not supported. */ qreal QQuickPopup::scale() const { -- cgit v1.2.3 From 637630cc7ed0e6efd43678b11d1309e72a957874 Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Wed, 20 Feb 2019 14:17:01 +0100 Subject: Remove the internal_module config to enable generation of cmake files After checking, it seems that this is not needed and was likely added by accident, so removing internal_module will enable the cmake file generation so QtQuickTemplates2 can be used in a project. Change-Id: I4a3287147c3c8afb715ba8e4d21b8af6fc1e48f6 Reviewed-by: Mitch Curtis Reviewed-by: Joerg Bornemann --- src/quicktemplates2/quicktemplates2.pro | 1 - 1 file changed, 1 deletion(-) diff --git a/src/quicktemplates2/quicktemplates2.pro b/src/quicktemplates2/quicktemplates2.pro index 59871a54..13b4f0e8 100644 --- a/src/quicktemplates2/quicktemplates2.pro +++ b/src/quicktemplates2/quicktemplates2.pro @@ -1,6 +1,5 @@ TARGET = QtQuickTemplates2 MODULE = quicktemplates2 -CONFIG += internal_module QT += quick QT_PRIVATE += core-private gui-private qml-private quick-private -- cgit v1.2.3 From 05eb8127594f0d40247e8c84a4704277dd12d16e Mon Sep 17 00:00:00 2001 From: Mitch Curtis Date: Fri, 1 Feb 2019 16:03:56 +0100 Subject: QQuickMenu: allow enter/return to be used to activate items Before this patch, only space was allowed. Windows 10 and macOS 10.14.2 both allow using enter to activate menu items. Change-Id: I64476347669ff73f233efd129563a18ba51618a5 Fixes: QTBUG-73354 Reviewed-by: Richard Moe Gustavsen --- src/quicktemplates2/qquickabstractbutton.cpp | 9 ++++++-- src/quicktemplates2/qquickabstractbutton_p_p.h | 2 ++ src/quicktemplates2/qquickmenuitem.cpp | 5 +++++ src/quicktemplates2/qquickmenuitem_p_p.h | 2 ++ tests/auto/qquickmenu/tst_qquickmenu.cpp | 31 +++++++++++++++++++++++++- 5 files changed, 46 insertions(+), 3 deletions(-) diff --git a/src/quicktemplates2/qquickabstractbutton.cpp b/src/quicktemplates2/qquickabstractbutton.cpp index 3b41f34c..c2df6dc2 100644 --- a/src/quicktemplates2/qquickabstractbutton.cpp +++ b/src/quicktemplates2/qquickabstractbutton.cpp @@ -201,6 +201,11 @@ void QQuickAbstractButtonPrivate::handleUngrab() emit q->canceled(); } +bool QQuickAbstractButtonPrivate::acceptKeyClick(Qt::Key key) const +{ + return key == Qt::Key_Space; +} + bool QQuickAbstractButtonPrivate::isPressAndHoldConnected() { Q_Q(QQuickAbstractButton); @@ -1029,7 +1034,7 @@ void QQuickAbstractButton::keyPressEvent(QKeyEvent *event) { Q_D(QQuickAbstractButton); QQuickControl::keyPressEvent(event); - if (event->key() == Qt::Key_Space) { + if (d->acceptKeyClick(static_cast(event->key()))) { d->setPressPoint(QPoint(qRound(width() / 2), qRound(height() / 2))); setPressed(true); @@ -1045,7 +1050,7 @@ void QQuickAbstractButton::keyReleaseEvent(QKeyEvent *event) { Q_D(QQuickAbstractButton); QQuickControl::keyReleaseEvent(event); - if (event->key() == Qt::Key_Space) { + if (d->acceptKeyClick(static_cast(event->key()))) { setPressed(false); nextCheckState(); diff --git a/src/quicktemplates2/qquickabstractbutton_p_p.h b/src/quicktemplates2/qquickabstractbutton_p_p.h index 718498a8..7394f115 100644 --- a/src/quicktemplates2/qquickabstractbutton_p_p.h +++ b/src/quicktemplates2/qquickabstractbutton_p_p.h @@ -75,6 +75,8 @@ public: void handleRelease(const QPointF &point) override; void handleUngrab() override; + virtual bool acceptKeyClick(Qt::Key key) const; + bool isPressAndHoldConnected(); void startPressAndHold(); void stopPressAndHold(); diff --git a/src/quicktemplates2/qquickmenuitem.cpp b/src/quicktemplates2/qquickmenuitem.cpp index b02b8e60..22fe664a 100644 --- a/src/quicktemplates2/qquickmenuitem.cpp +++ b/src/quicktemplates2/qquickmenuitem.cpp @@ -147,6 +147,11 @@ void QQuickMenuItemPrivate::executeArrow(bool complete) quickCompleteDeferred(q, arrowName(), arrow); } +bool QQuickMenuItemPrivate::acceptKeyClick(Qt::Key key) const +{ + return key == Qt::Key_Space || key == Qt::Key_Return || key == Qt::Key_Enter; +} + /*! \qmlsignal void QtQuick.Controls::MenuItem::triggered() diff --git a/src/quicktemplates2/qquickmenuitem_p_p.h b/src/quicktemplates2/qquickmenuitem_p_p.h index 034a199a..58a0ff20 100644 --- a/src/quicktemplates2/qquickmenuitem_p_p.h +++ b/src/quicktemplates2/qquickmenuitem_p_p.h @@ -73,6 +73,8 @@ public: void cancelArrow(); void executeArrow(bool complete = false); + bool acceptKeyClick(Qt::Key key) const override; + bool highlighted = false; QQuickDeferredPointer arrow; QQuickMenu *menu = nullptr; diff --git a/tests/auto/qquickmenu/tst_qquickmenu.cpp b/tests/auto/qquickmenu/tst_qquickmenu.cpp index a24305b7..e1f5d35f 100644 --- a/tests/auto/qquickmenu/tst_qquickmenu.cpp +++ b/tests/auto/qquickmenu/tst_qquickmenu.cpp @@ -316,9 +316,38 @@ void tst_QQuickMenu::contextMenuKeyboard() QCOMPARE(menu->currentIndex(), -1); QCOMPARE(menu->contentItem()->property("currentIndex"), QVariant(-1)); + // Enter/return should also work. + // Open the menu. menu->open(); QCOMPARE(visibleSpy.count(), 3); QVERIFY(menu->isVisible()); + // Give the first item focus. + QTest::keyClick(window, Qt::Key_Tab); + QVERIFY(firstItem->hasActiveFocus()); + QVERIFY(firstItem->hasVisualFocus()); + QVERIFY(firstItem->isHighlighted()); + QCOMPARE(firstItem->focusReason(), Qt::TabFocusReason); + QCOMPARE(menu->currentIndex(), 0); + QCOMPARE(menu->contentItem()->property("currentIndex"), QVariant(0)); + // Press enter. + QSignalSpy firstTriggeredSpy(firstItem, SIGNAL(triggered())); + QTest::keyClick(window, Qt::Key_Return); + QCOMPARE(firstTriggeredSpy.count(), 1); + QCOMPARE(visibleSpy.count(), 4); + QVERIFY(!menu->isVisible()); + QVERIFY(!window->overlay()->childItems().contains(menu->contentItem())); + QVERIFY(!firstItem->hasActiveFocus()); + QVERIFY(!firstItem->hasVisualFocus()); + QVERIFY(!firstItem->isHighlighted()); + QVERIFY(!secondItem->hasActiveFocus()); + QVERIFY(!secondItem->hasVisualFocus()); + QVERIFY(!secondItem->isHighlighted()); + QCOMPARE(menu->currentIndex(), -1); + QCOMPARE(menu->contentItem()->property("currentIndex"), QVariant(-1)); + + menu->open(); + QCOMPARE(visibleSpy.count(), 5); + QVERIFY(menu->isVisible()); QVERIFY(window->overlay()->childItems().contains(menu->contentItem()->parentItem())); QVERIFY(!firstItem->hasActiveFocus()); QVERIFY(!firstItem->hasVisualFocus()); @@ -393,7 +422,7 @@ void tst_QQuickMenu::contextMenuKeyboard() QVERIFY(!thirdItem->isHighlighted()); QTest::keyClick(window, Qt::Key_Escape); - QCOMPARE(visibleSpy.count(), 4); + QCOMPARE(visibleSpy.count(), 6); QVERIFY(!menu->isVisible()); } -- cgit v1.2.3 From 694438066eb88e53e4070630e6b99d0f552d254d Mon Sep 17 00:00:00 2001 From: Mikhail Svetkin Date: Tue, 22 Jan 2019 14:54:05 +0100 Subject: qtlite: Fix build the source code with -no-feature-shortcut Change-Id: I7247659b3c9f4634ff57bce1e55187def604e161 Reviewed-by: Mitch Curtis --- src/quicktemplates2/qquickabstractbutton.cpp | 2 ++ src/quicktemplates2/qquickaction.cpp | 34 +++++++++++++++++++++++----- src/quicktemplates2/qquickaction_p.h | 6 +++++ src/quicktemplates2/qquickaction_p_p.h | 8 ++++++- 4 files changed, 43 insertions(+), 7 deletions(-) diff --git a/src/quicktemplates2/qquickabstractbutton.cpp b/src/quicktemplates2/qquickabstractbutton.cpp index c2df6dc2..a2992191 100644 --- a/src/quicktemplates2/qquickabstractbutton.cpp +++ b/src/quicktemplates2/qquickabstractbutton.cpp @@ -454,7 +454,9 @@ QQuickAbstractButton::~QQuickAbstractButton() d->removeImplicitSizeListener(d->indicator); if (d->group) d->group->removeButton(this); +#if QT_CONFIG(shortcut) d->ungrabShortcut(); +#endif } /*! diff --git a/src/quicktemplates2/qquickaction.cpp b/src/quicktemplates2/qquickaction.cpp index 6ff3a183..e83fd353 100644 --- a/src/quicktemplates2/qquickaction.cpp +++ b/src/quicktemplates2/qquickaction.cpp @@ -113,6 +113,7 @@ QT_BEGIN_NAMESPACE when \l trigger() is called directly. */ +#if QT_CONFIG(shortcut) static QKeySequence variantToKeySequence(const QVariant &var) { if (var.type() == QVariant::Int) @@ -193,6 +194,7 @@ void QQuickActionPrivate::setShortcut(const QVariant &var) emit q->shortcutChanged(keySequence); } +#endif // QT_CONFIG(shortcut) void QQuickActionPrivate::setEnabled(bool enable) { @@ -202,9 +204,11 @@ void QQuickActionPrivate::setEnabled(bool enable) enabled = enable; +#if QT_CONFIG(shortcut) defaultShortcutEntry->setEnabled(enable); for (QQuickActionPrivate::ShortcutEntry *entry : qAsConst(shortcutEntries)) entry->setEnabled(enable); +#endif emit q->enabledChanged(enable); } @@ -236,16 +240,19 @@ void QQuickActionPrivate::registerItem(QQuickItem *item) if (!watchItem(item)) return; +#if QT_CONFIG(shortcut) QQuickActionPrivate::ShortcutEntry *entry = new QQuickActionPrivate::ShortcutEntry(item); if (item->isVisible()) entry->grab(keySequence, enabled); shortcutEntries += entry; updateDefaultShortcutEntry(); +#endif } void QQuickActionPrivate::unregisterItem(QQuickItem *item) { +#if QT_CONFIG(shortcut) QQuickActionPrivate::ShortcutEntry *entry = findShortcutEntry(item); if (!entry || !unwatchItem(item)) return; @@ -254,10 +261,12 @@ void QQuickActionPrivate::unregisterItem(QQuickItem *item) delete entry; updateDefaultShortcutEntry(); +#endif } void QQuickActionPrivate::itemVisibilityChanged(QQuickItem *item) { +#if QT_CONFIG(shortcut) QQuickActionPrivate::ShortcutEntry *entry = findShortcutEntry(item); if (!entry) return; @@ -268,6 +277,7 @@ void QQuickActionPrivate::itemVisibilityChanged(QQuickItem *item) entry->ungrab(); updateDefaultShortcutEntry(); +#endif } void QQuickActionPrivate::itemDestroyed(QQuickItem *item) @@ -275,6 +285,7 @@ void QQuickActionPrivate::itemDestroyed(QQuickItem *item) unregisterItem(item); } +#if QT_CONFIG(shortcut) bool QQuickActionPrivate::handleShortcutEvent(QObject *object, QShortcutEvent *event) { Q_Q(QQuickAction); @@ -316,12 +327,15 @@ void QQuickActionPrivate::updateDefaultShortcutEntry() else if (!defaultShortcutEntry->shortcutId()) defaultShortcutEntry->grab(keySequence, enabled); } +#endif // QT_CONFIG(shortcut) QQuickAction::QQuickAction(QObject *parent) : QObject(*(new QQuickActionPrivate), parent) { Q_D(QQuickAction); +#if QT_CONFIG(shortcut) d->defaultShortcutEntry = new QQuickActionPrivate::ShortcutEntry(this); +#endif } QQuickAction::~QQuickAction() @@ -330,11 +344,13 @@ QQuickAction::~QQuickAction() if (d->group) d->group->removeAction(this); +#if QT_CONFIG(shortcut) for (QQuickActionPrivate::ShortcutEntry *entry : qAsConst(d->shortcutEntries)) d->unwatchItem(qobject_cast(entry->target())); qDeleteAll(d->shortcutEntries); delete d->defaultShortcutEntry; +#endif } /*! @@ -460,6 +476,7 @@ void QQuickAction::setCheckable(bool checkable) emit checkableChanged(checkable); } +#if QT_CONFIG(shortcut) /*! \qmlproperty keysequence QtQuick.Controls::Action::shortcut @@ -486,6 +503,7 @@ void QQuickAction::setShortcut(const QKeySequence &shortcut) Q_D(QQuickAction); d->setShortcut(shortcut.toString()); } +#endif // QT_CONFIG(shortcut) /*! \qmlmethod void QtQuick.Controls::Action::toggle(QtObject source = null) @@ -537,17 +555,21 @@ void QQuickActionPrivate::trigger(QObject* source, bool doToggle) bool QQuickAction::event(QEvent *event) { Q_D(QQuickAction); - if (event->type() != QEvent::Shortcut) - return QObject::event(event); - return d->handleShortcutEvent(this, static_cast(event)); +#if QT_CONFIG(shortcut) + if (event->type() == QEvent::Shortcut) + return d->handleShortcutEvent(this, static_cast(event)); +#endif + return QObject::event(event); } bool QQuickAction::eventFilter(QObject *object, QEvent *event) { Q_D(QQuickAction); - if (event->type() != QEvent::Shortcut) - return false; - return d->handleShortcutEvent(object, static_cast(event)); +#if QT_CONFIG(shortcut) + if (event->type() == QEvent::Shortcut) + return d->handleShortcutEvent(object, static_cast(event)); +#endif + return false; } QT_END_NAMESPACE diff --git a/src/quicktemplates2/qquickaction_p.h b/src/quicktemplates2/qquickaction_p.h index ce989bed..cbe0d8fe 100644 --- a/src/quicktemplates2/qquickaction_p.h +++ b/src/quicktemplates2/qquickaction_p.h @@ -66,7 +66,9 @@ class Q_QUICKTEMPLATES2_PRIVATE_EXPORT QQuickAction : public QObject Q_PROPERTY(bool enabled READ isEnabled WRITE setEnabled NOTIFY enabledChanged RESET resetEnabled FINAL) Q_PROPERTY(bool checked READ isChecked WRITE setChecked NOTIFY checkedChanged FINAL) Q_PROPERTY(bool checkable READ isCheckable WRITE setCheckable NOTIFY checkableChanged FINAL) +#if QT_CONFIG(shortcut) Q_PRIVATE_PROPERTY(QQuickAction::d_func(), QVariant shortcut READ shortcut WRITE setShortcut NOTIFY shortcutChanged FINAL) +#endif public: explicit QQuickAction(QObject *parent = nullptr); @@ -88,8 +90,10 @@ public: bool isCheckable() const; void setCheckable(bool checkable); +#if QT_CONFIG(shortcut) QKeySequence shortcut() const; void setShortcut(const QKeySequence &shortcut); +#endif public Q_SLOTS: void toggle(QObject *source = nullptr); @@ -101,7 +105,9 @@ Q_SIGNALS: void enabledChanged(bool enabled); void checkedChanged(bool checked); void checkableChanged(bool checkable); +#if QT_CONFIG(shortcut) void shortcutChanged(const QKeySequence &shortcut); +#endif void toggled(QObject *source = nullptr); void triggered(QObject *source = nullptr); diff --git a/src/quicktemplates2/qquickaction_p_p.h b/src/quicktemplates2/qquickaction_p_p.h index 98b0973b..7c70bab1 100644 --- a/src/quicktemplates2/qquickaction_p_p.h +++ b/src/quicktemplates2/qquickaction_p_p.h @@ -69,8 +69,10 @@ public: return action->d_func(); } +#if QT_CONFIG(shortcut) QVariant shortcut() const; void setShortcut(const QVariant &shortcut); +#endif void setEnabled(bool enable); @@ -87,6 +89,7 @@ public: void trigger(QObject*, bool doToggle); +#if QT_CONFIG(shortcut) class ShortcutEntry { public: @@ -108,6 +111,7 @@ public: ShortcutEntry *findShortcutEntry(QObject *target) const; void updateDefaultShortcutEntry(); +#endif // QT_CONFIG(shortcut) bool explicitEnabled = false; bool enabled = true; @@ -115,10 +119,12 @@ public: bool checkable = false; QString text; QQuickIcon icon; - QVariant vshortcut; QKeySequence keySequence; +#if QT_CONFIG(shortcut) + QVariant vshortcut; ShortcutEntry *defaultShortcutEntry = nullptr; QVector shortcutEntries; +#endif QQuickActionGroup *group = nullptr; }; -- cgit v1.2.3 From 9fdbdea176007ed7b470e317e9002aa77ddd4ead Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Fri, 1 Mar 2019 08:40:49 +0100 Subject: Fix tst_cursor::controls(containers) test failing after change in the Windows QPA The test failed in case the mouse cursor was within the view to be created. Move the cursor away to prevent that. Fixes: QTBUG-74130 Change-Id: I8d77fc9b4cc5380ddb06ba128bca7c1666357b50 Reviewed-by: Mitch Curtis Reviewed-by: Qt CI Bot --- tests/auto/cursor/tst_cursor.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/tests/auto/cursor/tst_cursor.cpp b/tests/auto/cursor/tst_cursor.cpp index 0f24a29e..d59e7091 100644 --- a/tests/auto/cursor/tst_cursor.cpp +++ b/tests/auto/cursor/tst_cursor.cpp @@ -44,6 +44,11 @@ #include #include +#if QT_CONFIG(cursor) +# include +# include +#endif + using namespace QQuickVisualTestUtil; class tst_cursor : public QQmlDataTest @@ -51,6 +56,7 @@ class tst_cursor : public QQmlDataTest Q_OBJECT private slots: + void init(); void controls_data(); void controls(); void editable(); @@ -58,6 +64,17 @@ private slots: void scrollBar(); }; +void tst_cursor::init() +{ +#if QT_CONFIG(cursor) + // Ensure mouse cursor was not left by previous tests where widgets + // will appear, as it could cause events and interfere with the tests. + const QScreen *screen = QGuiApplication::primaryScreen(); + const QRect availableGeometry = screen->availableGeometry(); + QCursor::setPos(availableGeometry.topLeft()); +#endif +} + void tst_cursor::controls_data() { QTest::addColumn("testFile"); -- cgit v1.2.3 From 3725155f6c5cdfad0e99d232f09c7ae0d0de617f Mon Sep 17 00:00:00 2001 From: Nico Vertriest Date: Mon, 25 Feb 2019 14:51:17 +0100 Subject: Doc: minor language edit in title Change-Id: Ia84e572f6f16cc050991450a18f2e695e461280d Reviewed-by: Venugopal Shivashankar --- src/imports/controls/doc/src/qtquickcontrols2-differences.qdoc | 2 +- src/imports/controls/doc/src/qtquickcontrols2-index.qdoc | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/imports/controls/doc/src/qtquickcontrols2-differences.qdoc b/src/imports/controls/doc/src/qtquickcontrols2-differences.qdoc index 0b09edf6..e30285de 100644 --- a/src/imports/controls/doc/src/qtquickcontrols2-differences.qdoc +++ b/src/imports/controls/doc/src/qtquickcontrols2-differences.qdoc @@ -27,7 +27,7 @@ /*! \page qtquickcontrols2-differences.html - \title Differences between Qt Quick Controls 1 + \title Differences with Qt Quick Controls 1 Qt Quick Controls 1 was originally developed to support desktop platforms, with mobile and embedded support coming shortly afterwards. They have a diff --git a/src/imports/controls/doc/src/qtquickcontrols2-index.qdoc b/src/imports/controls/doc/src/qtquickcontrols2-index.qdoc index f95db512..d425f421 100644 --- a/src/imports/controls/doc/src/qtquickcontrols2-index.qdoc +++ b/src/imports/controls/doc/src/qtquickcontrols2-index.qdoc @@ -154,7 +154,7 @@ \li \l{Deploying Qt Quick Controls 2 Applications}{Deployment} \li \l{Qt Quick Controls 2 Configuration File}{Configuration File} \li \l{Supported Environment Variables in Qt Quick Controls 2}{Environment Variables} - \li \l{Differences between Qt Quick Controls 1} + \li \l{Differences with Qt Quick Controls 1} \endlist \section1 Reference -- cgit v1.2.3 From 18da9482bb52d7a59bc7ffac719bc03e2e164417 Mon Sep 17 00:00:00 2001 From: Kai Koehne Date: Mon, 25 Feb 2019 13:38:30 +0100 Subject: Explicitly set import names This makes sure the qmltypes target for qml_plugin's works. Change-Id: I4a7624aa2db2eb40b9b44f158e099c651b1249cb Reviewed-by: Joerg Bornemann --- src/imports/controls/fusion/fusion.pro | 2 ++ src/imports/controls/imagine/imagine.pro | 2 ++ src/imports/controls/material/material.pro | 2 ++ src/imports/controls/universal/universal.pro | 2 ++ 4 files changed, 8 insertions(+) diff --git a/src/imports/controls/fusion/fusion.pro b/src/imports/controls/fusion/fusion.pro index 4bc9fcc1..f2de422f 100644 --- a/src/imports/controls/fusion/fusion.pro +++ b/src/imports/controls/fusion/fusion.pro @@ -1,5 +1,7 @@ TARGET = qtquickcontrols2fusionstyleplugin TARGETPATH = QtQuick/Controls.2/Fusion + +IMPORT_NAME = QtQuick.Controls.Fusion IMPORT_VERSION = 2.5 QT += qml quick diff --git a/src/imports/controls/imagine/imagine.pro b/src/imports/controls/imagine/imagine.pro index 2368c0a4..c1f2aa8c 100644 --- a/src/imports/controls/imagine/imagine.pro +++ b/src/imports/controls/imagine/imagine.pro @@ -1,5 +1,7 @@ TARGET = qtquickcontrols2imaginestyleplugin TARGETPATH = QtQuick/Controls.2/Imagine + +IMPORT_NAME = QtQuick.Controls.Imagine IMPORT_VERSION = 2.5 QT += qml quick diff --git a/src/imports/controls/material/material.pro b/src/imports/controls/material/material.pro index c3cbb355..c2a55a61 100644 --- a/src/imports/controls/material/material.pro +++ b/src/imports/controls/material/material.pro @@ -1,5 +1,7 @@ TARGET = qtquickcontrols2materialstyleplugin TARGETPATH = QtQuick/Controls.2/Material + +IMPORT_NAME = QtQuick.Controls.Material IMPORT_VERSION = 2.5 QT += qml quick diff --git a/src/imports/controls/universal/universal.pro b/src/imports/controls/universal/universal.pro index 399de032..deea7878 100644 --- a/src/imports/controls/universal/universal.pro +++ b/src/imports/controls/universal/universal.pro @@ -1,5 +1,7 @@ TARGET = qtquickcontrols2universalstyleplugin TARGETPATH = QtQuick/Controls.2/Universal + +IMPORT_NAME = QtQuick.Controls.Universal IMPORT_VERSION = 2.5 QT += qml quick -- cgit v1.2.3