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)
32 readonly property var actions: root.widgetData ? root.widgetData["actions"] : null
33 anchors.right: parent.right
39 readonly property bool button: row.actions && row.actions.length == 2
40 readonly property bool combo: row.actions && row.actions.length > 2
41 source: button ? "PreviewActionButton.qml" : (combo ? "PreviewActionCombo.qml" : "")
42 width: (root.width - units.gu(1)) / 2
45 item.data = row.actions[1];
47 item.model = row.actions.slice(1);
52 property: "strokeColor"
53 value: root.scopeStyle ? root.scopeStyle.foreground : theme.palette.normal.baseText
58 root.triggered(root.widgetId, actionData.id, actionData);
64 data: visible ? row.actions[0] : null
65 visible: row.actions && row.actions.length > 0
66 onTriggeredAction: root.triggered(root.widgetId, actionData.id, actionData)
67 width: (root.width - units.gu(1)) / 2
68 color: root.scopeStyle ? root.scopeStyle.previewButtonColor : UbuntuColors.orange