@@ -1,357 +0,0 @@
2− * Copyright 2016 Canonical Ltd.
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.
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.
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/>.
18− * This component is based on Ubuntu.Components 1.3 OptionSelectorDelegate
19− * It affords the user slightly more control over certain visual attributes
23−import Ubuntu.Components.ListItems 1.3 as ListItem
24−import Ubuntu.Components 1.3 as Toolkit
29− __height: units.gu(5)
32− Subtext which appears below the main text.
34− property string subText
39− \b{Use iconName or iconSource instead.}
43− property url icon: iconSource
44− onIconChanged: if (icon != iconSource) {
45− console.warn("WARNING: OptionSelectorDelegate.icon is DEPRECATED. " +
46− "Use iconName and iconSource instead.")
50− Constrains the size of the image to nothing greater than that of the delegate. Changes fillMode to Image.PreserveAspectFit.
52− property bool constrainImage: false
55− Whether or not left image is colored by our theme.
57− property bool colorImage: listView.container.colourImage
62− property color assetColor: listView.container.themeColour
65− Color of the primary text
67− property color textColor: theme.palette.normal.raisedText
70− OptionSelector's ListView.
72− readonly property ListView listView: ListView.view
75− Colorising fragment shader.
77− readonly property string fragColorShader:
78− "varying highp vec2 qt_TexCoord0;
79− uniform sampler2D source;
80− uniform lowp vec4 color;
81− uniform lowp float qt_Opacity;
84− lowp vec4 sourceColor = texture2D(source, qt_TexCoord0);
85− gl_FragColor = color * sourceColor.a * qt_Opacity;
88− showDivider: index !== listView.count - 1 ? 1 : 0
89− highlightWhenPressed: false
90− selected: ListView.isCurrentItem
96− if (listView.container.currentlyExpanded) {
97− listView.delegateClicked(index);
99− if (!listView.multiSelection) {
100− listView.previousIndex = listView.currentIndex;
101− listView.currentIndex = index;
103− selected = !selected;
107− if (!listView.expanded && !listView.multiSelection) {
108− listView.container.currentlyExpanded = !listView.container.currentlyExpanded;
112− property color originalBackground: "transparent"
113− Component.onCompleted: {
114− height = listView.itemHeight = Qt.binding(function() { return childrenRect.height; });
117− //Since we don't want to add states to our divider, we use the exposed alias provided in Empty to access it and alter it's opacity from here.
119− name: "dividerExpanded"
120− when: listView.container.state === "expanded" && index === listView.currentIndex
122− target: option.divider
126− name: "dividerCollapsed"
127− when: listView.container.state === "collapsed" && index === listView.currentIndex
129− target: option.divider
135− //As with our states, we apply the transition with our divider as the target.
136− transitions: [ Transition {
137− from: "dividerExpanded"
138− to: "dividerCollapsed"
139− Toolkit.UbuntuNumberAnimation {
140− target: option.divider
141− properties: "opacity"
142− duration: Toolkit.UbuntuAnimation.SlowDuration
149− target: listView.container
150− ignoreUnknownSignals: true
151− onCurrentlyExpandedChanged: {
152− imageExpansion.stop();
153− selectedImageCollapse.stop();
154− deselectedImageCollapse.stop();
156− if (listView.container.currentlyExpanded === true) {
157− if (!option.selected) {
158− optionExpansion.start();
160− //Ensure a source change. This solves a bug which happens occasionaly when source is switched correctly. Probably related to the image.source binding.
161− image.source = listView.container.tick
163− imageExpansion.start();
166− if (!option.selected) {
167− optionCollapse.start();
169− if (listView.previousIndex !== listView.currentIndex)
170− selectedImageCollapse.start();
172− deselectedImageCollapse.start();
177− }, SequentialAnimation {
182− properties: "opacity"
185− duration: Toolkit.UbuntuAnimation.FastDuration
187− PauseAnimation { duration: Toolkit.UbuntuAnimation.BriskDuration - Toolkit.UbuntuAnimation.FastDuration }
191− value: listView.container.tick
195− properties: "opacity"
198− duration: Toolkit.UbuntuAnimation.FastDuration
200− }, PropertyAnimation {
204− properties: "opacity"
207− duration: Toolkit.UbuntuAnimation.SlowDuration
208− }, SequentialAnimation {
209− id: deselectedImageCollapse
211− PauseAnimation { duration: Toolkit.UbuntuAnimation.BriskDuration }
214− properties: "opacity"
217− duration: Toolkit.UbuntuAnimation.FastDuration
219− PauseAnimation { duration: Toolkit.UbuntuAnimation.FastDuration }
223− value: listView.container.chevron
227− properties: "opacity"
230− duration: Toolkit.UbuntuAnimation.FastDuration
232− }, SequentialAnimation {
233− id: selectedImageCollapse
237− properties: "opacity"
240− duration: Toolkit.UbuntuAnimation.FastDuration
242− PauseAnimation { duration: Toolkit.UbuntuAnimation.BriskDuration - Toolkit.UbuntuAnimation.FastDuration }
245− properties: "opacity"
248− duration: Toolkit.UbuntuAnimation.FastDuration
250− PauseAnimation { duration: Toolkit.UbuntuAnimation.FastDuration }
254− value: listView.container.chevron
258− properties: "opacity"
261− duration: Toolkit.UbuntuAnimation.FastDuration
263− }, PropertyAnimation {
266− properties: "opacity"
269− duration: Toolkit.UbuntuAnimation.SlowDuration
274− spacing: units.gu(1)
278− leftMargin: units.gu(2)
279− verticalCenter: parent.verticalCenter
286− height: constrainImage ? option.height : sourceSize.height
287− source: option.iconSource
288− fillMode: constrainImage ? Image.PreserveAspectFit : Image.Stretch
291− property color color: assetColor
292− property Image source: parent
295− height: source.height
298− fragmentShader: fragColorShader
304− verticalCenter: parent.verticalCenter
307− width: option.width - leftIcon.width - image.width
308− - parent.spacing * 2 - parent.anchors.leftMargin
311− text: option.text === "" ? modelData : option.text
313− elide: Text.ElideRight
314− color: option.textColor
317− text: option.subText
319− elide: Text.ElideRight
320− visible: option.subText !== "" ? true : false
321− textSize: Toolkit.Label.Small
330− source: listView.expanded || listView.multiSelection ? listView.container.tick : listView.container.chevron
331− opacity: option.selected ? 1.0 : 0.0
333− verticalCenter: parent.verticalCenter
336− //Our behaviour is only enabled for our expanded list due to flickering bugs in relation to all this other animations running on the expanding version.
337− Behavior on opacity {
338− enabled: listView.expanded
340− Toolkit.UbuntuNumberAnimation {
341− properties: "opacity"
342− duration: Toolkit.UbuntuAnimation.FastDuration
347− property color color: assetColor
348− property Image source: parent
351− height: source.height
353− fragmentShader: fragColorShader