From 47065844f666e1332a7fb5bcfdc6015e0f7e1591 Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Tue, 25 Oct 2016 00:19:55 +0200 Subject: Replace QStringLiteral with QLatin1String in the proxy themes This allows us, in theory, to test multiple styles in the same process by calling qmlClearTypeRegistrations() between each style test round. When QML types are cleared, QML plugins are unloaded, and the current style plugin's proxy platform theme is destroyed. It leads to a nasty crash if there are fonts stored in the Qt font database that have their family names stored in the read-only data of an unloaded plugin. Change-Id: I32a70077ac4502e16a753fb68f7efeef35d239b5 Reviewed-by: Mitch Curtis --- src/imports/controls/material/qquickmaterialtheme.cpp | 8 ++++---- src/imports/controls/universal/qquickuniversaltheme.cpp | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/imports/controls/material/qquickmaterialtheme.cpp b/src/imports/controls/material/qquickmaterialtheme.cpp index 0d2f8a70..1967a74b 100644 --- a/src/imports/controls/material/qquickmaterialtheme.cpp +++ b/src/imports/controls/material/qquickmaterialtheme.cpp @@ -45,15 +45,15 @@ QQuickMaterialTheme::QQuickMaterialTheme(QPlatformTheme *theme) : QQuickProxyTheme(theme) { QFont font; - font.setFamily(QStringLiteral("Roboto")); + font.setFamily(QLatin1String("Roboto")); QString family = QFontInfo(font).family(); - if (family != QStringLiteral("Roboto")) { - font.setFamily(QStringLiteral("Noto")); + if (family != QLatin1String("Roboto")) { + font.setFamily(QLatin1String("Noto")); family = QFontInfo(font).family(); } - if (family == QStringLiteral("Roboto") || family == QStringLiteral("Noto")) { + if (family == QLatin1String("Roboto") || family == QLatin1String("Noto")) { systemFont.setFamily(family); buttonFont.setFamily(family); toolTipFont.setFamily(family); diff --git a/src/imports/controls/universal/qquickuniversaltheme.cpp b/src/imports/controls/universal/qquickuniversaltheme.cpp index 51642c4a..dc516b45 100644 --- a/src/imports/controls/universal/qquickuniversaltheme.cpp +++ b/src/imports/controls/universal/qquickuniversaltheme.cpp @@ -44,8 +44,8 @@ QT_BEGIN_NAMESPACE QQuickUniversalTheme::QQuickUniversalTheme(QPlatformTheme *theme) : QQuickProxyTheme(theme) { - const QFont font(QStringLiteral("Segoe UI")); - if (QFontInfo(font).family() == QStringLiteral("Segoe UI")) { + const QFont font(QLatin1String("Segoe UI")); + if (QFontInfo(font).family() == QLatin1String("Segoe UI")) { const QString family = font.family(); systemFont.setFamily(family); groupBoxTitleFont.setFamily(family); -- cgit v1.2.3 From f6acc98f3a96ab6cafedfe2a3f097a1974abad16 Mon Sep 17 00:00:00 2001 From: Mitch Curtis Date: Wed, 26 Oct 2016 10:56:32 +0200 Subject: Default: make disable controls easier to see Task-number: QTBUG-56698 Change-Id: I8e82ee2f2f9c38755e49b6f1b46e9f83a1363463 Reviewed-by: J-P Nurmi --- src/imports/controls/Button.qml | 1 - src/imports/controls/CheckBox.qml | 2 +- src/imports/controls/ComboBox.qml | 4 ++-- src/imports/controls/RadioButton.qml | 2 +- src/imports/controls/RangeSlider.qml | 1 - src/imports/controls/Slider.qml | 1 - src/imports/controls/SpinBox.qml | 1 - src/imports/controls/SwitchIndicator.qml | 1 - 8 files changed, 4 insertions(+), 9 deletions(-) diff --git a/src/imports/controls/Button.qml b/src/imports/controls/Button.qml index f875a97a..cf1f6c99 100644 --- a/src/imports/controls/Button.qml +++ b/src/imports/controls/Button.qml @@ -66,7 +66,6 @@ T.Button { background: Rectangle { implicitWidth: 100 implicitHeight: 40 - opacity: enabled ? 1 : 0.3 visible: !control.flat || control.down || control.checked || control.highlighted color: control.checked || control.highlighted ? (control.visualFocus ? (control.down ? "#599bff" : "#0066ff") : (control.down ? "#585a5c" : "#353637")) : diff --git a/src/imports/controls/CheckBox.qml b/src/imports/controls/CheckBox.qml index 3615948a..78b42276 100644 --- a/src/imports/controls/CheckBox.qml +++ b/src/imports/controls/CheckBox.qml @@ -51,7 +51,7 @@ T.CheckBox { padding: 6 spacing: 6 - opacity: enabled ? 1 : 0.2 + opacity: enabled ? 1 : 0.3 //! [indicator] indicator: CheckIndicator { diff --git a/src/imports/controls/ComboBox.qml b/src/imports/controls/ComboBox.qml index 09930aad..791b5da6 100644 --- a/src/imports/controls/ComboBox.qml +++ b/src/imports/controls/ComboBox.qml @@ -54,8 +54,6 @@ T.ComboBox { leftPadding: padding + 6 rightPadding: padding + 6 - opacity: enabled ? 1 : 0.3 - //! [delegate] delegate: ItemDelegate { width: control.popup.width @@ -72,6 +70,7 @@ T.ComboBox { source: "image://default/double-arrow/" + (control.visualFocus ? "#0066ff" : "#353637") sourceSize.width: width sourceSize.height: height + opacity: enabled ? 1 : 0.3 } //! [indicator] @@ -86,6 +85,7 @@ T.ComboBox { horizontalAlignment: Text.AlignLeft verticalAlignment: Text.AlignVCenter elide: Text.ElideRight + opacity: enabled ? 1 : 0.3 } //! [contentItem] diff --git a/src/imports/controls/RadioButton.qml b/src/imports/controls/RadioButton.qml index 8a2d7c99..1c63a8de 100644 --- a/src/imports/controls/RadioButton.qml +++ b/src/imports/controls/RadioButton.qml @@ -51,7 +51,7 @@ T.RadioButton { padding: 6 spacing: 6 - opacity: enabled ? 1 : 0.2 + opacity: enabled ? 1 : 0.3 //! [indicator] indicator: RadioIndicator { diff --git a/src/imports/controls/RangeSlider.qml b/src/imports/controls/RangeSlider.qml index 7353e2b5..dae3ffe7 100644 --- a/src/imports/controls/RangeSlider.qml +++ b/src/imports/controls/RangeSlider.qml @@ -88,7 +88,6 @@ T.RangeSlider { width: horizontal ? control.availableWidth : implicitWidth height: horizontal ? implicitHeight : control.availableHeight radius: 3 - opacity: control.enabled ? 1 : 0.3 color: "#e0e0e0" scale: horizontal && control.mirrored ? -1 : 1 diff --git a/src/imports/controls/Slider.qml b/src/imports/controls/Slider.qml index 896dbca0..31f4a989 100644 --- a/src/imports/controls/Slider.qml +++ b/src/imports/controls/Slider.qml @@ -71,7 +71,6 @@ T.Slider { width: horizontal ? control.availableWidth : implicitWidth height: horizontal ? implicitHeight : control.availableHeight radius: 3 - opacity: control.enabled ? 1 : 0.3 color: "#e0e0e0" scale: horizontal && control.mirrored ? -1 : 1 diff --git a/src/imports/controls/SpinBox.qml b/src/imports/controls/SpinBox.qml index 89853116..de1228d1 100644 --- a/src/imports/controls/SpinBox.qml +++ b/src/imports/controls/SpinBox.qml @@ -137,7 +137,6 @@ T.SpinBox { //! [background] background: Rectangle { - opacity: control.enabled ? 1 : 0.3 implicitWidth: 140 border.color: "#e0e0e0" } diff --git a/src/imports/controls/SwitchIndicator.qml b/src/imports/controls/SwitchIndicator.qml index f11f7147..261d9999 100644 --- a/src/imports/controls/SwitchIndicator.qml +++ b/src/imports/controls/SwitchIndicator.qml @@ -47,7 +47,6 @@ Item { width: 56 height: 16 radius: 8 - opacity: control.enabled ? 1 : 0.3 color: control.checked ? (control.visualFocus ? "#0066ff" : "#353637") : "#e0e0e0" border.width: control.visualFocus ? 2 : 0 border.color: "#0066ff" -- cgit v1.2.3 From 4d2bd6929af05009b4a1f0502fe214fa57d5da2e Mon Sep 17 00:00:00 2001 From: Mitch Curtis Date: Wed, 26 Oct 2016 11:15:48 +0200 Subject: testbench: rename main.qml to testbench.qml This is one less main.qml to search through. Change-Id: I2d0a8a56a779a6d6acac579d44c641dea318fb3d Reviewed-by: J-P Nurmi --- tests/manual/testbench/main.cpp | 2 +- tests/manual/testbench/main.qml | 653 ----------------------------------- tests/manual/testbench/qml.qrc | 2 +- tests/manual/testbench/testbench.qml | 653 +++++++++++++++++++++++++++++++++++ 4 files changed, 655 insertions(+), 655 deletions(-) delete mode 100644 tests/manual/testbench/main.qml create mode 100644 tests/manual/testbench/testbench.qml diff --git a/tests/manual/testbench/main.cpp b/tests/manual/testbench/main.cpp index a782b5fe..5a54dab3 100644 --- a/tests/manual/testbench/main.cpp +++ b/tests/manual/testbench/main.cpp @@ -54,7 +54,7 @@ int main(int argc, char *argv[]) // TODO: move style selection into app UI and use settings to save choices. // qputenv("QT_QUICK_CONTROLS_STYLE", "material"); QQmlApplicationEngine engine; - engine.load(QUrl(QStringLiteral("qrc:/main.qml"))); + engine.load(QUrl(QStringLiteral("qrc:/testbench.qml"))); return app.exec(); } diff --git a/tests/manual/testbench/main.qml b/tests/manual/testbench/main.qml deleted file mode 100644 index 2fdc52af..00000000 --- a/tests/manual/testbench/main.qml +++ /dev/null @@ -1,653 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.6 -import QtQuick.Window 2.2 -import QtQuick.Layouts 1.0 -import QtQuick.Controls 2.0 -import QtQuick.Controls.Material 2.0 -import QtQuick.Controls.Universal 2.0 - -ApplicationWindow { - id: window - visible: true - width: 750 - height: 1000 - - Component.onCompleted: { - x = Screen.width / 2 - width / 2 - y = Screen.height / 2 - height / 2 - } - - Material.theme: themeSwitch.checked ? Material.Dark : Material.Light - Universal.theme: themeSwitch.checked ? Universal.Dark : Universal.Light - - property int controlSpacing: 10 - - Shortcut { - sequence: "Ctrl+Q" - onActivated: Qt.quit() - } - - header: ToolBar { - Material.theme: Material.Dark - - RowLayout { - anchors.fill: parent - - ToolButton { - text: "Normal" - hoverEnabled: true - ToolTip.text: text - ToolTip.delay: 1000 - ToolTip.visible: hovered - onClicked: menu.visible ? menu.close() : menu.open() - - Menu { - id: menu - x: 1 - y: 1 + parent.height - - MenuItem { - text: "Option 1" - checkable: true - } - MenuItem { - text: "Option 2" - checkable: true - } - MenuItem { - text: "Option 3" - checkable: true - } - } - } - ToolButton { - text: "Pressed" - down: true - hoverEnabled: true - ToolTip.text: text - ToolTip.delay: 1000 - ToolTip.visible: hovered - } - ToolButton { - text: "Checked" - checkable: true - checked: true - hoverEnabled: true - ToolTip.text: text - ToolTip.delay: 1000 - ToolTip.visible: hovered - } - ToolButton { - text: "Highlighted" - highlighted: true - hoverEnabled: true - ToolTip.text: text - ToolTip.delay: 1000 - ToolTip.visible: hovered - } - ToolButton { - text: "Disabled" - enabled: false - } - Item { - Layout.fillWidth: true - } - Label { - text: "Light/Dark" - } - Switch { - id: themeSwitch - } - } - } - - footer: TabBar { - TabButton { - text: "Normal" - } - TabButton { - text: "Pressed" - down: true - } - TabButton { - text: "Disabled" - enabled: false - } - } - - Pane { - anchors.fill: parent - - Flickable { - anchors.fill: parent - contentHeight: flow.height - - Flow { - id: flow - width: parent.width - spacing: 30 - - RowLayout { - spacing: window.controlSpacing - - Button { - text: "Normal" - } - Button { - text: "Pressed" - down: true - } - Button { - text: "Checked" - checked: true - } - Button { - text: "CH + PR" - checked: true - down: true - } - Button { - text: "Disabled" - enabled: false - } - Button { - text: "CH + DIS" - enabled: false - checked: true - } - } - - RowLayout { - spacing: window.controlSpacing - - Button { - text: "HI" - highlighted: true - } - Button { - text: "HI + PR" - highlighted: true - down: true - } - Button { - text: "HI + CH" - highlighted: true - checked: true - } - Button { - text: "HI+CH+PR" - highlighted: true - down: true - checked: true - } - Button { - text: "HI + DIS" - highlighted: true - enabled: false - } - Button { - text: "HI+CH+DIS" - highlighted: true - enabled: false - checked: true - } - } - - RowLayout { - CheckBox { - text: "Normal" - } - CheckBox { - text: "Pressed" - down: true - } - CheckBox { - text: "Checked" - checked: true - } - CheckBox { - text: "CH + PR" - checked: true - down: true - } - CheckBox { - text: "Disabled" - enabled: false - } - CheckBox { - text: "CH + DIS" - checked: true - enabled: false - } - } - - RowLayout { - RadioButton { - text: "Normal" - } - RadioButton { - text: "Pressed" - down: true - } - RadioButton { - text: "Checked" - checked: true - } - RadioButton { - text: "CH + PR" - checked: true - down: true - } - RadioButton { - text: "Disabled" - enabled: false - } - RadioButton { - text: "CH + DIS" - checked: true - enabled: false - } - } - - RowLayout { - Switch { - text: "Normal" - } - Switch { - text: "Pressed" - down: true - } - Switch { - text: "Checked" - checked: true - } - Switch { - text: "CH + PR" - checked: true - down: true - } - Switch { - text: "Disabled" - enabled: false - } - } - - RowLayout { - ProgressBar { - value: 0.5 - } - ProgressBar { - value: 0.5 - indeterminate: true - } - ProgressBar { - value: 0.5 - enabled: false - } - } - - RowLayout { - Slider { - value: 0.5 - } - Slider { - value: 0.5 - pressed: true - } - Slider { - value: 0.5 - enabled: false - } - } - - RowLayout { - RangeSlider { - first.value: 0.25 - second.value: 0.75 - } - RangeSlider { - first.value: 0.25 - first.pressed: true - second.value: 0.75 - } - RangeSlider { - first.value: 0.25 - second.value: 0.75 - enabled: false - } - } - - RowLayout { - Item { - implicitWidth: normalGroupBox.width - implicitHeight: normalTextArea.implicitHeight - - TextArea { - id: normalTextArea - text: "Normal" - } - } - Item { - implicitWidth: normalGroupBox.width - implicitHeight: normalTextArea.implicitHeight - - TextArea { - placeholderText: "Placeholder" - } - } - Item { - implicitWidth: normalGroupBox.width - implicitHeight: normalTextArea.implicitHeight - - TextArea { - text: "Disabled" - enabled: false - } - } - } - - RowLayout { - Item { - implicitWidth: normalGroupBox.implicitWidth - implicitHeight: normalTextField.implicitHeight - - TextField { - id: normalTextField - text: "Normal" - } - } - Item { - implicitWidth: normalGroupBox.implicitWidth - implicitHeight: normalTextField.implicitHeight - - TextField { - placeholderText: "Placeholder" - } - } - Item { - implicitWidth: normalGroupBox.implicitWidth - implicitHeight: normalTextField.implicitHeight - - TextField { - text: "Disabled" - enabled: false - } - } - } - - RowLayout { - Item { - implicitWidth: normalGroupBox.implicitWidth - implicitHeight: normalSpinBox.implicitHeight - - SpinBox { - id: normalSpinBox - } - } - Item { - implicitWidth: normalGroupBox.implicitWidth - implicitHeight: normalSpinBox.implicitHeight - - SpinBox { - up.pressed: true - } - } - Item { - implicitWidth: normalGroupBox.implicitWidth - implicitHeight: normalSpinBox.implicitHeight - - SpinBox { - enabled: false - } - } - } - - RowLayout { - Item { - implicitWidth: normalGroupBox.implicitWidth - implicitHeight: normalComboBox.implicitHeight - - ComboBox { - id: normalComboBox - model: 5 - } - } - - Item { - implicitWidth: normalGroupBox.implicitWidth - implicitHeight: normalComboBox.implicitHeight - - ComboBox { - pressed: true - model: ListModel { - ListElement { text: "Pressed" } - } - } - } - - Item { - implicitWidth: normalGroupBox.implicitWidth - implicitHeight: normalComboBox.implicitHeight - - ComboBox { - enabled: false - model: ["Disabled"] - } - } - } - - RowLayout { - GroupBox { - id: normalGroupBox - title: "Normal" - - Item { - implicitWidth: 200 - implicitHeight: 100 - - BusyIndicator { - anchors.centerIn: parent - } - } - } - GroupBox { - enabled: false - title: "Disabled" - - Item { - implicitWidth: 200 - implicitHeight: 100 - - BusyIndicator { - anchors.centerIn: parent - } - } - } - GroupBox { - enabled: false - title: "." - label.visible: false - - Item { - implicitWidth: 200 - implicitHeight: 100 - - PageIndicator { - count: 5 - enabled: false - anchors.bottom: parent.bottom - anchors.horizontalCenter: parent.horizontalCenter - } - } - } - } - - RowLayout { - Frame { - id: scrollBarFrame - - Item { - implicitWidth: 200 - implicitHeight: 100 - - Label { - text: "Normal" - anchors.centerIn: parent - } - - ScrollBar { - size: 0.3 - position: 0.2 - active: true - orientation: Qt.Vertical - height: parent.height - anchors.right: parent.right - } - } - } - - Frame { - Item { - implicitWidth: 200 - implicitHeight: 100 - - Label { - text: "Pressed" - anchors.centerIn: parent - } - - ScrollBar { - size: 0.3 - position: 0.2 - active: true - orientation: Qt.Vertical - height: parent.height - anchors.right: parent.right - pressed: true - } - } - } - - Frame { - Item { - implicitWidth: 200 - implicitHeight: 100 - enabled: false - - Label { - text: "Disabled" - anchors.centerIn: parent - } - - ScrollBar { - size: 0.3 - position: 0.2 - active: true - orientation: Qt.Vertical - height: parent.height - anchors.right: parent.right - } - } - } - } - - RowLayout { - Frame { - Layout.preferredWidth: 100 - Layout.preferredHeight: 100 - - ScrollIndicator { - size: 0.3 - position: 0.2 - active: true - orientation: Qt.Vertical - height: parent.height - anchors.right: parent.right - } - } - - Frame { - Layout.preferredWidth: 100 - Layout.preferredHeight: 100 - - ScrollIndicator { - size: 0.3 - position: 0.2 - active: true - orientation: Qt.Vertical - height: parent.height - anchors.right: parent.right - enabled: false - } - } - } - - RowLayout { - Frame { - Tumbler { - model: 5 - implicitWidth: 100 - implicitHeight: 100 - } - } - Frame { - Tumbler { - model: 5 - implicitWidth: 100 - implicitHeight: 100 - enabled: false - } - } - } - - RowLayout { - Dial { - } - Dial { - enabled: false - } - } - } - } - } -} - diff --git a/tests/manual/testbench/qml.qrc b/tests/manual/testbench/qml.qrc index 5f6483ac..9f4b1783 100644 --- a/tests/manual/testbench/qml.qrc +++ b/tests/manual/testbench/qml.qrc @@ -1,5 +1,5 @@ - main.qml + testbench.qml diff --git a/tests/manual/testbench/testbench.qml b/tests/manual/testbench/testbench.qml new file mode 100644 index 00000000..2fdc52af --- /dev/null +++ b/tests/manual/testbench/testbench.qml @@ -0,0 +1,653 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.6 +import QtQuick.Window 2.2 +import QtQuick.Layouts 1.0 +import QtQuick.Controls 2.0 +import QtQuick.Controls.Material 2.0 +import QtQuick.Controls.Universal 2.0 + +ApplicationWindow { + id: window + visible: true + width: 750 + height: 1000 + + Component.onCompleted: { + x = Screen.width / 2 - width / 2 + y = Screen.height / 2 - height / 2 + } + + Material.theme: themeSwitch.checked ? Material.Dark : Material.Light + Universal.theme: themeSwitch.checked ? Universal.Dark : Universal.Light + + property int controlSpacing: 10 + + Shortcut { + sequence: "Ctrl+Q" + onActivated: Qt.quit() + } + + header: ToolBar { + Material.theme: Material.Dark + + RowLayout { + anchors.fill: parent + + ToolButton { + text: "Normal" + hoverEnabled: true + ToolTip.text: text + ToolTip.delay: 1000 + ToolTip.visible: hovered + onClicked: menu.visible ? menu.close() : menu.open() + + Menu { + id: menu + x: 1 + y: 1 + parent.height + + MenuItem { + text: "Option 1" + checkable: true + } + MenuItem { + text: "Option 2" + checkable: true + } + MenuItem { + text: "Option 3" + checkable: true + } + } + } + ToolButton { + text: "Pressed" + down: true + hoverEnabled: true + ToolTip.text: text + ToolTip.delay: 1000 + ToolTip.visible: hovered + } + ToolButton { + text: "Checked" + checkable: true + checked: true + hoverEnabled: true + ToolTip.text: text + ToolTip.delay: 1000 + ToolTip.visible: hovered + } + ToolButton { + text: "Highlighted" + highlighted: true + hoverEnabled: true + ToolTip.text: text + ToolTip.delay: 1000 + ToolTip.visible: hovered + } + ToolButton { + text: "Disabled" + enabled: false + } + Item { + Layout.fillWidth: true + } + Label { + text: "Light/Dark" + } + Switch { + id: themeSwitch + } + } + } + + footer: TabBar { + TabButton { + text: "Normal" + } + TabButton { + text: "Pressed" + down: true + } + TabButton { + text: "Disabled" + enabled: false + } + } + + Pane { + anchors.fill: parent + + Flickable { + anchors.fill: parent + contentHeight: flow.height + + Flow { + id: flow + width: parent.width + spacing: 30 + + RowLayout { + spacing: window.controlSpacing + + Button { + text: "Normal" + } + Button { + text: "Pressed" + down: true + } + Button { + text: "Checked" + checked: true + } + Button { + text: "CH + PR" + checked: true + down: true + } + Button { + text: "Disabled" + enabled: false + } + Button { + text: "CH + DIS" + enabled: false + checked: true + } + } + + RowLayout { + spacing: window.controlSpacing + + Button { + text: "HI" + highlighted: true + } + Button { + text: "HI + PR" + highlighted: true + down: true + } + Button { + text: "HI + CH" + highlighted: true + checked: true + } + Button { + text: "HI+CH+PR" + highlighted: true + down: true + checked: true + } + Button { + text: "HI + DIS" + highlighted: true + enabled: false + } + Button { + text: "HI+CH+DIS" + highlighted: true + enabled: false + checked: true + } + } + + RowLayout { + CheckBox { + text: "Normal" + } + CheckBox { + text: "Pressed" + down: true + } + CheckBox { + text: "Checked" + checked: true + } + CheckBox { + text: "CH + PR" + checked: true + down: true + } + CheckBox { + text: "Disabled" + enabled: false + } + CheckBox { + text: "CH + DIS" + checked: true + enabled: false + } + } + + RowLayout { + RadioButton { + text: "Normal" + } + RadioButton { + text: "Pressed" + down: true + } + RadioButton { + text: "Checked" + checked: true + } + RadioButton { + text: "CH + PR" + checked: true + down: true + } + RadioButton { + text: "Disabled" + enabled: false + } + RadioButton { + text: "CH + DIS" + checked: true + enabled: false + } + } + + RowLayout { + Switch { + text: "Normal" + } + Switch { + text: "Pressed" + down: true + } + Switch { + text: "Checked" + checked: true + } + Switch { + text: "CH + PR" + checked: true + down: true + } + Switch { + text: "Disabled" + enabled: false + } + } + + RowLayout { + ProgressBar { + value: 0.5 + } + ProgressBar { + value: 0.5 + indeterminate: true + } + ProgressBar { + value: 0.5 + enabled: false + } + } + + RowLayout { + Slider { + value: 0.5 + } + Slider { + value: 0.5 + pressed: true + } + Slider { + value: 0.5 + enabled: false + } + } + + RowLayout { + RangeSlider { + first.value: 0.25 + second.value: 0.75 + } + RangeSlider { + first.value: 0.25 + first.pressed: true + second.value: 0.75 + } + RangeSlider { + first.value: 0.25 + second.value: 0.75 + enabled: false + } + } + + RowLayout { + Item { + implicitWidth: normalGroupBox.width + implicitHeight: normalTextArea.implicitHeight + + TextArea { + id: normalTextArea + text: "Normal" + } + } + Item { + implicitWidth: normalGroupBox.width + implicitHeight: normalTextArea.implicitHeight + + TextArea { + placeholderText: "Placeholder" + } + } + Item { + implicitWidth: normalGroupBox.width + implicitHeight: normalTextArea.implicitHeight + + TextArea { + text: "Disabled" + enabled: false + } + } + } + + RowLayout { + Item { + implicitWidth: normalGroupBox.implicitWidth + implicitHeight: normalTextField.implicitHeight + + TextField { + id: normalTextField + text: "Normal" + } + } + Item { + implicitWidth: normalGroupBox.implicitWidth + implicitHeight: normalTextField.implicitHeight + + TextField { + placeholderText: "Placeholder" + } + } + Item { + implicitWidth: normalGroupBox.implicitWidth + implicitHeight: normalTextField.implicitHeight + + TextField { + text: "Disabled" + enabled: false + } + } + } + + RowLayout { + Item { + implicitWidth: normalGroupBox.implicitWidth + implicitHeight: normalSpinBox.implicitHeight + + SpinBox { + id: normalSpinBox + } + } + Item { + implicitWidth: normalGroupBox.implicitWidth + implicitHeight: normalSpinBox.implicitHeight + + SpinBox { + up.pressed: true + } + } + Item { + implicitWidth: normalGroupBox.implicitWidth + implicitHeight: normalSpinBox.implicitHeight + + SpinBox { + enabled: false + } + } + } + + RowLayout { + Item { + implicitWidth: normalGroupBox.implicitWidth + implicitHeight: normalComboBox.implicitHeight + + ComboBox { + id: normalComboBox + model: 5 + } + } + + Item { + implicitWidth: normalGroupBox.implicitWidth + implicitHeight: normalComboBox.implicitHeight + + ComboBox { + pressed: true + model: ListModel { + ListElement { text: "Pressed" } + } + } + } + + Item { + implicitWidth: normalGroupBox.implicitWidth + implicitHeight: normalComboBox.implicitHeight + + ComboBox { + enabled: false + model: ["Disabled"] + } + } + } + + RowLayout { + GroupBox { + id: normalGroupBox + title: "Normal" + + Item { + implicitWidth: 200 + implicitHeight: 100 + + BusyIndicator { + anchors.centerIn: parent + } + } + } + GroupBox { + enabled: false + title: "Disabled" + + Item { + implicitWidth: 200 + implicitHeight: 100 + + BusyIndicator { + anchors.centerIn: parent + } + } + } + GroupBox { + enabled: false + title: "." + label.visible: false + + Item { + implicitWidth: 200 + implicitHeight: 100 + + PageIndicator { + count: 5 + enabled: false + anchors.bottom: parent.bottom + anchors.horizontalCenter: parent.horizontalCenter + } + } + } + } + + RowLayout { + Frame { + id: scrollBarFrame + + Item { + implicitWidth: 200 + implicitHeight: 100 + + Label { + text: "Normal" + anchors.centerIn: parent + } + + ScrollBar { + size: 0.3 + position: 0.2 + active: true + orientation: Qt.Vertical + height: parent.height + anchors.right: parent.right + } + } + } + + Frame { + Item { + implicitWidth: 200 + implicitHeight: 100 + + Label { + text: "Pressed" + anchors.centerIn: parent + } + + ScrollBar { + size: 0.3 + position: 0.2 + active: true + orientation: Qt.Vertical + height: parent.height + anchors.right: parent.right + pressed: true + } + } + } + + Frame { + Item { + implicitWidth: 200 + implicitHeight: 100 + enabled: false + + Label { + text: "Disabled" + anchors.centerIn: parent + } + + ScrollBar { + size: 0.3 + position: 0.2 + active: true + orientation: Qt.Vertical + height: parent.height + anchors.right: parent.right + } + } + } + } + + RowLayout { + Frame { + Layout.preferredWidth: 100 + Layout.preferredHeight: 100 + + ScrollIndicator { + size: 0.3 + position: 0.2 + active: true + orientation: Qt.Vertical + height: parent.height + anchors.right: parent.right + } + } + + Frame { + Layout.preferredWidth: 100 + Layout.preferredHeight: 100 + + ScrollIndicator { + size: 0.3 + position: 0.2 + active: true + orientation: Qt.Vertical + height: parent.height + anchors.right: parent.right + enabled: false + } + } + } + + RowLayout { + Frame { + Tumbler { + model: 5 + implicitWidth: 100 + implicitHeight: 100 + } + } + Frame { + Tumbler { + model: 5 + implicitWidth: 100 + implicitHeight: 100 + enabled: false + } + } + } + + RowLayout { + Dial { + } + Dial { + enabled: false + } + } + } + } + } +} + -- cgit v1.2.3 From 8cde7790a69a152c1840f16ccc7471b81c190cba Mon Sep 17 00:00:00 2001 From: Mitch Curtis Date: Wed, 26 Oct 2016 11:36:24 +0200 Subject: Improve testbench - Add delegate types - Make Dials smaller Change-Id: If95115b13a1aba61921d9924a0d37e4a263b798b Reviewed-by: J-P Nurmi --- tests/manual/testbench/testbench.qml | 140 ++++++++++++++++++++++++++++++++++- 1 file changed, 138 insertions(+), 2 deletions(-) diff --git a/tests/manual/testbench/testbench.qml b/tests/manual/testbench/testbench.qml index 2fdc52af..3e8b3d0f 100644 --- a/tests/manual/testbench/testbench.qml +++ b/tests/manual/testbench/testbench.qml @@ -625,14 +625,14 @@ ApplicationWindow { Frame { Tumbler { model: 5 - implicitWidth: 100 + implicitWidth: 80 implicitHeight: 100 } } Frame { Tumbler { model: 5 - implicitWidth: 100 + implicitWidth: 80 implicitHeight: 100 enabled: false } @@ -641,11 +641,147 @@ ApplicationWindow { RowLayout { Dial { + implicitWidth: 100 + implicitHeight: 100 } Dial { + implicitWidth: 100 + implicitHeight: 100 enabled: false } } + + ListModel { + id: checkableDelegateModel + ListElement { label: "Normal" } + ListElement { label: "Pressed"; press: true } + ListElement { label: "Checked"; check: true } + ListElement { label: "CH + PR"; check: true; press: true } + ListElement { label: "Disabled"; disabled: true } + } + + RowLayout { + Frame { + Column { + width: 200 + + Repeater { + model: checkableDelegateModel + delegate: CheckDelegate { + text: label + width: parent.width + down: press + checked: check + enabled: !disabled + ButtonGroup.group: radioButtonGroup + } + } + } + } + + ButtonGroup { + id: radioButtonGroup + } + + Frame { + Column { + width: 200 + + Repeater { + model: checkableDelegateModel + delegate: RadioDelegate { + text: label + down: press + width: parent.width + checked: check + enabled: !disabled + ButtonGroup.group: radioButtonGroup + } + } + } + } + + Frame { + Column { + width: 200 + + Repeater { + model: checkableDelegateModel + delegate: SwitchDelegate { + text: label + width: parent.width + checked: check + down: press + enabled: !disabled + } + } + } + } + } + + ListModel { + id: regularDelegateModel + ListElement { label: "Normal" } + ListElement { label: "Pressed"; press: true } + ListElement { label: "Disabled"; disabled: true } + } + + RowLayout { + Frame { + Column { + width: 200 + + Repeater { + model: regularDelegateModel + delegate: ItemDelegate { + text: label + width: parent.width + down: press + enabled: !disabled + } + } + } + } + Frame { + Column { + id: listView + width: 200 + clip: true + + Repeater { + model: regularDelegateModel + delegate: SwipeDelegate { + id: swipeDelegate + text: label + width: parent.width + down: press + enabled: !disabled + + Component { + id: removeComponent + + Rectangle { + color: swipeDelegate.swipe.complete && swipeDelegate.pressed ? "#333" : "#444" + width: parent.width + height: parent.height + clip: true + + Label { + font.pixelSize: swipeDelegate.font.pixelSize + text: "Boop" + color: "white" + anchors.centerIn: parent + } + } + } + + swipe.left: removeComponent + swipe.right: removeComponent + } + } + } + } + } } } } -- cgit v1.2.3 From 1b7ac95bc0296301dee0846e0ea4381c762d8a33 Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Fri, 21 Oct 2016 23:31:02 +0200 Subject: Gallery: add Escape shortcut This does not work very well, yet. The purpose is to demonstrate the lack of co-operation between of QML Shortcuts vs. QQC2 Popups. For example, the back navigation shortcut activates in the background when the modal settings dialog is open. The consequent commits are going to fix these issues step by step. Task-number: QTBUG-56562 Change-Id: Iceafc175f4da8054b65d664a3e0faf0087d0dec5 Reviewed-by: Mitch Curtis --- examples/quickcontrols2/gallery/gallery.qml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/examples/quickcontrols2/gallery/gallery.qml b/examples/quickcontrols2/gallery/gallery.qml index cc818abd..0d1c89f0 100644 --- a/examples/quickcontrols2/gallery/gallery.qml +++ b/examples/quickcontrols2/gallery/gallery.qml @@ -57,6 +57,15 @@ ApplicationWindow { property string style: "Default" } + Shortcut { + sequence: "Esc" + enabled: stackView.depth > 1 + onActivated: { + stackView.pop() + listView.currentIndex = -1 + } + } + header: ToolBar { Material.foreground: "white" -- cgit v1.2.3 From a66e08da7681f7301e23c55fd1f40ef8461f0896 Mon Sep 17 00:00:00 2001 From: Mitch Curtis Date: Wed, 26 Oct 2016 12:48:58 +0200 Subject: Default: move opacity assignments to individual delegates This way, users have control over the opacity of child items. Change-Id: Ie7c0b08eb0b22d11319f8c2f1807e6a3a68790ea Reviewed-by: J-P Nurmi --- src/imports/controls/CheckBox.qml | 2 +- src/imports/controls/CheckIndicator.qml | 1 + src/imports/controls/RadioButton.qml | 2 +- src/imports/controls/RadioIndicator.qml | 1 + 4 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/imports/controls/CheckBox.qml b/src/imports/controls/CheckBox.qml index 78b42276..52ce20ef 100644 --- a/src/imports/controls/CheckBox.qml +++ b/src/imports/controls/CheckBox.qml @@ -51,7 +51,6 @@ T.CheckBox { padding: 6 spacing: 6 - opacity: enabled ? 1 : 0.3 //! [indicator] indicator: CheckIndicator { @@ -73,6 +72,7 @@ T.CheckBox { visible: control.text horizontalAlignment: Text.AlignLeft verticalAlignment: Text.AlignVCenter + opacity: enabled ? 1 : 0.3 } //! [contentItem] } diff --git a/src/imports/controls/CheckIndicator.qml b/src/imports/controls/CheckIndicator.qml index d78e9e30..5aad92ef 100644 --- a/src/imports/controls/CheckIndicator.qml +++ b/src/imports/controls/CheckIndicator.qml @@ -47,6 +47,7 @@ Rectangle { color: control.enabled ? (control.down ? (control.visualFocus ? "#cce0ff" : "#f6f6f6") : "#ffffff") : "#353637" border.width: control.visualFocus ? 2 : 1 border.color: control.enabled ? (control.visualFocus ? "#0066ff" : (control.down ? "#808080" : "#909090")) : "transparent" + opacity: enabled ? 1 : 0.3 Image { x: (parent.width - width) / 2 diff --git a/src/imports/controls/RadioButton.qml b/src/imports/controls/RadioButton.qml index 1c63a8de..a1a5d1a1 100644 --- a/src/imports/controls/RadioButton.qml +++ b/src/imports/controls/RadioButton.qml @@ -51,7 +51,6 @@ T.RadioButton { padding: 6 spacing: 6 - opacity: enabled ? 1 : 0.3 //! [indicator] indicator: RadioIndicator { @@ -73,6 +72,7 @@ T.RadioButton { visible: control.text horizontalAlignment: Text.AlignLeft verticalAlignment: Text.AlignVCenter + opacity: enabled ? 1 : 0.3 } //! [contentItem] } diff --git a/src/imports/controls/RadioIndicator.qml b/src/imports/controls/RadioIndicator.qml index 08c24cc5..05ff6673 100644 --- a/src/imports/controls/RadioIndicator.qml +++ b/src/imports/controls/RadioIndicator.qml @@ -44,6 +44,7 @@ Rectangle { color: control.down ? (control.visualFocus ? "#cce0ff" : "#f6f6f6") : (control.visualFocus ? "#f0f6ff" : "#ffffff") border.width: control.visualFocus ? 2 : 1 border.color: control.visualFocus ? "#0066ff" : (control.down ? "#808080" : "#909090") + opacity: enabled ? 1 : 0.3 property Item control -- cgit v1.2.3 From e711ce99c8cafe2e7c1d81a20a280f3029c98ccb Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Thu, 29 Sep 2016 19:52:55 +0200 Subject: Gallery: make the drawer usable with keyboard Give it focus, and remove the check for the current index. It's a leftover from the days when Gallery used to replace the current page instead of doing a push. It looked silly to replace a page with the same page. This can no longer happen, because the drawer is not even accessible when navigated to a control page. And when navigating the drawer with keyboard, it is exactly the current item that must be triggered when you hit the spacebar. :) Change-Id: I00b48fbe4dd61b06041cb0c3370dfa9c12505dcf Reviewed-by: Mitch Curtis --- examples/quickcontrols2/gallery/gallery.qml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/quickcontrols2/gallery/gallery.qml b/examples/quickcontrols2/gallery/gallery.qml index 0d1c89f0..aadbcdec 100644 --- a/examples/quickcontrols2/gallery/gallery.qml +++ b/examples/quickcontrols2/gallery/gallery.qml @@ -135,6 +135,8 @@ ApplicationWindow { ListView { id: listView + + focus: true currentIndex: -1 anchors.fill: parent @@ -143,10 +145,8 @@ ApplicationWindow { text: model.title highlighted: ListView.isCurrentItem onClicked: { - if (listView.currentIndex != index) { - listView.currentIndex = index - stackView.push(model.source) - } + listView.currentIndex = index + stackView.push(model.source) drawer.close() } } -- cgit v1.2.3 From a7e39a28575dc3421970e007b78731b614da258a Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Wed, 26 Oct 2016 21:31:03 +0200 Subject: QQuickPopup: fix binding loops with size-dependent positioning Dependencies between popup's size and position easily lead to recursion into reposition(). Blocking recursive reposition() calls messes up the positioning, so schedule polish events instead. Task-number: QTBUG-56755 Change-Id: I72afd14573e5cd57f8162df04e193d4c42fd7236 Reviewed-by: Mitch Curtis --- src/quicktemplates2/qquickpopup.cpp | 16 ++++++++++++++++ src/quicktemplates2/qquickpopup_p_p.h | 3 +++ tests/auto/controls/data/tst_popup.qml | 31 +++++++++++++++++++++++++++++++ tests/auto/drawer/tst_drawer.cpp | 2 +- 4 files changed, 51 insertions(+), 1 deletion(-) diff --git a/src/quicktemplates2/qquickpopup.cpp b/src/quicktemplates2/qquickpopup.cpp index 124b8c5b..d343fad6 100644 --- a/src/quicktemplates2/qquickpopup.cpp +++ b/src/quicktemplates2/qquickpopup.cpp @@ -128,6 +128,7 @@ QQuickPopupPrivate::QQuickPopupPrivate() , hasDim(false) , visible(false) , complete(false) + , positioning(false) , hasWidth(false) , hasHeight(false) , hasTopMargin(false) @@ -401,6 +402,12 @@ QQuickPopupItem::QQuickPopupItem(QQuickPopup *popup) : // connect(QGuiApplication::styleHints(), &QStyleHints::useHoverEffectsChanged, this, &QQuickItem::setAcceptHoverEvents); } +void QQuickPopupItem::updatePolish() +{ + Q_D(QQuickPopupItem); + return QQuickPopupPrivate::get(d->popup)->reposition(); +} + bool QQuickPopupItem::childMouseEventFilter(QQuickItem *child, QEvent *event) { Q_D(QQuickPopupItem); @@ -594,6 +601,11 @@ void QQuickPopupPrivate::reposition() if (!popupItem->isVisible()) return; + if (positioning) { + popupItem->polish(); + return; + } + const qreal w = popupItem->width(); const qreal h = popupItem->height(); const qreal iw = popupItem->implicitWidth(); @@ -702,6 +714,8 @@ void QQuickPopupPrivate::reposition() } } + positioning = true; + popupItem->setPosition(rect.topLeft()); const QPointF effectivePos = parentItem ? parentItem->mapFromScene(rect.topLeft()) : rect.topLeft(); @@ -718,6 +732,8 @@ void QQuickPopupPrivate::reposition() popupItem->setWidth(rect.width()); if (!hasHeight && heightAdjusted && rect.height() > 0) popupItem->setHeight(rect.height()); + + positioning = false; } void QQuickPopupPrivate::resizeOverlay() diff --git a/src/quicktemplates2/qquickpopup_p_p.h b/src/quicktemplates2/qquickpopup_p_p.h index c8c83ada..d2f16e11 100644 --- a/src/quicktemplates2/qquickpopup_p_p.h +++ b/src/quicktemplates2/qquickpopup_p_p.h @@ -87,6 +87,8 @@ public: explicit QQuickPopupItem(QQuickPopup *popup); protected: + void updatePolish() override; + bool childMouseEventFilter(QQuickItem *child, QEvent *event) override; void focusInEvent(QFocusEvent *event) override; void focusOutEvent(QFocusEvent *event) override; @@ -185,6 +187,7 @@ public: bool hasDim; bool visible; bool complete; + bool positioning; bool hasWidth; bool hasHeight; bool hasTopMargin; diff --git a/tests/auto/controls/data/tst_popup.qml b/tests/auto/controls/data/tst_popup.qml index 82fcbf8b..0ca8ce57 100644 --- a/tests/auto/controls/data/tst_popup.qml +++ b/tests/auto/controls/data/tst_popup.qml @@ -1229,4 +1229,35 @@ TestCase { control.destroy() } + + Component { + id: xyBindingLoop + ApplicationWindow { + id: window + width: 360 + height: 360 + visible: true + property alias popup: popup + + Popup { + id: popup + visible: true + x: (parent.width - width) / 2 + y: (parent.height - height) / 2 + Label { + text: "Content" + anchors.fill: parent + } + } + } + } + + function test_xyBindingLoop() { + var window = xyBindingLoop.createObject(testCase) + var control = window.popup + waitForRendering(control.contentItem) + compare(control.x, (control.parent.width - control.width) / 2) + compare(control.y, (control.parent.height - control.height) / 2) + window.destroy() + } } diff --git a/tests/auto/drawer/tst_drawer.cpp b/tests/auto/drawer/tst_drawer.cpp index 80385421..830f63b0 100644 --- a/tests/auto/drawer/tst_drawer.cpp +++ b/tests/auto/drawer/tst_drawer.cpp @@ -380,7 +380,7 @@ void tst_Drawer::reposition() window->setWidth(window->width() + 100); QTRY_COMPARE(geometry(dimmer), QRectF(0, 150, window->width(), window->height() - 150)); - QCOMPARE(geometry(popupItem), QRectF(window->width() - drawer->width(), 150, window->width() / 2, window->height() - 150)); + QTRY_COMPARE(geometry(popupItem), QRectF(window->width() - drawer->width(), 150, window->width() / 2, window->height() - 150)); drawer->close(); QTRY_COMPARE(geometry(popupItem), QRectF(window->width(), 150, window->width() / 2, window->height() - 150)); -- cgit v1.2.3 From 929fd7b919fb873750f97f3e74b0986ce7c4e022 Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Wed, 26 Oct 2016 20:27:16 +0200 Subject: Scrollers: give control over layouting if parent != flickable This allows utilizing the convenient attached properties of ScrollBar and ScrollIndicator, but positioning the scrollers outside of a clipping Flickable. Change-Id: I46fe79110658f4797469d042c56f51548eef6c70 Reviewed-by: Mitch Curtis --- src/quicktemplates2/qquickscrollbar.cpp | 33 +++++++++++++++++++++--- src/quicktemplates2/qquickscrollindicator.cpp | 33 +++++++++++++++++++++--- tests/auto/controls/data/tst_scrollbar.qml | 16 ++++++++++++ tests/auto/controls/data/tst_scrollindicator.qml | 16 ++++++++++++ 4 files changed, 92 insertions(+), 6 deletions(-) diff --git a/src/quicktemplates2/qquickscrollbar.cpp b/src/quicktemplates2/qquickscrollbar.cpp index 69cac6ee..d3a2355c 100644 --- a/src/quicktemplates2/qquickscrollbar.cpp +++ b/src/quicktemplates2/qquickscrollbar.cpp @@ -65,9 +65,9 @@ QT_BEGIN_NAMESPACE } \endcode - \note When ScrollBar is attached \l {ScrollBar::vertical}{vertically} or - \l {ScrollBar::horizontal}{horizontally} to a Flickable, its geometry and - the following properties are automatically set and updated as appropriate: + When ScrollBar is attached \l {ScrollBar::vertical}{vertically} or + \l {ScrollBar::horizontal}{horizontally} to a Flickable, the following + properties are automatically set and updated as appropriate: \list \li \l orientation \li \l position @@ -75,6 +75,29 @@ QT_BEGIN_NAMESPACE \li \l active \endlist + An attached ScrollBar re-parents itself to the target Flickable. A vertically + attached ScrollBar resizes itself to the height of the Flickable, and positions + itself to either side of it based on the \l {Control::mirrored}{layout direction}. + A horizontally attached ScrollBar resizes itself to the width of the Flickable, + and positions itself to the bottom. The automatic geometry management can be disabled + by specifying another parent for the attached ScrollBar. This can be useful, for + example, if the ScrollBar should be placed outside a clipping Flickable. This is + demonstrated by the following example: + + \code + Flickable { + id: flickable + clip: true + // ... + ScrollBar.vertical: ScrollBar { + parent: flickable.parent + anchors.top: flickable.top + anchors.left: flickable.right + anchors.bottom: flickable.bottom + } + } + \endcode + Notice that ScrollBar does not filter key events of the Flickable it is attached to. The following example illustrates how to implement scrolling with up and down keys: @@ -465,6 +488,8 @@ void QQuickScrollBarAttachedPrivate::mirrorVertical() void QQuickScrollBarAttachedPrivate::layoutHorizontal(bool move) { Q_ASSERT(horizontal && flickable); + if (horizontal->parentItem() != flickable) + return; horizontal->setWidth(flickable->width()); if (move) horizontal->setY(flickable->height() - horizontal->height()); @@ -473,6 +498,8 @@ void QQuickScrollBarAttachedPrivate::layoutHorizontal(bool move) void QQuickScrollBarAttachedPrivate::layoutVertical(bool move) { Q_ASSERT(vertical && flickable); + if (vertical->parentItem() != flickable) + return; vertical->setHeight(flickable->height()); if (move) vertical->setX(vertical->isMirrored() ? 0 : flickable->width() - vertical->width()); diff --git a/src/quicktemplates2/qquickscrollindicator.cpp b/src/quicktemplates2/qquickscrollindicator.cpp index 48adda0a..91d03ec9 100644 --- a/src/quicktemplates2/qquickscrollindicator.cpp +++ b/src/quicktemplates2/qquickscrollindicator.cpp @@ -65,9 +65,9 @@ QT_BEGIN_NAMESPACE } \endcode - \note When ScrollIndicator is attached \l {ScrollIndicator::vertical}{vertically} - or \l {ScrollIndicator::horizontal}{horizontally} to a Flickable, its geometry and - the following properties are automatically set and updated as appropriate: + When ScrollIndicator is attached \l {ScrollIndicator::vertical}{vertically} or + \l {ScrollIndicator::horizontal}{horizontally} to a Flickable, the following + properties are automatically set and updated as appropriate: \list \li \l orientation \li \l position @@ -75,6 +75,29 @@ QT_BEGIN_NAMESPACE \li \l active \endlist + An attached ScrollIndicator re-parents itself to the target Flickable. A vertically + attached ScrollIndicator resizes itself to the height of the Flickable, and positions + itself to either side of it based on the \l {Control::mirrored}{layout direction}. + A horizontally attached ScrollIndicator resizes itself to the width of the Flickable, + and positions itself to the bottom. The automatic geometry management can be disabled + by specifying another parent for the attached ScrollIndicator. This can be useful, for + example, if the ScrollIndicator should be placed outside a clipping Flickable. This is + demonstrated by the following example: + + \code + Flickable { + id: flickable + clip: true + // ... + ScrollIndicator.vertical: ScrollIndicator { + parent: flickable.parent + anchors.top: flickable.top + anchors.left: flickable.right + anchors.bottom: flickable.bottom + } + } + \endcode + Horizontal and vertical scroll indicators do not share the \l active state with each other by default. In order to keep both indicators visible whilst scrolling to either direction, establish a two-way binding between the active states as @@ -268,6 +291,8 @@ void QQuickScrollIndicatorAttachedPrivate::activateVertical() void QQuickScrollIndicatorAttachedPrivate::layoutHorizontal(bool move) { Q_ASSERT(horizontal && flickable); + if (horizontal->parentItem() != flickable) + return; horizontal->setWidth(flickable->width()); if (move) horizontal->setY(flickable->height() - horizontal->height()); @@ -276,6 +301,8 @@ void QQuickScrollIndicatorAttachedPrivate::layoutHorizontal(bool move) void QQuickScrollIndicatorAttachedPrivate::layoutVertical(bool move) { Q_ASSERT(vertical && flickable); + if (vertical->parentItem() != flickable) + return; vertical->setHeight(flickable->height()); if (move && !QQuickItemPrivate::get(vertical)->isMirrored()) vertical->setX(flickable->width() - vertical->width()); diff --git a/tests/auto/controls/data/tst_scrollbar.qml b/tests/auto/controls/data/tst_scrollbar.qml index 1684ba51..7c83cca9 100644 --- a/tests/auto/controls/data/tst_scrollbar.qml +++ b/tests/auto/controls/data/tst_scrollbar.qml @@ -141,6 +141,22 @@ TestCase { compare(horizontal.size, container.visibleArea.widthRatio) compare(horizontal.position, container.visibleArea.xPosition) + var oldY = vertical.y + var oldHeight = vertical.height + vertical.parent = testCase + vertical.y -= 10 + container.height += 10 + compare(vertical.y, oldY - 10) + compare(vertical.height, oldHeight) + + var oldX = horizontal.x + var oldWidth = horizontal.width + horizontal.parent = testCase + horizontal.x -= 10 + container.width += 10 + compare(horizontal.x, oldX - 10) + compare(horizontal.width, oldWidth) + container.destroy() } diff --git a/tests/auto/controls/data/tst_scrollindicator.qml b/tests/auto/controls/data/tst_scrollindicator.qml index 90d9287a..f5e57e2d 100644 --- a/tests/auto/controls/data/tst_scrollindicator.qml +++ b/tests/auto/controls/data/tst_scrollindicator.qml @@ -136,6 +136,22 @@ TestCase { compare(horizontal.size, container.visibleArea.widthRatio) compare(horizontal.position, container.visibleArea.xPosition) + var oldY = vertical.y + var oldHeight = vertical.height + vertical.parent = testCase + vertical.y -= 10 + container.height += 10 + compare(vertical.y, oldY - 10) + compare(vertical.height, oldHeight) + + var oldX = horizontal.x + var oldWidth = horizontal.width + horizontal.parent = testCase + horizontal.x -= 10 + container.width += 10 + compare(horizontal.x, oldX - 10) + compare(horizontal.width, oldWidth) + container.destroy() } -- cgit v1.2.3 From 541fc438b0c0e49b9eb7a861322ec6dce4dbc238 Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Fri, 28 Oct 2016 15:03:03 +0200 Subject: Material: fix blurry ComboBox drop indicators Change-Id: I2c3f101182f8b985180695f6cf3c6baabe9969ed Reviewed-by: Mitch Curtis --- src/imports/controls/material/images/drop-indicator.png | Bin 342 -> 192 bytes src/imports/controls/material/images/drop-indicator.svg | 5 +++++ .../controls/material/images/drop-indicator@2x.png | Bin 273 -> 221 bytes .../controls/material/images/drop-indicator@3x.png | Bin 406 -> 256 bytes .../controls/material/images/drop-indicator@4x.png | Bin 520 -> 289 bytes 5 files changed, 5 insertions(+) create mode 100644 src/imports/controls/material/images/drop-indicator.svg diff --git a/src/imports/controls/material/images/drop-indicator.png b/src/imports/controls/material/images/drop-indicator.png index b4396ec6..08bb4855 100644 Binary files a/src/imports/controls/material/images/drop-indicator.png and b/src/imports/controls/material/images/drop-indicator.png differ diff --git a/src/imports/controls/material/images/drop-indicator.svg b/src/imports/controls/material/images/drop-indicator.svg new file mode 100644 index 00000000..94b5ca15 --- /dev/null +++ b/src/imports/controls/material/images/drop-indicator.svg @@ -0,0 +1,5 @@ + + + + + diff --git a/src/imports/controls/material/images/drop-indicator@2x.png b/src/imports/controls/material/images/drop-indicator@2x.png index 1c711bc2..ccdfc2b1 100644 Binary files a/src/imports/controls/material/images/drop-indicator@2x.png and b/src/imports/controls/material/images/drop-indicator@2x.png differ diff --git a/src/imports/controls/material/images/drop-indicator@3x.png b/src/imports/controls/material/images/drop-indicator@3x.png index 06dd8bd2..00cae691 100644 Binary files a/src/imports/controls/material/images/drop-indicator@3x.png and b/src/imports/controls/material/images/drop-indicator@3x.png differ diff --git a/src/imports/controls/material/images/drop-indicator@4x.png b/src/imports/controls/material/images/drop-indicator@4x.png index b2157c30..0a61cb01 100644 Binary files a/src/imports/controls/material/images/drop-indicator@4x.png and b/src/imports/controls/material/images/drop-indicator@4x.png differ -- cgit v1.2.3 From e32ffa19f0cabc50f264c2e20cdae3557e658ac7 Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Fri, 28 Oct 2016 15:32:36 +0200 Subject: Doc: fix review findings for Drawer Change-Id: Ibdf3f1dee5664979cdf77ba7485e3d71110fc860 Task-number: QTBUG-55904 Reviewed-by: Mitch Curtis --- src/quicktemplates2/qquickdrawer.cpp | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/quicktemplates2/qquickdrawer.cpp b/src/quicktemplates2/qquickdrawer.cpp index d35b30cf..dc427bc9 100644 --- a/src/quicktemplates2/qquickdrawer.cpp +++ b/src/quicktemplates2/qquickdrawer.cpp @@ -156,7 +156,9 @@ QT_BEGIN_NAMESPACE the drawer is opened, don't apply a translation. \note On some platforms, certain edges may be reserved for system - gestures and therefore cannot be used with Drawer. + gestures and therefore cannot be used with Drawer. For example, the + top and bottom edges may be reserved for system notifications and + control centers on Android and iOS. \sa SwipeView, {Customizing Drawer}, {Navigation Controls}, {Popup Controls} */ @@ -481,13 +483,13 @@ QQuickDrawer::QQuickDrawer(QObject *parent) : /*! \qmlproperty enumeration QtQuick.Controls::Drawer::edge - This property holds the edge of the content item at which the drawer will + This property holds the edge of the window at which the drawer will open from. The acceptable values are: - \value Qt.TopEdge The top edge of the content item. - \value Qt.LeftEdge The left edge of the content item (default). - \value Qt.RightEdge The right edge of the content item. - \value Qt.BottomEdge The bottom edge of the content item. + \value Qt.TopEdge The top edge of the window. + \value Qt.LeftEdge The left edge of the window (default). + \value Qt.RightEdge The right edge of the window. + \value Qt.BottomEdge The bottom edge of the window. */ Qt::Edge QQuickDrawer::edge() const { @@ -511,8 +513,8 @@ void QQuickDrawer::setEdge(Qt::Edge edge) \qmlproperty real QtQuick.Controls::Drawer::position This property holds the position of the drawer relative to its final - destination. That is, the position will be \c 0 when the drawer - is fully closed, and \c 1 when fully open. + destination. That is, the position will be \c 0.0 when the drawer + is fully closed, and \c 1.0 when fully open. */ qreal QQuickDrawer::position() const { -- cgit v1.2.3 From dac9c6bd1d7be53a659ce0bffe9221c5ca255b2e Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Fri, 28 Oct 2016 15:43:15 +0200 Subject: Doc: link to Control::contentItem in GroupBox detailed description Change-Id: I0f0a93a3ebf0a884e81f9c856490d564b30a90c8 Task-number: QTBUG-55904 Reviewed-by: Mitch Curtis --- src/quicktemplates2/qquickgroupbox.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/quicktemplates2/qquickgroupbox.cpp b/src/quicktemplates2/qquickgroupbox.cpp index 27c325ef..5a5a8005 100644 --- a/src/quicktemplates2/qquickgroupbox.cpp +++ b/src/quicktemplates2/qquickgroupbox.cpp @@ -56,8 +56,8 @@ QT_BEGIN_NAMESPACE or a \l ColumnLayout. Items declared as children of a GroupBox are automatically parented to the - GroupBox's contentItem. Items created dynamically need to be explicitly - parented to the contentItem. + GroupBox's \l {Control::}{contentItem}. Items created dynamically need to be + explicitly parented to the contentItem. If only a single item is used within a GroupBox, it will resize to fit the implicit size of its contained item. This makes it particularly suitable -- cgit v1.2.3 From 97decc60e91be415b39785564cc40f8b30362809 Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Fri, 28 Oct 2016 16:18:11 +0200 Subject: Doc: add one more link to Text in the detailed description of Label Change-Id: Ic205fe6840274c12a3e4c3f1f355080aff8861d7 Task-number: QTBUG-55904 Reviewed-by: Mitch Curtis --- src/quicktemplates2/qquicklabel.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/quicktemplates2/qquicklabel.cpp b/src/quicktemplates2/qquicklabel.cpp index 03bed16f..b3596022 100644 --- a/src/quicktemplates2/qquicklabel.cpp +++ b/src/quicktemplates2/qquicklabel.cpp @@ -66,7 +66,7 @@ QT_BEGIN_NAMESPACE \snippet qtquickcontrols2-label.qml 1 - You can use the properties of Text to change the appearance of the text as desired: + You can use the properties of \l Text to change the appearance of the text as desired: \qml Label { -- cgit v1.2.3 From a7687dbbb0fa0f619324b43bba1ccb9d5b75ce64 Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Fri, 28 Oct 2016 16:27:58 +0200 Subject: Doc: fix review findings for Switch & SwitchDelegate Change-Id: I1626cb83d75e9b64fc5e274dc29fff04a157741b Task-number: QTBUG-55904 Reviewed-by: Mitch Curtis --- src/quicktemplates2/qquickswitch.cpp | 14 ++++---------- src/quicktemplates2/qquickswitchdelegate.cpp | 8 ++++++-- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/src/quicktemplates2/qquickswitch.cpp b/src/quicktemplates2/qquickswitch.cpp index a7d17e86..8c3d9f0b 100644 --- a/src/quicktemplates2/qquickswitch.cpp +++ b/src/quicktemplates2/qquickswitch.cpp @@ -57,17 +57,11 @@ QT_BEGIN_NAMESPACE Switch is an option button that can be dragged or toggled on (checked) or off (unchecked). Switches are typically used to select between two states. + For larger sets of options, such as those in a list, consider using + \l SwitchDelegate instead. - \table - \row \li \image qtquickcontrols2-switch-normal.png - \li A switch in its normal state. - \row \li \image qtquickcontrols2-switch-checked.png - \li A switch that is checked. - \row \li \image qtquickcontrols2-switch-focused.png - \li A switch that has active focus. - \row \li \image qtquickcontrols2-switch-disabled.png - \li A switch that is disabled. - \endtable + Switch inherits its API from \l AbstractButton. For instance, the state + of the switch can be set with the \l {AbstractButton::}{checked} property. \code ColumnLayout { diff --git a/src/quicktemplates2/qquickswitchdelegate.cpp b/src/quicktemplates2/qquickswitchdelegate.cpp index 62b677e5..edfb15d5 100644 --- a/src/quicktemplates2/qquickswitchdelegate.cpp +++ b/src/quicktemplates2/qquickswitchdelegate.cpp @@ -53,9 +53,13 @@ QT_BEGIN_NAMESPACE SwitchDelegate presents an item delegate that can be toggled on (checked) or off (unchecked). Switch delegates are typically used to select one or more - options from a set of options. + options from a set of options. For smaller sets of options, or for options + that need to be uniquely identifiable, consider using \l Switch instead. - The state of the check delegate can be set with the + SwitchDelegate inherits its API from \l ItemDelegate, which is inherited + from \l AbstractButton. For instance, you can set \l {AbstractButton::text}{text}, + and react to \l {AbstractButton::clicked}{clicks} using the \l AbstractButton + API. The state of the switch delegate can be set with the \l {AbstractButton::}{checked} property. \code -- cgit v1.2.3 From 548b0bdd0f57c2209c8cbd7ac4ecda204cf69a2e Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Fri, 28 Oct 2016 16:31:51 +0200 Subject: Doc: fix review findings for TextArea Change-Id: I0d9ff52d019bfae37e1fd191e914e61a1a07aee0 Task-number: QTBUG-55904 Reviewed-by: Mitch Curtis --- src/quicktemplates2/qquicktextarea.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/quicktemplates2/qquicktextarea.cpp b/src/quicktemplates2/qquicktextarea.cpp index 1b6aef9f..ee20d477 100644 --- a/src/quicktemplates2/qquicktextarea.cpp +++ b/src/quicktemplates2/qquicktextarea.cpp @@ -79,6 +79,8 @@ QT_BEGIN_NAMESPACE decoration of the TextArea scrolls together with the rest of the scrollable content. + \section2 Scrollable TextArea + If you want to make a TextArea scrollable, for example, when it covers an entire application page, attach it to a \l Flickable and combine with a \l ScrollBar or \l ScrollIndicator. @@ -87,7 +89,7 @@ QT_BEGIN_NAMESPACE \snippet qtquickcontrols2-textarea-flickable.qml 1 - A TextArea that is attached to a Flickable does the following: + A TextArea that is attached to a \l Flickable does the following: \list \li Sets the content size automatically @@ -630,9 +632,7 @@ QQuickTextAreaAttached::~QQuickTextAreaAttached() This property attaches a text area to a \l Flickable. - \snippet qtquickcontrols2-textarea-flickable.qml 1 - - \sa ScrollBar, ScrollIndicator + \sa ScrollBar, ScrollIndicator, {Scrollable TextArea} */ QQuickTextArea *QQuickTextAreaAttached::flickable() const { -- cgit v1.2.3