2
* Copyright (C) 2014 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 0.1
19
import Ubuntu.Components.ListItems 0.1 as ListItem
20
import Ubuntu.Components.Popups 0.1
25
property bool expanded
27
property int startIndex
28
readonly property double itemHeight: units.gu(5)
30
signal triggered(string id)
32
color: Theme.palette.normal.base
34
height: expanded ? (optionToggleRepeater.count - startIndex) * itemHeight : itemHeight
40
id: optionToggleContent
44
id: optionToggleRepeater
45
model: optionToggle.model
49
visible: status === Loader.Ready
50
property string actionLabel: label
51
property string actionId: id
52
readonly property var splitLabel: actionLabel.match(/(^([-a-z0-9]+):)?(.*)$/)
58
objectName: "notify_button" + index
59
width: optionToggleContent.width
60
height: optionToggle.itemHeight
63
if (index === startIndex) {
64
optionToggle.expanded = !optionToggle.expanded
66
optionToggle.triggered(actionId)
70
ListItem.ThinDivider {
71
visible: index > startIndex
78
leftMargin: units.gu(2)
79
verticalCenter: parent.verticalCenter
81
visible: index !== startIndex
84
name: splitLabel[2] !== undefined ? splitLabel[2] : ""
90
left: delegateIcon.visible ? delegateIcon.right : parent.left
91
leftMargin: delegateIcon.visible ? units.gu(1) : units.gu(2)
93
rightMargin: units.gu(2)
94
verticalCenter: delegateIcon.visible ? delegateIcon.verticalCenter : parent.verticalCenter
102
elide: Text.ElideRight
108
rightMargin: units.gu(2)
109
verticalCenter: delegateIcon.verticalCenter
112
visible: index === startIndex
113
name: optionToggle.height === optionToggle.itemHeight ? "down" : "up"
119
sourceComponent: (index >= startIndex) ? optionToggleEntry : undefined