on xenial help sign in
Progress Widget
9fcfc21Albert Astals
qml/Dash/Previews/PreviewProgress.qmlnew file+66
@@ -0,0 +1,66 @@
1+/*
2+ * Copyright (C) 2014 Canonical, Ltd.
3+ *
4+ * This program is free software; you can redistribute it and/or modify
5+ * it under the terms of the GNU General Public License as published by
6+ * the Free Software Foundation; version 3.
7+ *
8+ * This program is distributed in the hope that it will be useful,
9+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
10+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11+ * GNU General Public License for more details.
12+ *
13+ * You should have received a copy of the GNU General Public License
14+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
15+ */
16+
17+import QtQuick 2.1
18+import Ubuntu.Components 0.1
19+import Ubuntu.DownloadDaemonListener 0.1
20+
21+
22+/*! This preview widget shows a progress bar.
23+ * It feeds itself from the source determined in widgetData["source"]
24+ * At the moment we only support the dbus source defined
25+ * by source["dbus-name"] and source["dbus-object"]
26+ */
27+
28+PreviewWidget {
29+ id: root
30+
31+ implicitHeight: progressBar.implicitHeight
32+ implicitWidth: progressBar.implicitWidth
33+
34+ ProgressBar {
35+ id: progressBar
36+ objectName: "progressBar"
37+ value: 0
38+ maximumValue: 100
39+ implicitHeight: units.gu(5)
40+ height: parent.height
41+ width: parent.width
42+
43+ property var source: widgetData["source"]
44+ // TODO Eventually we will need to support more sources other
45+ // than DownloadTracker via dbus so we'll need a Loader based on source contents
46+
47+ DownloadTracker {
48+ service: progressBar.source["dbus-name"] || ""
49+ dbusPath: progressBar.source["dbus-object"] || ""
50+
51+ onProgress: {
52+ var percentage = parseInt(received * 100 / total);
53+ progressBar.value = percentage;
54+ }
55+
56+ onFinished: {
57+ root.triggered(widgetId, "finished", widgetData)
58+ }
59+
60+ onError: {
61+ root.triggered(widgetId, "failed", widgetData)
62+ }
63+ }
64+
65+ }
66+}
qml/Dash/Previews/PreviewWidgetFactory.qml+1
@@ -46,6 +46,7 @@ Loader {
46 case "audio": return "PreviewAudioPlayback.qml";
46 case "audio": return "PreviewAudioPlayback.qml";
47 case "gallery": return "PreviewImageGallery.qml";
47 case "gallery": return "PreviewImageGallery.qml";
48 case "header": return "PreviewHeader.qml";
48 case "header": return "PreviewHeader.qml";
49+ case "progress": return "PreviewProgress.qml";
49 case "text": return "PreviewTextSummary.qml";
50 case "text": return "PreviewTextSummary.qml";
50 default: return "";
51 default: return "";
51 }
52 }
tests/qmltests/CMakeLists.txt+1
@@ -60,6 +60,7 @@ add_qml_test(Dash/Previews PreviewActions IMPORT_PATHS ${qmltest_DEFAULT_IMPORT_
60add_qml_test(Dash/Previews PreviewAudioPlayback IMPORT_PATHS ${qmltest_DEFAULT_IMPORT_PATHS} ${CMAKE_BINARY_DIR}/tests/mocks)
60add_qml_test(Dash/Previews PreviewAudioPlayback IMPORT_PATHS ${qmltest_DEFAULT_IMPORT_PATHS} ${CMAKE_BINARY_DIR}/tests/mocks)
61add_qml_test(Dash/Previews PreviewImageGallery IMPORT_PATHS ${qmltest_DEFAULT_IMPORT_PATHS} ${CMAKE_BINARY_DIR}/tests/mocks)
61add_qml_test(Dash/Previews PreviewImageGallery IMPORT_PATHS ${qmltest_DEFAULT_IMPORT_PATHS} ${CMAKE_BINARY_DIR}/tests/mocks)
62add_qml_test(Dash/Previews PreviewHeader IMPORT_PATHS ${qmltest_DEFAULT_IMPORT_PATHS} ${CMAKE_BINARY_DIR}/tests/mocks)
62add_qml_test(Dash/Previews PreviewHeader IMPORT_PATHS ${qmltest_DEFAULT_IMPORT_PATHS} ${CMAKE_BINARY_DIR}/tests/mocks)
63+add_qml_test(Dash/Previews PreviewProgress IMPORT_PATHS ${qmltest_DEFAULT_IMPORT_PATHS} ${CMAKE_BINARY_DIR}/tests/mocks)
63add_qml_test(Dash/Previews PreviewTextSummary IMPORT_PATHS ${qmltest_DEFAULT_IMPORT_PATHS} ${CMAKE_BINARY_DIR}/tests/mocks)
64add_qml_test(Dash/Previews PreviewTextSummary IMPORT_PATHS ${qmltest_DEFAULT_IMPORT_PATHS} ${CMAKE_BINARY_DIR}/tests/mocks)
64add_qml_test(Greeter Lockscreen IMPORT_PATHS ${CMAKE_BINARY_DIR}/plugins ${qmltest_DEFAULT_IMPORT_PATHS}
65add_qml_test(Greeter Lockscreen IMPORT_PATHS ${CMAKE_BINARY_DIR}/plugins ${qmltest_DEFAULT_IMPORT_PATHS}
65 PROPERTIES ENVIRONMENT "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/tests/mocks/libusermetrics:${CMAKE_BINARY_DIR}/tests/mocks/LightDM/full")
66 PROPERTIES ENVIRONMENT "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/tests/mocks/libusermetrics:${CMAKE_BINARY_DIR}/tests/mocks/LightDM/full")
tests/qmltests/Dash/Previews/tst_PreviewWidgetFactory.qml+1
@@ -80,6 +80,7 @@ Rectangle {
80 { tag: "Gallery", type: "gallery", source: "PreviewImageGallery.qml" },
80 { tag: "Gallery", type: "gallery", source: "PreviewImageGallery.qml" },
81 { tag: "Actions", type: "actions", source: "PreviewActions.qml" },
81 { tag: "Actions", type: "actions", source: "PreviewActions.qml" },
82 { tag: "Header", type: "header", source: "PreviewHeader.qml" },
82 { tag: "Header", type: "header", source: "PreviewHeader.qml" },
83+ { tag: "Progress", type: "progress", source: "PreviewProgress.qml" },
83 ];
84 ];
84 }
85 }
85
86