2 * Copyright (C) 2014-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/>.
18import Lomiri.Components 1.3
19import Lomiri.Components.ListItems 1.3 as ListItem
20import Lomiri.Components.Popups 1.3
25 property bool expanded
27 property int startIndex
28 readonly property double itemHeight: units.gu(4)
30 signal triggered(string id)
32 color: theme.palette.normal.background
33 height: expanded ? (optionToggleRepeater.count - startIndex) * itemHeight : itemHeight
37 border.width: units.dp(1)
38 border.color: theme.palette.normal.base
41 id: optionToggleContent
45 id: optionToggleRepeater
46 model: optionToggle.model
50 visible: status === Loader.Ready
51 property string actionLabel: label
52 property string actionId: id
53 readonly property var splitLabel: actionLabel.match(/(^([-a-z0-9]+):)?(.*)$/)
59 objectName: "notify_button" + index
60 width: optionToggleContent.width
61 height: optionToggle.itemHeight
64 if (index === startIndex) {
65 optionToggle.expanded = !optionToggle.expanded
67 optionToggle.triggered(actionId)
71 ListItem.ThinDivider {
72 visible: index > startIndex
79 leftMargin: units.gu(1)
80 verticalCenter: parent.verticalCenter
82 visible: index !== startIndex
85 name: splitLabel[2] !== undefined ? splitLabel[2] : ""
91 left: delegateIcon.visible ? delegateIcon.right : parent.left
92 leftMargin: delegateIcon.visible ? units.gu(1) : units.gu(2)
94 rightMargin: units.gu(1)
95 verticalCenter: delegateIcon.visible ? delegateIcon.verticalCenter : parent.verticalCenter
100 color: theme.palette.normal.backgroundSecondaryText
102 font.weight: Font.Light
104 elide: Text.ElideRight
110 rightMargin: units.gu(1)
111 verticalCenter: delegateIcon.verticalCenter
114 visible: index === startIndex
115 name: optionToggle.height === optionToggle.itemHeight ? "down" : "up"
121 sourceComponent: (index >= startIndex) ? optionToggleEntry : undefined