Merge lp:~ken-vandine/ubuntu-system-settings/storage_page_speedup into lp:ubuntu-system-settings

Proposed by Ken VanDine
Status: Merged
Approved by: Jonas G. Drange
Approved revision: 1637
Merged at revision: 1632
Proposed branch: lp:~ken-vandine/ubuntu-system-settings/storage_page_speedup
Merge into: lp:ubuntu-system-settings
Diff against target: 323 lines (+160/-108)
3 files modified
plugins/about/Storage.qml (+119/-92)
plugins/about/storageabout.cpp (+36/-13)
plugins/about/storageabout.h (+5/-3)
To merge this branch: bzr merge lp:~ken-vandine/ubuntu-system-settings/storage_page_speedup
Reviewer Review Type Date Requested Status
Jonas G. Drange (community) Approve
Review via email: mp+290159@code.launchpad.net

Commit message

* Use a loader for the Storage page and show an ActivityIndicator until the page is ready
* Improved performance of building the list of mountedVolumes

Description of the change

* Use a loader for the Storage page and show an ActivityIndicator until the page is ready
* Improved performance of building the list of mountedVolumes

To post a comment you must log in.
1631. By Ken VanDine

Trying to speed up device checking

1632. By Ken VanDine

Merged trunk

1633. By Ken VanDine

Added a label to show while the page is loading

1634. By Ken VanDine

Simplified string to just "Scanning"

Revision history for this message
Jonas G. Drange (jonas-drange) wrote :

Added a couple of comments. Also, you're basically solving bug 1488005 for the storage panel only. Should we consider solving it for all pages on the pageStack?

review: Needs Fixing
1635. By Ken VanDine

remove debug logging

1636. By Ken VanDine

Only build the list of mountedVolumes once

1637. By Ken VanDine

removed some debug logging

Revision history for this message
Matthew Paul Thomas (mpt) wrote :

Agreed with Jonas. If you’re just “show[ing] an ActivityIndicator until the page is ready”, please fix bug 1488005 by making that ActivityIndicator part of a class that every System Settings page inherits from — or will inherit from, starting with this page.

Revision history for this message
Ken VanDine (ken-vandine) wrote :

I took a look at fixing bug 148805 in a generic way and it's a bit more involved than this plus it would need to be a fix with the way we use the PageStack. We should fix that when we switch to the AdaptivePageLayout. For now let's just land the handling in this slow page.

Revision history for this message
Jonas G. Drange (jonas-drange) wrote :

