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/>.
19 /*! This preview widget shows either one button, two buttons or one button
20 * and a combo button depending on the number of items in widgetData["actions"].
21 * For each of the items we recognize the fields "label", "icon" and "id".
27 height: row.height + units.gu(1)
31 readonly property var actions: root.widgetData ? root.widgetData["actions"] : null
32 anchors.right: parent.right
38 readonly property bool button: row.actions && row.actions.length == 2
39 readonly property bool combo: row.actions && row.actions.length > 2
40 source: button ? "PreviewActionButton.qml" : (combo ? "PreviewActionCombo.qml" : "")
41 width: (root.width - units.gu(1)) / 2
44 item.data = row.actions[1];
46 item.model = row.actions.slice(1);
51 property: "strokeColor"
52 value: root.scopeStyle ? root.scopeStyle.foreground : Theme.palette.normal.baseText
57 root.triggered(root.widgetId, actionData.id, actionData);
63 data: visible ? row.actions[0] : null
64 visible: row.actions && row.actions.length > 0
65 onTriggeredAction: root.triggered(root.widgetId, actionData.id, actionData)
66 width: (root.width - units.gu(1)) / 2
67 color: root.scopeStyle ? root.scopeStyle.previewButtonColor : Theme.palette.selected.foreground