on xenial help sign in
move buttons to GenericPreview, clean them up
c7b2c49Michael Zanetti
Dash/Apps/AppPreview.qml−58
@@ -17,7 +17,6 @@
17import QtQuick 2.0
17import QtQuick 2.0
18import Ubuntu.Components 0.1
18import Ubuntu.Components 0.1
19import Ubuntu.Components.ListItems 0.1 as ListItems
19import Ubuntu.Components.ListItems 0.1 as ListItems
20−import Ubuntu.DownloadDaemonListener 0.1
21import ".."
20import ".."
22import "../Generic"
21import "../Generic"
23import "../Previews"
22import "../Previews"
@@ -29,7 +28,6 @@ GenericPreview {
29 signal sendUserReview(string review)
28 signal sendUserReview(string review)
30
29
31 previewImages: previewImagesComponent
30 previewImages: previewImagesComponent
32− actions: root.previewData.infoMap["show_progressbar"] ? progressComponent : buttonsComponent
33 description: descriptionComponent
31 description: descriptionComponent
34 header: headerComponent
32 header: headerComponent
35
33
@@ -76,62 +74,6 @@ GenericPreview {
76 }
74 }
77 }
75 }
78
76
79− Component {
80− id: buttonsComponent
81−
82− Column {
83− id: buttonList
84− objectName: "gridButtons"
85− spacing: units.gu(1)
86− Repeater {
87− model: root.previewData.actions
88−
89− delegate: Button {
90− width: parent.width
91− height: buttonList.buttonHeight
92− color: Theme.palette.selected.foreground
93− text: modelData.displayName
94− iconSource: modelData.iconHint
95− iconPosition: "right"
96− onClicked: root.previewData.execute(modelData.id, { })
97− }
98− }
99− }
100− }
101−
102− Component {
103− id: progressComponent
104−
105− ProgressBar {
106− id: progressBar
107− objectName: "progressBar"
108− value: 0
109− maximumValue: 100
110− height: units.gu(5)
111−
112− property var model: root.previewData.actions
113−
114− DownloadTracker {
115− service: "com.canonical.applications.Downloader"
116− dbusPath: root.previewData.infoMap["progressbar_source"] ? root.previewData.infoMap["progressbar_source"].value : ""
117−
118− onProgress: {
119− var percentage = parseInt(received * 100 / total);
120− progressBar.value = percentage;
121− }
122−
123− onFinished: {
124− root.previewData.execute(progressBar.model[0].id, { })
125− }
126−
127− onError: {
128− root.previewData.execute(progressBar.model[1].id, { "error": error });
129− }
130− }
131−
132− }
133− }
134−
135 Component {
77 Component {
136 id: descriptionComponent
78 id: descriptionComponent
137 Column {
79 Column {
Dash/Generic/GenericPreview.qml+51−27
@@ -17,6 +17,7 @@
17import QtQuick 2.0
17import QtQuick 2.0
18import Ubuntu.Components 0.1
18import Ubuntu.Components 0.1
19import Ubuntu.Components.ListItems 0.1 as ListItems
19import Ubuntu.Components.ListItems 0.1 as ListItems
20+import Ubuntu.DownloadDaemonListener 0.1
20import "../../Components"
21import "../../Components"
21import ".."
22import ".."
22import "../Previews"
23import "../Previews"
@@ -27,7 +28,7 @@ DashPreview {
27
28
28 previewImages: previewImagesComponent
29 previewImages: previewImagesComponent
29 header: headerComponent
30 header: headerComponent
30− actions: actionsComponent
31+ actions: root.previewData.infoMap["show_progressbar"] ? progressComponent : actionsComponent
31 description: descriptionComponent
32 description: descriptionComponent
32
33
33 Component {
34 Component {
@@ -61,34 +62,57 @@ DashPreview {
61
62
62 Component {
63 Component {
63 id: actionsComponent
64 id: actionsComponent
64− GridView {
65+
65− id: buttons
66+ Column {
66− model: genericPreview.previewData.actions
67+ id: buttonList
67−
68+ objectName: "buttonList"
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)
69+ spacing: units.gu(1)
72− height: Math.max(units.gu(4), units.gu(4)*numOfRows + spacing*(numOfRows - 1))
70+ Repeater {
73−
71+ model: root.previewData.actions
74− cellWidth: width / numOfColumns
72+
75− cellHeight: buttonHeight + spacing
76− property int buttonWidth: cellWidth - spacing / 2
77− property int buttonHeight: units.gu(4)
78−
79− delegate: Button {
73+ delegate: Button {
80− width: Math.max(units.gu(4), buttons.buttonWidth)
74+ width: parent.width
81− height: buttons.buttonHeight
75+ height: buttonList.buttonHeight
82− color: "#dd4814"
76+ color: Theme.palette.selected.foreground
83− text: modelData.displayName
77+ text: modelData.displayName
84− iconSource: modelData.iconHint
78+ iconSource: modelData.iconHint
85− iconPosition: "right"
79+ iconPosition: "right"
86− visible: true
80+ onClicked: root.previewData.execute(modelData.id, { })
87− onClicked: {
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: {
88− genericPreview.previewData.execute(modelData.id, { })
112+ root.previewData.execute(progressBar.model[1].id, { "error": error });
89 }
113 }
90 }
114 }
91− focus: false
115+
92 }
116 }
93 }
117 }
94
118