aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJ-P Nurmi <jpnurmi@qt.io>2017-01-27 12:50:17 +0100
committerJ-P Nurmi <jpnurmi@qt.io>2017-01-27 13:37:47 +0000
commitb026ebf67a95c6bca186e69e6e71b6fb70b4eeb3 (patch)
treeaa2230cf29158360c3a1869ee121b96ed37c8da7
parent8968ce178453c3b6a74b95ba34fb492fd29ef764 (diff)
Default QQuickSlider::live to true
[ChangeLog][Important Behavior Changes] On a popular demand, Slider has been changed to report live value updates. This can be disabled by setting Slider::live to false. Change-Id: I48c6a92eb794d2846cfff96d8784c53c22843573 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
-rw-r--r--src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-tooltip-slider.qml53
-rw-r--r--src/quicktemplates2/qquickslider.cpp21
-rw-r--r--tests/auto/controls/data/tst_slider.qml10
3 files changed, 10 insertions, 74 deletions
diff --git a/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-tooltip-slider.qml b/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-tooltip-slider.qml
deleted file mode 100644
index fc2790b0..00000000
--- a/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-tooltip-slider.qml
+++ /dev/null
@@ -1,53 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: http://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** 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 Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: http://www.gnu.org/copyleft/fdl.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-import QtQuick.Window 2.2
-import QtQuick.Controls 2.1
-
-Item {
- id: root
- width: slider.width
- height: slider.height * 2.0
-
- Binding { target: slider.anchors; property: "centerIn"; value: root }
- Binding { target: slider.anchors; property: "verticalCenterOffset"; value: slider.height / 2 }
- Binding { target: slider; property: "pressed"; value: root.Window.active }
-
- //! [1]
- Slider {
- id: slider
- value: 0.5
-
- ToolTip {
- parent: slider.handle
- visible: slider.pressed
- text: slider.valueAt(slider.position).toFixed(1)
- }
- }
- //! [1]
-}
diff --git a/src/quicktemplates2/qquickslider.cpp b/src/quicktemplates2/qquickslider.cpp
index ff41595b..c95385dd 100644
--- a/src/quicktemplates2/qquickslider.cpp
+++ b/src/quicktemplates2/qquickslider.cpp
@@ -94,7 +94,7 @@ public:
value(0),
position(0),
stepSize(0),
- live(false),
+ live(true),
pressed(false),
touchId(-1),
orientation(Qt::Horizontal),
@@ -304,12 +304,7 @@ void QQuickSlider::setTo(qreal to)
This property holds the value in the range \c from - \c to. The default value is \c 0.0.
- Unlike the \l position property, the \c value is not updated by default
- while the handle is dragged, but only after the value has been chosen and
- the slider has been released. The \l live property can be used to make the
- slider provide live updates for the \c value property.
-
- \sa position, live, valueAt()
+ \sa position
*/
qreal QQuickSlider::value() const
{
@@ -338,8 +333,7 @@ void QQuickSlider::setValue(qreal value)
This property holds the logical position of the handle.
The position is expressed as a fraction of the control's size, in the range
- \c {0.0 - 1.0}. The \c position is continuously updated while the
- handle is dragged. For visualizing a slider, the right-to-left aware
+ \c {0.0 - 1.0}. For visualizing a slider, the right-to-left aware
\l visualPosition should be used instead.
\sa value, visualPosition, valueAt()
@@ -441,9 +435,9 @@ void QQuickSlider::setSnapMode(SnapMode mode)
This property holds whether the slider provides live updates for the \l value
property while the handle is dragged.
- The default value is \c false.
+ The default value is \c true.
- \sa value
+ \sa value, valueAt()
*/
bool QQuickSlider::live() const
{
@@ -540,11 +534,6 @@ void QQuickSlider::setHandle(QQuickItem *handle)
Returns the value for the given \a position.
- The \l value property is not updated while the handle is dragged, but this
- method can be used to get continuous value updates:
-
- \snippet qtquickcontrols2-tooltip-slider.qml 1
-
\sa value, position
*/
qreal QQuickSlider::valueAt(qreal position) const
diff --git a/tests/auto/controls/data/tst_slider.qml b/tests/auto/controls/data/tst_slider.qml
index 8a3499be..94c9922f 100644
--- a/tests/auto/controls/data/tst_slider.qml
+++ b/tests/auto/controls/data/tst_slider.qml
@@ -377,7 +377,7 @@ TestCase {
}
function test_multiTouch() {
- var control1 = createTemporaryObject(slider, testCase)
+ var control1 = createTemporaryObject(slider, testCase, {live: false})
verify(control1)
var pressedCount1 = 0
@@ -407,7 +407,7 @@ TestCase {
compare(control1.pressed, true)
compare(control1.position, 1.0)
- var control2 = createTemporaryObject(slider, testCase, {y: control1.height})
+ var control2 = createTemporaryObject(slider, testCase, {y: control1.height, live: false})
verify(control2)
waitForRendering(control2)
@@ -565,7 +565,7 @@ TestCase {
// test with "unbalanced" paddings (left padding != right padding) to ensure
// that the slider position calculation is done taking padding into account
// ==> the position is _not_ 0.5 in the middle of the control
- var control = createTemporaryObject(slider, testCase, {leftPadding: 10, rightPadding: 20})
+ var control = createTemporaryObject(slider, testCase, {leftPadding: 10, rightPadding: 20, live: false})
verify(control)
var pressedSpy = signalSpy.createObject(control, {target: control, signalName: "pressedChanged"})
@@ -651,7 +651,7 @@ TestCase {
}
function test_snapMode_mouse(data) {
- var control = createTemporaryObject(slider, testCase, {snapMode: data.snapMode, from: data.from, to: data.to, stepSize: 0.2})
+ var control = createTemporaryObject(slider, testCase, {live: false, snapMode: data.snapMode, from: data.from, to: data.to, stepSize: 0.2})
verify(control)
function sliderCompare(left, right) {
@@ -677,7 +677,7 @@ TestCase {
}
function test_snapMode_touch(data) {
- var control = createTemporaryObject(slider, testCase, {snapMode: data.snapMode, from: data.from, to: data.to, stepSize: 0.2})
+ var control = createTemporaryObject(slider, testCase, {live: false, snapMode: data.snapMode, from: data.from, to: data.to, stepSize: 0.2})
verify(control)
function sliderCompare(left, right) {