@@ -0,0 +1,165 @@
1+/*
2+ * Copyright (C) 2013 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.0
18+import Ubuntu.Components 0.1
19+import ".."
20+import "../../Components"
21+
22+DashPreview {
23+ id: root
24+
25+ property bool ready: previewData ? true : false
26+ property bool playable: previewData.imageSourceUri != null
27+ property url url: ready ? previewData.image : ""
28+
29+ title: root.ready ? previewData.title : ""
30+ previewWidthRatio: 0.6
31+
32+ onPreviewImageClicked: {
33+ if (playable) {
34+ shell.activateApplication('/usr/share/applications/mediaplayer-app.desktop', previewData.imageSourceUri);
35+ }
36+ }
37+
38+ header: UbuntuShape {
39+ id: urlLoader
40+ anchors.left: parent.left
41+ anchors.right: parent.right
42+ radius: "medium"
43+ image: Image {
44+ id: previewImage
45+ asynchronous: true
46+ source: root.url
47+ fillMode: Image.PreserveAspectCrop
48+ }
49+
50+ Image {
51+ objectName: "playButton"
52+ anchors.centerIn: parent
53+ visible: root.playable
54+ readonly property bool bigButton: parent.width > units.gu(40)
55+ width: bigButton ? units.gu(8) : units.gu(4.5)
56+ height: width
57+ source: "../graphics/play_button%1%2.png".arg(previewImageMouseArea.pressed ? "_active" : "").arg(bigButton ? "_big" : "")
58+ }
59+
60+ MouseArea {
61+ id: previewImageMouseArea
62+ anchors.fill: parent
63+ onClicked: root.previewImageClicked()
64+ }
65+ }
66+
67+ buttons: GridView {
68+ id: buttons
69+ objectName: "gridButtons"
70+ model: root.previewData.actions
71+ interactive: false
72+
73+ anchors.left: parent.left
74+ anchors.right: parent.right
75+
76+ property int numOfRows: (count + numOfColumns - 1) / numOfColumns
77+ property int numOfColumns: Math.max(1, Math.floor(width / (buttonWidth + spacing)))
78+ property int spacing: units.gu(1)
79+ height: Math.max(units.gu(4), units.gu(4)*numOfRows + spacing*(numOfRows - 1))
80+
81+ cellWidth: width / buttons.numOfColumns
82+ cellHeight: buttonHeight + buttons.spacing
83+ property int buttonWidth: units.gu(17) - spacing
84+ property int buttonHeight: units.gu(4)
85+
86+ delegate: Button {
87+ width: Math.max(units.gu(4), buttons.buttonWidth)
88+ height: buttons.buttonHeight
89+ color: "#dd4814"
90+ text: modelData.displayName
91+ iconSource: modelData.iconHint
92+ iconPosition: "right"
93+ visible: true
94+ onClicked: {
95+ root.previewData.execute(modelData.id, { })
96+ }
97+ }
98+ focus: false
99+ }
100+
101+ body: Column {
102+ spacing: units.gu(2)
103+ RatingStars {
104+ visible: previewData.rating >= 0.0
105+ rating: previewData.rating >= 0.0 ? previewData.rating * 5 : 0
106+ }
107+
108+ Label {
109+ text: ready ? previewData.description : ""
110+ color: Theme.palette.selected.backgroundText
111+ opacity: .6
112+ fontSize: "medium"
113+ width: parent.width
114+ wrapMode: Text.WordWrap
115+ style: Text.Raised
116+ styleColor: "black"
117+ }
118+
119+ Grid {
120+ columns: 2
121+ spacing: units.gu(1)
122+ width: parent.width
123+ property int firstColWidth: units.gu(9)
124+ property int secondColWidth: width - firstColWidth - spacing
125+ Label {
126+ visible: directedLabel.visible
127+ fontSize: "small"
128+ opacity: 0.9
129+ color: "white"
130+ horizontalAlignment: Text.AlignRight
131+ width: parent.firstColWidth
132+ text: i18n.tr("Date:")
133+ style: Text.Raised
134+ styleColor: "black"
135+ }
136+ Label {
137+ id: directedLabel
138+ visible: text != ""
139+ fontSize: "small"
140+ opacity: 0.6
141+ color: "white"
142+ width: parent.secondColWidth
143+ text: ready ? previewData.subtitle : ""
144+ style: Text.Raised
145+ styleColor: "black"
146+ wrapMode: Text.WordWrap
147+ }
148+ }
149+
150+ Label {
151+ fontSize: "small"
152+ opacity: 0.6
153+ color: "white"
154+ text: {
155+ var parts = []
156+ if (ready) {
157+ if (previewData.year) parts.push(previewData.year)
158+ }
159+ return parts.join(", ");
160+ }
161+ style: Text.Raised
162+ styleColor: "black"
163+ }
164+ }
165+}