2
* Copyright (C) 2016 Canonical, Ltd.
4
* This program is free software; you can redistribute it and/or modify
5
* it under the terms of the GNU 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 General Public License for more details.
13
* You should have received a copy of the GNU General Public License
14
* along with this program. If not, see <http://www.gnu.org/licenses/>.
18
import Ubuntu.Components 1.3
19
import Ubuntu.Components.ListItems 1.3 as ListItem
20
import "../Components"
25
property bool expanded
27
property int selectedIndex: -1
28
readonly property double itemHeight: units.gu(4)
29
readonly property int maxVisibleItems: 6
31
color: theme.palette.normal.foreground
32
height: expanded ? maxVisibleItems * itemHeight : itemHeight
34
UbuntuNumberAnimation { id: heightAnimation }
40
border.width: units.dp(1)
41
border.color: theme.palette.normal.base
46
flickableDirection: Flickable.VerticalFlick
49
contentHeight: optionToggleRepeater.count * itemHeight
52
id: optionToggleContent
56
id: optionToggleRepeater
57
model: optionToggle.model
61
visible: status === Loader.Ready
67
width: optionToggleContent.width
68
height: optionToggle.itemHeight
71
selectedIndex = index;
76
ListItem.ThinDivider {
77
visible: expanded && index != 0
84
leftMargin: units.gu(1)
86
rightMargin: units.gu(3)
87
verticalCenter: parent.verticalCenter
91
text: expanded ? modelData : optionToggle.model[selectedIndex]
93
font.weight: Font.Light
95
elide: Text.ElideRight
101
rightMargin: units.gu(1)
102
verticalCenter: parent.verticalCenter
105
visible: (index == 0 || !expanded) && !heightAnimation.running
106
name: expanded ? "up" : "down"
114
rightMargin: units.gu(1)
115
verticalCenter: parent.verticalCenter
117
visible: expanded && index == optionToggle.selectedIndex && index != 0
118
height: units.gu(1.5)
119
fillMode: Image.PreserveAspectFit
120
source: Qt.resolvedUrl("Pages/data/Tick@30.png")
124
sourceComponent: optionToggleEntry