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/>.
18 import QtQuick.Layouts 1.1
19 import Ubuntu.Components 1.3
24 signal requestFavorite(string scopeId, bool favorite)
25 signal handlePressed(var handle)
26 signal handleReleased(var handle)
28 property real topMargin: 0
29 property alias icon: shapeImage.source
30 property alias text: titleLabel.text
31 property alias subtext: subtitleLabel.text
33 property bool showStar: false
34 property bool isFavorite: false
35 property bool hideChildren: false
40 anchors.topMargin: root.topMargin
46 leftMargin: units.gu(1)
47 verticalCenter: parent.verticalCenter
51 visible: !hideChildren
52 aspect: UbuntuShape.Flat
53 sourceFillMode: UbuntuShape.PreserveAspectCrop
57 sourceSize { width: shape.width; height: shape.height }
62 visible: !hideChildren
65 leftMargin: units.gu(1)
67 verticalCenter: parent.verticalCenter
71 Layout.fillWidth: true
72 elide: Text.ElideRight
75 verticalAlignment: Text.AlignHCenter
79 Layout.fillWidth: true
80 elide: Text.ElideRight
84 verticalAlignment: Text.AlignHCenter
90 objectName: "starArea"
93 anchors.right: parent.right
94 onClicked: if (!editMode) root.requestFavorite(model.scopeId, !isFavorite);
97 if (pressed) root.handlePressed(starArea.__mouseArea);
98 else root.handleReleased(starArea.__mouseArea);
101 visible: editMode || showStar
104 anchors.centerIn: parent
107 visible: !hideChildren
108 // TODO is view-grid-symbolic what we really want here? Looks good but seems semantically wrong
109 source: editMode ? "image://theme/view-grid-symbolic" : isFavorite ? "image://theme/starred" : "image://theme/non-starred"