on xenial help sign in
Added the file
b8e0779Andrea Cimitan
plugins/Dash/CardSocialAttributes.qmlnew file+91
@@ -0,0 +1,91 @@
1+/*
2+ * Copyright 2016 Canonical Ltd.
3+ *
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.
7+ *
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.
12+ *
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/>.
15+ */
16+
17+import QtQuick 2.4
18+import QtQuick.Layouts 1.1
19+import Ubuntu.Components 1.3
20+import "../../../qml/Components/ListItems" as ListItems
21+
22+Column {
23+ id: socialAttributes
24+ height: divider.height + row.height + spacing
25+ spacing: units.gu(0.5)
26+
27+ property alias model: repeater.model
28+ property color color: theme.palette.normal.baseText
29+ property real fontScale: 1.0
30+
31+ signal clicked(var result)
32+
33+ ListItems.ThinDivider {
34+ id: divider
35+ anchors { left: parent.left; right: parent.right; }
36+ }
37+
38+ Row {
39+ id: row
40+ height: units.gu(2)
41+ spacing: units.gu(1)
42+ anchors {
43+ left: parent.left
44+ right: parent.right
45+ leftMargin: units.gu(1)
46+ rightMargin: units.gu(1)
47+ }
48+
49+ Repeater {
50+ id: repeater
51+ delegate: Row {
52+ id: delegate
53+ objectName: "delegate" + index
54+ spacing: units.gu(0.5)
55+ height: units.gu(2)
56+ AbstractButton {
57+ height: units.gu(2)
58+ width: icon.width
59+ Icon {
60+ id: icon
61+ objectName: "icon"
62+
63+ property url urlIcon: "icon" in modelData && modelData["icon"] || ""
64+ property url urlTemporaryIcon: "temporaryIcon" in modelData && modelData["temporaryIcon"] || ""
65+
66+ height: units.gu(2)
67+ // FIXME Workaround for bug https://bugs.launchpad.net/ubuntu/+source/ubuntu-ui-toolkit/+bug/1421293
68+ width: implicitWidth > 0 && implicitHeight > 0 ? (implicitWidth / implicitHeight * height) : implicitWidth
69+ source: urlIcon
70+ color: socialAttributes.color
71+
72+ onUrlIconChanged: if (urlIcon) source = urlIcon
73+ }
74+
75+ onClicked: socialAttributes.clicked(modelData["id"]);
76+ onPressedChanged: if (pressed && icon.urlTemporaryIcon != "") icon.source = icon.urlTemporaryIcon
77+ }
78+ Label {
79+ id: label
80+ anchors.verticalCenter: parent.verticalCenter
81+ text: "label" in modelData && modelData["label"] || "";
82+ elide: Text.ElideRight
83+ maximumLineCount: 1
84+ fontSize: "small"
85+ font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale)
86+ color: socialAttributes.color
87+ }
88+ }
89+ }
90+ }
91+}