WFM!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'plugins/about/Storage.qml'
2--- plugins/about/Storage.qml 2015-12-09 21:18:41 +0000
3+++ plugins/about/Storage.qml 2016-03-30 17:37:59 +0000
4@@ -28,100 +28,125 @@
5
6 ItemPage {
7 id: storagePage
8-
9 objectName: "storagePage"
10 title: i18n.tr("Storage")
11- flickable: scrollWidget
12-
13- property var allDrives: {
14- var drives = ["/"] // Always consider /
15- var paths = [backendInfo.getDevicePath("/")]
16- var systemDrives = backendInfo.mountedVolumes
17- for (var i = 0; i < systemDrives.length; i++) {
18- var drive = systemDrives[i]
19- var path = backendInfo.getDevicePath(drive)
20- /* only deal with the device's storage for now, external mounts
21- handling would require being smarter on the categories
22- computation as well and is not in the current design */
23- if (backendInfo.isInternal(drive) &&
24- paths.indexOf(path) == -1 && // Haven't seen this device before
25- path.charAt(0) === "/") { // Has a real mount point
26- drives.push(drive)
27- paths.push(path)
28- }
29- }
30- return drives
31- }
32- property real diskSpace: {
33- var space = 0
34- for (var i = 0; i < allDrives.length; i++) {
35- space += backendInfo.getTotalSpace(allDrives[i])
36- }
37- return space
38- }
39- /* Limit the free space to the user available one (see bug #1374134) */
40- property real freediskSpace: {
41- return backendInfo.getFreeSpace("/home")
42- }
43-
44- property real usedByUbuntu: diskSpace -
45- freediskSpace -
46- backendInfo.homeSize -
47- backendInfo.totalClickSize
48- property real otherSize: diskSpace -
49- freediskSpace -
50- usedByUbuntu -
51- backendInfo.totalClickSize -
52- backendInfo.moviesSize -
53- backendInfo.picturesSize -
54- backendInfo.audioSize
55- property variant spaceColors: [
56- UbuntuColors.orange,
57- "red",
58- "blue",
59- "green",
60- "yellow",
61- UbuntuColors.lightAubergine]
62- property variant spaceLabels: [
63- i18n.tr("Used by Ubuntu"),
64- i18n.tr("Videos"),
65- i18n.tr("Audio"),
66- i18n.tr("Pictures"),
67- i18n.tr("Other files"),
68- i18n.tr("Used by apps")]
69- property variant spaceValues: [
70- usedByUbuntu, // Used by Ubuntu
71- backendInfo.moviesSize,
72- backendInfo.audioSize,
73- backendInfo.picturesSize,
74- otherSize, //Other Files
75- backendInfo.totalClickSize]
76- property variant spaceObjectNames: [
77- "usedByUbuntuItem",
78- "moviesItem",
79- "audioItem",
80- "picturesItem",
81- "otherFilesItem",
82- "usedByAppsItem"]
83-
84- GSettings {
85- id: settingsId
86- schema.id: "com.ubuntu.touch.system-settings"
87- }
88-
89- UbuntuStorageAboutPanel {
90- id: backendInfo
91- property bool ready: false
92- // All of these events come simultaneously
93- onMoviesSizeChanged: ready = true
94- Component.onCompleted: populateSizes()
95- sortRole: settingsId.storageSortByName ?
96- ClickRoles.DisplayNameRole :
97- ClickRoles.InstalledSizeRole
98-
99- }
100-
101- Flickable {
102+
103+ Column {
104+ anchors.centerIn: parent
105+ visible: progress.running
106+ spacing: units.gu(2)
107+ Label {
108+ anchors {
109+ left: parent.left
110+ right: parent.right
111+ }
112+ horizontalAlignment: Text.AlignHCenter
113+ text: i18n.tr("Scanning")
114+ }
115+ ActivityIndicator {
116+ id: progress
117+ visible: running
118+ running: !pageLoader.visible
119+ }
120+ }
121+
122+ Loader {
123+ id: pageLoader
124+ anchors.fill: parent
125+ onStateChanged: {
126+ if (state === Loader.Ready)
127+ storagePage.flickable = scrollWidget;
128+ }
129+
130+ asynchronous: true
131+ visible: status == Loader.Ready
132+ sourceComponent: Item {
133+ anchors.fill: parent
134+ property var allDrives: {
135+ var drives = ["/"] // Always consider /
136+ var paths = [backendInfo.getDevicePath("/")]
137+ var systemDrives = backendInfo.mountedVolumes
138+ for (var i = 0; i < systemDrives.length; i++) {
139+ var drive = systemDrives[i]
140+ var path = backendInfo.getDevicePath(drive)
141+ if (paths.indexOf(path) == -1 && // Haven't seen this device before
142+ path.charAt(0) === "/") { // Has a real mount point
143+ drives.push(drive)
144+ paths.push(path)
145+ }
146+ }
147+ return drives
148+ }
149+ property real diskSpace: {
150+ var space = 0
151+ for (var i = 0; i < allDrives.length; i++) {
152+ space += backendInfo.getTotalSpace(allDrives[i])
153+ }
154+ return space
155+ }
156+ /* Limit the free space to the user available one (see bug #1374134) */
157+ property real freediskSpace: {
158+ return backendInfo.getFreeSpace("/home")
159+ }
160+
161+ property real usedByUbuntu: diskSpace -
162+ freediskSpace -
163+ backendInfo.homeSize -
164+ backendInfo.totalClickSize
165+ property real otherSize: diskSpace -
166+ freediskSpace -
167+ usedByUbuntu -
168+ backendInfo.totalClickSize -
169+ backendInfo.moviesSize -
170+ backendInfo.picturesSize -
171+ backendInfo.audioSize
172+ property variant spaceColors: [
173+ UbuntuColors.orange,
174+ "red",
175+ "blue",
176+ "green",
177+ "yellow",
178+ UbuntuColors.lightAubergine]
179+ property variant spaceLabels: [
180+ i18n.tr("Used by Ubuntu"),
181+ i18n.tr("Videos"),
182+ i18n.tr("Audio"),
183+ i18n.tr("Pictures"),
184+ i18n.tr("Other files"),
185+ i18n.tr("Used by apps")]
186+ property variant spaceValues: [
187+ usedByUbuntu, // Used by Ubuntu
188+ backendInfo.moviesSize,
189+ backendInfo.audioSize,
190+ backendInfo.picturesSize,
191+ otherSize, //Other Files
192+ backendInfo.totalClickSize]
193+ property variant spaceObjectNames: [
194+ "usedByUbuntuItem",
195+ "moviesItem",
196+ "audioItem",
197+ "picturesItem",
198+ "otherFilesItem",
199+ "usedByAppsItem"]
200+
201+ GSettings {
202+ id: settingsId
203+ schema.id: "com.ubuntu.touch.system-settings"
204+ }
205+
206+ UbuntuStorageAboutPanel {
207+ id: backendInfo
208+ property bool ready: false
209+ // All of these events come simultaneously
210+ onMoviesSizeChanged: ready = true
211+ Component.onCompleted: populateSizes()
212+ sortRole: settingsId.storageSortByName ?
213+ ClickRoles.DisplayNameRole :
214+ ClickRoles.InstalledSizeRole
215+
216+ }
217+
218+ Flickable {
219 id: scrollWidget
220 anchors.fill: parent
221 contentHeight: columnId.height
222@@ -202,4 +227,6 @@
223 }
224 }
225 }
226+ }
227+ }
228 }
229
230=== modified file 'plugins/about/storageabout.cpp'
231--- plugins/about/storageabout.cpp 2015-07-13 18:26:10 +0000
232+++ plugins/about/storageabout.cpp 2016-03-30 17:37:59 +0000
233@@ -315,18 +315,41 @@
234 m_cancellable));
235 }
236
237-QStringList StorageAbout::getMountedVolumes() const
238-{
239- QStringList out;
240-
241- Q_FOREACH (const QStorageInfo &storage, QStorageInfo::mountedVolumes())
242- if (storage.isValid() && storage.isReady())
243- out.append(storage.rootPath());
244-
245- return out;
246-}
247-
248-QString StorageAbout::getDevicePath(const QString mount_point)
249+QStringList StorageAbout::getMountedVolumes()
250+{
251+ if (m_mountedVolumes.isEmpty())
252+ prepareMountedVolumes();
253+
254+ return m_mountedVolumes;
255+}
256+
257+void StorageAbout::prepareMountedVolumes()
258+{
259+ QStringList checked;
260+
261+ Q_FOREACH (const QStorageInfo &storage, QStorageInfo::mountedVolumes()) {
262+ if (storage.isValid() && storage.isReady()) {
263+ QString drive(storage.rootPath());
264+ /* Only check devices once */
265+ if (checked.contains(drive))
266+ continue;
267+
268+ checked.append(drive);
269+ QString devicePath(getDevicePath(drive));
270+ if (devicePath.isEmpty() || m_mountedVolumes.contains(drive))
271+ continue;
272+
273+ /* only deal with the device's storage for now, external mounts
274+ handling would require being smarter on the categories
275+ computation as well and is not in the current design */
276+ if (isInternal(drive)) {
277+ m_mountedVolumes.append(drive);
278+ }
279+ }
280+ }
281+}
282+
283+QString StorageAbout::getDevicePath(const QString mount_point) const
284 {
285 QString s_mount_point;
286 GUnixMountEntry * g_mount_point = nullptr;
287@@ -362,7 +385,7 @@
288 * met: http://www.gnu.org/copyleft/gpl.html.
289 *
290 */
291-bool StorageAbout::isInternal(const QString &drive)
292+bool StorageAbout::isInternal(const QString &drive) const
293 {
294 bool ret = false;
295 FILE *fsDescription = setmntent(_PATH_MOUNTED, "r");
296
297=== modified file 'plugins/about/storageabout.h'
298--- plugins/about/storageabout.h 2015-07-13 18:26:10 +0000
299+++ plugins/about/storageabout.h 2016-03-30 17:37:59 +0000
300@@ -108,11 +108,11 @@
301 quint64 getPicturesSize();
302 quint64 getHomeSize();
303 Q_INVOKABLE void populateSizes();
304- QStringList getMountedVolumes() const;
305- Q_INVOKABLE QString getDevicePath (const QString mount_point);
306+ QStringList getMountedVolumes();
307+ Q_INVOKABLE QString getDevicePath (const QString mount_point) const;
308 Q_INVOKABLE qint64 getFreeSpace (const QString mount_point);
309 Q_INVOKABLE qint64 getTotalSpace (const QString mount_point);
310- Q_INVOKABLE bool isInternal(const QString &drive);
311+ Q_INVOKABLE bool isInternal(const QString &drive) const;
312 bool getDeveloperMode();
313 void setDeveloperMode(bool newMode);
314
315@@ -121,6 +121,8 @@
316 void sizeReady();
317
318 private:
319+ void prepareMountedVolumes();
320+ QStringList m_mountedVolumes;
321 QString m_serialNumber;
322 QString m_vendorString;
323 QString m_deviceBuildDisplayID;

Subscribers

People subscribed via source and target branches