1
/****************************************************************************
3
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
4
** All rights reserved.
5
** Contact: Nokia Corporation (qt-info@nokia.com)
7
** This file is part of the Qt Components project on Qt Labs.
10
** This file contains pre-release code and may not be distributed.
11
** You may use this file in accordance with the terms and conditions contained
12
** in the Technology Preview License Agreement accompanying this package.
14
** GNU Lesser General Public License Usage
15
** Alternatively, this file may be used under the terms of the GNU Lesser
16
** General Public License version 2.1 as published by the Free Software
17
** Foundation and appearing in the file LICENSE.LGPL included in the
18
** packaging of this file. Please review the following information to
19
** ensure the GNU Lesser General Public License version 2.1 requirements
20
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
22
** If you have questions regarding the use of this file, please contact
23
** Nokia at qt-info@nokia.com.
25
****************************************************************************/
28
import StyleItemType 0.1
29
import WheelAreaType 0.1
30
// jens: ContainsMouse breaks drag functionality
38
property alias maximumValue: range.maximumValue
39
property alias minimumValue: range.minimumValue
40
property alias containsMouse: mouseArea.containsMouse
41
property alias value: range.value
42
property alias stepSize: range.stepSize
44
property bool wrapping: false
45
property bool tickmarksEnabled: false
46
property bool activeFocusOnPress: false
64
value = valueFromPoint(mouseX, mouseY)
69
value = valueFromPoint(mouseX, mouseY)
70
if (activeFocusOnPress) dial.focus = true
73
onReleased:inDrag = false;
74
function bound(val) { return Math.max(minimumValue, Math.min(maximumValue, val)); }
76
function valueFromPoint(x, y)
78
var yy = height/2.0 - y;
79
var xx = x - width/2.0;
80
var a = (xx || yy) ? Math.atan2(yy, xx) : 0;
86
var minv = minimumValue*100, maxv = maximumValue*100;
88
if (minimumValue < 0) {
91
maxv = maximumValue + dist;
97
v = (0.5 + minv + r * (Math.PI * 3 / 2 - a) / (2 * Math.PI));
99
v = (0.5 + minv + r* (Math.PI * 4 / 3 - a) / (Math.PI * 10 / 6));
103
return maximumValue - bound(v/100)
110
sunken: mouseArea.pressed
111
maximum: range.maximumValue * 100
112
minimum: range.minimumValue * 100
113
value: visualPos * 100
114
enabled: dial.enabled
115
step: range.stepSize * 100
116
activeControl: tickmarksEnabled ? "tick" : ""
117
property double visualPos : range.value
119
Behavior on visualPos {
120
enabled: !mouseArea.inDrag
123
easing.type: Easing.OutSine
130
horizontalMinimumValue: dial.minimumValue
131
horizontalMaximumValue: dial.maximumValue
132
verticalMinimumValue: dial.minimumValue
133
verticalMaximumValue: dial.maximumValue
134
property double step: (dial.maximumValue - dial.minimumValue)/100
136
onVerticalWheelMoved: {
137
value += verticalDelta/4*step
140
onHorizontalWheelMoved: {
141
value += horizontalDelta/4*step