diff options
author | Liang Qi <liang.qi@qt.io> | 2018-01-09 21:52:12 +0100 |
---|---|---|
committer | Liang Qi <liang.qi@qt.io> | 2018-01-09 21:54:50 +0100 |
commit | ef5e426bed3b1362394c7cc0c97522bb20cacff0 (patch) | |
tree | 0450da77b661d2e97eb7628b4c667ee22c6dc443 /src | |
parent | 2cdec3eadc7ac1d1e5c4cd505b60196e44df1a7d (diff) | |
parent | 10b8f6af42a1cd80273d0a2d36e75b79078b5994 (diff) |
Merge remote-tracking branch 'origin/5.10' into dev
Conflicts:
.qmake.conf
src/quicktemplates2/qquickabstractbutton_p.h
Change-Id: I265cbd2ce51beaf2afef99292c2e2798dadb4ba3
Diffstat (limited to 'src')
114 files changed, 2630 insertions, 387 deletions
diff --git a/src/imports/controls/CheckDelegate.qml b/src/imports/controls/CheckDelegate.qml index 5fe39101..087c9d75 100644 --- a/src/imports/controls/CheckDelegate.qml +++ b/src/imports/controls/CheckDelegate.qml @@ -76,7 +76,7 @@ T.CheckDelegate { implicitWidth: 28 implicitHeight: 28 - x: text ? (control.mirrored ? control.width - width - control.rightPadding : control.leftPadding) : control.leftPadding + (control.availableWidth - width) / 2 + x: control.mirrored ? control.leftPadding : control.width - width - control.rightPadding y: control.topPadding + (control.availableHeight - height) / 2 color: control.down ? control.palette.light : control.palette.base diff --git a/src/imports/controls/ComboBox.qml b/src/imports/controls/ComboBox.qml index 3bfa2ea7..defbff29 100644 --- a/src/imports/controls/ComboBox.qml +++ b/src/imports/controls/ComboBox.qml @@ -80,7 +80,7 @@ T.ComboBox { enabled: control.editable autoScroll: control.editable - readOnly: control.popup.visible + readOnly: control.down inputMethodHints: control.inputMethodHints validator: control.validator @@ -103,7 +103,7 @@ T.ComboBox { implicitWidth: 140 implicitHeight: 40 - color: control.down || popup.visible ? control.palette.mid : control.palette.button + color: control.down ? control.palette.mid : control.palette.button border.color: control.palette.highlight border.width: !control.editable && control.visualFocus ? 2 : 0 visible: !control.flat || control.down @@ -119,7 +119,7 @@ T.ComboBox { contentItem: ListView { clip: true implicitHeight: contentHeight - model: control.popup.visible ? control.delegateModel : null + model: control.delegateModel currentIndex: control.highlightedIndex highlightMoveDuration: 0 diff --git a/src/imports/controls/designer/AbstractButtonSection.qml b/src/imports/controls/designer/AbstractButtonSection.qml new file mode 100644 index 00000000..3d3dad5d --- /dev/null +++ b/src/imports/controls/designer/AbstractButtonSection.qml @@ -0,0 +1,105 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt Quick Controls 2 module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.1 +import HelperWidgets 2.0 +import QtQuick.Layouts 1.0 + +Section { + caption: qsTr("AbstractButton") + + SectionLayout { + Label { + text: qsTr("Text") + tooltip: qsTr("The text displayed on the button.") + } + SecondColumnLayout { + LineEdit { + backendValue: backendValues.text + Layout.fillWidth: true + } + } + + Label { + visible: checkable + text: qsTr("Checkable") + tooltip: qsTr("Whether the button is checkable.") + } + SecondColumnLayout { + CheckBox { + text: backendValues.checkable.valueToString + backendValue: backendValues.checkable + Layout.fillWidth: true + } + } + + Label { + text: qsTr("Checked") + tooltip: qsTr("Whether the button is checked.") + } + SecondColumnLayout { + CheckBox { + text: backendValues.checked.valueToString + backendValue: backendValues.checked + Layout.fillWidth: true + } + } + + Label { + text: qsTr("Exclusive") + tooltip: qsTr("Whether the button is exclusive.") + } + SecondColumnLayout { + CheckBox { + text: backendValues.autoExclusive.valueToString + backendValue: backendValues.autoExclusive + Layout.fillWidth: true + } + } + + Label { + text: qsTr("Repeat") + tooltip: qsTr("Whether the button repeats while pressed and held down.") + } + SecondColumnLayout { + CheckBox { + text: backendValues.autoRepeat.valueToString + backendValue: backendValues.autoRepeat + Layout.fillWidth: true + } + } + } +} diff --git a/src/imports/controls/designer/BusyIndicatorSpecifics.qml b/src/imports/controls/designer/BusyIndicatorSpecifics.qml index 78a00e8e..cf51efd2 100644 --- a/src/imports/controls/designer/BusyIndicatorSpecifics.qml +++ b/src/imports/controls/designer/BusyIndicatorSpecifics.qml @@ -43,7 +43,7 @@ Column { Section { width: parent.width - caption: qsTr("Busy Indicator") + caption: qsTr("BusyIndicator") SectionLayout { Label { diff --git a/src/imports/controls/designer/ButtonSection.qml b/src/imports/controls/designer/ButtonSection.qml index 05834fdf..15e23df9 100644 --- a/src/imports/controls/designer/ButtonSection.qml +++ b/src/imports/controls/designer/ButtonSection.qml @@ -40,22 +40,12 @@ import QtQuick.Layouts 1.0 Section { id: section + caption: qsTr("Button") SectionLayout { Label { - text: qsTr("Text") - tooltip: qsTr("The text displayed on the %1.").arg(section.caption.toLowerCase()) - } - SecondColumnLayout { - LineEdit { - backendValue: backendValues.text - Layout.fillWidth: true - } - } - - Label { text: qsTr("Highlighted") - tooltip: qsTr("Whether the %1 is highlighted.").arg(section.caption.toLowerCase()) + tooltip: qsTr("Whether the button is highlighted.") } SecondColumnLayout { CheckBox { @@ -64,54 +54,5 @@ Section { Layout.fillWidth: true } } - - Label { - visible: checkable - text: qsTr("Checkable") - tooltip: qsTr("Whether the %1 is checkable.").arg(section.caption.toLowerCase()) - } - SecondColumnLayout { - CheckBox { - text: backendValues.checkable.valueToString - backendValue: backendValues.checkable - Layout.fillWidth: true - } - } - - Label { - text: qsTr("Checked") - tooltip: qsTr("Whether the %1 is checked.").arg(section.caption.toLowerCase()) - } - SecondColumnLayout { - CheckBox { - text: backendValues.checked.valueToString - backendValue: backendValues.checked - Layout.fillWidth: true - } - } - - Label { - text: qsTr("Exclusive") - tooltip: qsTr("Whether the %1 is exclusive.").arg(section.caption.toLowerCase()) - } - SecondColumnLayout { - CheckBox { - text: backendValues.autoExclusive.valueToString - backendValue: backendValues.autoExclusive - Layout.fillWidth: true - } - } - - Label { - text: qsTr("Repeat") - tooltip: qsTr("Whether the %1 repeats while pressed and held down.").arg(section.caption.toLowerCase()) - } - SecondColumnLayout { - CheckBox { - text: backendValues.autoRepeat.valueToString - backendValue: backendValues.autoRepeat - Layout.fillWidth: true - } - } } } diff --git a/src/imports/controls/designer/ButtonSpecifics.qml b/src/imports/controls/designer/ButtonSpecifics.qml index 4a9e58c2..7b5d0a24 100644 --- a/src/imports/controls/designer/ButtonSpecifics.qml +++ b/src/imports/controls/designer/ButtonSpecifics.qml @@ -42,7 +42,10 @@ Column { width: parent.width ButtonSection { - caption: qsTr("Button") + width: parent.width + } + + AbstractButtonSection { width: parent.width } diff --git a/src/imports/controls/designer/CheckBoxSpecifics.qml b/src/imports/controls/designer/CheckBoxSpecifics.qml index bae0a03c..f11c55a1 100644 --- a/src/imports/controls/designer/CheckBoxSpecifics.qml +++ b/src/imports/controls/designer/CheckBoxSpecifics.qml @@ -41,8 +41,12 @@ import QtQuick.Layouts 1.0 Column { width: parent.width - ButtonSection { - caption: qsTr("Check Box") + CheckSection { + width: parent.width + caption: qsTr("CheckBox") + } + + AbstractButtonSection { width: parent.width } diff --git a/src/imports/controls/designer/CheckDelegateSpecifics.qml b/src/imports/controls/designer/CheckDelegateSpecifics.qml index bd885430..d5c92d87 100644 --- a/src/imports/controls/designer/CheckDelegateSpecifics.qml +++ b/src/imports/controls/designer/CheckDelegateSpecifics.qml @@ -41,8 +41,16 @@ import QtQuick.Layouts 1.0 Column { width: parent.width - ButtonSection { - caption: qsTr("Check Delegate") + CheckSection { + width: parent.width + caption: qsTr("CheckDelegate") + } + + ItemDelegateSection { + width: parent.width + } + + AbstractButtonSection { width: parent.width } diff --git a/src/imports/controls/designer/CheckSection.qml b/src/imports/controls/designer/CheckSection.qml new file mode 100644 index 00000000..28353874 --- /dev/null +++ b/src/imports/controls/designer/CheckSection.qml @@ -0,0 +1,68 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt Quick Controls 2 module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.1 +import HelperWidgets 2.0 +import QtQuick.Layouts 1.0 + +Section { + SectionLayout { + Label { + text: qsTr("Check State") + tooltip: qsTr("The current check state.") + } + SecondColumnLayout { + ComboBox { + backendValue: backendValues.checkState + model: [ "Unchecked", "PartiallyChecked", "Checked" ] + scope: "Qt" + Layout.fillWidth: true + } + } + + Label { + text: qsTr("Tri-state") + tooltip: qsTr("Whether the checkbox has three states.") + } + SecondColumnLayout { + CheckBox { + text: backendValues.tristate.valueToString + backendValue: backendValues.tristate + Layout.fillWidth: true + } + } + } +} diff --git a/src/imports/controls/designer/ComboBoxSpecifics.qml b/src/imports/controls/designer/ComboBoxSpecifics.qml index 410ae51e..3ed283ca 100644 --- a/src/imports/controls/designer/ComboBoxSpecifics.qml +++ b/src/imports/controls/designer/ComboBoxSpecifics.qml @@ -43,7 +43,7 @@ Column { Section { width: parent.width - caption: qsTr("Combo Box") + caption: qsTr("ComboBox") SectionLayout { Label { diff --git a/src/imports/controls/designer/ContainerSection.qml b/src/imports/controls/designer/ContainerSection.qml new file mode 100644 index 00000000..9a31069a --- /dev/null +++ b/src/imports/controls/designer/ContainerSection.qml @@ -0,0 +1,59 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt Quick Controls 2 module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.1 +import HelperWidgets 2.0 +import QtQuick.Layouts 1.0 + +Section { + caption: qsTr("Container") + + SectionLayout { + Label { + text: qsTr("Current") + tooltip: qsTr("The index of the current item.") + } + SecondColumnLayout { + SpinBox { + maximumValue: 9999999 + minimumValue: -9999999 + decimals: 0 + backendValue: backendValues.currentIndex + Layout.fillWidth: true + } + } + } +} diff --git a/src/imports/controls/designer/ControlSection.qml b/src/imports/controls/designer/ControlSection.qml index 7ecb5760..90dd3816 100644 --- a/src/imports/controls/designer/ControlSection.qml +++ b/src/imports/controls/designer/ControlSection.qml @@ -55,6 +55,31 @@ Section { } Label { + text: qsTr("Focus Policy") + tooltip: qsTr("Focus policy of the control.") + } + SecondColumnLayout { + ComboBox { + backendValue: backendValues.focusPolicy + model: [ "TabFocus", "ClickFocus", "StrongFocus", "WheelFocus", "NoFocus" ] + scope: "Qt" + Layout.fillWidth: true + } + } + + Label { + text: qsTr("Hover") + tooltip: qsTr("Whether control accepts hover evets.") + } + SecondColumnLayout { + CheckBox { + text: backendValues.hoverEnabled.valueToString + backendValue: backendValues.hoverEnabled + Layout.fillWidth: true + } + } + + Label { text: qsTr("Spacing") tooltip: qsTr("Spacing between internal elements of the control.") } @@ -67,5 +92,17 @@ Section { Layout.fillWidth: true } } + + Label { + text: qsTr("Wheel") + tooltip: qsTr("Whether control accepts wheel evets.") + } + SecondColumnLayout { + CheckBox { + text: backendValues.wheelEnabled.valueToString + backendValue: backendValues.wheelEnabled + Layout.fillWidth: true + } + } } } diff --git a/src/imports/controls/designer/DelayButtonSpecifics.qml b/src/imports/controls/designer/DelayButtonSpecifics.qml new file mode 100644 index 00000000..3821edc2 --- /dev/null +++ b/src/imports/controls/designer/DelayButtonSpecifics.qml @@ -0,0 +1,81 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt Quick Controls 2 module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.1 +import HelperWidgets 2.0 +import QtQuick.Layouts 1.0 + +Column { + width: parent.width + + Section { + width: parent.width + caption: qsTr("DelayButton") + + SectionLayout { + Label { + text: qsTr("Delay") + tooltip: qsTr("The delay in milliseconds.") + } + SecondColumnLayout { + SpinBox { + minimumValue: 0 + maximumValue: 9999999 + decimals: 0 + stepSize: 1 + backendValue: backendValues.delay + Layout.fillWidth: true + } + } + } + } + + AbstractButtonSection { + width: parent.width + } + + ControlSection { + width: parent.width + } + + FontSection { + width: parent.width + } + + PaddingSection { + width: parent.width + } +} diff --git a/src/imports/controls/designer/DialSpecifics.qml b/src/imports/controls/designer/DialSpecifics.qml index 52bba078..6c9bda34 100644 --- a/src/imports/controls/designer/DialSpecifics.qml +++ b/src/imports/controls/designer/DialSpecifics.qml @@ -55,6 +55,7 @@ Column { minimumValue: Math.min(backendValues.from.value, backendValues.to.value) maximumValue: Math.max(backendValues.from.value, backendValues.to.value) decimals: 2 + stepSize: 0.1 backendValue: backendValues.value Layout.fillWidth: true } @@ -69,6 +70,7 @@ Column { maximumValue: 9999999 minimumValue: -9999999 decimals: 2 + stepSize: 0.1 backendValue: backendValues.from Layout.fillWidth: true } @@ -83,6 +85,7 @@ Column { maximumValue: 9999999 minimumValue: -9999999 decimals: 2 + stepSize: 0.1 backendValue: backendValues.to Layout.fillWidth: true } @@ -97,10 +100,36 @@ Column { maximumValue: 9999999 minimumValue: -9999999 decimals: 2 + stepSize: 0.1 backendValue: backendValues.stepSize Layout.fillWidth: true } } + + Label { + text: qsTr("Snap Mode") + tooltip: qsTr("The snap mode of the dial.") + } + SecondColumnLayout { + ComboBox { + backendValue: backendValues.orientation + model: [ "NoSnap", "SnapOnRelease", "SnapAlways" ] + scope: "Dial" + Layout.fillWidth: true + } + } + + Label { + text: qsTr("Live") + tooltip: qsTr("Whether the dial provides live value updates.") + } + SecondColumnLayout { + CheckBox { + text: backendValues.live.valueToString + backendValue: backendValues.live + Layout.fillWidth: true + } + } } } diff --git a/src/imports/controls/designer/FrameSpecifics.qml b/src/imports/controls/designer/FrameSpecifics.qml index 1eef1c68..8b2cd97d 100644 --- a/src/imports/controls/designer/FrameSpecifics.qml +++ b/src/imports/controls/designer/FrameSpecifics.qml @@ -41,6 +41,10 @@ import QtQuick.Layouts 1.0 Column { width: parent.width + PaneSection { + width: parent.width + } + ControlSection { width: parent.width } diff --git a/src/imports/controls/designer/GroupBoxSpecifics.qml b/src/imports/controls/designer/GroupBoxSpecifics.qml index 8629b991..59b3299d 100644 --- a/src/imports/controls/designer/GroupBoxSpecifics.qml +++ b/src/imports/controls/designer/GroupBoxSpecifics.qml @@ -43,7 +43,7 @@ Column { Section { width: parent.width - caption: qsTr("Group Box") + caption: qsTr("GroupBox") SectionLayout { Label { @@ -59,6 +59,10 @@ Column { } } + PaneSection { + width: parent.width + } + ControlSection { width: parent.width } diff --git a/src/imports/controls/designer/ItemDelegateSection.qml b/src/imports/controls/designer/ItemDelegateSection.qml new file mode 100644 index 00000000..6f466439 --- /dev/null +++ b/src/imports/controls/designer/ItemDelegateSection.qml @@ -0,0 +1,58 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt Quick Controls 2 module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.1 +import HelperWidgets 2.0 +import QtQuick.Layouts 1.0 + +Section { + id: section + caption: qsTr("ItemDelegate") + + SectionLayout { + Label { + text: qsTr("Highlighted") + tooltip: qsTr("Whether the delegate is highlighted.") + } + SecondColumnLayout { + CheckBox { + text: backendValues.highlighted.valueToString + backendValue: backendValues.highlighted + Layout.fillWidth: true + } + } + } +} diff --git a/src/imports/controls/designer/ItemDelegateSpecifics.qml b/src/imports/controls/designer/ItemDelegateSpecifics.qml index 0e0a482e..6efb1bdc 100644 --- a/src/imports/controls/designer/ItemDelegateSpecifics.qml +++ b/src/imports/controls/designer/ItemDelegateSpecifics.qml @@ -41,8 +41,11 @@ import QtQuick.Layouts 1.0 Column { width: parent.width - ButtonSection { - caption: qsTr("Item Delegate") + ItemDelegateSection { + width: parent.width + } + + AbstractButtonSection { width: parent.width } diff --git a/src/imports/controls/designer/PageIndicatorSpecifics.qml b/src/imports/controls/designer/PageIndicatorSpecifics.qml index 02258c92..f8bf09d4 100644 --- a/src/imports/controls/designer/PageIndicatorSpecifics.qml +++ b/src/imports/controls/designer/PageIndicatorSpecifics.qml @@ -43,7 +43,7 @@ Column { Section { width: parent.width - caption: qsTr("Indicator") + caption: qsTr("PageIndicator") SectionLayout { Label { diff --git a/src/imports/controls/designer/PageSpecifics.qml b/src/imports/controls/designer/PageSpecifics.qml new file mode 100644 index 00000000..32feedd7 --- /dev/null +++ b/src/imports/controls/designer/PageSpecifics.qml @@ -0,0 +1,101 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt Quick Controls 2 module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.1 +import HelperWidgets 2.0 +import QtQuick.Layouts 1.0 + +Column { + width: parent.width + + Section { + width: parent.width + caption: qsTr("Page") + + SectionLayout { + Label { + text: qsTr("Title") + tooltip: qsTr("Title of the page.") + } + SecondColumnLayout { + LineEdit { + backendValue: backendValues.title + Layout.fillWidth: true + } + } + + Label { + text: qsTr("Content Width") + tooltip: qsTr("Content height used for calculating the total implicit width.") + } + SecondColumnLayout { + SpinBox { + maximumValue: 9999999 + minimumValue: -9999999 + decimals: 0 + backendValue: backendValues.contentWidth + Layout.fillWidth: true + } + } + + Label { + text: qsTr("Content Height") + tooltip: qsTr("Content height used for calculating the total implicit height.") + } + SecondColumnLayout { + SpinBox { + maximumValue: 9999999 + minimumValue: -9999999 + decimals: 0 + backendValue: backendValues.contentHeight + Layout.fillWidth: true + } + } + } + } + + ControlSection { + width: parent.width + } + + FontSection { + width: parent.width + } + + PaddingSection { + width: parent.width + } +} diff --git a/src/imports/controls/designer/PaneSection.qml b/src/imports/controls/designer/PaneSection.qml new file mode 100644 index 00000000..57aa53ae --- /dev/null +++ b/src/imports/controls/designer/PaneSection.qml @@ -0,0 +1,73 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt Quick Controls 2 module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.1 +import HelperWidgets 2.0 +import QtQuick.Layouts 1.0 + +Section { + caption: qsTr("Pane") + + SectionLayout { + Label { + text: qsTr("Content Width") + tooltip: qsTr("Content height used for calculating the total implicit width.") + } + SecondColumnLayout { + SpinBox { + maximumValue: 9999999 + minimumValue: -9999999 + decimals: 0 + backendValue: backendValues.contentWidth + Layout.fillWidth: true + } + } + + Label { + text: qsTr("Content Height") + tooltip: qsTr("Content height used for calculating the total implicit height.") + } + SecondColumnLayout { + SpinBox { + maximumValue: 9999999 + minimumValue: -9999999 + decimals: 0 + backendValue: backendValues.contentHeight + Layout.fillWidth: true + } + } + } +} diff --git a/src/imports/controls/designer/PaneSpecifics.qml b/src/imports/controls/designer/PaneSpecifics.qml index 1eef1c68..8b2cd97d 100644 --- a/src/imports/controls/designer/PaneSpecifics.qml +++ b/src/imports/controls/designer/PaneSpecifics.qml @@ -41,6 +41,10 @@ import QtQuick.Layouts 1.0 Column { width: parent.width + PaneSection { + width: parent.width + } + ControlSection { width: parent.width } diff --git a/src/imports/controls/designer/ProgressBarSpecifics.qml b/src/imports/controls/designer/ProgressBarSpecifics.qml index 7abb895d..fb1eb838 100644 --- a/src/imports/controls/designer/ProgressBarSpecifics.qml +++ b/src/imports/controls/designer/ProgressBarSpecifics.qml @@ -43,7 +43,7 @@ Column { Section { width: parent.width - caption: qsTr("Progress Bar") + caption: qsTr("ProgressBar") SectionLayout { Label { @@ -67,6 +67,7 @@ Column { minimumValue: Math.min(backendValues.from.value, backendValues.to.value) maximumValue: Math.max(backendValues.from.value, backendValues.to.value) decimals: 2 + stepSize: 0.1 backendValue: backendValues.value Layout.fillWidth: true } @@ -81,6 +82,7 @@ Column { maximumValue: 9999999 minimumValue: -9999999 decimals: 2 + stepSize: 0.1 backendValue: backendValues.from Layout.fillWidth: true } @@ -95,6 +97,7 @@ Column { maximumValue: 9999999 minimumValue: -9999999 decimals: 2 + stepSize: 0.1 backendValue: backendValues.to Layout.fillWidth: true } diff --git a/src/imports/controls/designer/RadioButtonSpecifics.qml b/src/imports/controls/designer/RadioButtonSpecifics.qml index a7a5a3f7..671218a8 100644 --- a/src/imports/controls/designer/RadioButtonSpecifics.qml +++ b/src/imports/controls/designer/RadioButtonSpecifics.qml @@ -41,8 +41,7 @@ import QtQuick.Layouts 1.0 Column { width: parent.width - ButtonSection { - caption: qsTr("Radio Button") + AbstractButtonSection { width: parent.width } diff --git a/src/imports/controls/designer/RadioDelegateSpecifics.qml b/src/imports/controls/designer/RadioDelegateSpecifics.qml index 09ee6590..6efb1bdc 100644 --- a/src/imports/controls/designer/RadioDelegateSpecifics.qml +++ b/src/imports/controls/designer/RadioDelegateSpecifics.qml @@ -41,8 +41,11 @@ import QtQuick.Layouts 1.0 Column { width: parent.width - ButtonSection { - caption: qsTr("Radio Delegate") + ItemDelegateSection { + width: parent.width + } + + AbstractButtonSection { width: parent.width } diff --git a/src/imports/controls/designer/RangeSliderSpecifics.qml b/src/imports/controls/designer/RangeSliderSpecifics.qml new file mode 100644 index 00000000..d1a81512 --- /dev/null +++ b/src/imports/controls/designer/RangeSliderSpecifics.qml @@ -0,0 +1,175 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt Quick Controls 2 module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.1 +import HelperWidgets 2.0 +import QtQuick.Layouts 1.1 + +Column { + width: parent.width + + Section { + width: parent.width + caption: qsTr("RangeSlider") + + SectionLayout { + Label { + text: qsTr("First Value") + tooltip: qsTr("The value of the first range slider handle.") + } + SecondColumnLayout { + SpinBox { + minimumValue: Math.min(backendValues.from.value, backendValues.to.value) + maximumValue: Math.max(backendValues.from.value, backendValues.to.value) + decimals: 2 + stepSize: 0.1 + backendValue: backendValues.first_value + Layout.fillWidth: true + } + } + + Label { + text: qsTr("Second Value") + tooltip: qsTr("The value of the second range slider handle.") + } + SecondColumnLayout { + SpinBox { + minimumValue: Math.min(backendValues.from.value, backendValues.to.value) + maximumValue: Math.max(backendValues.from.value, backendValues.to.value) + decimals: 2 + stepSize: 0.1 + backendValue: backendValues.second_value + Layout.fillWidth: true + } + } + + Label { + text: qsTr("From") + tooltip: qsTr("The starting value of the range slider range.") + } + SecondColumnLayout { + SpinBox { + maximumValue: 9999999 + minimumValue: -9999999 + decimals: 2 + stepSize: 0.1 + backendValue: backendValues.from + Layout.fillWidth: true + } + } + + Label { + text: qsTr("To") + tooltip: qsTr("The ending value of the range slider range.") + } + SecondColumnLayout { + SpinBox { + maximumValue: 9999999 + minimumValue: -9999999 + decimals: 2 + stepSize: 0.1 + backendValue: backendValues.to + Layout.fillWidth: true + } + } + + Label { + text: qsTr("Step Size") + tooltip: qsTr("The step size of the range slider.") + } + SecondColumnLayout { + SpinBox { + maximumValue: 9999999 + minimumValue: -9999999 + decimals: 2 + stepSize: 0.1 + backendValue: backendValues.stepSize + Layout.fillWidth: true + } + } + + Label { + text: qsTr("Snap Mode") + tooltip: qsTr("The snap mode of the range slider.") + } + SecondColumnLayout { + ComboBox { + backendValue: backendValues.orientation + model: [ "NoSnap", "SnapOnRelease", "SnapAlways" ] + scope: "RangeSlider" + Layout.fillWidth: true + } + } + + Label { + text: qsTr("Orientation") + tooltip: qsTr("The orientation of the range slider.") + } + SecondColumnLayout { + ComboBox { + backendValue: backendValues.orientation + model: [ "Horizontal", "Vertical" ] + scope: "Qt" + Layout.fillWidth: true + } + } + + Label { + text: qsTr("Live") + tooltip: qsTr("Whether the range slider provides live value updates.") + } + SecondColumnLayout { + CheckBox { + text: backendValues.live.valueToString + backendValue: backendValues.live + Layout.fillWidth: true + } + } + } + } + + ControlSection { + width: parent.width + } + + FontSection { + width: parent.width + } + + PaddingSection { + width: parent.width + } +} diff --git a/src/imports/controls/designer/RoundButtonSpecifics.qml b/src/imports/controls/designer/RoundButtonSpecifics.qml new file mode 100644 index 00000000..1c1eed43 --- /dev/null +++ b/src/imports/controls/designer/RoundButtonSpecifics.qml @@ -0,0 +1,83 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt Quick Controls 2 module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.1 +import HelperWidgets 2.0 +import QtQuick.Layouts 1.0 + +Column { + width: parent.width + + Section { + caption: qsTr("RoundButton") + + SectionLayout { + Label { + text: qsTr("Radius") + tooltip: qsTr("Radius of the button.") + } + SecondColumnLayout { + SpinBox { + maximumValue: 9999999 + minimumValue: -9999999 + decimals: 0 + backendValue: backendValues.radius + Layout.fillWidth: true + } + } + } + } + + ButtonSection { + width: parent.width + } + + AbstractButtonSection { + width: parent.width + } + + ControlSection { + width: parent.width + } + + FontSection { + width: parent.width + } + + PaddingSection { + width: parent.width + } +} diff --git a/src/imports/controls/designer/ScrollViewSpecifics.qml b/src/imports/controls/designer/ScrollViewSpecifics.qml new file mode 100644 index 00000000..4ce7668a --- /dev/null +++ b/src/imports/controls/designer/ScrollViewSpecifics.qml @@ -0,0 +1,90 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt Quick Controls 2 module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.1 +import HelperWidgets 2.0 +import QtQuick.Layouts 1.0 + +Column { + width: parent.width + + Section { + width: parent.width + caption: qsTr("ScrollView") + + SectionLayout { + Label { + text: qsTr("Content Width") + tooltip: qsTr("Content height used for calculating the total implicit width.") + } + SecondColumnLayout { + SpinBox { + maximumValue: 9999999 + minimumValue: -9999999 + decimals: 0 + backendValue: backendValues.contentWidth + Layout.fillWidth: true + } + } + + Label { + text: qsTr("Content Height") + tooltip: qsTr("Content height used for calculating the total implicit height.") + } + SecondColumnLayout { + SpinBox { + maximumValue: 9999999 + minimumValue: -9999999 + decimals: 0 + backendValue: backendValues.contentHeight + Layout.fillWidth: true + } + } + } + } + + ControlSection { + width: parent.width + } + + FontSection { + width: parent.width + } + + PaddingSection { + width: parent.width + } +} diff --git a/src/imports/controls/designer/SliderSpecifics.qml b/src/imports/controls/designer/SliderSpecifics.qml index fb215001..69bc2574 100644 --- a/src/imports/controls/designer/SliderSpecifics.qml +++ b/src/imports/controls/designer/SliderSpecifics.qml @@ -55,6 +55,7 @@ Column { minimumValue: Math.min(backendValues.from.value, backendValues.to.value) maximumValue: Math.max(backendValues.from.value, backendValues.to.value) decimals: 2 + stepSize: 0.1 backendValue: backendValues.value Layout.fillWidth: true } @@ -69,6 +70,7 @@ Column { maximumValue: 9999999 minimumValue: -9999999 decimals: 2 + stepSize: 0.1 backendValue: backendValues.from Layout.fillWidth: true } @@ -83,6 +85,7 @@ Column { maximumValue: 9999999 minimumValue: -9999999 decimals: 2 + stepSize: 0.1 backendValue: backendValues.to Layout.fillWidth: true } @@ -97,12 +100,26 @@ Column { maximumValue: 9999999 minimumValue: -9999999 decimals: 2 + stepSize: 0.1 backendValue: backendValues.stepSize Layout.fillWidth: true } } Label { + text: qsTr("Snap Mode") + tooltip: qsTr("The snap mode of the slider.") + } + SecondColumnLayout { + ComboBox { + backendValue: backendValues.orientation + model: [ "NoSnap", "SnapOnRelease", "SnapAlways" ] + scope: "Slider" + Layout.fillWidth: true + } + } + + Label { text: qsTr("Orientation") tooltip: qsTr("The orientation of the slider.") } @@ -114,6 +131,18 @@ Column { Layout.fillWidth: true } } + + Label { + text: qsTr("Live") + tooltip: qsTr("Whether the slider provides live value updates.") + } + SecondColumnLayout { + CheckBox { + text: backendValues.live.valueToString + backendValue: backendValues.live + Layout.fillWidth: true + } + } } } diff --git a/src/imports/controls/designer/SpinBoxSpecifics.qml b/src/imports/controls/designer/SpinBoxSpecifics.qml index 4290801a..335b15db 100644 --- a/src/imports/controls/designer/SpinBoxSpecifics.qml +++ b/src/imports/controls/designer/SpinBoxSpecifics.qml @@ -43,7 +43,7 @@ Column { Section { width: parent.width - caption: qsTr("Spin Box") + caption: qsTr("SpinBox") SectionLayout { Label { @@ -101,6 +101,18 @@ Column { Layout.fillWidth: true } } + + Label { + text: qsTr("Editable") + tooltip: qsTr("Whether the spinbox is editable.") + } + SecondColumnLayout { + CheckBox { + text: backendValues.editable.valueToString + backendValue: backendValues.editable + Layout.fillWidth: true + } + } } } diff --git a/src/imports/controls/designer/StackViewSpecifics.qml b/src/imports/controls/designer/StackViewSpecifics.qml new file mode 100644 index 00000000..1eef1c68 --- /dev/null +++ b/src/imports/controls/designer/StackViewSpecifics.qml @@ -0,0 +1,55 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt Quick Controls 2 module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.1 +import HelperWidgets 2.0 +import QtQuick.Layouts 1.0 + +Column { + width: parent.width + + ControlSection { + width: parent.width + } + + FontSection { + width: parent.width + } + + PaddingSection { + width: parent.width + } +} diff --git a/src/imports/controls/designer/SwipeDelegateSpecifics.qml b/src/imports/controls/designer/SwipeDelegateSpecifics.qml index 0e0a482e..6efb1bdc 100644 --- a/src/imports/controls/designer/SwipeDelegateSpecifics.qml +++ b/src/imports/controls/designer/SwipeDelegateSpecifics.qml @@ -41,8 +41,11 @@ import QtQuick.Layouts 1.0 Column { width: parent.width - ButtonSection { - caption: qsTr("Item Delegate") + ItemDelegateSection { + width: parent.width + } + + AbstractButtonSection { width: parent.width } diff --git a/src/imports/controls/designer/SwipeViewSpecifics.qml b/src/imports/controls/designer/SwipeViewSpecifics.qml new file mode 100644 index 00000000..ac91880c --- /dev/null +++ b/src/imports/controls/designer/SwipeViewSpecifics.qml @@ -0,0 +1,91 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt Quick Controls 2 module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.1 +import HelperWidgets 2.0 +import QtQuick.Layouts 1.0 + +Column { + width: parent.width + + Section { + width: parent.width + caption: qsTr("SwipeView") + + SectionLayout { + Label { + text: qsTr("Interactive") + tooltip: qsTr("Whether the view is interactive.") + } + SecondColumnLayout { + CheckBox { + text: backendValues.interactive.valueToString + backendValue: backendValues.interactive + Layout.fillWidth: true + } + } + + Label { + text: qsTr("Orientation") + tooltip: qsTr("Orientation of the view.") + } + SecondColumnLayout { + ComboBox { + backendValue: backendValues.orientation + model: [ "Horizontal", "Vertical" ] + scope: "Qt" + Layout.fillWidth: true + } + } + } + } + + ContainerSection { + width: parent.width + } + + ControlSection { + width: parent.width + } + + FontSection { + width: parent.width + } + + PaddingSection { + width: parent.width + } +} diff --git a/src/imports/controls/designer/SwitchDelegateSpecifics.qml b/src/imports/controls/designer/SwitchDelegateSpecifics.qml index 84784758..c71cb13d 100644 --- a/src/imports/controls/designer/SwitchDelegateSpecifics.qml +++ b/src/imports/controls/designer/SwitchDelegateSpecifics.qml @@ -41,8 +41,11 @@ import QtQuick.Layouts 1.0 Column { width: parent.width - ButtonSection { - caption: qsTr("Switch Delegate") + ItemDelegateSection { + width: parent.width + } + + AbstractButtonSection { width: parent.width } diff --git a/src/imports/controls/designer/SwitchSpecifics.qml b/src/imports/controls/designer/SwitchSpecifics.qml index 53172765..671218a8 100644 --- a/src/imports/controls/designer/SwitchSpecifics.qml +++ b/src/imports/controls/designer/SwitchSpecifics.qml @@ -41,8 +41,7 @@ import QtQuick.Layouts 1.0 Column { width: parent.width - ButtonSection { - caption: qsTr("Switch") + AbstractButtonSection { width: parent.width } diff --git a/src/imports/controls/designer/TabBarSpecifics.qml b/src/imports/controls/designer/TabBarSpecifics.qml new file mode 100644 index 00000000..7a4984a1 --- /dev/null +++ b/src/imports/controls/designer/TabBarSpecifics.qml @@ -0,0 +1,107 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt Quick Controls 2 module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.1 +import HelperWidgets 2.0 +import QtQuick.Layouts 1.0 + +Column { + width: parent.width + + Section { + width: parent.width + caption: qsTr("TabBar") + + SectionLayout { + Label { + text: qsTr("Position") + tooltip: qsTr("Position of the tabbar.") + } + SecondColumnLayout { + ComboBox { + backendValue: backendValues.position + model: [ "Header", "Footer" ] + scope: "TabBar" + Layout.fillWidth: true + } + } + + Label { + text: qsTr("Content Width") + tooltip: qsTr("Content height used for calculating the total implicit width.") + } + SecondColumnLayout { + SpinBox { + maximumValue: 9999999 + minimumValue: -9999999 + decimals: 0 + backendValue: backendValues.contentWidth + Layout.fillWidth: true + } + } + + Label { + text: qsTr("Content Height") + tooltip: qsTr("Content height used for calculating the total implicit height.") + } + SecondColumnLayout { + SpinBox { + maximumValue: 9999999 + minimumValue: -9999999 + decimals: 0 + backendValue: backendValues.contentHeight + Layout.fillWidth: true + } + } + } + } + + ContainerSection { + width: parent.width + } + + ControlSection { + width: parent.width + } + + FontSection { + width: parent.width + } + + PaddingSection { + width: parent.width + } +} diff --git a/src/imports/controls/designer/TabButtonSpecifics.qml b/src/imports/controls/designer/TabButtonSpecifics.qml new file mode 100644 index 00000000..671218a8 --- /dev/null +++ b/src/imports/controls/designer/TabButtonSpecifics.qml @@ -0,0 +1,59 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt Quick Controls 2 module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.1 +import HelperWidgets 2.0 +import QtQuick.Layouts 1.0 + +Column { + width: parent.width + + AbstractButtonSection { + width: parent.width + } + + ControlSection { + width: parent.width + } + + FontSection { + width: parent.width + } + + PaddingSection { + width: parent.width + } +} diff --git a/src/imports/controls/designer/TextAreaSpecifics.qml b/src/imports/controls/designer/TextAreaSpecifics.qml index 20f5013b..e8bed83d 100644 --- a/src/imports/controls/designer/TextAreaSpecifics.qml +++ b/src/imports/controls/designer/TextAreaSpecifics.qml @@ -41,6 +41,25 @@ import QtQuick.Layouts 1.0 Column { width: parent.width + Section { + width: parent.width + caption: qsTr("TextArea") + + SectionLayout { + Label { + text: qsTr("Placeholder") + tooltip: qsTr("Placeholder text displayed when the editor is empty.") + } + SecondColumnLayout { + LineEdit { + backendValue: backendValues.placeholderText + Layout.fillWidth: true + } + + } + } + } + StandardTextSection { width: parent.width showIsWrapping: true diff --git a/src/imports/controls/designer/TextFieldSpecifics.qml b/src/imports/controls/designer/TextFieldSpecifics.qml index 3d604e6d..5faeb914 100644 --- a/src/imports/controls/designer/TextFieldSpecifics.qml +++ b/src/imports/controls/designer/TextFieldSpecifics.qml @@ -41,6 +41,25 @@ import QtQuick.Layouts 1.0 Column { width: parent.width + Section { + width: parent.width + caption: qsTr("TextField") + + SectionLayout { + Label { + text: qsTr("Placeholder") + tooltip: qsTr("Placeholder text displayed when the editor is empty.") + } + SecondColumnLayout { + LineEdit { + backendValue: backendValues.placeholderText + Layout.fillWidth: true + } + + } + } + } + StandardTextSection { width: parent.width } diff --git a/src/imports/controls/designer/ToolBarSpecifics.qml b/src/imports/controls/designer/ToolBarSpecifics.qml index 1eef1c68..9c0a3da1 100644 --- a/src/imports/controls/designer/ToolBarSpecifics.qml +++ b/src/imports/controls/designer/ToolBarSpecifics.qml @@ -41,6 +41,30 @@ import QtQuick.Layouts 1.0 Column { width: parent.width + Section { + width: parent.width + caption: qsTr("ToolBar") + + SectionLayout { + Label { + text: qsTr("Position") + tooltip: qsTr("Position of the toolbar.") + } + SecondColumnLayout { + ComboBox { + backendValue: backendValues.position + model: [ "Header", "Footer" ] + scope: "ToolBar" + Layout.fillWidth: true + } + } + } + } + + PaneSection { + width: parent.width + } + ControlSection { width: parent.width } diff --git a/src/imports/controls/designer/ToolButtonSpecifics.qml b/src/imports/controls/designer/ToolButtonSpecifics.qml index 3dc80b2c..7b5d0a24 100644 --- a/src/imports/controls/designer/ToolButtonSpecifics.qml +++ b/src/imports/controls/designer/ToolButtonSpecifics.qml @@ -42,7 +42,10 @@ Column { width: parent.width ButtonSection { - caption: qsTr("Tool Button") + width: parent.width + } + + AbstractButtonSection { width: parent.width } diff --git a/src/imports/controls/designer/TumblerSpecifics.qml b/src/imports/controls/designer/TumblerSpecifics.qml index 2018f796..0f1b2a74 100644 --- a/src/imports/controls/designer/TumblerSpecifics.qml +++ b/src/imports/controls/designer/TumblerSpecifics.qml @@ -73,6 +73,18 @@ Column { Layout.fillWidth: true } } + + Label { + text: qsTr("Wrap") + tooltip: qsTr("Whether the tumbler wrap.") + } + SecondColumnLayout { + CheckBox { + text: backendValues.wrap.valueToString + backendValue: backendValues.wrap + Layout.fillWidth: true + } + } } } diff --git a/src/imports/controls/designer/designer.pri b/src/imports/controls/designer/designer.pri index d8ce8d8a..5be660c2 100644 --- a/src/imports/controls/designer/designer.pri +++ b/src/imports/controls/designer/designer.pri @@ -2,33 +2,49 @@ QML_FILES += \ $$PWD/qtquickcontrols2.metainfo QML_FILES += \ + $$PWD/AbstractButtonSection.qml \ $$PWD/BusyIndicatorSpecifics.qml \ $$PWD/ButtonSection.qml \ $$PWD/ButtonSpecifics.qml \ $$PWD/CheckBoxSpecifics.qml \ $$PWD/CheckDelegateSpecifics.qml \ + $$PWD/CheckSection.qml \ $$PWD/ComboBoxSpecifics.qml \ + $$PWD/ContainerSection.qml \ $$PWD/ControlSection.qml \ $$PWD/ControlSpecifics.qml \ + $$PWD/DelayButtonSpecifics.qml \ $$PWD/DialSpecifics.qml \ $$PWD/FrameSpecifics.qml \ $$PWD/GroupBoxSpecifics.qml \ + $$PWD/ItemDelegateSection.qml \ $$PWD/ItemDelegateSpecifics.qml \ $$PWD/LabelSpecifics.qml \ $$PWD/PaddingSection.qml \ + $$PWD/PageSpecifics.qml \ $$PWD/PageIndicatorSpecifics.qml \ + $$PWD/PaneSection.qml \ $$PWD/PaneSpecifics.qml \ $$PWD/ProgressBarSpecifics.qml \ $$PWD/RadioButtonSpecifics.qml \ $$PWD/RadioDelegateSpecifics.qml \ + $$PWD/RangeSliderSpecifics.qml \ + $$PWD/RoundButtonSpecifics.qml \ + $$PWD/ScrollViewSpecifics.qml \ $$PWD/SliderSpecifics.qml \ $$PWD/SpinBoxSpecifics.qml \ + $$PWD/StackViewSpecifics.qml \ $$PWD/SwipeDelegateSpecifics.qml \ + $$PWD/SwipeViewSpecifics.qml \ $$PWD/SwitchSpecifics.qml \ + $$PWD/SwitchDelegateSpecifics.qml \ + $$PWD/TabBarSpecifics.qml \ + $$PWD/TabButtonSpecifics.qml \ $$PWD/TextAreaSpecifics.qml \ $$PWD/TextFieldSpecifics.qml \ $$PWD/ToolBarSpecifics.qml \ $$PWD/ToolButtonSpecifics.qml \ + $$PWD/ToolSeparatorSpecifics.qml \ $$PWD/TumblerSpecifics.qml QML_FILES += \ diff --git a/src/imports/controls/designer/images/delaybutton-icon.png b/src/imports/controls/designer/images/delaybutton-icon.png Binary files differnew file mode 100644 index 00000000..38a8f7e0 --- /dev/null +++ b/src/imports/controls/designer/images/delaybutton-icon.png diff --git a/src/imports/controls/designer/images/delaybutton-icon16.png b/src/imports/controls/designer/images/delaybutton-icon16.png Binary files differnew file mode 100644 index 00000000..b92dad21 --- /dev/null +++ b/src/imports/controls/designer/images/delaybutton-icon16.png diff --git a/src/imports/controls/designer/images/delaybutton-icon16@2x.png b/src/imports/controls/designer/images/delaybutton-icon16@2x.png Binary files differnew file mode 100644 index 00000000..8df985bb --- /dev/null +++ b/src/imports/controls/designer/images/delaybutton-icon16@2x.png diff --git a/src/imports/controls/designer/images/delaybutton-icon@2x.png b/src/imports/controls/designer/images/delaybutton-icon@2x.png Binary files differnew file mode 100644 index 00000000..556ecf6f --- /dev/null +++ b/src/imports/controls/designer/images/delaybutton-icon@2x.png diff --git a/src/imports/controls/designer/qtquickcontrols2.metainfo b/src/imports/controls/designer/qtquickcontrols2.metainfo index 1f861d41..9e6030b1 100644 --- a/src/imports/controls/designer/qtquickcontrols2.metainfo +++ b/src/imports/controls/designer/qtquickcontrols2.metainfo @@ -71,6 +71,21 @@ MetaInfo { } Type { + name: "QtQuick.Controls.DelayButton" + icon: "images/button-icon16.png" + + ItemLibraryEntry { + name: "Delay Button" + category: "Qt Quick - Controls 2" + libraryIcon: "images/delaybutton-icon.png" + version: "2.2" + requiredImport: "QtQuick.Controls" + + Property { name: "text"; type: "binding"; value: "qsTr(\"Delay Button\")" } + } + } + + Type { name: "QtQuick.Controls.Dial" icon: "images/dial-icon16.png" @@ -255,6 +270,20 @@ MetaInfo { } Type { + name: "QtQuick.Controls.RoundButton" + icon: "images/roundbutton-icon16.png" + + ItemLibraryEntry { + name: "Round Button" + category: "Qt Quick - Controls 2" + libraryIcon: "images/roundbutton-icon.png" + version: "2.1" + requiredImport: "QtQuick.Controls" + Property { name: "text"; type: "string"; value: "+" } + } + } + + Type { name: "QtQuick.Controls.Slider" icon: "images/slider-icon16.png" @@ -283,225 +312,211 @@ MetaInfo { } Type { - name: "QtQuick.Controls.SwipeDelegate" - icon: "images/itemdelegate-icon16.png" + name: "QtQuick.Controls.ScrollView" + icon: "images/scrollview-icon16.png" ItemLibraryEntry { - name: "Swipe Delegate" + name: "Scroll View" category: "Qt Quick - Controls 2" - libraryIcon: "images/itemdelegate-icon.png" - version: "2.0" + libraryIcon: "images/scrollview-icon.png" + version: "2.2" requiredImport: "QtQuick.Controls" - Property { name: "text"; type: "binding"; value: "qsTr(\"Swipe Delegate\")" } + Property { name: "width"; type: "int"; value: 200 } + Property { name: "height"; type: "int"; value: 200 } } } Type { - name: "QtQuick.Controls.Switch" - icon: "images/switch-icon16.png" + name: "QtQuick.Controls.StackView" + icon: "images/stackview-icon16.png" ItemLibraryEntry { - name: "Switch" + name: "Stack View" category: "Qt Quick - Controls 2" - libraryIcon: "images/switch-icon.png" + libraryIcon: "images/stackview-icon.png" version: "2.0" requiredImport: "QtQuick.Controls" - Property { name: "text"; type: "binding"; value: "qsTr(\"Switch\")" } + Property { name: "width"; type: "int"; value: 200 } + Property { name: "height"; type: "int"; value: 200 } } } Type { - name: "QtQuick.Controls.SwitchDelegate" - icon: "images/switch-icon16.png" + name: "QtQuick.Controls.SwipeDelegate" + icon: "images/itemdelegate-icon16.png" ItemLibraryEntry { - name: "Switch Delegate" + name: "Swipe Delegate" category: "Qt Quick - Controls 2" - libraryIcon: "images/switch-icon.png" + libraryIcon: "images/itemdelegate-icon.png" version: "2.0" requiredImport: "QtQuick.Controls" - Property { name: "text"; type: "binding"; value: "qsTr(\"Switch Delegate\")" } + Property { name: "text"; type: "binding"; value: "qsTr(\"Swipe Delegate\")" } } } Type { - name: "QtQuick.Controls.TextArea" - icon: "images/textarea-icon16.png" + name: "QtQuick.Controls.SwipeView" + icon: "images/swipeview-icon16.png" ItemLibraryEntry { - name: "Text Area" + name: "Swipe View" category: "Qt Quick - Controls 2" - libraryIcon: "images/textarea-icon.png" + libraryIcon: "images/swipeview-icon.png" version: "2.0" requiredImport: "QtQuick.Controls" - Property { name: "text"; type: "binding"; value: "qsTr(\"Text Area\")" } + Property { name: "width"; type: "int"; value: 200 } + Property { name: "height"; type: "int"; value: 200 } } } Type { - name: "QtQuick.Controls.TextField" - icon: "images/textfield-icon16.png" + name: "QtQuick.Controls.Switch" + icon: "images/switch-icon16.png" ItemLibraryEntry { - name: "Text Field" + name: "Switch" category: "Qt Quick - Controls 2" - libraryIcon: "images/textfield-icon.png" + libraryIcon: "images/switch-icon.png" version: "2.0" requiredImport: "QtQuick.Controls" - Property { name: "text"; type: "binding"; value: "qsTr(\"Text Field\")" } + Property { name: "text"; type: "binding"; value: "qsTr(\"Switch\")" } } } Type { - name: "QtQuick.Controls.ToolButton" - icon: "images/toolbutton-icon16.png" + name: "QtQuick.Controls.SwitchDelegate" + icon: "images/switch-icon16.png" ItemLibraryEntry { - name: "Tool Button" + name: "Switch Delegate" category: "Qt Quick - Controls 2" - libraryIcon: "images/toolbutton-icon.png" + libraryIcon: "images/switch-icon.png" version: "2.0" requiredImport: "QtQuick.Controls" - Property { name: "text"; type: "binding"; value: "qsTr(\"Tool Button\")" } + Property { name: "text"; type: "binding"; value: "qsTr(\"Switch Delegate\")" } } } Type { - name: "QtQuick.Controls.ToolBar" + name: "QtQuick.Controls.TabBar" icon: "images/toolbar-icon16.png" ItemLibraryEntry { - name: "Tool Bar" + name: "Tab Bar" category: "Qt Quick - Controls 2" libraryIcon: "images/toolbar-icon.png" version: "2.0" requiredImport: "QtQuick.Controls" - - Property { name: "width"; type: "int"; value: 360 } + Property { name: "width"; type: "int"; value: 240 } } } Type { - name: "QtQuick.Controls.ToolSeparator" - icon: "images/toolseparator-icon16.png" + name: "QtQuick.Controls.TabButton" + icon: "images/toolbutton-icon16.png" ItemLibraryEntry { - name: "ToolSeparator" + name: "Tab Button" category: "Qt Quick - Controls 2" - libraryIcon: "images/toolseparator-icon.png" - version: "2.1" + libraryIcon: "images/toolbutton-icon.png" + version: "2.0" requiredImport: "QtQuick.Controls" + Property { name: "text"; type: "binding"; value: "qsTr(\"Tab Button\")" } } } Type { - name: "QtQuick.Controls.Tumbler" - icon: "images/tumbler-icon16.png" + name: "QtQuick.Controls.TextArea" + icon: "images/textarea-icon16.png" ItemLibraryEntry { - name: "Tumbler" + name: "Text Area" category: "Qt Quick - Controls 2" - libraryIcon: "images/tumbler-icon.png" + libraryIcon: "images/textarea-icon.png" version: "2.0" requiredImport: "QtQuick.Controls" - Property { name: "model"; type: "int"; value: "10" } + Property { name: "text"; type: "binding"; value: "qsTr(\"Text Area\")" } } } Type { - name: "QtQuick.Controls.TabBar" - icon: "images/toolbar-icon16.png" + name: "QtQuick.Controls.TextField" + icon: "images/textfield-icon16.png" ItemLibraryEntry { - name: "Tab Bar" + name: "Text Field" category: "Qt Quick - Controls 2" - libraryIcon: "images/toolbar-icon.png" + libraryIcon: "images/textfield-icon.png" version: "2.0" requiredImport: "QtQuick.Controls" - Property { name: "width"; type: "int"; value: 240 } + + Property { name: "text"; type: "binding"; value: "qsTr(\"Text Field\")" } } } Type { - name: "QtQuick.Controls.TabButton" - icon: "images/toolbutton-icon16.png" + name: "QtQuick.Controls.ToolBar" + icon: "images/toolbar-icon16.png" ItemLibraryEntry { - name: "Tab Button" + name: "Tool Bar" category: "Qt Quick - Controls 2" - libraryIcon: "images/toolbutton-icon.png" + libraryIcon: "images/toolbar-icon.png" version: "2.0" requiredImport: "QtQuick.Controls" - Property { name: "text"; type: "binding"; value: "qsTr(\"Tab Button\")" } + + Property { name: "width"; type: "int"; value: 360 } } } Type { - name: "QtQuick.Controls.RoundButton" - icon: "images/roundbutton-icon16.png" + name: "QtQuick.Controls.ToolButton" + icon: "images/toolbutton-icon16.png" ItemLibraryEntry { - name: "Round Button" + name: "Tool Button" category: "Qt Quick - Controls 2" - libraryIcon: "images/roundbutton-icon.png" - version: "2.1" + libraryIcon: "images/toolbutton-icon.png" + version: "2.0" requiredImport: "QtQuick.Controls" - Property { name: "text"; type: "string"; value: "+" } + + Property { name: "text"; type: "binding"; value: "qsTr(\"Tool Button\")" } } } Type { - name: "QtQuick.Controls.StackView" - icon: "images/stackview-icon16.png" + name: "QtQuick.Controls.ToolSeparator" + icon: "images/toolseparator-icon16.png" ItemLibraryEntry { - name: "Stack View" - category: "Qt Quick - Views" - libraryIcon: "images/stackview-icon.png" + name: "Tool Separator" + category: "Qt Quick - Controls 2" + libraryIcon: "images/toolseparator-icon.png" version: "2.1" requiredImport: "QtQuick.Controls" - - Property { name: "width"; type: "int"; value: 200 } - Property { name: "height"; type: "int"; value: 200 } } } Type { - name: "QtQuick.Controls.SwipeView" - icon: "images/swipeview-icon16.png" + name: "QtQuick.Controls.Tumbler" + icon: "images/tumbler-icon16.png" ItemLibraryEntry { - name: "Swipe View" - category: "Qt Quick - Views" - libraryIcon: "images/swipeview-icon.png" + name: "Tumbler" + category: "Qt Quick - Controls 2" + libraryIcon: "images/tumbler-icon.png" version: "2.0" requiredImport: "QtQuick.Controls" - Property { name: "width"; type: "int"; value: 200 } - Property { name: "height"; type: "int"; value: 200 } - } - } - - Type { - name: "QtQuick.Controls.ScrollView" - icon: "images/scrollview-icon16.png" - - ItemLibraryEntry { - name: "Scroll View" - category: "Qt Quick - Views" - libraryIcon: "images/scrollview-icon.png" - version: "2.2" - requiredImport: "QtQuick.Controls" - - Property { name: "width"; type: "int"; value: 200 } - Property { name: "height"; type: "int"; value: 200 } + Property { name: "model"; type: "int"; value: "10" } } } } diff --git a/src/imports/controls/doc/src/qtquickcontrols2-customize.qdoc b/src/imports/controls/doc/src/qtquickcontrols2-customize.qdoc index 69e8bc59..eed9ff94 100644 --- a/src/imports/controls/doc/src/qtquickcontrols2-customize.qdoc +++ b/src/imports/controls/doc/src/qtquickcontrols2-customize.qdoc @@ -458,7 +458,7 @@ ComboBox consists of \l {Control::background}{background}, \l {Control::contentItem}{content item}, \l {ComboBox::popup}{popup}, - and \l {ComboBox::delegate}{delegate}. + \l {ComboBox::indicator}{indicator}, and \l {ComboBox::delegate}{delegate}. \image qtquickcontrols2-combobox-custom.png diff --git a/src/imports/controls/doc/src/qtquickcontrols2-imagine.qdoc b/src/imports/controls/doc/src/qtquickcontrols2-imagine.qdoc index 9f736e36..cabd66da 100644 --- a/src/imports/controls/doc/src/qtquickcontrols2-imagine.qdoc +++ b/src/imports/controls/doc/src/qtquickcontrols2-imagine.qdoc @@ -2446,5 +2446,7 @@ \list \li \l{Styling Qt Quick Controls 2} + \li \l{Qt Quick Controls 2 - Imagine Style Example: Automotive}{Automotive Example} + \li \l{Qt Quick Controls 2 - Imagine Style Example: Music Player}{Music Player Example} \endlist */ diff --git a/src/imports/controls/doc/src/qtquickcontrols2-index.qdoc b/src/imports/controls/doc/src/qtquickcontrols2-index.qdoc index 661266aa..43c38745 100644 --- a/src/imports/controls/doc/src/qtquickcontrols2-index.qdoc +++ b/src/imports/controls/doc/src/qtquickcontrols2-index.qdoc @@ -137,6 +137,8 @@ \li \l{Qt Quick Controls 2 - Chat Tutorial}{Chat Tutorial} \li \l{Qt Quick Controls 2 - Text Editor}{Text Editor} \li \l{Qt Quick Controls 2 - Wearable Demo}{Wearable Demo} + \li \l{Qt Quick Controls 2 - Imagine Style Example: Automotive}{Automotive Example} + \li \l{Qt Quick Controls 2 - Imagine Style Example: Music Player}{Music Player Example} \li \l{Qt Quick Controls 2 Examples}{All Examples} \endlist diff --git a/src/imports/controls/fusion/CheckBox.qml b/src/imports/controls/fusion/CheckBox.qml index e2774b7c..4a10238d 100644 --- a/src/imports/controls/fusion/CheckBox.qml +++ b/src/imports/controls/fusion/CheckBox.qml @@ -68,8 +68,6 @@ T.CheckBox { font: control.font color: control.palette.windowText elide: Text.ElideRight - visible: control.text - horizontalAlignment: Text.AlignLeft verticalAlignment: Text.AlignVCenter } } diff --git a/src/imports/controls/fusion/ComboBox.qml b/src/imports/controls/fusion/ComboBox.qml index 80128f1e..c4d49e0f 100644 --- a/src/imports/controls/fusion/ComboBox.qml +++ b/src/imports/controls/fusion/ComboBox.qml @@ -89,7 +89,6 @@ T.ComboBox { color: control.editable ? control.palette.text : control.palette.buttonText selectionColor: control.palette.highlight selectedTextColor: control.palette.highlightedText - horizontalAlignment: Text.AlignLeft verticalAlignment: Text.AlignVCenter background: PaddedRectangle { diff --git a/src/imports/controls/fusion/GroupBox.qml b/src/imports/controls/fusion/GroupBox.qml index a43686c7..a98cc9a8 100644 --- a/src/imports/controls/fusion/GroupBox.qml +++ b/src/imports/controls/fusion/GroupBox.qml @@ -64,7 +64,6 @@ T.GroupBox { font: control.font color: control.palette.windowText elide: Text.ElideRight - horizontalAlignment: Text.AlignLeft verticalAlignment: Text.AlignVCenter } diff --git a/src/imports/controls/fusion/RadioButton.qml b/src/imports/controls/fusion/RadioButton.qml index d6f5ddc4..612319b4 100644 --- a/src/imports/controls/fusion/RadioButton.qml +++ b/src/imports/controls/fusion/RadioButton.qml @@ -68,8 +68,6 @@ T.RadioButton { font: control.font color: control.palette.windowText elide: Text.ElideRight - visible: control.text - horizontalAlignment: Text.AlignLeft verticalAlignment: Text.AlignVCenter } } diff --git a/src/imports/controls/fusion/Switch.qml b/src/imports/controls/fusion/Switch.qml index 6cd0140b..0f5d484b 100644 --- a/src/imports/controls/fusion/Switch.qml +++ b/src/imports/controls/fusion/Switch.qml @@ -68,8 +68,6 @@ T.Switch { font: control.font color: control.palette.text elide: Text.ElideRight - visible: control.text - horizontalAlignment: Text.AlignLeft verticalAlignment: Text.AlignVCenter } } diff --git a/src/imports/controls/imagine/CheckBox.qml b/src/imports/controls/imagine/CheckBox.qml index db0a6680..8c5cd918 100644 --- a/src/imports/controls/imagine/CheckBox.qml +++ b/src/imports/controls/imagine/CheckBox.qml @@ -82,8 +82,6 @@ T.CheckBox { font: control.font color: control.palette.windowText elide: Text.ElideRight - visible: control.text - horizontalAlignment: Text.AlignLeft verticalAlignment: Text.AlignVCenter } diff --git a/src/imports/controls/imagine/ComboBox.qml b/src/imports/controls/imagine/ComboBox.qml index fc9fce61..eae8569e 100644 --- a/src/imports/controls/imagine/ComboBox.qml +++ b/src/imports/controls/imagine/ComboBox.qml @@ -98,7 +98,6 @@ T.ComboBox { color: control.flat ? control.palette.windowText : control.editable ? control.palette.text : control.palette.buttonText selectionColor: control.palette.highlight selectedTextColor: control.palette.highlightedText - horizontalAlignment: Text.AlignLeft verticalAlignment: Text.AlignVCenter } diff --git a/src/imports/controls/imagine/GroupBox.qml b/src/imports/controls/imagine/GroupBox.qml index 88e8d21c..b2b199a3 100644 --- a/src/imports/controls/imagine/GroupBox.qml +++ b/src/imports/controls/imagine/GroupBox.qml @@ -68,7 +68,6 @@ T.GroupBox { text: control.title font: control.font elide: Text.ElideRight - horizontalAlignment: Text.AlignLeft verticalAlignment: Text.AlignVCenter color: control.palette.windowText diff --git a/src/imports/controls/imagine/RadioButton.qml b/src/imports/controls/imagine/RadioButton.qml index 4a111bc3..57bdedaa 100644 --- a/src/imports/controls/imagine/RadioButton.qml +++ b/src/imports/controls/imagine/RadioButton.qml @@ -81,8 +81,6 @@ T.RadioButton { font: control.font color: control.palette.windowText elide: Text.ElideRight - visible: control.text - horizontalAlignment: Text.AlignLeft verticalAlignment: Text.AlignVCenter } diff --git a/src/imports/controls/imagine/Switch.qml b/src/imports/controls/imagine/Switch.qml index f9878851..44e5d68e 100644 --- a/src/imports/controls/imagine/Switch.qml +++ b/src/imports/controls/imagine/Switch.qml @@ -110,8 +110,6 @@ T.Switch { font: control.font color: control.palette.windowText elide: Text.ElideRight - visible: control.text - horizontalAlignment: Text.AlignLeft verticalAlignment: Text.AlignVCenter } diff --git a/src/imports/controls/imagine/plugins.qmltypes b/src/imports/controls/imagine/plugins.qmltypes new file mode 100644 index 00000000..b09ae141 --- /dev/null +++ b/src/imports/controls/imagine/plugins.qmltypes @@ -0,0 +1,21 @@ +import QtQuick.tooling 1.2 + +// This file describes the plugin-supplied types contained in the library. +// It is used for QML tooling purposes only. +// +// This file was auto-generated by: +// 'qmlplugindump -nonrelocatable QtQuick.Controls.Imagine 2.3' + +Module { + dependencies: [] + Component { name: "QQuickAttachedObject"; prototype: "QObject" } + Component { + name: "QQuickImagineStyle" + prototype: "QQuickAttachedObject" + exports: ["QtQuick.Controls.Imagine/Imagine 2.3"] + isCreatable: false + exportMetaObjectRevisions: [0] + Property { name: "path"; type: "string" } + Property { name: "url"; type: "QUrl"; isReadonly: true } + } +} diff --git a/src/imports/controls/imagine/qquickimaginetheme.cpp b/src/imports/controls/imagine/qquickimaginetheme.cpp index 17fb920f..5505e7ce 100644 --- a/src/imports/controls/imagine/qquickimaginetheme.cpp +++ b/src/imports/controls/imagine/qquickimaginetheme.cpp @@ -43,20 +43,8 @@ QT_BEGIN_NAMESPACE QQuickImagineTheme::QQuickImagineTheme() : QQuickTheme(QStringLiteral("Imagine")) { - QFont font; - font.setFamily(QLatin1String("Open Sans")); - const QString family = QFontInfo(font).family(); - if (family == QLatin1String("Open Sans")) { - buttonFont.setFamily(family); - checkBoxFont.setFamily(family); - editorFont.setFamily(family); - groupBoxFont.setFamily(family); - labelFont.setFamily(family); - itemViewFont.setFamily(family); - menuItemFont.setFamily(family); - systemFont.setFamily(family); - toolTipFont.setFamily(family); - } + systemFont.setFamily(QLatin1String("Open Sans")); + systemFont = resolveFont(systemFont); const QColor accentColor = QColor::fromRgb(0x4fc1e9); const QColor windowTextColor = QColor::fromRgb(0x434a54); @@ -76,29 +64,8 @@ QQuickImagineTheme::QQuickImagineTheme() const QFont *QQuickImagineTheme::font(QPlatformTheme::Font type) const { - switch (type) { - case QPlatformTheme::TabButtonFont: - case QPlatformTheme::PushButtonFont: - case QPlatformTheme::ToolButtonFont: - return &buttonFont; - case QPlatformTheme::CheckBoxFont: - return &checkBoxFont; - case QPlatformTheme::GroupBoxTitleFont: - return &groupBoxFont; - case QPlatformTheme::LabelFont: - return &labelFont; - case QPlatformTheme::TipLabelFont: - return &toolTipFont; - case QPlatformTheme::ItemViewFont: - return &itemViewFont; - case QPlatformTheme::MenuItemFont: - case QPlatformTheme::ComboMenuItemFont: - return &menuItemFont; - case QPlatformTheme::EditorFont: - return &editorFont; - default: - return &systemFont; - } + Q_UNUSED(type); + return &systemFont; } const QPalette *QQuickImagineTheme::palette(QPlatformTheme::Palette type) const diff --git a/src/imports/controls/imagine/qquickimaginetheme_p.h b/src/imports/controls/imagine/qquickimaginetheme_p.h index 9006e6ef..ea3a1cbd 100644 --- a/src/imports/controls/imagine/qquickimaginetheme_p.h +++ b/src/imports/controls/imagine/qquickimaginetheme_p.h @@ -61,16 +61,7 @@ public: const QPalette *palette(Palette type = SystemPalette) const override; private: - QFont buttonFont; - QFont checkBoxFont; - QFont editorFont; - QFont groupBoxFont; - QFont labelFont; - QFont itemViewFont; - QFont menuItemFont; QFont systemFont; - QFont toolTipFont; - QPalette systemPalette; }; diff --git a/src/imports/controls/material/ComboBox.qml b/src/imports/controls/material/ComboBox.qml index 0c7c7e74..a58f1a37 100644 --- a/src/imports/controls/material/ComboBox.qml +++ b/src/imports/controls/material/ComboBox.qml @@ -84,7 +84,7 @@ T.ComboBox { enabled: control.editable autoScroll: control.editable - readOnly: control.popup.visible + readOnly: control.down inputMethodHints: control.inputMethodHints validator: control.validator @@ -161,7 +161,7 @@ T.ComboBox { contentItem: ListView { clip: true implicitHeight: contentHeight - model: control.popup.visible ? control.delegateModel : null + model: control.delegateModel currentIndex: control.highlightedIndex highlightMoveDuration: 0 @@ -170,7 +170,7 @@ T.ComboBox { background: Rectangle { radius: 2 - color: control.popup.Material.dialogColor + color: parent.Material.dialogColor layer.enabled: control.enabled layer.effect: ElevationEffect { diff --git a/src/imports/controls/material/plugins.qmltypes b/src/imports/controls/material/plugins.qmltypes index 0ff64084..2ddf99a7 100644 --- a/src/imports/controls/material/plugins.qmltypes +++ b/src/imports/controls/material/plugins.qmltypes @@ -4,13 +4,14 @@ import QtQuick.tooling 1.2 // It is used for QML tooling purposes only. // // This file was auto-generated by: -// 'qmlplugindump -nonrelocatable QtQuick.Controls.Material 2.0' +// 'qmlplugindump -nonrelocatable QtQuick.Controls.Material 2.3' Module { dependencies: [] + Component { name: "QQuickAttachedObject"; prototype: "QObject" } Component { name: "QQuickMaterialStyle" - prototype: "QQuickStyle" + prototype: "QQuickAttachedObject" exports: ["QtQuick.Controls.Material/Material 2.0"] isCreatable: false exportMetaObjectRevisions: [0] @@ -18,7 +19,8 @@ Module { name: "Theme" values: { "Light": 0, - "Dark": 1 + "Dark": 1, + "System": 2 } } Enum { @@ -69,6 +71,7 @@ Module { Property { name: "accent"; type: "QVariant" } Property { name: "foreground"; type: "QVariant" } Property { name: "background"; type: "QVariant" } + Property { name: "elevation"; type: "int" } Signal { name: "paletteChanged" } Method { name: "color" @@ -88,5 +91,4 @@ Module { Parameter { name: "shade"; type: "Shade" } } } - Component { name: "QQuickStyle"; prototype: "QObject" } } diff --git a/src/imports/controls/universal/ComboBox.qml b/src/imports/controls/universal/ComboBox.qml index 2bb605c9..2a5a4f3f 100644 --- a/src/imports/controls/universal/ComboBox.qml +++ b/src/imports/controls/universal/ComboBox.qml @@ -91,7 +91,7 @@ T.ComboBox { enabled: control.editable autoScroll: control.editable - readOnly: control.popup.visible + readOnly: control.down inputMethodHints: control.inputMethodHints validator: control.validator @@ -111,7 +111,7 @@ T.ComboBox { border.width: control.flat ? 0 : 2 // ComboBoxBorderThemeThickness border.color: !control.enabled ? control.Universal.baseLowColor : control.editable && control.activeFocus ? control.Universal.accent : - control.down || popup.visible ? control.Universal.baseMediumLowColor : + control.down ? control.Universal.baseMediumLowColor : control.hovered ? control.Universal.baseMediumColor : control.Universal.baseMediumLowColor color: !control.enabled ? control.Universal.baseLowColor : control.down ? control.Universal.listMediumColor : @@ -143,7 +143,7 @@ T.ComboBox { contentItem: ListView { clip: true implicitHeight: contentHeight - model: control.popup.visible ? control.delegateModel : null + model: control.delegateModel currentIndex: control.highlightedIndex highlightMoveDuration: 0 diff --git a/src/imports/controls/universal/plugins.qmltypes b/src/imports/controls/universal/plugins.qmltypes index 165e658e..979e8437 100644 --- a/src/imports/controls/universal/plugins.qmltypes +++ b/src/imports/controls/universal/plugins.qmltypes @@ -4,14 +4,14 @@ import QtQuick.tooling 1.2 // It is used for QML tooling purposes only. // // This file was auto-generated by: -// 'qmlplugindump -nonrelocatable QtQuick.Controls.Universal 2.0' +// 'qmlplugindump -nonrelocatable QtQuick.Controls.Universal 2.3' Module { dependencies: [] - Component { name: "QQuickStyle"; prototype: "QObject" } + Component { name: "QQuickAttachedObject"; prototype: "QObject" } Component { name: "QQuickUniversalStyle" - prototype: "QQuickStyle" + prototype: "QQuickAttachedObject" exports: ["QtQuick.Controls.Universal/Universal 2.0"] isCreatable: false exportMetaObjectRevisions: [0] @@ -19,7 +19,8 @@ Module { name: "Theme" values: { "Light": 0, - "Dark": 1 + "Dark": 1, + "System": 2 } } Enum { diff --git a/src/quickcontrols2/qquickanimatednode.cpp b/src/quickcontrols2/qquickanimatednode.cpp index 83539fc6..3a18c757 100644 --- a/src/quickcontrols2/qquickanimatednode.cpp +++ b/src/quickcontrols2/qquickanimatednode.cpp @@ -112,8 +112,14 @@ void QQuickAnimatedNode::start(int duration) m_timer.restart(); if (duration > 0) m_duration = duration; - connect(m_window, &QQuickWindow::beforeRendering, this, &QQuickAnimatedNode::advance); - connect(m_window, &QQuickWindow::frameSwapped, this, &QQuickAnimatedNode::update); + + connect(m_window, &QQuickWindow::beforeRendering, this, &QQuickAnimatedNode::advance, Qt::DirectConnection); + connect(m_window, &QQuickWindow::frameSwapped, this, &QQuickAnimatedNode::update, Qt::DirectConnection); + + // If we're inside a QQuickWidget, this call is necessary to ensure the widget + // gets updated for the first time. + m_window->update(); + emit started(); } @@ -152,6 +158,9 @@ void QQuickAnimatedNode::advance() } } updateCurrentTime(time); + + // If we're inside a QQuickWidget, this call is necessary to ensure the widget gets updated. + m_window->update(); } void QQuickAnimatedNode::update() diff --git a/src/quickcontrols2/qquickiconlabel.cpp b/src/quickcontrols2/qquickiconlabel.cpp index 266d30d7..960d9905 100644 --- a/src/quickcontrols2/qquickiconlabel.cpp +++ b/src/quickcontrols2/qquickiconlabel.cpp @@ -128,6 +128,10 @@ void QQuickIconLabelPrivate::syncImage() image->setSource(icon.source()); image->setSourceSize(QSize(icon.width(), icon.height())); image->setColor(icon.color()); + const int valign = alignment & Qt::AlignVertical_Mask; + image->setVerticalAlignment(static_cast<QQuickImage::VAlignment>(valign)); + const int halign = alignment & Qt::AlignHorizontal_Mask; + image->setHorizontalAlignment(static_cast<QQuickImage::HAlignment>(halign)); } void QQuickIconLabelPrivate::updateOrSyncImage() @@ -155,6 +159,10 @@ bool QQuickIconLabelPrivate::createLabel() label->setFont(font); label->setColor(color); label->setElideMode(QQuickText::ElideRight); + const int valign = alignment & Qt::AlignVertical_Mask; + label->setVAlign(static_cast<QQuickText::VAlignment>(valign)); + const int halign = alignment & Qt::AlignHorizontal_Mask; + label->setHAlign(static_cast<QQuickText::HAlignment>(halign)); label->setText(text); if (componentComplete) completeComponent(label); @@ -523,6 +531,14 @@ void QQuickIconLabel::setAlignment(Qt::Alignment alignment) return; d->alignment = static_cast<Qt::Alignment>(align); + if (d->label) { + d->label->setVAlign(static_cast<QQuickText::VAlignment>(valign)); + d->label->setHAlign(static_cast<QQuickText::HAlignment>(halign)); + } + if (d->image) { + d->image->setVerticalAlignment(static_cast<QQuickImage::VAlignment>(valign)); + d->image->setHorizontalAlignment(static_cast<QQuickImage::HAlignment>(halign)); + } d->layout(); } diff --git a/src/quickcontrols2/qquickstyle.cpp b/src/quickcontrols2/qquickstyle.cpp index c4555ee7..c9c5ba54 100644 --- a/src/quickcontrols2/qquickstyle.cpp +++ b/src/quickcontrols2/qquickstyle.cpp @@ -215,7 +215,7 @@ struct QQuickStyleSpec for (const QString &path : stylePaths) { QString stylePath = findStyle(path, style); if (!stylePath.isEmpty()) { - custom = !stylePath.startsWith(baseUrl.toLocalFile()); + custom = !stylePath.startsWith(QQmlFile::urlToLocalFileOrQrc(baseUrl)); style = stylePath; resolved = true; break; @@ -296,7 +296,7 @@ void QQuickStylePrivate::init(const QUrl &baseUrl) spec->resolve(baseUrl); if (!spec->fallbackStyle.isEmpty()) { - QString fallbackStyle = spec->findStyle(baseUrl.toLocalFile(), spec->fallbackStyle); + QString fallbackStyle = spec->findStyle(QQmlFile::urlToLocalFileOrQrc(baseUrl), spec->fallbackStyle); if (fallbackStyle.isEmpty()) { if (spec->fallbackStyle.compare(QStringLiteral("Default")) != 0) { qWarning() << "ERROR: unable to locate fallback style" << spec->fallbackStyle; diff --git a/src/quickcontrols2/qquicktumblerview.cpp b/src/quickcontrols2/qquicktumblerview.cpp index 5e6d9f5a..e8f0c364 100644 --- a/src/quickcontrols2/qquicktumblerview.cpp +++ b/src/quickcontrols2/qquicktumblerview.cpp @@ -148,6 +148,7 @@ void QQuickTumblerView::createView() m_pathView->setDelegate(m_delegate); m_pathView->setPreferredHighlightBegin(0.5); m_pathView->setPreferredHighlightEnd(0.5); + m_pathView->setHighlightMoveDuration(1000); m_pathView->setClip(true); // Give the view a size. @@ -172,6 +173,7 @@ void QQuickTumblerView::createView() m_listView->setParentItem(this); m_listView->setSnapMode(QQuickListView::SnapToItem); m_listView->setHighlightRangeMode(QQuickListView::StrictlyEnforceRange); + m_listView->setHighlightMoveDuration(1000); m_listView->setClip(true); m_listView->setDelegate(m_delegate); diff --git a/src/quicktemplates2/qquickabstractbutton.cpp b/src/quicktemplates2/qquickabstractbutton.cpp index 9e1a2502..b8c6eb84 100644 --- a/src/quicktemplates2/qquickabstractbutton.cpp +++ b/src/quicktemplates2/qquickabstractbutton.cpp @@ -40,6 +40,7 @@ #include "qquickaction_p.h" #include "qquickaction_p_p.h" #include "qquickshortcutcontext_p_p.h" +#include "qquickdeferredexecute_p_p.h" #include <QtGui/qstylehints.h> #include <QtGui/qguiapplication.h> @@ -117,7 +118,8 @@ static const int AUTO_REPEAT_INTERVAL = 100; */ QQuickAbstractButtonPrivate::QQuickAbstractButtonPrivate() - : down(false), + : explicitText(false), + down(false), explicitDown(false), pressed(false), keepPressed(false), @@ -305,6 +307,27 @@ void QQuickAbstractButtonPrivate::ungrabShortcut() } #endif +void QQuickAbstractButtonPrivate::actionTextChange() +{ + Q_Q(QQuickAbstractButton); + if (explicitText) + return; + + q->buttonChange(QQuickAbstractButton::ButtonTextChange); +} + +void QQuickAbstractButtonPrivate::setText(const QString &newText, bool isExplicit) +{ + Q_Q(QQuickAbstractButton); + const QString oldText = q->text(); + explicitText = isExplicit; + text = newText; + if (oldText == q->text()) + return; + + q->buttonChange(QQuickAbstractButton::ButtonTextChange); +} + void QQuickAbstractButtonPrivate::click() { Q_Q(QQuickAbstractButton); @@ -316,7 +339,7 @@ void QQuickAbstractButtonPrivate::trigger() { Q_Q(QQuickAbstractButton); if (action && action->isEnabled()) - action->trigger(q); // -> click() + QQuickActionPrivate::get(action)->trigger(q, false); else if (effectiveEnable) emit q->clicked(); } @@ -330,6 +353,20 @@ void QQuickAbstractButtonPrivate::toggle(bool value) emit q->toggled(); } +static inline QString indicatorName() { return QStringLiteral("indicator"); } + +void QQuickAbstractButtonPrivate::executeIndicator(bool complete) +{ + Q_Q(QQuickControl); + if (indicator.wasExecuted()) + return; + + if (!indicator) + quickBeginDeferred(q, indicatorName(), indicator); + if (complete) + quickCompleteDeferred(q, indicatorName(), indicator); +} + QQuickAbstractButton *QQuickAbstractButtonPrivate::findCheckedButton() const { Q_Q(const QQuickAbstractButton); @@ -418,23 +455,19 @@ QQuickAbstractButton::~QQuickAbstractButton() QString QQuickAbstractButton::text() const { Q_D(const QQuickAbstractButton); - return d->text; + return d->explicitText || !d->action ? d->text : d->action->text(); } void QQuickAbstractButton::setText(const QString &text) { Q_D(QQuickAbstractButton); - if (d->text == text) - return; - -#if QT_CONFIG(shortcut) - setShortcut(QKeySequence::mnemonic(text)); -#endif + d->setText(text, true); +} - d->text = text; - setAccessibleName(d->text); - buttonChange(ButtonTextChange); - emit textChanged(); +void QQuickAbstractButton::resetText() +{ + Q_D(QQuickAbstractButton); + d->setText(QString(), false); } /*! @@ -637,7 +670,9 @@ void QQuickAbstractButton::setAutoRepeat(bool repeat) */ QQuickItem *QQuickAbstractButton::indicator() const { - Q_D(const QQuickAbstractButton); + QQuickAbstractButtonPrivate *d = const_cast<QQuickAbstractButtonPrivate *>(d_func()); + if (!d->indicator) + d->executeIndicator(); return d->indicator; } @@ -647,14 +682,15 @@ void QQuickAbstractButton::setIndicator(QQuickItem *indicator) if (d->indicator == indicator) return; - QQuickControlPrivate::destroyDelegate(d->indicator, this); + delete d->indicator; d->indicator = indicator; if (indicator) { if (!indicator->parentItem()) indicator->setParentItem(this); indicator->setAcceptedMouseButtons(Qt::LeftButton); } - emit indicatorChanged(); + if (!d->indicator.isExecuting()) + emit indicatorChanged(); } /*! @@ -740,11 +776,13 @@ void QQuickAbstractButton::setAction(QQuickAction *action) if (d->action == action) return; + const QString oldText = text(); + if (QQuickAction *oldAction = d->action.data()) { QQuickActionPrivate::get(oldAction)->unregisterItem(this); QObjectPrivate::disconnect(oldAction, &QQuickAction::triggered, d, &QQuickAbstractButtonPrivate::click); + QObjectPrivate::disconnect(oldAction, &QQuickAction::textChanged, d, &QQuickAbstractButtonPrivate::actionTextChange); - disconnect(oldAction, &QQuickAction::textChanged, this, &QQuickAbstractButton::setText); disconnect(oldAction, &QQuickAction::iconChanged, this, &QQuickAbstractButton::setIcon); disconnect(oldAction, &QQuickAction::checkedChanged, this, &QQuickAbstractButton::setChecked); disconnect(oldAction, &QQuickAction::checkableChanged, this, &QQuickAbstractButton::setCheckable); @@ -754,8 +792,8 @@ void QQuickAbstractButton::setAction(QQuickAction *action) if (action) { QQuickActionPrivate::get(action)->registerItem(this); QObjectPrivate::connect(action, &QQuickAction::triggered, d, &QQuickAbstractButtonPrivate::click); + QObjectPrivate::connect(action, &QQuickAction::textChanged, d, &QQuickAbstractButtonPrivate::actionTextChange); - connect(action, &QQuickAction::textChanged, this, &QQuickAbstractButton::setText); connect(action, &QQuickAction::iconChanged, this, &QQuickAbstractButton::setIcon); connect(action, &QQuickAction::checkedChanged, this, &QQuickAbstractButton::setChecked); connect(action, &QQuickAction::checkableChanged, this, &QQuickAbstractButton::setCheckable); @@ -783,13 +821,16 @@ void QQuickAbstractButton::setAction(QQuickAction *action) if (color != Qt::transparent) d->icon.setColor(color); - setText(action->text()); setChecked(action->isChecked()); setCheckable(action->isCheckable()); setEnabled(action->isEnabled()); } d->action = action; + + if (oldText != text()) + buttonChange(ButtonTextChange); + emit actionChanged(); } @@ -908,6 +949,13 @@ void QQuickAbstractButton::toggle() setChecked(!d->checked); } +void QQuickAbstractButton::componentComplete() +{ + Q_D(QQuickAbstractButton); + d->executeIndicator(true); + QQuickControl::componentComplete(); +} + bool QQuickAbstractButton::event(QEvent *event) { Q_D(QQuickAbstractButton); @@ -1019,6 +1067,15 @@ void QQuickAbstractButton::buttonChange(ButtonChange change) button->setChecked(false); } break; + case ButtonTextChange: { + const QString txt = text(); + setAccessibleName(txt); +#if QT_CONFIG(shortcut) + setShortcut(QKeySequence::mnemonic(txt)); +#endif + emit textChanged(); + break; + } default: break; } @@ -1038,7 +1095,7 @@ void QQuickAbstractButton::accessibilityActiveChanged(bool active) Q_D(QQuickAbstractButton); if (active) { - setAccessibleName(d->text); + setAccessibleName(text()); setAccessibleProperty("pressed", d->pressed); setAccessibleProperty("checked", d->checked); setAccessibleProperty("checkable", d->checkable); diff --git a/src/quicktemplates2/qquickabstractbutton_p.h b/src/quicktemplates2/qquickabstractbutton_p.h index 78401d49..de0c26ab 100644 --- a/src/quicktemplates2/qquickabstractbutton_p.h +++ b/src/quicktemplates2/qquickabstractbutton_p.h @@ -59,7 +59,7 @@ class QQuickAbstractButtonPrivate; class Q_QUICKTEMPLATES2_PRIVATE_EXPORT QQuickAbstractButton : public QQuickControl { Q_OBJECT - Q_PROPERTY(QString text READ text WRITE setText NOTIFY textChanged FINAL) + Q_PROPERTY(QString text READ text WRITE setText RESET resetText NOTIFY textChanged FINAL) Q_PROPERTY(bool down READ isDown WRITE setDown NOTIFY downChanged RESET resetDown FINAL) Q_PROPERTY(bool pressed READ isPressed NOTIFY pressedChanged FINAL) Q_PROPERTY(bool checked READ isChecked WRITE setChecked NOTIFY checkedChanged FINAL) @@ -76,6 +76,7 @@ class Q_QUICKTEMPLATES2_PRIVATE_EXPORT QQuickAbstractButton : public QQuickContr Q_PROPERTY(int autoRepeatInterval READ autoRepeatInterval WRITE setAutoRepeatInterval NOTIFY autoRepeatIntervalChanged FINAL REVISION 4) Q_PROPERTY(qreal pressX READ pressX NOTIFY pressXChanged FINAL REVISION 4) Q_PROPERTY(qreal pressY READ pressY NOTIFY pressYChanged FINAL REVISION 4) + Q_CLASSINFO("DeferredPropertyNames", "background,contentItem,indicator") public: explicit QQuickAbstractButton(QQuickItem *parent = nullptr); @@ -83,6 +84,7 @@ public: QString text() const; void setText(const QString &text); + void resetText(); bool isDown() const; void setDown(bool down); @@ -172,6 +174,8 @@ Q_SIGNALS: protected: QQuickAbstractButton(QQuickAbstractButtonPrivate &dd, QQuickItem *parent); + void componentComplete() override; + bool event(QEvent *event) override; void focusOutEvent(QFocusEvent *event) override; void keyPressEvent(QKeyEvent *event) override; diff --git a/src/quicktemplates2/qquickabstractbutton_p_p.h b/src/quicktemplates2/qquickabstractbutton_p_p.h index 765664d9..d5afc4cf 100644 --- a/src/quicktemplates2/qquickabstractbutton_p_p.h +++ b/src/quicktemplates2/qquickabstractbutton_p_p.h @@ -93,11 +93,17 @@ public: QQuickAbstractButton *findCheckedButton() const; QList<QQuickAbstractButton *> findExclusiveButtons() const; + void actionTextChange(); + void setText(const QString &text, bool isExplicit); + void click(); void trigger(); void toggle(bool value); + void executeIndicator(bool complete = false); + QString text; + bool explicitText; bool down; bool explicitDown; bool pressed; @@ -120,7 +126,7 @@ public: QPointF pressPoint; QPointF movePoint; Qt::MouseButtons pressButtons; - QQuickItem *indicator; + QQuickDeferredPointer<QQuickItem> indicator; QQuickButtonGroup *group; QQuickAbstractButton::Display display; QPointer<QQuickAction> action; diff --git a/src/quicktemplates2/qquickaction.cpp b/src/quicktemplates2/qquickaction.cpp index 0e51daef..fd899d0b 100644 --- a/src/quicktemplates2/qquickaction.cpp +++ b/src/quicktemplates2/qquickaction.cpp @@ -523,16 +523,26 @@ void QQuickAction::toggle(QObject *source) void QQuickAction::trigger(QObject *source) { Q_D(QQuickAction); - if (!d->enabled) + d->trigger(source, true); +} + +void QQuickActionPrivate::trigger(QObject* source, bool doToggle) +{ + Q_Q(QQuickAction); + if (!enabled) return; - QPointer<QObject> guard = this; + QPointer<QObject> guard = q; // the checked action of an exclusive group cannot be unchecked - if (d->checkable && (!d->checked || !d->group || !d->group->isExclusive() || d->group->checkedAction() != this)) - toggle(source); + if (checkable && (!checked || !group || !group->isExclusive() || group->checkedAction() != q)) { + if (doToggle) + q->toggle(source); + else + emit q->toggled(source); + } if (!guard.isNull()) - emit triggered(source); + emit q->triggered(source); } bool QQuickAction::event(QEvent *event) diff --git a/src/quicktemplates2/qquickaction_p_p.h b/src/quicktemplates2/qquickaction_p_p.h index 08c442ed..331bcb65 100644 --- a/src/quicktemplates2/qquickaction_p_p.h +++ b/src/quicktemplates2/qquickaction_p_p.h @@ -87,6 +87,8 @@ public: bool handleShortcutEvent(QObject *object, QShortcutEvent *event); + void trigger(QObject*, bool doToggle); + class ShortcutEntry { public: diff --git a/src/quicktemplates2/qquickapplicationwindow.cpp b/src/quicktemplates2/qquickapplicationwindow.cpp index d579afb2..94b0de98 100644 --- a/src/quicktemplates2/qquickapplicationwindow.cpp +++ b/src/quicktemplates2/qquickapplicationwindow.cpp @@ -43,6 +43,8 @@ #include "qquicktoolbar_p.h" #include "qquicktabbar_p.h" #include "qquickdialogbuttonbox_p.h" +#include "qquickdeferredexecute_p_p.h" +#include "qquickdeferredpointer_p_p.h" #include <QtCore/private/qobject_p.h> #include <QtQuick/private/qquickitem_p.h> @@ -164,8 +166,10 @@ public: static void contentData_append(QQmlListProperty<QObject> *prop, QObject *obj); + void executeBackground(bool complete = false); + bool complete; - QQuickItem *background; + QQuickDeferredPointer<QQuickItem> background; QQuickItem *contentItem; QQuickItem *menuBar; QQuickItem *header; @@ -328,6 +332,20 @@ void QQuickApplicationWindowPrivate::contentData_append(QQmlListProperty<QObject QQuickPopupPrivate::get(popup)->setWindow(static_cast<QQuickApplicationWindow *>(prop->data)); } +static inline QString backgroundName() { return QStringLiteral("background"); } + +void QQuickApplicationWindowPrivate::executeBackground(bool complete) +{ + Q_Q(QQuickApplicationWindow); + if (background.wasExecuted()) + return; + + if (!background) + quickBeginDeferred(q, backgroundName(), background); + if (complete) + quickCompleteDeferred(q, backgroundName(), background); +} + QQuickApplicationWindow::QQuickApplicationWindow(QWindow *parent) : QQuickWindowQmlImpl(parent), d_ptr(new QQuickApplicationWindowPrivate) { @@ -374,7 +392,9 @@ QQuickApplicationWindowAttached *QQuickApplicationWindow::qmlAttachedProperties( */ QQuickItem *QQuickApplicationWindow::background() const { - Q_D(const QQuickApplicationWindow); + QQuickApplicationWindowPrivate *d = const_cast<QQuickApplicationWindowPrivate *>(d_func()); + if (!d->background) + d->executeBackground(); return d->background; } @@ -384,7 +404,7 @@ void QQuickApplicationWindow::setBackground(QQuickItem *background) if (d->background == background) return; - QQuickControlPrivate::destroyDelegate(d->background, this); + delete d->background; d->background = background; if (background) { background->setParentItem(QQuickWindow::contentItem()); @@ -393,7 +413,8 @@ void QQuickApplicationWindow::setBackground(QQuickItem *background) if (isComponentComplete()) d->relayout(); } - emit backgroundChanged(); + if (!d->background.isExecuting()) + emit backgroundChanged(); } /*! @@ -812,6 +833,7 @@ void QQuickApplicationWindow::componentComplete() { Q_D(QQuickApplicationWindow); d->complete = true; + d->executeBackground(true); QQuickWindowQmlImpl::componentComplete(); d->relayout(); } diff --git a/src/quicktemplates2/qquickapplicationwindow_p.h b/src/quicktemplates2/qquickapplicationwindow_p.h index 4e24009f..d74d3c9d 100644 --- a/src/quicktemplates2/qquickapplicationwindow_p.h +++ b/src/quicktemplates2/qquickapplicationwindow_p.h @@ -76,6 +76,7 @@ class Q_QUICKTEMPLATES2_PRIVATE_EXPORT QQuickApplicationWindow : public QQuickWi // 2.3 (Qt 5.10) Q_PROPERTY(QPalette palette READ palette WRITE setPalette RESET resetPalette NOTIFY paletteChanged FINAL REVISION 3) Q_PROPERTY(QQuickItem *menuBar READ menuBar WRITE setMenuBar NOTIFY menuBarChanged FINAL REVISION 3) + Q_CLASSINFO("DeferredPropertyNames", "background") Q_CLASSINFO("DefaultProperty", "contentData") public: diff --git a/src/quicktemplates2/qquickcombobox.cpp b/src/quicktemplates2/qquickcombobox.cpp index 6b20e6a5..3b37900d 100644 --- a/src/quicktemplates2/qquickcombobox.cpp +++ b/src/quicktemplates2/qquickcombobox.cpp @@ -39,6 +39,7 @@ #include "qquickabstractbutton_p.h" #include "qquickabstractbutton_p_p.h" #include "qquickpopup_p_p.h" +#include "qquickdeferredexecute_p_p.h" #include <QtCore/qregexp.h> #include <QtCore/qabstractitemmodel.h> @@ -255,6 +256,9 @@ public: void handleRelease(const QPointF &point) override; void handleUngrab() override; + void executeIndicator(bool complete = false); + void executePopup(bool complete = false); + bool flat; bool down; bool hasDown; @@ -272,8 +276,8 @@ public: QQuickItem *pressedItem; QQmlInstanceModel *delegateModel; QQmlComponent *delegate; - QQuickItem *indicator; - QQuickPopup *popup; + QQuickDeferredPointer<QQuickItem> indicator; + QQuickDeferredPointer<QQuickPopup> popup; struct ExtraData { ExtraData() @@ -318,6 +322,9 @@ bool QQuickComboBoxPrivate::isPopupVisible() const void QQuickComboBoxPrivate::showPopup() { + if (!popup) + executePopup(true); + if (popup && !popup->isVisible()) popup->open(); } @@ -335,13 +342,10 @@ void QQuickComboBoxPrivate::hidePopup(bool accept) void QQuickComboBoxPrivate::togglePopup(bool accept) { - if (!popup) - return; - - if (popup->isVisible()) - hidePopup(accept); - else + if (!popup || !popup->isVisible()) showPopup(); + else + hidePopup(accept); } void QQuickComboBoxPrivate::popupVisibleChanged() @@ -398,8 +402,11 @@ void QQuickComboBoxPrivate::createdItem(int index, QObject *object) { Q_Q(QQuickComboBox); QQuickItem *item = qobject_cast<QQuickItem *>(object); - if (popup && item && !item->parentItem()) { - item->setParentItem(popup->contentItem()); + if (item && !item->parentItem()) { + if (popup) + item->setParentItem(popup->contentItem()); + else + item->setParentItem(q); QQuickItemPrivate::get(item)->setCulled(true); } @@ -695,6 +702,34 @@ void QQuickComboBoxPrivate::handleUngrab() q->setPressed(false); } +static inline QString indicatorName() { return QStringLiteral("indicator"); } + +void QQuickComboBoxPrivate::executeIndicator(bool complete) +{ + Q_Q(QQuickComboBox); + if (indicator.wasExecuted()) + return; + + if (!indicator) + quickBeginDeferred(q, indicatorName(), indicator); + if (complete) + quickCompleteDeferred(q, indicatorName(), indicator); +} + +static inline QString popupName() { return QStringLiteral("popup"); } + +void QQuickComboBoxPrivate::executePopup(bool complete) +{ + Q_Q(QQuickComboBox); + if (popup.wasExecuted()) + return; + + if (!popup) + quickBeginDeferred(q, popupName(), popup); + if (complete) + quickCompleteDeferred(q, popupName(), popup); +} + QQuickComboBox::QQuickComboBox(QQuickItem *parent) : QQuickControl(*(new QQuickComboBoxPrivate), parent) { @@ -710,14 +745,13 @@ QQuickComboBox::QQuickComboBox(QQuickItem *parent) QQuickComboBox::~QQuickComboBox() { Q_D(QQuickComboBox); - // Disconnect visibleChanged() to avoid a spurious highlightedIndexChanged() signal - // emission during the destruction of the (visible) popup. (QTBUG-57650) - QObjectPrivate::disconnect(d->popup, &QQuickPopup::visibleChanged, d, &QQuickComboBoxPrivate::popupVisibleChanged); - - // Delete the popup directly instead of calling setPopup(nullptr) to avoid calling - // destroyDelegate(popup) and potentially accessing a destroyed QML context. (QTBUG-50992) - delete d->popup; - d->popup = nullptr; + if (d->popup) { + // Disconnect visibleChanged() to avoid a spurious highlightedIndexChanged() signal + // emission during the destruction of the (visible) popup. (QTBUG-57650) + QObjectPrivate::disconnect(d->popup.data(), &QQuickPopup::visibleChanged, d, &QQuickComboBoxPrivate::popupVisibleChanged); + delete d->popup; + d->popup = nullptr; + } } /*! @@ -1002,7 +1036,9 @@ void QQuickComboBox::setDelegate(QQmlComponent* delegate) */ QQuickItem *QQuickComboBox::indicator() const { - Q_D(const QQuickComboBox); + QQuickComboBoxPrivate *d = const_cast<QQuickComboBoxPrivate *>(d_func()); + if (!d->indicator) + d->executeIndicator(); return d->indicator; } @@ -1012,13 +1048,14 @@ void QQuickComboBox::setIndicator(QQuickItem *indicator) if (d->indicator == indicator) return; - QQuickControlPrivate::destroyDelegate(d->indicator, this); + delete d->indicator; d->indicator = indicator; if (indicator) { if (!indicator->parentItem()) indicator->setParentItem(this); } - emit indicatorChanged(); + if (!d->indicator.isExecuting()) + emit indicatorChanged(); } /*! @@ -1036,7 +1073,9 @@ void QQuickComboBox::setIndicator(QQuickItem *indicator) */ QQuickPopup *QQuickComboBox::popup() const { - Q_D(const QQuickComboBox); + QQuickComboBoxPrivate *d = const_cast<QQuickComboBoxPrivate *>(d_func()); + if (!d->popup) + d->executePopup(isComponentComplete()); return d->popup; } @@ -1047,8 +1086,8 @@ void QQuickComboBox::setPopup(QQuickPopup *popup) return; if (d->popup) { - QObjectPrivate::disconnect(d->popup, &QQuickPopup::visibleChanged, d, &QQuickComboBoxPrivate::popupVisibleChanged); - QQuickControlPrivate::destroyDelegate(d->popup, this); + QObjectPrivate::disconnect(d->popup.data(), &QQuickPopup::visibleChanged, d, &QQuickComboBoxPrivate::popupVisibleChanged); + delete d->popup; } if (popup) { QQuickPopupPrivate::get(popup)->allowVerticalFlip = true; @@ -1059,7 +1098,8 @@ void QQuickComboBox::setPopup(QQuickPopup *popup) itemView->setHighlightRangeMode(QQuickItemView::NoHighlightRange); } d->popup = popup; - emit popupChanged(); + if (!d->popup.isExecuting()) + emit popupChanged(); } /*! @@ -1537,9 +1577,8 @@ void QQuickComboBox::keyReleaseEvent(QKeyEvent *event) { Q_D(QQuickComboBox); QQuickControl::keyReleaseEvent(event); - d->keyNavigating = false; - if (!d->popup || event->isAutoRepeat()) + if (event->isAutoRepeat()) return; switch (event->key()) { @@ -1586,6 +1625,9 @@ void QQuickComboBox::wheelEvent(QWheelEvent *event) void QQuickComboBox::componentComplete() { Q_D(QQuickComboBox); + d->executeIndicator(true); + if (d->popup) + d->executePopup(true); QQuickControl::componentComplete(); if (d->delegateModel && d->ownModel) diff --git a/src/quicktemplates2/qquickcombobox_p.h b/src/quicktemplates2/qquickcombobox_p.h index dd1e1d4f..ee926daf 100644 --- a/src/quicktemplates2/qquickcombobox_p.h +++ b/src/quicktemplates2/qquickcombobox_p.h @@ -82,6 +82,7 @@ class Q_QUICKTEMPLATES2_PRIVATE_EXPORT QQuickComboBox : public QQuickControl Q_PROPERTY(Qt::InputMethodHints inputMethodHints READ inputMethodHints WRITE setInputMethodHints NOTIFY inputMethodHintsChanged FINAL REVISION 2) Q_PROPERTY(bool inputMethodComposing READ isInputMethodComposing NOTIFY inputMethodComposingChanged FINAL REVISION 2) Q_PROPERTY(bool acceptableInput READ hasAcceptableInput NOTIFY acceptableInputChanged FINAL REVISION 2) + Q_CLASSINFO("DeferredPropertyNames", "background,contentItem,indicator,popup") public: explicit QQuickComboBox(QQuickItem *parent = nullptr); diff --git a/src/quicktemplates2/qquickcontainer.cpp b/src/quicktemplates2/qquickcontainer.cpp index 07fe04d2..048cfdfa 100644 --- a/src/quicktemplates2/qquickcontainer.cpp +++ b/src/quicktemplates2/qquickcontainer.cpp @@ -634,6 +634,9 @@ QVariant QQuickContainer::contentModel() const */ QQmlListProperty<QObject> QQuickContainer::contentData() { + Q_D(QQuickContainer); + if (!d->contentItem) + d->executeContentItem(); return QQmlListProperty<QObject>(this, nullptr, QQuickContainerPrivate::contentData_append, QQuickContainerPrivate::contentData_count, diff --git a/src/quicktemplates2/qquickcontrol.cpp b/src/quicktemplates2/qquickcontrol.cpp index 8448f9ad..950ec384 100644 --- a/src/quicktemplates2/qquickcontrol.cpp +++ b/src/quicktemplates2/qquickcontrol.cpp @@ -48,6 +48,7 @@ #include "qquickpopup_p.h" #include "qquickpopupitem_p_p.h" #include "qquickapplicationwindow_p.h" +#include "qquickdeferredexecute_p_p.h" #include <QtGui/private/qguiapplication_p.h> #include <QtGui/qpa/qplatformtheme.h> @@ -279,6 +280,8 @@ void QQuickControlPrivate::resizeContent() QQuickItem *QQuickControlPrivate::getContentItem() { + if (!contentItem) + executeContentItem(); return contentItem; } @@ -289,7 +292,7 @@ void QQuickControlPrivate::setContentItem_helper(QQuickItem *item, bool notify) return; q->contentItemChange(item, contentItem); - destroyDelegate(contentItem, q); + delete contentItem; contentItem = item; if (item) { @@ -299,7 +302,7 @@ void QQuickControlPrivate::setContentItem_helper(QQuickItem *item, bool notify) resizeContent(); } - if (notify) + if (notify && !contentItem.isExecuting()) emit q->contentItemChanged(); } @@ -644,6 +647,34 @@ bool QQuickControlPrivate::calcHoverEnabled(const QQuickItem *item) } #endif +static inline QString contentItemName() { return QStringLiteral("contentItem"); } + +void QQuickControlPrivate::executeContentItem(bool complete) +{ + Q_Q(QQuickControl); + if (contentItem.wasExecuted()) + return; + + if (!contentItem) + quickBeginDeferred(q, contentItemName(), contentItem); + if (complete) + quickCompleteDeferred(q, contentItemName(), contentItem); +} + +static inline QString backgroundName() { return QStringLiteral("background"); } + +void QQuickControlPrivate::executeBackground(bool complete) +{ + Q_Q(QQuickControl); + if (background.wasExecuted()) + return; + + if (!background) + quickBeginDeferred(q, backgroundName(), background); + if (complete) + quickCompleteDeferred(q, backgroundName(), background); +} + /* Cancels incubation recursively to avoid "Object destroyed during incubation" (QTBUG-50992) */ @@ -724,9 +755,14 @@ void QQuickControl::itemChange(QQuickItem::ItemChange change, const QQuickItem:: The default font depends on the system environment. ApplicationWindow maintains a system/theme font which serves as a default for all controls. There may also be special font defaults for - certain types of controls. You can also set the default font for controls by passing a custom - font to QGuiApplication::setFont(), before loading the QML. Finally, the font is matched - against Qt's font database to find the best match. + certain types of controls. You can also set the default font for controls by either: + + \list + \li passing a custom font to QGuiApplication::setFont(), before loading the QML; or + \li specifying the fonts in the \l {Qt Quick Controls 2 Configuration File}{qtquickcontrols2.conf file}. + \endlist + + Finally, the font is matched against Qt's font database to find the best match. Control propagates explicit font properties from parent to children. If you change a specific property on a control's font, that property propagates to all of the control's children, @@ -747,6 +783,9 @@ void QQuickControl::itemChange(QQuickItem::ItemChange change, const QQuickItem:: } } \endcode + + For the full list of available font properties, see the + \l [QtQuick]{font}{font QML Basic Type} documentation. */ QFont QQuickControl::font() const { @@ -1262,7 +1301,9 @@ void QQuickControl::setWheelEnabled(bool enabled) */ QQuickItem *QQuickControl::background() const { - Q_D(const QQuickControl); + QQuickControlPrivate *d = const_cast<QQuickControlPrivate *>(d_func()); + if (!d->background) + d->executeBackground(); return d->background; } @@ -1272,7 +1313,7 @@ void QQuickControl::setBackground(QQuickItem *background) if (d->background == background) return; - QQuickControlPrivate::destroyDelegate(d->background, this); + delete d->background; d->background = background; if (background) { background->setParentItem(this); @@ -1281,7 +1322,8 @@ void QQuickControl::setBackground(QQuickItem *background) if (isComponentComplete()) d->resizeBackground(); } - emit backgroundChanged(); + if (!d->background.isExecuting()) + emit backgroundChanged(); } /*! @@ -1339,8 +1381,12 @@ void QQuickControl::setContentItem(QQuickItem *item) The default palette depends on the system environment. ApplicationWindow maintains a system/theme palette which serves as a default for all controls. There may also be special palette defaults for - certain types of controls. You can also set the default palette for controls by passing a custom - palette to QGuiApplication::setPalette(), before loading any QML. + certain types of controls. You can also set the default palette for controls by either: + + \list + \li passing a custom palette to QGuiApplication::setPalette(), before loading any QML; or + \li specifying the colors in the \l {Qt Quick Controls 2 Configuration File}{qtquickcontrols2.conf file}. + \endlist Control propagates explicit palette properties from parent to children. If you change a specific property on a control's palette, that property propagates to all of the control's children, @@ -1362,7 +1408,10 @@ void QQuickControl::setContentItem(QQuickItem *item) } \endcode - \sa ApplicationWindow::palette, Popup::palette, {qtquickcontrols2-palette}{palette QML Basic Type} + For the full list of available palette colors, see the + \l {qtquickcontrols2-palette}{palette QML Basic Type} documentation. + + \sa ApplicationWindow::palette, Popup::palette */ QPalette QQuickControl::palette() const { @@ -1399,6 +1448,8 @@ void QQuickControl::classBegin() void QQuickControl::componentComplete() { Q_D(QQuickControl); + d->executeBackground(true); + d->executeContentItem(true); QQuickItem::componentComplete(); d->resizeContent(); if (!d->hasLocale) diff --git a/src/quicktemplates2/qquickcontrol_p.h b/src/quicktemplates2/qquickcontrol_p.h index 7dd1deb3..6b2d48d6 100644 --- a/src/quicktemplates2/qquickcontrol_p.h +++ b/src/quicktemplates2/qquickcontrol_p.h @@ -81,6 +81,7 @@ class Q_QUICKTEMPLATES2_PRIVATE_EXPORT QQuickControl : public QQuickItem Q_PROPERTY(QQuickItem *contentItem READ contentItem WRITE setContentItem NOTIFY contentItemChanged FINAL) // 2.3 (Qt 5.10) Q_PROPERTY(QPalette palette READ palette WRITE setPalette RESET resetPalette NOTIFY paletteChanged FINAL REVISION 3) + Q_CLASSINFO("DeferredPropertyNames", "background,contentItem") public: explicit QQuickControl(QQuickItem *parent = nullptr); diff --git a/src/quicktemplates2/qquickcontrol_p_p.h b/src/quicktemplates2/qquickcontrol_p_p.h index e7e9d46f..f159c96d 100644 --- a/src/quicktemplates2/qquickcontrol_p_p.h +++ b/src/quicktemplates2/qquickcontrol_p_p.h @@ -49,6 +49,7 @@ // #include <QtQuickTemplates2/private/qquickcontrol_p.h> +#include <QtQuickTemplates2/private/qquickdeferredpointer_p_p.h> #include <QtQuick/private/qquickitem_p.h> #include <QtQml/private/qlazilyallocated_p.h> @@ -139,6 +140,9 @@ public: static bool calcHoverEnabled(const QQuickItem *item); #endif + void executeContentItem(bool complete = false); + void executeBackground(bool complete = false); + static void destroyDelegate(QObject *object, QObject *parent); struct ExtraData { @@ -170,8 +174,8 @@ public: QPalette resolvedPalette; Qt::FocusPolicy focusPolicy; Qt::FocusReason focusReason; - QQuickItem *background; - QQuickItem *contentItem; + QQuickDeferredPointer<QQuickItem> background; + QQuickDeferredPointer<QQuickItem> contentItem; }; QT_END_NAMESPACE diff --git a/src/quicktemplates2/qquickdeferredexecute.cpp b/src/quicktemplates2/qquickdeferredexecute.cpp new file mode 100644 index 00000000..802ed3d0 --- /dev/null +++ b/src/quicktemplates2/qquickdeferredexecute.cpp @@ -0,0 +1,131 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt Quick Templates 2 module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qquickdeferredexecute_p_p.h" + +#include <QtCore/qhash.h> +#include <QtQml/qqmlengine.h> +#include <QtQml/private/qqmldata_p.h> +#include <QtQml/private/qqmlcomponent_p.h> +#include <QtQml/private/qqmlobjectcreator_p.h> + +QT_BEGIN_NAMESPACE + +namespace QtQuickPrivate { + +typedef QHash<uint, QQmlComponentPrivate::DeferredState *> DeferredStates; + +static inline uint qHash(QObject *object, const QString &propertyName) +{ + return ::qHash(object) + ::qHash(propertyName); +} + +Q_GLOBAL_STATIC(DeferredStates, deferredStates) + +static void beginDeferred(QQmlEnginePrivate *enginePriv, const QQmlProperty &property, QQmlComponentPrivate::DeferredState *deferredState) +{ + QObject *object = property.object(); + QQmlData *ddata = QQmlData::get(object); + Q_ASSERT(!ddata->deferredData.isEmpty()); + + int propertyIndex = property.index(); + + for (auto dit = ddata->deferredData.rbegin(); dit != ddata->deferredData.rend(); ++dit) { + QQmlData::DeferredData *deferData = *dit; + + auto range = deferData->bindings.equal_range(propertyIndex); + if (range.first == deferData->bindings.end()) + continue; + + QQmlComponentPrivate::ConstructionState *state = new QQmlComponentPrivate::ConstructionState; + state->completePending = true; + + QQmlContextData *creationContext = nullptr; + state->creator.reset(new QQmlObjectCreator(deferData->context->parent, deferData->compilationUnit, creationContext)); + + enginePriv->inProgressCreations++; + + typedef QMultiHash<int, const QV4::CompiledData::Binding *> QV4PropertyBindingHash; + auto it = std::reverse_iterator<QV4PropertyBindingHash::iterator>(range.second); + auto last = std::reverse_iterator<QV4PropertyBindingHash::iterator>(range.first); + while (it != last) { + if (!state->creator->populateDeferredBinding(property, deferData, *it)) + state->errors << state->creator->errors; + ++it; + } + + deferredState->constructionStates += state; + + // Cleanup any remaining deferred bindings for this property, also in inner contexts, + // to avoid executing them later and overriding the property that was just populated. + while (dit != ddata->deferredData.rend()) { + (*dit)->bindings.remove(propertyIndex); + ++dit; + } + break; + } +} + +void beginDeferred(QObject *object, const QString &property) +{ + QQmlData *data = QQmlData::get(object); + if (data && !data->deferredData.isEmpty() && !data->wasDeleted(object)) { + QQmlEnginePrivate *ep = QQmlEnginePrivate::get(data->context->engine); + + QQmlComponentPrivate::DeferredState *state = new QQmlComponentPrivate::DeferredState; + beginDeferred(ep, QQmlProperty(object, property), state); + + // Release deferred data for those compilation units that no longer have deferred bindings + data->releaseDeferredData(); + + deferredStates()->insert(qHash(object, property), state); + } +} + +void completeDeferred(QObject *object, const QString &property) +{ + QQmlData *data = QQmlData::get(object); + QQmlComponentPrivate::DeferredState *state = deferredStates()->take(qHash(object, property)); + if (data && state && !data->wasDeleted(object)) { + QQmlEnginePrivate *ep = QQmlEnginePrivate::get(data->context->engine); + QQmlComponentPrivate::completeDeferred(ep, state); + } + delete state; +} + +} // QtQuickPrivate + +QT_END_NAMESPACE diff --git a/src/quicktemplates2/qquickdeferredexecute_p_p.h b/src/quicktemplates2/qquickdeferredexecute_p_p.h new file mode 100644 index 00000000..87124e48 --- /dev/null +++ b/src/quicktemplates2/qquickdeferredexecute_p_p.h @@ -0,0 +1,85 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt Quick Templates 2 module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QQUICKDEFERREDEXECUTE_P_P_H +#define QQUICKDEFERREDEXECUTE_P_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtCore/qglobal.h> +#include <QtQuickTemplates2/private/qquickdeferredpointer_p_p.h> + +QT_BEGIN_NAMESPACE + +class QString; +class QObject; + +namespace QtQuickPrivate { + void beginDeferred(QObject *object, const QString &property); + void completeDeferred(QObject *object, const QString &property); +} + +template<typename T> +void quickBeginDeferred(QObject *object, const QString &property, QQuickDeferredPointer<T> &delegate) +{ + Q_ASSERT(delegate.isNull()); + delegate.setExecuting(true); + QtQuickPrivate::beginDeferred(object, property); + delegate.setExecuting(false); +} + +template<typename T> +void quickCompleteDeferred(QObject *object, const QString &property, QQuickDeferredPointer<T> &delegate) +{ + Q_ASSERT(!delegate.wasExecuted()); + delegate.setExecuting(true); + QtQuickPrivate::completeDeferred(object, property); + delegate.setExecuting(false); + delegate.setExecuted(); +} + +QT_END_NAMESPACE + +#endif // QQUICKDEFERREDEXECUTE_P_P_H diff --git a/src/quicktemplates2/qquickdeferredpointer_p_p.h b/src/quicktemplates2/qquickdeferredpointer_p_p.h new file mode 100644 index 00000000..c793964f --- /dev/null +++ b/src/quicktemplates2/qquickdeferredpointer_p_p.h @@ -0,0 +1,189 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt Quick Templates 2 module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QQUICKDEFERREDPOINTER_P_P_H +#define QQUICKDEFERREDPOINTER_P_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtCore/qglobal.h> + +QT_BEGIN_NAMESPACE + +template<typename T> +class QQuickDeferredPointer +{ +public: + inline QQuickDeferredPointer(); + inline QQuickDeferredPointer(T *); + inline QQuickDeferredPointer(const QQuickDeferredPointer<T> &o); + + inline bool isNull() const; + + inline bool wasExecuted() const; + inline void setExecuted(); + + inline bool isExecuting() const; + inline void setExecuting(bool); + + inline operator T*() const; + inline operator bool() const; + + inline T *data() const; + inline T *operator*() const; + inline T *operator->() const; + + inline QQuickDeferredPointer<T> &operator=(T *); + inline QQuickDeferredPointer<T> &operator=(const QQuickDeferredPointer &o); + +private: + quintptr ptr_value; + + static const quintptr WasExecutedBit = 0x1; + static const quintptr IsExecutingBit = 0x2; + static const quintptr FlagsMask = WasExecutedBit | IsExecutingBit; +}; + +template<typename T> +QQuickDeferredPointer<T>::QQuickDeferredPointer() +: ptr_value(0) +{ +} + +template<typename T> +QQuickDeferredPointer<T>::QQuickDeferredPointer(T *v) +: ptr_value(quintptr(v)) +{ + Q_ASSERT((ptr_value & FlagsMask) == 0); +} + +template<typename T> +QQuickDeferredPointer<T>::QQuickDeferredPointer(const QQuickDeferredPointer<T> &o) +: ptr_value(o.ptr_value) +{ +} + +template<typename T> +bool QQuickDeferredPointer<T>::isNull() const +{ + return 0 == (ptr_value & (~FlagsMask)); +} + +template<typename T> +bool QQuickDeferredPointer<T>::wasExecuted() const +{ + return ptr_value & WasExecutedBit; +} + +template<typename T> +void QQuickDeferredPointer<T>::setExecuted() +{ + ptr_value |= WasExecutedBit; +} + +template<typename T> +bool QQuickDeferredPointer<T>::isExecuting() const +{ + return ptr_value & IsExecutingBit; +} + +template<typename T> +void QQuickDeferredPointer<T>::setExecuting(bool b) +{ + if (b) + ptr_value |= IsExecutingBit; + else + ptr_value &= ~IsExecutingBit; +} + +template<typename T> +QQuickDeferredPointer<T>::operator T*() const +{ + return data(); +} + +template<typename T> +QQuickDeferredPointer<T>::operator bool() const +{ + return !isNull(); +} + +template<typename T> +T *QQuickDeferredPointer<T>::data() const +{ + return (T *)(ptr_value & ~FlagsMask); +} + +template<typename T> +T *QQuickDeferredPointer<T>::operator*() const +{ + return (T *)(ptr_value & ~FlagsMask); +} + +template<typename T> +T *QQuickDeferredPointer<T>::operator->() const +{ + return (T *)(ptr_value & ~FlagsMask); +} + +template<typename T> +QQuickDeferredPointer<T> &QQuickDeferredPointer<T>::operator=(T *o) +{ + Q_ASSERT((quintptr(o) & FlagsMask) == 0); + + ptr_value = quintptr(o) | (ptr_value & FlagsMask); + return *this; +} + +template<typename T> +QQuickDeferredPointer<T> &QQuickDeferredPointer<T>::operator=(const QQuickDeferredPointer &o) +{ + ptr_value = o.ptr_value; + return *this; +} + +QT_END_NAMESPACE + +#endif // QQUICKDEFERREDPOINTER_P_P_H diff --git a/src/quicktemplates2/qquickdial.cpp b/src/quicktemplates2/qquickdial.cpp index c0e2c8ed..964cefe1 100644 --- a/src/quicktemplates2/qquickdial.cpp +++ b/src/quicktemplates2/qquickdial.cpp @@ -35,6 +35,7 @@ ****************************************************************************/ #include "qquickdial_p.h" +#include "qquickdeferredexecute_p_p.h" #include <QtCore/qmath.h> #include <QtQuick/private/qquickflickable_p.h> @@ -122,6 +123,8 @@ public: void handleRelease(const QPointF &point) override; void handleUngrab() override; + void executeHandle(bool complete = false); + qreal from; qreal to; qreal value; @@ -133,7 +136,7 @@ public: QQuickDial::SnapMode snapMode; bool wrap; bool live; - QQuickItem *handle; + QQuickDeferredPointer<QQuickItem> handle; }; qreal QQuickDialPrivate::valueAt(qreal position) const @@ -253,6 +256,20 @@ void QQuickDialPrivate::handleUngrab() q->setPressed(false); } +static inline QString handleName() { return QStringLiteral("handle"); } + +void QQuickDialPrivate::executeHandle(bool complete) +{ + Q_Q(QQuickDial); + if (handle.wasExecuted()) + return; + + if (!handle) + quickBeginDeferred(q, handleName(), handle); + if (complete) + quickCompleteDeferred(q, handleName(), handle); +} + QQuickDial::QQuickDial(QQuickItem *parent) : QQuickControl(*(new QQuickDialPrivate), parent) { @@ -524,7 +541,9 @@ void QQuickDial::setPressed(bool pressed) */ QQuickItem *QQuickDial::handle() const { - Q_D(const QQuickDial); + QQuickDialPrivate *d = const_cast<QQuickDialPrivate *>(d_func()); + if (!d->handle) + d->executeHandle(); return d->handle; } @@ -534,11 +553,12 @@ void QQuickDial::setHandle(QQuickItem *handle) if (handle == d->handle) return; - QQuickControlPrivate::destroyDelegate(d->handle, this); + delete d->handle; d->handle = handle; if (d->handle && !d->handle->parentItem()) d->handle->setParentItem(this); - emit handleChanged(); + if (!d->handle.isExecuting()) + emit handleChanged(); } /*! @@ -730,6 +750,7 @@ void QQuickDial::mirrorChange() void QQuickDial::componentComplete() { Q_D(QQuickDial); + d->executeHandle(true); QQuickControl::componentComplete(); setValue(d->value); d->updatePosition(); diff --git a/src/quicktemplates2/qquickdial_p.h b/src/quicktemplates2/qquickdial_p.h index 296f7986..d7bab0ad 100644 --- a/src/quicktemplates2/qquickdial_p.h +++ b/src/quicktemplates2/qquickdial_p.h @@ -72,6 +72,7 @@ class Q_QUICKTEMPLATES2_PRIVATE_EXPORT QQuickDial : public QQuickControl Q_PROPERTY(QQuickItem *handle READ handle WRITE setHandle NOTIFY handleChanged FINAL) // 2.2 (Qt 5.9) Q_PROPERTY(bool live READ live WRITE setLive NOTIFY liveChanged FINAL REVISION 2) + Q_CLASSINFO("DeferredPropertyNames", "background,handle") public: explicit QQuickDial(QQuickItem *parent = nullptr); diff --git a/src/quicktemplates2/qquickgroupbox.cpp b/src/quicktemplates2/qquickgroupbox.cpp index c227afdc..c127192c 100644 --- a/src/quicktemplates2/qquickgroupbox.cpp +++ b/src/quicktemplates2/qquickgroupbox.cpp @@ -36,6 +36,7 @@ #include "qquickgroupbox_p.h" #include "qquickframe_p_p.h" +#include "qquickdeferredexecute_p_p.h" #include <QtGui/qpa/qplatformtheme.h> @@ -85,13 +86,31 @@ QT_BEGIN_NAMESPACE class QQuickGroupBoxPrivate : public QQuickFramePrivate { + Q_DECLARE_PUBLIC(QQuickGroupBox) + public: QQuickGroupBoxPrivate() : label(nullptr) { } + void executeLabel(bool complete = false); + QString title; - QQuickItem *label; + QQuickDeferredPointer<QQuickItem> label; }; +static inline QString labelName() { return QStringLiteral("label"); } + +void QQuickGroupBoxPrivate::executeLabel(bool complete) +{ + Q_Q(QQuickGroupBox); + if (label.wasExecuted()) + return; + + if (!label) + quickBeginDeferred(q, labelName(), label); + if (complete) + quickCompleteDeferred(q, labelName(), label); +} + QQuickGroupBox::QQuickGroupBox(QQuickItem *parent) : QQuickFrame(*(new QQuickGroupBoxPrivate), parent) { @@ -131,7 +150,9 @@ void QQuickGroupBox::setTitle(const QString &title) */ QQuickItem *QQuickGroupBox::label() const { - Q_D(const QQuickGroupBox); + QQuickGroupBoxPrivate *d = const_cast<QQuickGroupBoxPrivate *>(d_func()); + if (!d->label) + d->executeLabel(); return d->label; } @@ -141,11 +162,19 @@ void QQuickGroupBox::setLabel(QQuickItem *label) if (d->label == label) return; - QQuickControlPrivate::destroyDelegate(d->label, this); + delete d->label; d->label = label; if (label && !label->parentItem()) label->setParentItem(this); - emit labelChanged(); + if (!d->label.isExecuting()) + emit labelChanged(); +} + +void QQuickGroupBox::componentComplete() +{ + Q_D(QQuickGroupBox); + d->executeLabel(true); + QQuickFrame::componentComplete(); } QFont QQuickGroupBox::defaultFont() const diff --git a/src/quicktemplates2/qquickgroupbox_p.h b/src/quicktemplates2/qquickgroupbox_p.h index b74389e4..b46d91fd 100644 --- a/src/quicktemplates2/qquickgroupbox_p.h +++ b/src/quicktemplates2/qquickgroupbox_p.h @@ -59,6 +59,7 @@ class Q_QUICKTEMPLATES2_PRIVATE_EXPORT QQuickGroupBox : public QQuickFrame Q_OBJECT Q_PROPERTY(QString title READ title WRITE setTitle NOTIFY titleChanged FINAL) Q_PROPERTY(QQuickItem *label READ label WRITE setLabel NOTIFY labelChanged FINAL) + Q_CLASSINFO("DeferredPropertyNames", "background,contentItem,label") public: explicit QQuickGroupBox(QQuickItem *parent = nullptr); @@ -74,6 +75,8 @@ Q_SIGNALS: void labelChanged(); protected: + void componentComplete() override; + QFont defaultFont() const override; QPalette defaultPalette() const override; diff --git a/src/quicktemplates2/qquicklabel.cpp b/src/quicktemplates2/qquicklabel.cpp index 724fd086..d27393ae 100644 --- a/src/quicktemplates2/qquicklabel.cpp +++ b/src/quicktemplates2/qquicklabel.cpp @@ -38,6 +38,7 @@ #include "qquicklabel_p_p.h" #include "qquickcontrol_p.h" #include "qquickcontrol_p_p.h" +#include "qquickdeferredexecute_p_p.h" #include <QtQuick/private/qquickitem_p.h> #include <QtQuick/private/qquicktext_p.h> @@ -202,6 +203,20 @@ QAccessible::Role QQuickLabelPrivate::accessibleRole() const } #endif +static inline QString backgroundName() { return QStringLiteral("background"); } + +void QQuickLabelPrivate::executeBackground(bool complete) +{ + Q_Q(QQuickLabel); + if (background.wasExecuted()) + return; + + if (!background) + quickBeginDeferred(q, backgroundName(), background); + if (complete) + quickCompleteDeferred(q, backgroundName(), background); +} + QQuickLabel::QQuickLabel(QQuickItem *parent) : QQuickText(*(new QQuickLabelPrivate), parent) { @@ -237,7 +252,9 @@ void QQuickLabel::setFont(const QFont &font) */ QQuickItem *QQuickLabel::background() const { - Q_D(const QQuickLabel); + QQuickLabelPrivate *d = const_cast<QQuickLabelPrivate *>(d_func()); + if (!d->background) + d->executeBackground(); return d->background; } @@ -247,14 +264,15 @@ void QQuickLabel::setBackground(QQuickItem *background) if (d->background == background) return; - QQuickControlPrivate::destroyDelegate(d->background, this); + delete d->background; d->background = background; if (background) { background->setParentItem(this); if (qFuzzyIsNull(background->z())) background->setZ(-1); } - emit backgroundChanged(); + if (!d->background.isExecuting()) + emit backgroundChanged(); } /*! @@ -300,6 +318,7 @@ void QQuickLabel::classBegin() void QQuickLabel::componentComplete() { Q_D(QQuickLabel); + d->executeBackground(true); QQuickText::componentComplete(); #if QT_CONFIG(accessibility) if (QAccessible::isActive()) diff --git a/src/quicktemplates2/qquicklabel_p.h b/src/quicktemplates2/qquicklabel_p.h index 937c57eb..5486d311 100644 --- a/src/quicktemplates2/qquicklabel_p.h +++ b/src/quicktemplates2/qquicklabel_p.h @@ -63,6 +63,7 @@ class Q_QUICKTEMPLATES2_PRIVATE_EXPORT QQuickLabel : public QQuickText Q_PROPERTY(QQuickItem *background READ background WRITE setBackground NOTIFY backgroundChanged FINAL) // 2.3 (Qt 5.10) Q_PROPERTY(QPalette palette READ palette WRITE setPalette RESET resetPalette NOTIFY paletteChanged FINAL REVISION 3) + Q_CLASSINFO("DeferredPropertyNames", "background") public: explicit QQuickLabel(QQuickItem *parent = nullptr); diff --git a/src/quicktemplates2/qquicklabel_p_p.h b/src/quicktemplates2/qquicklabel_p_p.h index a8214d77..5f432a22 100644 --- a/src/quicktemplates2/qquicklabel_p_p.h +++ b/src/quicktemplates2/qquicklabel_p_p.h @@ -50,6 +50,7 @@ #include <QtQml/private/qlazilyallocated_p.h> #include <QtQuick/private/qquicktext_p_p.h> +#include <QtQuickTemplates2/private/qquickdeferredpointer_p_p.h> #if QT_CONFIG(accessibility) #include <QtGui/qaccessible.h> @@ -98,6 +99,8 @@ public: QAccessible::Role accessibleRole() const override; #endif + void executeBackground(bool complete = false); + struct ExtraData { QFont requestedFont; QPalette requestedPalette; @@ -105,7 +108,7 @@ public: QLazilyAllocated<ExtraData> extra; QPalette resolvedPalette; - QQuickItem *background; + QQuickDeferredPointer<QQuickItem> background; }; QT_END_NAMESPACE diff --git a/src/quicktemplates2/qquickpage.cpp b/src/quicktemplates2/qquickpage.cpp index 50050df3..907b01e9 100644 --- a/src/quicktemplates2/qquickpage.cpp +++ b/src/quicktemplates2/qquickpage.cpp @@ -106,9 +106,9 @@ QQuickPagePrivate::QQuickPagePrivate() QQuickItem *QQuickPagePrivate::getContentItem() { Q_Q(QQuickPage); - if (!contentItem) - return new QQuickItem(q); - return contentItem; + if (QQuickItem *item = QQuickControlPrivate::getContentItem()) + return item; + return new QQuickItem(q); } QQuickPage::QQuickPage(QQuickItem *parent) diff --git a/src/quicktemplates2/qquickpane.cpp b/src/quicktemplates2/qquickpane.cpp index b89131c4..4c3e1422 100644 --- a/src/quicktemplates2/qquickpane.cpp +++ b/src/quicktemplates2/qquickpane.cpp @@ -113,9 +113,9 @@ QQuickPanePrivate::QQuickPanePrivate() QQuickItem *QQuickPanePrivate::getContentItem() { Q_Q(QQuickPane); - if (!contentItem) - return new QQuickItem(q); - return contentItem; + if (QQuickItem *item = QQuickControlPrivate::getContentItem()) + return item; + return new QQuickItem(q); } QQuickPane::QQuickPane(QQuickItem *parent) diff --git a/src/quicktemplates2/qquickpopupitem.cpp b/src/quicktemplates2/qquickpopupitem.cpp index 27528f2f..af4d03a4 100644 --- a/src/quicktemplates2/qquickpopupitem.cpp +++ b/src/quicktemplates2/qquickpopupitem.cpp @@ -104,9 +104,9 @@ void QQuickPopupItemPrivate::resolvePalette() QQuickItem *QQuickPopupItemPrivate::getContentItem() { Q_Q(QQuickPopupItem); - if (!contentItem) - return new QQuickItem(q); - return contentItem; + if (QQuickItem *item = QQuickControlPrivate::getContentItem()) + return item; + return new QQuickItem(q); } QQuickPopupItem::QQuickPopupItem(QQuickPopup *popup) diff --git a/src/quicktemplates2/qquickrangeslider.cpp b/src/quicktemplates2/qquickrangeslider.cpp index d16cd3b4..937de9c9 100644 --- a/src/quicktemplates2/qquickrangeslider.cpp +++ b/src/quicktemplates2/qquickrangeslider.cpp @@ -36,6 +36,7 @@ #include "qquickrangeslider_p.h" #include "qquickcontrol_p_p.h" +#include "qquickdeferredexecute_p_p.h" #include <QtCore/qscopedpointer.h> #include <QtQuick/private/qquickwindow_p.h> @@ -109,13 +110,15 @@ public: void setPosition(qreal position, bool ignoreOtherPosition = false); void updatePosition(bool ignoreOtherPosition = false); + void executeHandle(bool complete = false); + static QQuickRangeSliderNodePrivate *get(QQuickRangeSliderNode *node); qreal value; bool isPendingValue; qreal pendingValue; qreal position; - QQuickItem *handle; + QQuickDeferredPointer<QQuickItem> handle; QQuickRangeSlider *slider; bool pressed; bool hovered; @@ -149,6 +152,20 @@ void QQuickRangeSliderNodePrivate::updatePosition(bool ignoreOtherPosition) setPosition(pos, ignoreOtherPosition); } +static inline QString handleName() { return QStringLiteral("handle"); } + +void QQuickRangeSliderNodePrivate::executeHandle(bool complete) +{ + Q_Q(QQuickRangeSliderNode); + if (handle.wasExecuted()) + return; + + if (!handle) + quickBeginDeferred(q, handleName(), handle); + if (complete) + quickCompleteDeferred(q, handleName(), handle); +} + QQuickRangeSliderNodePrivate *QQuickRangeSliderNodePrivate::get(QQuickRangeSliderNode *node) { return node->d_func(); @@ -227,7 +244,9 @@ qreal QQuickRangeSliderNode::visualPosition() const QQuickItem *QQuickRangeSliderNode::handle() const { - Q_D(const QQuickRangeSliderNode); + QQuickRangeSliderNodePrivate *d = const_cast<QQuickRangeSliderNodePrivate *>(d_func()); + if (!d->handle) + d->executeHandle(); return d->handle; } @@ -237,7 +256,7 @@ void QQuickRangeSliderNode::setHandle(QQuickItem *handle) if (d->handle == handle) return; - QQuickControlPrivate::destroyDelegate(d->handle, d->slider); + delete d->handle; d->handle = handle; if (handle) { if (!handle->parentItem()) @@ -263,7 +282,8 @@ void QQuickRangeSliderNode::setHandle(QQuickItem *handle) handle->setActiveFocusOnTab(true); } - emit handleChanged(); + if (!d->handle.isExecuting()) + emit handleChanged(); } bool QQuickRangeSliderNode::isPressed() const @@ -1077,13 +1097,27 @@ void QQuickRangeSlider::mirrorChange() emit d->second->visualPositionChanged(); } -void QQuickRangeSlider::componentComplete() +void QQuickRangeSlider::classBegin() { Q_D(QQuickRangeSlider); - QQuickControl::componentComplete(); + QQuickControl::classBegin(); + QQmlContext *context = qmlContext(this); + if (context) { + QQmlEngine::setContextForObject(d->first, context); + QQmlEngine::setContextForObject(d->second, context); + } +} + +void QQuickRangeSlider::componentComplete() +{ + Q_D(QQuickRangeSlider); QQuickRangeSliderNodePrivate *firstPrivate = QQuickRangeSliderNodePrivate::get(d->first); QQuickRangeSliderNodePrivate *secondPrivate = QQuickRangeSliderNodePrivate::get(d->second); + firstPrivate->executeHandle(true); + secondPrivate->executeHandle(true); + + QQuickControl::componentComplete(); if (firstPrivate->isPendingValue || secondPrivate->isPendingValue || !qFuzzyCompare(d->from, defaultFrom) || !qFuzzyCompare(d->to, defaultTo)) { diff --git a/src/quicktemplates2/qquickrangeslider_p.h b/src/quicktemplates2/qquickrangeslider_p.h index ef6e5677..a6326441 100644 --- a/src/quicktemplates2/qquickrangeslider_p.h +++ b/src/quicktemplates2/qquickrangeslider_p.h @@ -131,6 +131,7 @@ protected: void touchEvent(QTouchEvent *event) override; #endif void mirrorChange() override; + void classBegin() override; void componentComplete() override; #if QT_CONFIG(accessibility) @@ -156,6 +157,7 @@ class Q_QUICKTEMPLATES2_PRIVATE_EXPORT QQuickRangeSliderNode : public QObject Q_PROPERTY(bool pressed READ isPressed WRITE setPressed NOTIFY pressedChanged FINAL) // 2.1 (Qt 5.8) Q_PROPERTY(bool hovered READ isHovered WRITE setHovered NOTIFY hoveredChanged FINAL REVISION 1) + Q_CLASSINFO("DeferredPropertyNames", "handle") public: explicit QQuickRangeSliderNode(qreal value, QQuickRangeSlider *slider); diff --git a/src/quicktemplates2/qquickscrollview.cpp b/src/quicktemplates2/qquickscrollview.cpp index fa9a6c3b..254a90d7 100644 --- a/src/quicktemplates2/qquickscrollview.cpp +++ b/src/quicktemplates2/qquickscrollview.cpp @@ -146,6 +146,8 @@ QQuickScrollViewPrivate::QQuickScrollViewPrivate() QQuickItem *QQuickScrollViewPrivate::getContentItem() { + if (!contentItem) + executeContentItem(); return ensureFlickable(false); } diff --git a/src/quicktemplates2/qquickshortcutcontext.cpp b/src/quicktemplates2/qquickshortcutcontext.cpp index b44c723b..b491cab2 100644 --- a/src/quicktemplates2/qquickshortcutcontext.cpp +++ b/src/quicktemplates2/qquickshortcutcontext.cpp @@ -42,6 +42,7 @@ #include "qquickmenubaritem_p.h" #include <QtGui/qguiapplication.h> +#include <QtQuick/qquickrendercontrol.h> QT_BEGIN_NAMESPACE @@ -84,6 +85,8 @@ bool QQuickShortcutContext::matcher(QObject *obj, Qt::ShortcutContext context) item = popup->popupItem(); } } + if (QWindow *renderWindow = QQuickRenderControl::renderWindowFor(qobject_cast<QQuickWindow *>(obj))) + obj = renderWindow; return obj && obj == QGuiApplication::focusWindow() && !isBlockedByPopup(item); default: return false; diff --git a/src/quicktemplates2/qquickslider.cpp b/src/quicktemplates2/qquickslider.cpp index b358663d..21aeda39 100644 --- a/src/quicktemplates2/qquickslider.cpp +++ b/src/quicktemplates2/qquickslider.cpp @@ -36,6 +36,7 @@ #include "qquickslider_p.h" #include "qquickcontrol_p_p.h" +#include "qquickdeferredexecute_p_p.h" #include <QtQuick/private/qquickwindow_p.h> @@ -112,6 +113,8 @@ public: void handleRelease(const QPointF &point) override; void handleUngrab() override; + void executeHandle(bool complete = false); + qreal from; qreal to; qreal value; @@ -122,7 +125,7 @@ public: QPointF pressPoint; Qt::Orientation orientation; QQuickSlider::SnapMode snapMode; - QQuickItem *handle; + QQuickDeferredPointer<QQuickItem> handle; }; qreal QQuickSliderPrivate::snapPosition(qreal position) const @@ -235,6 +238,20 @@ void QQuickSliderPrivate::handleUngrab() q->setPressed(false); } +static inline QString handleName() { return QStringLiteral("handle"); } + +void QQuickSliderPrivate::executeHandle(bool complete) +{ + Q_Q(QQuickSlider); + if (handle.wasExecuted()) + return; + + if (!handle) + quickBeginDeferred(q, handleName(), handle); + if (complete) + quickCompleteDeferred(q, handleName(), handle); +} + QQuickSlider::QQuickSlider(QQuickItem *parent) : QQuickControl(*(new QQuickSliderPrivate), parent) { @@ -517,7 +534,9 @@ void QQuickSlider::setOrientation(Qt::Orientation orientation) */ QQuickItem *QQuickSlider::handle() const { - Q_D(const QQuickSlider); + QQuickSliderPrivate *d = const_cast<QQuickSliderPrivate *>(d_func()); + if (!d->handle) + d->executeHandle(); return d->handle; } @@ -527,11 +546,12 @@ void QQuickSlider::setHandle(QQuickItem *handle) if (d->handle == handle) return; - QQuickControlPrivate::destroyDelegate(d->handle, this); + delete d->handle; d->handle = handle; if (handle && !handle->parentItem()) handle->setParentItem(this); - emit handleChanged(); + if (!d->handle.isExecuting()) + emit handleChanged(); } /*! @@ -736,6 +756,7 @@ void QQuickSlider::mirrorChange() void QQuickSlider::componentComplete() { Q_D(QQuickSlider); + d->executeHandle(true); QQuickControl::componentComplete(); setValue(d->value); d->updatePosition(); diff --git a/src/quicktemplates2/qquickslider_p.h b/src/quicktemplates2/qquickslider_p.h index b2f4897c..95545462 100644 --- a/src/quicktemplates2/qquickslider_p.h +++ b/src/quicktemplates2/qquickslider_p.h @@ -71,6 +71,7 @@ class Q_QUICKTEMPLATES2_PRIVATE_EXPORT QQuickSlider : public QQuickControl // 2.3 (Qt 5.10) Q_PROPERTY(bool horizontal READ isHorizontal NOTIFY orientationChanged FINAL REVISION 3) Q_PROPERTY(bool vertical READ isVertical NOTIFY orientationChanged FINAL REVISION 3) + Q_CLASSINFO("DeferredPropertyNames", "background,handle") public: explicit QQuickSlider(QQuickItem *parent = nullptr); diff --git a/src/quicktemplates2/qquickspinbox.cpp b/src/quicktemplates2/qquickspinbox.cpp index 588944af..f7af2015 100644 --- a/src/quicktemplates2/qquickspinbox.cpp +++ b/src/quicktemplates2/qquickspinbox.cpp @@ -36,6 +36,7 @@ #include "qquickspinbox_p.h" #include "qquickcontrol_p_p.h" +#include "qquickdeferredexecute_p_p.h" #include <QtGui/qguiapplication.h> #include <QtGui/qstylehints.h> @@ -166,6 +167,30 @@ public: Qt::InputMethodHints inputMethodHints; }; +class QQuickSpinButtonPrivate : public QObjectPrivate +{ + Q_DECLARE_PUBLIC(QQuickSpinButton) + +public: + QQuickSpinButtonPrivate() + : pressed(false), + hovered(false), + indicator(nullptr) + { + } + + static QQuickSpinButtonPrivate *get(QQuickSpinButton *button) + { + return button->d_func(); + } + + void executeIndicator(bool complete = false); + + bool pressed; + bool hovered; + QQuickDeferredPointer<QQuickItem> indicator; +}; + int QQuickSpinBoxPrivate::boundValue(int value, bool wrap) const { bool inverted = from > to; @@ -934,9 +959,24 @@ void QQuickSpinBox::wheelEvent(QWheelEvent *event) } #endif +void QQuickSpinBox::classBegin() +{ + Q_D(QQuickSpinBox); + QQuickControl::classBegin(); + + QQmlContext *context = qmlContext(this); + if (context) { + QQmlEngine::setContextForObject(d->up, context); + QQmlEngine::setContextForObject(d->down, context); + } +} + void QQuickSpinBox::componentComplete() { Q_D(QQuickSpinBox); + QQuickSpinButtonPrivate::get(d->up)->executeIndicator(true); + QQuickSpinButtonPrivate::get(d->down)->executeIndicator(true); + QQuickControl::componentComplete(); if (!d->setValue(d->value, /* allowWrap = */ false, /* modified = */ false)) { d->updateDisplayText(); @@ -961,6 +1001,8 @@ void QQuickSpinBox::contentItemChange(QQuickItem *newItem, QQuickItem *oldItem) if (newItem) { newItem->setActiveFocusOnTab(true); + if (d->activeFocus) + newItem->forceActiveFocus(d->focusReason); #if QT_CONFIG(cursor) if (d->editable) newItem->setCursor(Qt::IBeamCursor); @@ -1004,20 +1046,19 @@ void QQuickSpinBox::accessibilityActiveChanged(bool active) } #endif -class QQuickSpinButtonPrivate : public QObjectPrivate +static inline QString indicatorName() { return QStringLiteral("indicator"); } + +void QQuickSpinButtonPrivate::executeIndicator(bool complete) { -public: - QQuickSpinButtonPrivate() - : pressed(false), - hovered(false), - indicator(nullptr) - { - } + Q_Q(QQuickSpinButton); + if (indicator.wasExecuted()) + return; - bool pressed; - bool hovered; - QQuickItem *indicator; -}; + if (!indicator) + quickBeginDeferred(q, indicatorName(), indicator); + if (complete) + quickCompleteDeferred(q, indicatorName(), indicator); +} QQuickSpinButton::QQuickSpinButton(QQuickSpinBox *parent) : QObject(*(new QQuickSpinButtonPrivate), parent) @@ -1042,7 +1083,9 @@ void QQuickSpinButton::setPressed(bool pressed) QQuickItem *QQuickSpinButton::indicator() const { - Q_D(const QQuickSpinButton); + QQuickSpinButtonPrivate *d = const_cast<QQuickSpinButtonPrivate *>(d_func()); + if (!d->indicator) + d->executeIndicator(); return d->indicator; } @@ -1052,14 +1095,15 @@ void QQuickSpinButton::setIndicator(QQuickItem *indicator) if (d->indicator == indicator) return; - QQuickControlPrivate::destroyDelegate(d->indicator, d->parent); + delete d->indicator; d->indicator = indicator; if (indicator) { if (!indicator->parentItem()) indicator->setParentItem(static_cast<QQuickItem *>(parent())); } - emit indicatorChanged(); + if (!d->indicator.isExecuting()) + emit indicatorChanged(); } bool QQuickSpinButton::isHovered() const diff --git a/src/quicktemplates2/qquickspinbox_p.h b/src/quicktemplates2/qquickspinbox_p.h index 8e537f72..f5370331 100644 --- a/src/quicktemplates2/qquickspinbox_p.h +++ b/src/quicktemplates2/qquickspinbox_p.h @@ -156,6 +156,7 @@ protected: void wheelEvent(QWheelEvent *event) override; #endif + void classBegin() override; void componentComplete() override; void itemChange(ItemChange change, const ItemChangeData &value) override; void contentItemChange(QQuickItem *newItem, QQuickItem *oldItem) override; @@ -181,6 +182,7 @@ class Q_QUICKTEMPLATES2_PRIVATE_EXPORT QQuickSpinButton : public QObject Q_PROPERTY(QQuickItem *indicator READ indicator WRITE setIndicator NOTIFY indicatorChanged FINAL) // 2.1 (Qt 5.8) Q_PROPERTY(bool hovered READ isHovered WRITE setHovered NOTIFY hoveredChanged FINAL REVISION 1) + Q_CLASSINFO("DeferredPropertyNames", "indicator") public: explicit QQuickSpinButton(QQuickSpinBox *parent); diff --git a/src/quicktemplates2/qquicktextarea.cpp b/src/quicktemplates2/qquicktextarea.cpp index 02e84a35..d2458c24 100644 --- a/src/quicktemplates2/qquicktextarea.cpp +++ b/src/quicktemplates2/qquicktextarea.cpp @@ -39,6 +39,7 @@ #include "qquickcontrol_p.h" #include "qquickcontrol_p_p.h" #include "qquickscrollview_p.h" +#include "qquickdeferredexecute_p_p.h" #include <QtQml/qqmlinfo.h> #include <QtQuick/private/qquickitem_p.h> @@ -437,6 +438,20 @@ QAccessible::Role QQuickTextAreaPrivate::accessibleRole() const } #endif +static inline QString backgroundName() { return QStringLiteral("background"); } + +void QQuickTextAreaPrivate::executeBackground(bool complete) +{ + Q_Q(QQuickTextArea); + if (background.wasExecuted()) + return; + + if (!background) + quickBeginDeferred(q, backgroundName(), background); + if (complete) + quickCompleteDeferred(q, backgroundName(), background); +} + QQuickTextArea::QQuickTextArea(QQuickItem *parent) : QQuickTextEdit(*(new QQuickTextAreaPrivate), parent) { @@ -490,7 +505,9 @@ void QQuickTextArea::setFont(const QFont &font) */ QQuickItem *QQuickTextArea::background() const { - Q_D(const QQuickTextArea); + QQuickTextAreaPrivate *d = const_cast<QQuickTextAreaPrivate *>(d_func()); + if (!d->background) + d->executeBackground(); return d->background; } @@ -500,7 +517,7 @@ void QQuickTextArea::setBackground(QQuickItem *background) if (d->background == background) return; - QQuickControlPrivate::destroyDelegate(d->background, this); + delete d->background; d->background = background; if (background) { background->setParentItem(this); @@ -509,7 +526,8 @@ void QQuickTextArea::setBackground(QQuickItem *background) if (isComponentComplete()) d->resizeBackground(); } - emit backgroundChanged(); + if (!d->background.isExecuting()) + emit backgroundChanged(); } /*! @@ -686,6 +704,7 @@ void QQuickTextArea::classBegin() void QQuickTextArea::componentComplete() { Q_D(QQuickTextArea); + d->executeBackground(true); QQuickTextEdit::componentComplete(); #if QT_CONFIG(quicktemplates2_hover) if (!d->explicitHoverEnabled) diff --git a/src/quicktemplates2/qquicktextarea_p.h b/src/quicktemplates2/qquicktextarea_p.h index 26799532..5482ceae 100644 --- a/src/quicktemplates2/qquicktextarea_p.h +++ b/src/quicktemplates2/qquicktextarea_p.h @@ -73,6 +73,7 @@ class Q_QUICKTEMPLATES2_PRIVATE_EXPORT QQuickTextArea : public QQuickTextEdit Q_PROPERTY(bool hoverEnabled READ isHoverEnabled WRITE setHoverEnabled RESET resetHoverEnabled NOTIFY hoverEnabledChanged FINAL REVISION 1) // 2.3 (Qt 5.10) Q_PROPERTY(QPalette palette READ palette WRITE setPalette RESET resetPalette NOTIFY paletteChanged FINAL REVISION 3) + Q_CLASSINFO("DeferredPropertyNames", "background") public: explicit QQuickTextArea(QQuickItem *parent = nullptr); diff --git a/src/quicktemplates2/qquicktextarea_p_p.h b/src/quicktemplates2/qquicktextarea_p_p.h index 32f53c4f..d27af8f6 100644 --- a/src/quicktemplates2/qquicktextarea_p_p.h +++ b/src/quicktemplates2/qquicktextarea_p_p.h @@ -52,6 +52,7 @@ #include <QtQuick/private/qquicktextedit_p_p.h> #include <QtQuick/private/qquickitemchangelistener_p.h> #include <QtQuickTemplates2/private/qquickpresshandler_p_p.h> +#include <QtQuickTemplates2/private/qquickdeferredpointer_p_p.h> #include <QtQuickTemplates2/private/qquicktextarea_p.h> @@ -124,6 +125,8 @@ public: QAccessible::Role accessibleRole() const override; #endif + void executeBackground(bool complete = false); + #if QT_CONFIG(quicktemplates2_hover) bool hovered; bool explicitHoverEnabled; @@ -136,7 +139,7 @@ public: QLazilyAllocated<ExtraData> extra; QPalette resolvedPalette; - QQuickItem *background; + QQuickDeferredPointer<QQuickItem> background; QString placeholder; Qt::FocusReason focusReason; QQuickPressHandler pressHandler; diff --git a/src/quicktemplates2/qquicktextfield.cpp b/src/quicktemplates2/qquicktextfield.cpp index fba0e67c..03da9323 100644 --- a/src/quicktemplates2/qquicktextfield.cpp +++ b/src/quicktemplates2/qquicktextfield.cpp @@ -38,6 +38,7 @@ #include "qquicktextfield_p_p.h" #include "qquickcontrol_p.h" #include "qquickcontrol_p_p.h" +#include "qquickdeferredexecute_p_p.h" #include <QtQuick/private/qquickitem_p.h> #include <QtQuick/private/qquicktextinput_p.h> @@ -311,6 +312,20 @@ QAccessible::Role QQuickTextFieldPrivate::accessibleRole() const } #endif +static inline QString backgroundName() { return QStringLiteral("background"); } + +void QQuickTextFieldPrivate::executeBackground(bool complete) +{ + Q_Q(QQuickTextField); + if (background.wasExecuted()) + return; + + if (!background) + quickBeginDeferred(q, backgroundName(), background); + if (complete) + quickCompleteDeferred(q, backgroundName(), background); +} + QQuickTextField::QQuickTextField(QQuickItem *parent) : QQuickTextInput(*(new QQuickTextFieldPrivate), parent) { @@ -352,7 +367,9 @@ void QQuickTextField::setFont(const QFont &font) */ QQuickItem *QQuickTextField::background() const { - Q_D(const QQuickTextField); + QQuickTextFieldPrivate *d = const_cast<QQuickTextFieldPrivate *>(d_func()); + if (!d->background) + d->executeBackground(); return d->background; } @@ -362,7 +379,7 @@ void QQuickTextField::setBackground(QQuickItem *background) if (d->background == background) return; - QQuickControlPrivate::destroyDelegate(d->background, this); + delete d->background; d->background = background; if (background) { background->setParentItem(this); @@ -371,7 +388,8 @@ void QQuickTextField::setBackground(QQuickItem *background) if (isComponentComplete()) d->resizeBackground(); } - emit backgroundChanged(); + if (!d->background.isExecuting()) + emit backgroundChanged(); } /*! @@ -540,6 +558,7 @@ void QQuickTextField::classBegin() void QQuickTextField::componentComplete() { Q_D(QQuickTextField); + d->executeBackground(true); QQuickTextInput::componentComplete(); #if QT_CONFIG(quicktemplates2_hover) if (!d->explicitHoverEnabled) diff --git a/src/quicktemplates2/qquicktextfield_p.h b/src/quicktemplates2/qquicktextfield_p.h index 7dab0caf..4757bd2d 100644 --- a/src/quicktemplates2/qquicktextfield_p.h +++ b/src/quicktemplates2/qquicktextfield_p.h @@ -72,6 +72,7 @@ class Q_QUICKTEMPLATES2_PRIVATE_EXPORT QQuickTextField : public QQuickTextInput Q_PROPERTY(bool hoverEnabled READ isHoverEnabled WRITE setHoverEnabled RESET resetHoverEnabled NOTIFY hoverEnabledChanged FINAL REVISION 1) // 2.3 (Qt 5.10) Q_PROPERTY(QPalette palette READ palette WRITE setPalette RESET resetPalette NOTIFY paletteChanged FINAL REVISION 3) + Q_CLASSINFO("DeferredPropertyNames", "background") public: explicit QQuickTextField(QQuickItem *parent = nullptr); diff --git a/src/quicktemplates2/qquicktextfield_p_p.h b/src/quicktemplates2/qquicktextfield_p_p.h index 65767452..5ae79b7f 100644 --- a/src/quicktemplates2/qquicktextfield_p_p.h +++ b/src/quicktemplates2/qquicktextfield_p_p.h @@ -51,6 +51,7 @@ #include <QtQml/private/qlazilyallocated_p.h> #include <QtQuick/private/qquicktextinput_p_p.h> #include <QtQuickTemplates2/private/qquickpresshandler_p_p.h> +#include <QtQuickTemplates2/private/qquickdeferredpointer_p_p.h> #include <QtQuickTemplates2/private/qquicktextfield_p.h> @@ -112,6 +113,8 @@ public: QAccessible::Role accessibleRole() const override; #endif + void executeBackground(bool complete = false); + #if QT_CONFIG(quicktemplates2_hover) bool hovered; bool explicitHoverEnabled; @@ -124,7 +127,7 @@ public: QLazilyAllocated<ExtraData> extra; QPalette resolvedPalette; - QQuickItem *background; + QQuickDeferredPointer<QQuickItem> background; QString placeholder; Qt::FocusReason focusReason; QQuickPressHandler pressHandler; diff --git a/src/quicktemplates2/qquicktumbler_p.h b/src/quicktemplates2/qquicktumbler_p.h index 5d4df4a7..c388c28d 100644 --- a/src/quicktemplates2/qquicktumbler_p.h +++ b/src/quicktemplates2/qquicktumbler_p.h @@ -70,6 +70,7 @@ class Q_QUICKTEMPLATES2_PRIVATE_EXPORT QQuickTumbler : public QQuickControl Q_PROPERTY(bool wrap READ wrap WRITE setWrap RESET resetWrap NOTIFY wrapChanged FINAL REVISION 1) // 2.2 (Qt 5.9) Q_PROPERTY(bool moving READ isMoving NOTIFY movingChanged FINAL REVISION 2) + Q_CLASSINFO("DeferredPropertyNames", "background") public: explicit QQuickTumbler(QQuickItem *parent = nullptr); diff --git a/src/quicktemplates2/quicktemplates2.pri b/src/quicktemplates2/quicktemplates2.pri index a90b4f94..ee51f995 100644 --- a/src/quicktemplates2/quicktemplates2.pri +++ b/src/quicktemplates2/quicktemplates2.pri @@ -17,6 +17,8 @@ HEADERS += \ $$PWD/qquickcontainer_p_p.h \ $$PWD/qquickcontrol_p.h \ $$PWD/qquickcontrol_p_p.h \ + $$PWD/qquickdeferredexecute_p_p.h \ + $$PWD/qquickdeferredpointer_p_p.h \ $$PWD/qquickdelaybutton_p.h \ $$PWD/qquickdial_p.h \ $$PWD/qquickdialog_p.h \ @@ -102,6 +104,7 @@ SOURCES += \ $$PWD/qquickcombobox.cpp \ $$PWD/qquickcontainer.cpp \ $$PWD/qquickcontrol.cpp \ + $$PWD/qquickdeferredexecute.cpp \ $$PWD/qquickdelaybutton.cpp \ $$PWD/qquickdial.cpp \ $$PWD/qquickdialog.cpp \ |