diff options
-rw-r--r-- | src/imports/controls/designer/ControlSection.qml | 4 | ||||
-rw-r--r-- | src/imports/controls/designer/DialSpecifics.qml | 12 | ||||
-rw-r--r-- | src/imports/controls/designer/InsetSection.qml | 119 | ||||
-rw-r--r-- | src/imports/controls/designer/LabelSpecifics.qml | 4 | ||||
-rw-r--r-- | src/imports/controls/designer/PageIndicatorSpecifics.qml | 16 | ||||
-rw-r--r-- | src/imports/controls/designer/RangeSliderSpecifics.qml | 14 | ||||
-rw-r--r-- | src/imports/controls/designer/RoundButtonSpecifics.qml | 5 | ||||
-rw-r--r-- | src/imports/controls/designer/SliderSpecifics.qml | 14 | ||||
-rw-r--r-- | src/imports/controls/designer/SpinBoxSpecifics.qml | 12 | ||||
-rw-r--r-- | src/imports/controls/designer/TextAreaSpecifics.qml | 27 | ||||
-rw-r--r-- | src/imports/controls/designer/TextFieldSpecifics.qml | 27 | ||||
-rw-r--r-- | src/imports/controls/designer/designer.pri | 1 | ||||
-rw-r--r-- | src/quicktemplates2/qquickcombobox.cpp | 12 | ||||
-rw-r--r-- | tests/auto/controls/data/tst_combobox.qml | 49 |
14 files changed, 302 insertions, 14 deletions
diff --git a/src/imports/controls/designer/ControlSection.qml b/src/imports/controls/designer/ControlSection.qml index 7c53ac73..3446c08f 100644 --- a/src/imports/controls/designer/ControlSection.qml +++ b/src/imports/controls/designer/ControlSection.qml @@ -69,7 +69,7 @@ Section { Label { text: qsTr("Hover") - tooltip: qsTr("Whether control accepts hover evets.") + tooltip: qsTr("Whether control accepts hover events.") } SecondColumnLayout { CheckBox { @@ -95,7 +95,7 @@ Section { Label { text: qsTr("Wheel") - tooltip: qsTr("Whether control accepts wheel evets.") + tooltip: qsTr("Whether control accepts wheel events.") } SecondColumnLayout { CheckBox { diff --git a/src/imports/controls/designer/DialSpecifics.qml b/src/imports/controls/designer/DialSpecifics.qml index fc5b5e83..45f647f1 100644 --- a/src/imports/controls/designer/DialSpecifics.qml +++ b/src/imports/controls/designer/DialSpecifics.qml @@ -143,6 +143,18 @@ Column { Layout.fillWidth: true } } + + Label { + text: qsTr("Wrap") + tooltip: qsTr("Whether the dial wraps when dragged.") + } + SecondColumnLayout { + CheckBox { + text: backendValues.wrap.valueToString + backendValue: backendValues.wrap + Layout.fillWidth: true + } + } } } diff --git a/src/imports/controls/designer/InsetSection.qml b/src/imports/controls/designer/InsetSection.qml new file mode 100644 index 00000000..4253b170 --- /dev/null +++ b/src/imports/controls/designer/InsetSection.qml @@ -0,0 +1,119 @@ +/**************************************************************************** +** +** Copyright (C) 2020 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.12 +import HelperWidgets 2.0 +import QtQuick.Layouts 1.12 + +Section { + caption: qsTr("Inset") + + SectionLayout { + Label { + text: qsTr("Vertical") + } + SecondColumnLayout { + Label { + text: qsTr("Top") + tooltip: qsTr("Top inset for the background.") + width: 42 + } + SpinBox { + maximumValue: 10000 + minimumValue: -10000 + realDragRange: 5000 + decimals: 0 + backendValue: backendValues.topInset + Layout.fillWidth: true + } + Item { + width: 4 + height: 4 + } + + Label { + text: qsTr("Bottom") + tooltip: qsTr("Bottom inset for the background.") + width: 42 + } + SpinBox { + maximumValue: 10000 + minimumValue: -10000 + realDragRange: 5000 + decimals: 0 + backendValue: backendValues.bottomInset + Layout.fillWidth: true + } + } + + Label { + text: qsTr("Horizontal") + } + SecondColumnLayout { + Label { + text: qsTr("Left") + tooltip: qsTr("Left inset for the background.") + width: 42 + } + SpinBox { + maximumValue: 10000 + minimumValue: -10000 + realDragRange: 5000 + decimals: 0 + backendValue: backendValues.leftInset + Layout.fillWidth: true + } + Item { + width: 4 + height: 4 + } + + Label { + text: qsTr("Right") + tooltip: qsTr("Right inset for the background.") + width: 42 + } + SpinBox { + maximumValue: 10000 + minimumValue: -10000 + realDragRange: 5000 + decimals: 0 + backendValue: backendValues.rightInset + Layout.fillWidth: true + } + } + } +} diff --git a/src/imports/controls/designer/LabelSpecifics.qml b/src/imports/controls/designer/LabelSpecifics.qml index c832f894..e5d5e04f 100644 --- a/src/imports/controls/designer/LabelSpecifics.qml +++ b/src/imports/controls/designer/LabelSpecifics.qml @@ -79,4 +79,8 @@ Column { PaddingSection { width: parent.width } + + InsetSection { + width: parent.width + } } diff --git a/src/imports/controls/designer/PageIndicatorSpecifics.qml b/src/imports/controls/designer/PageIndicatorSpecifics.qml index 042672a9..20aa8577 100644 --- a/src/imports/controls/designer/PageIndicatorSpecifics.qml +++ b/src/imports/controls/designer/PageIndicatorSpecifics.qml @@ -73,6 +73,18 @@ Column { Layout.fillWidth: true } } + + Label { + text: qsTr("Interactive") + tooltip: qsTr("Whether the control is interactive.") + } + SecondColumnLayout { + CheckBox { + text: backendValues.interactive.valueToString + backendValue: backendValues.interactive + Layout.fillWidth: true + } + } } } @@ -80,10 +92,6 @@ Column { width: parent.width } - FontSection { - width: parent.width - } - PaddingSection { width: parent.width } diff --git a/src/imports/controls/designer/RangeSliderSpecifics.qml b/src/imports/controls/designer/RangeSliderSpecifics.qml index 79d2404f..2324a66f 100644 --- a/src/imports/controls/designer/RangeSliderSpecifics.qml +++ b/src/imports/controls/designer/RangeSliderSpecifics.qml @@ -158,6 +158,20 @@ Column { Layout.fillWidth: true } } + + Label { + text: qsTr("Touch drag threshold") + tooltip: qsTr("The threshold (in logical pixels) at which a touch drag event will be initiated.") + } + SecondColumnLayout { + SpinBox { + minimumValue: 0 + maximumValue: 10000 + decimals: 0 + backendValue: backendValues.touchDragThreshold + Layout.fillWidth: true + } + } } } diff --git a/src/imports/controls/designer/RoundButtonSpecifics.qml b/src/imports/controls/designer/RoundButtonSpecifics.qml index 2da4cda6..af4ab5d0 100644 --- a/src/imports/controls/designer/RoundButtonSpecifics.qml +++ b/src/imports/controls/designer/RoundButtonSpecifics.qml @@ -42,6 +42,7 @@ Column { width: parent.width Section { + width: parent.width caption: qsTr("RoundButton") SectionLayout { @@ -51,8 +52,8 @@ Column { } SecondColumnLayout { SpinBox { - maximumValue: 9999999 - minimumValue: -9999999 + minimumValue: 0 + maximumValue: 10000 decimals: 0 backendValue: backendValues.radius Layout.fillWidth: true diff --git a/src/imports/controls/designer/SliderSpecifics.qml b/src/imports/controls/designer/SliderSpecifics.qml index 076d8a1c..d126dd06 100644 --- a/src/imports/controls/designer/SliderSpecifics.qml +++ b/src/imports/controls/designer/SliderSpecifics.qml @@ -143,6 +143,20 @@ Column { Layout.fillWidth: true } } + + Label { + text: qsTr("Touch drag threshold") + tooltip: qsTr("The threshold (in logical pixels) at which a touch drag event will be initiated.") + } + SecondColumnLayout { + SpinBox { + minimumValue: 0 + maximumValue: 10000 + decimals: 0 + backendValue: backendValues.touchDragThreshold + Layout.fillWidth: true + } + } } } diff --git a/src/imports/controls/designer/SpinBoxSpecifics.qml b/src/imports/controls/designer/SpinBoxSpecifics.qml index d6375d7c..db59f074 100644 --- a/src/imports/controls/designer/SpinBoxSpecifics.qml +++ b/src/imports/controls/designer/SpinBoxSpecifics.qml @@ -113,6 +113,18 @@ Column { Layout.fillWidth: true } } + + Label { + text: qsTr("Wrap") + tooltip: qsTr("Whether the spinbox wraps.") + } + SecondColumnLayout { + CheckBox { + text: backendValues.wrap.valueToString + backendValue: backendValues.wrap + Layout.fillWidth: true + } + } } } diff --git a/src/imports/controls/designer/TextAreaSpecifics.qml b/src/imports/controls/designer/TextAreaSpecifics.qml index a14584e7..f8cf92e8 100644 --- a/src/imports/controls/designer/TextAreaSpecifics.qml +++ b/src/imports/controls/designer/TextAreaSpecifics.qml @@ -57,6 +57,29 @@ Column { } } + + Label { + text: qsTr("Hover") + tooltip: qsTr("Whether text area accepts hover events.") + } + SecondColumnLayout { + CheckBox { + text: backendValues.hoverEnabled.valueToString + backendValue: backendValues.hoverEnabled + Layout.fillWidth: true + } + } + } + } + + Section { + width: parent.width + caption: qsTr("Placeholder Text Color") + + ColorEditor { + caption: qsTr("Placeholder Text Color") + backendValue: backendValues.placeholderTextColor + supportGradient: false } } @@ -74,4 +97,8 @@ Column { PaddingSection { width: parent.width } + + InsetSection { + width: parent.width + } } diff --git a/src/imports/controls/designer/TextFieldSpecifics.qml b/src/imports/controls/designer/TextFieldSpecifics.qml index 67a63ec4..f95f282c 100644 --- a/src/imports/controls/designer/TextFieldSpecifics.qml +++ b/src/imports/controls/designer/TextFieldSpecifics.qml @@ -57,6 +57,29 @@ Column { } } + + Label { + text: qsTr("Hover") + tooltip: qsTr("Whether text field accepts hover events.") + } + SecondColumnLayout { + CheckBox { + text: backendValues.hoverEnabled.valueToString + backendValue: backendValues.hoverEnabled + Layout.fillWidth: true + } + } + } + } + + Section { + width: parent.width + caption: qsTr("Placeholder Text Color") + + ColorEditor { + caption: qsTr("Placeholder Text Color") + backendValue: backendValues.placeholderTextColor + supportGradient: false } } @@ -71,4 +94,8 @@ Column { PaddingSection { width: parent.width } + + InsetSection { + width: parent.width + } } diff --git a/src/imports/controls/designer/designer.pri b/src/imports/controls/designer/designer.pri index 3ad99df7..6692b203 100644 --- a/src/imports/controls/designer/designer.pri +++ b/src/imports/controls/designer/designer.pri @@ -17,6 +17,7 @@ AUX_QML_FILES += \ $$PWD/DialSpecifics.qml \ $$PWD/FrameSpecifics.qml \ $$PWD/GroupBoxSpecifics.qml \ + $$PWD/InsetSection.qml \ $$PWD/ItemDelegateSection.qml \ $$PWD/ItemDelegateSpecifics.qml \ $$PWD/LabelSpecifics.qml \ diff --git a/src/quicktemplates2/qquickcombobox.cpp b/src/quicktemplates2/qquickcombobox.cpp index d9bbd2bd..d7a67325 100644 --- a/src/quicktemplates2/qquickcombobox.cpp +++ b/src/quicktemplates2/qquickcombobox.cpp @@ -404,13 +404,13 @@ void QQuickComboBoxPrivate::createdItem(int index, QObject *object) } if (index == currentIndex && !q->isEditable()) - updateCurrentText(); + updateCurrentTextAndValue(); } void QQuickComboBoxPrivate::modelUpdated() { if (!extra.isAllocated() || !extra->accepting) - updateCurrentText(); + updateCurrentTextAndValue(); } void QQuickComboBoxPrivate::countChanged() @@ -866,11 +866,11 @@ void QQuickComboBox::setModel(const QVariant& m) if (QAbstractItemModel* aim = qvariant_cast<QAbstractItemModel *>(d->model)) { QObjectPrivate::disconnect(aim, &QAbstractItemModel::dataChanged, - d, QOverload<>::of(&QQuickComboBoxPrivate::updateCurrentText)); + d, QOverload<>::of(&QQuickComboBoxPrivate::updateCurrentTextAndValue)); } if (QAbstractItemModel* aim = qvariant_cast<QAbstractItemModel *>(model)) { QObjectPrivate::connect(aim, &QAbstractItemModel::dataChanged, - d, QOverload<>::of(&QQuickComboBoxPrivate::updateCurrentText)); + d, QOverload<>::of(&QQuickComboBoxPrivate::updateCurrentTextAndValue)); } d->model = model; @@ -878,7 +878,7 @@ void QQuickComboBox::setModel(const QVariant& m) emit countChanged(); if (isComponentComplete()) { setCurrentIndex(count() > 0 ? 0 : -1); - d->updateCurrentText(); + d->updateCurrentTextAndValue(); } emit modelChanged(); } @@ -1869,7 +1869,7 @@ bool QQuickComboBox::event(QEvent *e) { Q_D(QQuickComboBox); if (e->type() == QEvent::LanguageChange) - d->updateCurrentText(); + d->updateCurrentTextAndValue(); return QQuickControl::event(e); } diff --git a/tests/auto/controls/data/tst_combobox.qml b/tests/auto/controls/data/tst_combobox.qml index 2d5069b3..e9156fee 100644 --- a/tests/auto/controls/data/tst_combobox.qml +++ b/tests/auto/controls/data/tst_combobox.qml @@ -296,12 +296,30 @@ TestCase { ListElement { name: "Banana"; color: "yellow" } } + Component { + id: fruitModelComponent + ListModel { + ListElement { name: "Apple"; color: "red" } + ListElement { name: "Orange"; color: "orange" } + ListElement { name: "Banana"; color: "yellow" } + } + } + property var fruitarray: [ { name: "Apple", color: "red" }, { name: "Orange", color: "orange" }, { name: "Banana", color: "yellow" } ] + Component { + id: birdModelComponent + ListModel { + ListElement { name: "Galah"; color: "pink" } + ListElement { name: "Kookaburra"; color: "brown" } + ListElement { name: "Magpie"; color: "black" } + } + } + function test_textRole_data() { return [ { tag: "ListModel", model: fruitmodel }, @@ -447,6 +465,37 @@ TestCase { compare(control.indexOfValue(data.tag), data.expectedIndex) } + function test_currentValueAfterModelChanged() { + let fruitModel = createTemporaryObject(fruitModelComponent, testCase) + verify(fruitModel) + + let control = createTemporaryObject(comboBox, testCase, + { model: fruitModel, textRole: "name", valueRole: "color", currentIndex: 1 }) + verify(control) + compare(control.currentText, "Orange") + compare(control.currentValue, "orange") + + // Remove "Apple"; the current item should now be "Banana", so currentValue should be "yellow". + fruitModel.remove(0) + compare(control.currentText, "Banana") + compare(control.currentValue, "yellow") + } + + function test_currentValueAfterNewModelSet() { + let control = createTemporaryObject(comboBox, testCase, + { model: fruitmodel, textRole: "name", valueRole: "color", currentIndex: 0 }) + verify(control) + compare(control.currentText, "Apple") + compare(control.currentValue, "red") + + // Swap the model out entirely. Since the currentIndex was 0 and + // is reset to 0 when a new model is set, it remains 0. + let birdModel = createTemporaryObject(birdModelComponent, testCase) + verify(birdModel) + control.model = birdModel + compare(control.currentText, "Galah") + compare(control.currentValue, "pink") + } function test_arrowKeys() { var control = createTemporaryObject(comboBox, testCase, |