Debian Codegraph @

src/qml/CustomPickers/1.0/Dialer.qml

raw
1 /*
2 * Copyright 2015 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17 import QtQuick 2.4
18 import Lomiri.Components 1.3
19
20 /*!
21 \qmltype Dialer
22 \inqmlmodule Lomiri.Components.Pickers 1.0
23 \ingroup ubuntu-pickers
24 \brief Dialer is a phone dialer style picker component.
25 \deprecated
26
27 The Dialer component is dedicated for value selection where the value is
28 compound of several sections, i.e. hour, minute and second, or integral and
29 decimal values. Each section is defined by a DialerHand, which shares the
30 same range as the dialer is having. Dialer hand visuals are placed on the
31 same dialer disk, however this can be altered by setting different values
32 to DialerHand propertries.
33
34 The following example shows how to create a dialer component to select a
35 value between 0 and 50.
36
37 \qml
38 import QtQuick 2.4
39 import Lomiri.Components.Pickers 1.0
40
41 Dialer {
42 size: units.gu(20)
43 minimumValue: 0
44 maximumValue: 50
45
46 DialerHand {
47 id: mainHand
48 onValueChanged: console.log(value)
49 }
50 }
51 \endqml
52
53 \sa DialerHand
54 */
55
56 StyledItem {
57
58 /*!
59 \qmlproperty real minimumValue: 0
60 \qmlproperty real maximumValue: 360
61
62 These properties define the value range the dialer hand values can take.
63 The default values are 0 and 360.
64 */
65 property real minimumValue: 0.0
66
67 /*! \internal - documented in previous block*/
68 property real maximumValue: 360.0
69
70 /*!
71 The property holds the size of the dialer. The component should be sized
72 using this property instead of using width and/or height properties. Sizing
73 with this property it is made sure that the component will scale evenly.
74 */
75 property real size: units.gu(32)
76
77 /*!
78 The property holds the height reserved for the dialer hands, being the distance
79 between the outer and the inner dialer disks. This value cannot be higher than
80 the half of the dialer \l size.
81 */
82 property real handSpace: units.gu(6.5)
83
84 /*!
85 \qmlproperty Item centerItem
86 The property holds the component from the center of the Dialer. Items wanted
87 to be placed into the center of the Dialer must be reparented to this component,
88 or listed in the \l centerContent property.
89
90 Beside that, the property helps anchoring the center disk content to the
91 item.
92 \qml
93 Dialer {
94 DialerHand {
95 id: hand
96 Label {
97 parent: hand.centerItem
98 // [...]
99 }
100 }
101 // [...]
102 }
103 \endqml
104 */
105 readonly property alias centerItem: centerHolder
106
107 /*!
108 \qmlproperty list<var> centerContent
109 The property holds the list of items to be placed inside of the center disk.
110 Items placed inside the center disk can either be listed in this property or
111 reparented to \l centerItem property.
112 \qml
113 Dialer {
114 DialerHand {
115 id: hand
116 centerContent: [
117 Label {
118 // [...]
119 }
120 // [...]
121 ]
122 }
123 // [...]
124 }
125 \endqml
126 */
127 property alias centerContent: centerHolder.data
128
129 /*!
130 \qmlproperty list<DialerHands> hands
131 \readonly
132 The property holds the list of DialerHands added to Dialer. This may be the
133 same as the children, however will contain only DialerHand objects.
134 */
135 readonly property alias hands: internal.hands
136
137 /*!
138 \qmlmethod void handUpdated(DialerHand hand)
139 The signal is emitted when the hand value is updated.
140 */
141 signal handUpdated(var hand)
142
143 id: dialer
144 implicitWidth: size
145 implicitHeight: size
146 activeFocusOnPress: true
147
148 styleName: "DialerStyle"
149
150 Item {
151 id: internal
152 // internal property holding only the list of DialerHand components
153 // workaround for readonly public property
154 property var hands: []
155
156 height: size - handSpace * 2
157 width: size - handSpace * 2
158 anchors.centerIn: parent
159 Item {
160 id: centerHolder
161 anchors.fill: parent
162 z: 1
163 }
164 }
165
166 /*! \internal */
167 onChildrenChanged: {
168 // apply dialer presets if the hand sizes were not set
169 // check dialers only
170 var idx = 0;
171 var stack = [];
172 for (var i in children) {
173 if (children[i].hasOwnProperty("hand")) {
174 children[i].__grabber.index = idx++;
175 stack.push(children[i]);
176 }
177 internal.hands = stack;
178 }
179 }
180 }