@@ -17,6 +17,7 @@
1717import QtQuick 2.0
1818import Ubuntu.Components 0.1
1919import Ubuntu.Components.ListItems 0.1 as ListItems
20+import Ubuntu.DownloadDaemonListener 0.1
2021import "../../Components"
2122import ".."
2223import "../Previews"
@@ -27,7 +28,7 @@ DashPreview {
2728
2829 previewImages: previewImagesComponent
2930 header: headerComponent
30− actions: actionsComponent
31+ actions: root.previewData.infoMap["show_progressbar"] ? progressComponent : actionsComponent
3132 description: descriptionComponent
3233
3334 Component {
@@ -61,34 +62,57 @@ DashPreview {
6162
6263 Component {
6364 id: actionsComponent
64− GridView {
65− id: buttons
66− model: genericPreview.previewData.actions
67−
68− property int buttonMaxWidth: units.gu(34)
69− property int numOfColumns: Math.ceil((width + spacing) / (buttonMaxWidth + spacing))
70− property int numOfRows: Math.ceil(count / numOfColumns)
71− property int spacing: units.gu(1)
72− height: Math.max(units.gu(4), units.gu(4)*numOfRows + spacing*(numOfRows - 1))
73−
74− cellWidth: width / numOfColumns
75− cellHeight: buttonHeight + spacing
76− property int buttonWidth: cellWidth - spacing / 2
77− property int buttonHeight: units.gu(4)
78−
79− delegate: Button {
80− width: Math.max(units.gu(4), buttons.buttonWidth)
81− height: buttons.buttonHeight
82− color: "#dd4814"
83− text: modelData.displayName
84− iconSource: modelData.iconHint
85− iconPosition: "right"
86− visible: true
87− onClicked: {
88− genericPreview.previewData.execute(modelData.id, { })
65+
66+ Column {
67+ id: buttonList
68+ objectName: "buttonList"
69+ spacing: units.gu(1)
70+ Repeater {
71+ model: root.previewData.actions
72+
73+ delegate: Button {
74+ width: parent.width
75+ height: buttonList.buttonHeight
76+ color: Theme.palette.selected.foreground
77+ text: modelData.displayName
78+ iconSource: modelData.iconHint
79+ iconPosition: "right"
80+ onClicked: root.previewData.execute(modelData.id, { })
81+ }
82+ }
83+ }
84+ }
85+
86+ Component {
87+ id: progressComponent
88+
89+ ProgressBar {
90+ id: progressBar
91+ objectName: "progressBar"
92+ value: 0
93+ maximumValue: 100
94+ height: units.gu(5)
95+
96+ property var model: root.previewData.actions
97+
98+ DownloadTracker {
99+ service: "com.canonical.applications.Downloader"
100+ dbusPath: root.previewData.infoMap["progressbar_source"] ? root.previewData.infoMap["progressbar_source"].value : ""
101+
102+ onProgress: {
103+ var percentage = parseInt(received * 100 / total);
104+ progressBar.value = percentage;
105+ }
106+
107+ onFinished: {
108+ root.previewData.execute(progressBar.model[0].id, { })
109+ }
110+
111+ onError: {
112+ root.previewData.execute(progressBar.model[1].id, { "error": error });
89113 }
90114 }
91− focus: false
115+
92116 }
93117 }
94118