diff options
-rw-r--r-- | src/controls/ComboBox.qml | 2 | ||||
-rw-r--r-- | src/controls/Private/qquickrangemodel_p_p.h | 6 | ||||
-rw-r--r-- | src/controls/plugins.qmltypes | 8 | ||||
-rw-r--r-- | src/extras/Styles/Flat/flatstyleplugin.cpp | 2 | ||||
-rw-r--r-- | tests/auto/controls/data/slider/rounder.qml | 75 | ||||
-rw-r--r-- | tests/auto/controls/data/tst_combobox.qml | 19 | ||||
-rw-r--r-- | tests/auto/controls/data/tst_slider.qml | 27 |
7 files changed, 134 insertions, 5 deletions
diff --git a/src/controls/ComboBox.qml b/src/controls/ComboBox.qml index 4e29dfe9..10702ff6 100644 --- a/src/controls/ComboBox.qml +++ b/src/controls/ComboBox.qml @@ -564,7 +564,7 @@ Control { style: isPopup ? __style.__popupStyle : __style.__dropDownStyle property string currentText: selectedText - onSelectedTextChanged: if (selectedText) popup.currentText = selectedText + onSelectedTextChanged: popup.currentText = selectedText property string selectedText on__SelectedIndexChanged: { diff --git a/src/controls/Private/qquickrangemodel_p_p.h b/src/controls/Private/qquickrangemodel_p_p.h index 67f0745c..235ba069 100644 --- a/src/controls/Private/qquickrangemodel_p_p.h +++ b/src/controls/Private/qquickrangemodel_p_p.h @@ -93,7 +93,11 @@ public: return minimum; const qreal scale = (maximum - minimum) / posRange; - return (pos - effectivePosAtMin()) * scale + minimum; + // Avoid perverse rounding glitches when at an end: + const qreal mid = (effectivePosAtMax() + effectivePosAtMin()) * 0.5; + if (pos < mid) + return (pos - effectivePosAtMin()) * scale + minimum; + return maximum - scale * (effectivePosAtMax() - pos); } qreal publicPosition(qreal position) const; diff --git a/src/controls/plugins.qmltypes b/src/controls/plugins.qmltypes index 866ef043..89b9260a 100644 --- a/src/controls/plugins.qmltypes +++ b/src/controls/plugins.qmltypes @@ -2339,8 +2339,12 @@ Module { name: "QQuickWindow" defaultProperty: "data" prototype: "QWindow" - exports: ["QtQuick.Window/Window 2.0"] - exportMetaObjectRevisions: [0] + exports: [ + "QtQuick.Window/Window 2.0", + "QtQuick.Window/Window 2.1", + "QtQuick.Window/Window 2.2" + ] + exportMetaObjectRevisions: [0, 1, 2] Enum { name: "SceneGraphError" values: { diff --git a/src/extras/Styles/Flat/flatstyleplugin.cpp b/src/extras/Styles/Flat/flatstyleplugin.cpp index db464c38..a207f0a0 100644 --- a/src/extras/Styles/Flat/flatstyleplugin.cpp +++ b/src/extras/Styles/Flat/flatstyleplugin.cpp @@ -69,7 +69,7 @@ QtQuickExtrasStylesPlugin::QtQuickExtrasStylesPlugin(QObject *parent) : void QtQuickExtrasStylesPlugin::registerTypes(const char *uri) { - Q_INIT_RESOURCE(flatstyle); + initResources(); const QString prefix = "qrc:/ExtrasImports/QtQuick/Controls/Styles/Flat/"; // register version 1.0 diff --git a/tests/auto/controls/data/slider/rounder.qml b/tests/auto/controls/data/slider/rounder.qml new file mode 100644 index 00000000..b7191892 --- /dev/null +++ b/tests/auto/controls/data/slider/rounder.qml @@ -0,0 +1,75 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.2 +import QtQuick.Controls 1.2 +import QtQuick.Controls.Styles 1.2 + +/* Rounding errors in the value at end of range are elusive. + * They're sensitive to fine details in hard-to-anticipate ways. + */ +Item { + visible: true + /* Sensitive to slider width */ + width: 800 + height: 400 + + /* Let test know value and where to click */ + property int waist: slider.y + slider.height / 2 + property alias value: slider.value + + Slider { + id: slider + width: parent.width + + /* Sensitive to value range. */ + minimumValue: 0 + maximumValue: 100 + + style: SliderStyle { + /* Sensitive to handle size. */ + handle: Rectangle { + implicitHeight: 26 + implicitWidth: 26 + color: "salmon" + } + } + } +} diff --git a/tests/auto/controls/data/tst_combobox.qml b/tests/auto/controls/data/tst_combobox.qml index da8c79f8..cecc3928 100644 --- a/tests/auto/controls/data/tst_combobox.qml +++ b/tests/auto/controls/data/tst_combobox.qml @@ -682,6 +682,25 @@ TestCase { return index } + function test_emptyTextItem() { + var comboBox = Qt.createQmlObject('import QtQuick.Controls 1.2 ; ComboBox { }', testCase, ''); + comboBox.model = [ + "1", + "", + "3" + ] + compare(comboBox.currentIndex, 0) + compare(comboBox.currentText, "1") + comboBox.currentIndex = 1 + compare(comboBox.currentIndex, 1) + compare(comboBox.currentText, "") + comboBox.currentIndex = 2 + compare(comboBox.currentIndex, 2) + compare(comboBox.currentText, "3") + compare(comboBox.find(""), 1) + comboBox.destroy() + } + function test_minusOneIndexResetsSelection_QTBUG_35794() { var qmlObjects = ['import QtQuick.Controls 1.2 ; ComboBox { model: ["A", "B", "C"] }', 'import QtQuick.Controls 1.2 ; ComboBox { editable: true; model: ["A", "B", "C"] }'] diff --git a/tests/auto/controls/data/tst_slider.qml b/tests/auto/controls/data/tst_slider.qml index 305605f6..1589f2ab 100644 --- a/tests/auto/controls/data/tst_slider.qml +++ b/tests/auto/controls/data/tst_slider.qml @@ -330,5 +330,32 @@ Item { control.destroy() } + + function test_dragRounding() { + // Regression test: ends of range should be exact, not 99.99999999 &c. + var component = Qt.createComponent("slider/rounder.qml") + compare(component.status, Component.Ready) + var control = component.createObject(container) + + // Does moving to maximum (100) actually reach it ? + mousePress(control, 0, control.waist) + mouseMove(control, control.width, control.waist) + mouseRelease(control, control.width, control.waist) + // Equality checks are dodgy with floats, but this should still be exact: + verify(control.value == 100) + // Neither of the following caught the bug, with value 100 -1.421e-14 + // compare(control.value, 100) + // fuzzyCompare(control.value, 100, 1e-16) + + // Now check it all works going the other way, too: + mousePress(control, control.width, control.waist) + mouseMove(control, 0, control.waist) + mouseRelease(control, 0, control.waist) + verify(control.value == 0) + + // Tidy up. + control.destroy() + component.destroy() + } } } |