@@ -0,0 +1,66 @@
2+ * Copyright (C) 2014 Canonical, Ltd.
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.
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.
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/>.
18+import Ubuntu.Components 0.1
19+import Ubuntu.DownloadDaemonListener 0.1
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"]
31+ implicitHeight: progressBar.implicitHeight
32+ implicitWidth: progressBar.implicitWidth
36+ objectName: "progressBar"
39+ implicitHeight: units.gu(5)
40+ height: parent.height
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
48+ service: progressBar.source["dbus-name"] || ""
49+ dbusPath: progressBar.source["dbus-object"] || ""
52+ var percentage = parseInt(received * 100 / total);
53+ progressBar.value = percentage;
57+ root.triggered(widgetId, "finished", widgetData)
61+ root.triggered(widgetId, "failed", widgetData)