2 * Copyright (C) 2014,2015 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
20 /*! This preview widget shows either one button, two buttons or one button
21 * and a combo button depending on the number of items in widgetData["actions"].
22 * For each of the items we recognize the fields "label", "icon" and "id".
28 implicitHeight: row.height + units.gu(1)
29 readonly property var actions: root.widgetData ? root.widgetData["actions"] : null
33 anchors.right: parent.right
40 readonly property bool button: root.actions && root.actions.length == 2
41 readonly property bool combo: root.actions && root.actions.length > 2
42 source: button ? "PreviewActionButton.qml" : (combo ? "PreviewActionCombo.qml" : "")
43 width: (root.width - units.gu(1)) / 2
46 item.data = Qt.binding(function() { return root.actions[1]; });
48 item.model = Qt.binding(function() { return root.actions.slice(1); });
53 property: "strokeColor"
54 value: root.scopeStyle ? root.scopeStyle.foreground : theme.palette.normal.baseText
59 root.triggered(root.widgetId, actionData.id, actionData);
65 data: visible ? root.actions[0] : null
66 visible: root.actions && root.actions.length > 0
67 onTriggeredAction: root.triggered(root.widgetId, actionData.id, actionData)
68 width: (root.width - units.gu(1)) / 2
69 color: root.scopeStyle ? root.scopeStyle.previewButtonColor : theme.palette.normal.positive