on xenial help sign in
move buttons to GenericPreview, clean them up
commitc7b2c491ffa2c3deff3307148ef3ae84aec7f669 authorMichael Zanetti <michael.zanetti@canonical.com> dateTue 1 Oct 2013, 19:30 (13 years ago) parent196037b
2 files changed+51−85
Dash/Apps/AppPreview.qml−58 Dash/Generic/GenericPreview.qml+51−27
Dash/Apps/AppPreview.qml−58
@@ -17,7 +17,6 @@
1717import QtQuick 2.0
1818import Ubuntu.Components 0.1
1919import Ubuntu.Components.ListItems 0.1 as ListItems
20−import Ubuntu.DownloadDaemonListener 0.1
2120import ".."
2221import "../Generic"
2322import "../Previews"
@@ -29,7 +28,6 @@ GenericPreview {
2928 signal sendUserReview(string review)
3029
3130 previewImages: previewImagesComponent
32− actions: root.previewData.infoMap["show_progressbar"] ? progressComponent : buttonsComponent
3331 description: descriptionComponent
3432 header: headerComponent
3533
@@ -76,62 +74,6 @@ GenericPreview {
7674 }
7775 }
7876
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−
13577 Component {
13678 id: descriptionComponent
13779 Column {
Dash/Generic/GenericPreview.qml+51−27
@@ -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