@@ -19,6 +19,7 @@ import Ubuntu.Components 0.1
19import ".."
19import ".."
20import "../Generic"
20import "../Generic"
21import "../../Components"
21import "../../Components"
23GenericPreview {
24GenericPreview {
@@ -27,68 +28,89 @@ GenericPreview {
27 property bool playable: previewData.imageSourceUri != null
28 property bool playable: previewData.imageSourceUri != null
28 property url url: ready ? previewData.image : ""
29 property url url: ready ? previewData.image : ""
31+ previewImages: previewImageComponent
32+ header: headerComponent
33+ actions: actionsComponent
34+ ratings: ratingsComponent
37+ id: previewImageComponent
30− previewImages: UbuntuShape {
38+ UbuntuShape {
31− id: urlLoader
39+ id: urlLoader
32− anchors.left: parent.left
40+ anchors.left: parent.left
33− anchors.right: parent.right
41+ anchors.right: parent.right
34− height: width * previewImage.sourceSize.height / previewImage.sourceSize.width
42+ height: width * previewImage.sourceSize.height / previewImage.sourceSize.width
35− radius: "medium"
43+ radius: "medium"
36− visible: height > 0
44+ visible: height > 0
37− image: Image {
45+ image: Image {
38− id: previewImage
46+ id: previewImage
39− asynchronous: true
47+ asynchronous: true
40− source: root.url
48+ source: root.url
41− fillMode: Image.PreserveAspectCrop
49+ fillMode: Image.PreserveAspectCrop
45− objectName: "playButton"
53+ objectName: "playButton"
46− anchors.centerIn: parent
54+ anchors.centerIn: parent
47− visible: root.playable
55+ visible: root.playable
48− readonly property bool bigButton: parent.width > units.gu(40)
56+ readonly property bool bigButton: parent.width > units.gu(40)
49− width: bigButton ? units.gu(8) : units.gu(4.5)
57+ width: bigButton ? units.gu(8) : units.gu(4.5)
50− height: width
58+ height: width
51− source: "../graphics/play_button%1%2.png".arg(previewImageMouseArea.pressed ? "_active" : "").arg(bigButton ? "_big" : "")
59+ source: "../graphics/play_button%1%2.png".arg(previewImageMouseArea.pressed ? "_active" : "").arg(bigButton ? "_big" : "")
63+ id: previewImageMouseArea
65+ onClicked: shell.activateApplication('/usr/share/applications/mediaplayer-app.desktop', previewData.imageSourceUri);
54− MouseArea {
70+ Component {
55− id: previewImageMouseArea
71+ id: headerComponent
56− anchors.fill: parent
72+ Header {
57− onClicked: shell.activateApplication('/usr/share/applications/mediaplayer-app.desktop', previewData.imageSourceUri);
73+ title: previewData.title
74+ rating: Math.round(root.previewData.rating * 10)
75+ reviews: root.previewData.numRatings
76+ rated: root.previewData.infoMap["rated"] ? root.previewData.infoMap["rated"].value : 0
61− actions: GridView {
82+ GridView {
62− id: buttons
83+ id: buttons
63− objectName: "gridButtons"
84+ objectName: "gridButtons"
64− model: root.previewData.actions
85+ model: root.previewData.actions
65− interactive: false
86+ interactive: false
67− anchors.left: parent.left
88+ anchors.left: parent.left
68− anchors.right: parent.right
89+ anchors.right: parent.right
70− property int numOfRows: (count + numOfColumns - 1) / numOfColumns
91+ property int numOfRows: (count + numOfColumns - 1) / numOfColumns
71− property int numOfColumns: Math.max(1, Math.floor(width / (buttonWidth + spacing)))
92+ property int numOfColumns: Math.max(1, Math.floor(width / (buttonWidth + spacing)))
72− property int spacing: units.gu(1)
93+ property int spacing: units.gu(1)
73− height: Math.max(units.gu(4), units.gu(4)*numOfRows + spacing*(numOfRows - 1))
94+ height: Math.max(units.gu(4), units.gu(4)*numOfRows + spacing*(numOfRows - 1))
75− cellWidth: width / buttons.numOfColumns
96+ cellWidth: width / buttons.numOfColumns
76− cellHeight: buttonHeight + buttons.spacing
97+ cellHeight: buttonHeight + buttons.spacing
77− property int buttonWidth: units.gu(17) - spacing
98+ property int buttonWidth: units.gu(17) - spacing
78− property int buttonHeight: units.gu(4)
99+ property int buttonHeight: units.gu(4)
80− delegate: Button {
101+ delegate: Button {
81− width: Math.max(units.gu(4), buttons.buttonWidth)
102+ width: Math.max(units.gu(4), buttons.buttonWidth)
82− height: buttons.buttonHeight
103+ height: buttons.buttonHeight
83− color: "#dd4814"
104+ color: "#dd4814"
84− text: modelData.displayName
105+ text: modelData.displayName
85− iconSource: modelData.iconHint
106+ iconSource: modelData.iconHint
86− iconPosition: "right"
107+ iconPosition: "right"
87− visible: true
108+ visible: true
88− onClicked: {
109+ onClicked: {
89− root.previewData.execute(modelData.id, { })
110+ root.previewData.execute(modelData.id, { })