2 * Copyright 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/>.
18 import QtQuick.Layouts 1.1
19 import Ubuntu.Components 1.3
23 spacing: units.gu(0.5)
25 property alias model: repeater.model
26 property color color: theme.palette.normal.baseText
28 signal clicked(var actionId)
32 visible: repeater.count > 0
36 leftMargin:units.dp(1);
37 rightMargin: units.dp(1);
39 color: Qt.darker(theme.palette.normal.background, 1.12)
40 height: visible ? units.dp(1) : 0
48 leftMargin: units.gu(1)
49 rightMargin: units.gu(1)
52 readonly property int visibleItems: {
53 if (width <= units.gu(12)) // small card
55 else if (width <= units.gu(21)) // medium card
57 else // large or horizontal card
65 active: index < row.visibleItems
66 sourceComponent: AbstractButton {
67 objectName: "delegate" + index
74 readonly property url urlIcon: modelData && modelData["icon"] || ""
75 readonly property url urlTemporaryIcon: "temporaryIcon" in modelData && modelData["temporaryIcon"] || ""
78 // FIXME Workaround for bug https://bugs.launchpad.net/ubuntu/+source/ubuntu-ui-toolkit/+bug/1421293
79 width: implicitWidth > 0 && implicitHeight > 0 ? (implicitWidth / implicitHeight * height) : implicitWidth
81 color: socialActions.color
84 if (urlIcon) source = urlIcon
88 onClicked: socialActions.clicked(modelData["id"]);
89 onPressedChanged: if (pressed && icon.urlTemporaryIcon != "") icon.source = icon.urlTemporaryIcon