@@ -19,6 +19,7 @@ import Ubuntu.Components 0.1
1919import ".."
2020import "../Generic"
2121import "../../Components"
22+import "../Previews"
2223
2324GenericPreview {
2425 id: root
@@ -27,68 +28,89 @@ GenericPreview {
2728 property bool playable: previewData.imageSourceUri != null
2829 property url url: ready ? previewData.image : ""
2930
30− previewImages: UbuntuShape {
31− id: urlLoader
32− anchors.left: parent.left
33− anchors.right: parent.right
34− height: width * previewImage.sourceSize.height / previewImage.sourceSize.width
35− radius: "medium"
36− visible: height > 0
37− image: Image {
38− id: previewImage
39− asynchronous: true
40− source: root.url
41− fillMode: Image.PreserveAspectCrop
42− }
31+ previewImages: previewImageComponent
32+ header: headerComponent
33+ actions: actionsComponent
34+ ratings: ratingsComponent
35+
36+ Component {
37+ id: previewImageComponent
38+ UbuntuShape {
39+ id: urlLoader
40+ anchors.left: parent.left
41+ anchors.right: parent.right
42+ height: width * previewImage.sourceSize.height / previewImage.sourceSize.width
43+ radius: "medium"
44+ visible: height > 0
45+ image: Image {
46+ id: previewImage
47+ asynchronous: true
48+ source: root.url
49+ fillMode: Image.PreserveAspectCrop
50+ }
4351
44− Image {
45− objectName: "playButton"
46− anchors.centerIn: parent
47− visible: root.playable
48− readonly property bool bigButton: parent.width > units.gu(40)
49− width: bigButton ? units.gu(8) : units.gu(4.5)
50− height: width
51− source: "../graphics/play_button%1%2.png".arg(previewImageMouseArea.pressed ? "_active" : "").arg(bigButton ? "_big" : "")
52+ Image {
53+ objectName: "playButton"
54+ anchors.centerIn: parent
55+ visible: root.playable
56+ readonly property bool bigButton: parent.width > units.gu(40)
57+ width: bigButton ? units.gu(8) : units.gu(4.5)
58+ height: width
59+ source: "../graphics/play_button%1%2.png".arg(previewImageMouseArea.pressed ? "_active" : "").arg(bigButton ? "_big" : "")
60+ }
61+
62+ MouseArea {
63+ id: previewImageMouseArea
64+ anchors.fill: parent
65+ onClicked: shell.activateApplication('/usr/share/applications/mediaplayer-app.desktop', previewData.imageSourceUri);
66+ }
5267 }
68+ }
5369
54− MouseArea {
55− id: previewImageMouseArea
56− anchors.fill: parent
57− onClicked: shell.activateApplication('/usr/share/applications/mediaplayer-app.desktop', previewData.imageSourceUri);
70+ Component {
71+ id: headerComponent
72+ Header {
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
5877 }
5978 }
6079
61− actions: GridView {
62− id: buttons
63− objectName: "gridButtons"
64− model: root.previewData.actions
65− interactive: false
80+ Component {
81+ id: actionsComponent
82+ GridView {
83+ id: buttons
84+ objectName: "gridButtons"
85+ model: root.previewData.actions
86+ interactive: false
6687
67− anchors.left: parent.left
68− anchors.right: parent.right
88+ anchors.left: parent.left
89+ anchors.right: parent.right
6990
70− property int numOfRows: (count + numOfColumns - 1) / numOfColumns
71− property int numOfColumns: Math.max(1, Math.floor(width / (buttonWidth + spacing)))
72− property int spacing: units.gu(1)
73− height: Math.max(units.gu(4), units.gu(4)*numOfRows + spacing*(numOfRows - 1))
91+ property int numOfRows: (count + numOfColumns - 1) / numOfColumns
92+ property int numOfColumns: Math.max(1, Math.floor(width / (buttonWidth + spacing)))
93+ property int spacing: units.gu(1)
94+ height: Math.max(units.gu(4), units.gu(4)*numOfRows + spacing*(numOfRows - 1))
7495
75− cellWidth: width / buttons.numOfColumns
76− cellHeight: buttonHeight + buttons.spacing
77− property int buttonWidth: units.gu(17) - spacing
78− property int buttonHeight: units.gu(4)
96+ cellWidth: width / buttons.numOfColumns
97+ cellHeight: buttonHeight + buttons.spacing
98+ property int buttonWidth: units.gu(17) - spacing
99+ property int buttonHeight: units.gu(4)
79100
80− delegate: Button {
81− width: Math.max(units.gu(4), buttons.buttonWidth)
82− height: buttons.buttonHeight
83− color: "#dd4814"
84− text: modelData.displayName
85− iconSource: modelData.iconHint
86− iconPosition: "right"
87− visible: true
88− onClicked: {
89− root.previewData.execute(modelData.id, { })
101+ delegate: Button {
102+ width: Math.max(units.gu(4), buttons.buttonWidth)
103+ height: buttons.buttonHeight
104+ color: "#dd4814"
105+ text: modelData.displayName
106+ iconSource: modelData.iconHint
107+ iconPosition: "right"
108+ visible: true
109+ onClicked: {
110+ root.previewData.execute(modelData.id, { })
111+ }
90112 }
113+ focus: false
91114 }
92− focus: false
93115 }
94116}