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
=== modified file 'plugins/about/Storage.qml'
--- plugins/about/Storage.qml 2015-12-09 21:18:41 +0000
+++ plugins/about/Storage.qml 2016-03-30 17:37:59 +0000
@@ -28,100 +28,125 @@
2828
29ItemPage {29ItemPage {
30 id: storagePage30 id: storagePage
31
32 objectName: "storagePage"31 objectName: "storagePage"
33 title: i18n.tr("Storage")32 title: i18n.tr("Storage")
34 flickable: scrollWidget33
3534 Column {
36 property var allDrives: {35 anchors.centerIn: parent
37 var drives = ["/"] // Always consider /36 visible: progress.running
38 var paths = [backendInfo.getDevicePath("/")]37 spacing: units.gu(2)
39 var systemDrives = backendInfo.mountedVolumes38 Label {
40 for (var i = 0; i < systemDrives.length; i++) {39 anchors {
41 var drive = systemDrives[i]40 left: parent.left
42 var path = backendInfo.getDevicePath(drive)41 right: parent.right
43 /* only deal with the device's storage for now, external mounts42 }
44 handling would require being smarter on the categories43 horizontalAlignment: Text.AlignHCenter
45 computation as well and is not in the current design */44 text: i18n.tr("Scanning")
46 if (backendInfo.isInternal(drive) &&45 }
47 paths.indexOf(path) == -1 && // Haven't seen this device before46 ActivityIndicator {
48 path.charAt(0) === "/") { // Has a real mount point47 id: progress
49 drives.push(drive)48 visible: running
50 paths.push(path)49 running: !pageLoader.visible
51 }50 }
52 }51 }
53 return drives52
54 }53 Loader {
55 property real diskSpace: {54 id: pageLoader
56 var space = 055 anchors.fill: parent
57 for (var i = 0; i < allDrives.length; i++) {56 onStateChanged: {
58 space += backendInfo.getTotalSpace(allDrives[i])57 if (state === Loader.Ready)
59 }58 storagePage.flickable = scrollWidget;
60 return space59 }
61 }60
62 /* Limit the free space to the user available one (see bug #1374134) */61 asynchronous: true
63 property real freediskSpace: {62 visible: status == Loader.Ready
64 return backendInfo.getFreeSpace("/home")63 sourceComponent: Item {
65 }64 anchors.fill: parent
6665 property var allDrives: {
67 property real usedByUbuntu: diskSpace -66 var drives = ["/"] // Always consider /
68 freediskSpace -67 var paths = [backendInfo.getDevicePath("/")]
69 backendInfo.homeSize -68 var systemDrives = backendInfo.mountedVolumes
70 backendInfo.totalClickSize69 for (var i = 0; i < systemDrives.length; i++) {
71 property real otherSize: diskSpace -70 var drive = systemDrives[i]
72 freediskSpace -71 var path = backendInfo.getDevicePath(drive)
73 usedByUbuntu -72 if (paths.indexOf(path) == -1 && // Haven't seen this device before
74 backendInfo.totalClickSize -73 path.charAt(0) === "/") { // Has a real mount point
75 backendInfo.moviesSize -74 drives.push(drive)
76 backendInfo.picturesSize -75 paths.push(path)
77 backendInfo.audioSize76 }
78 property variant spaceColors: [77 }
79 UbuntuColors.orange,78 return drives
80 "red",79 }
81 "blue",80 property real diskSpace: {
82 "green",81 var space = 0
83 "yellow",82 for (var i = 0; i < allDrives.length; i++) {
84 UbuntuColors.lightAubergine]83 space += backendInfo.getTotalSpace(allDrives[i])
85 property variant spaceLabels: [84 }
86 i18n.tr("Used by Ubuntu"),85 return space
87 i18n.tr("Videos"),86 }
88 i18n.tr("Audio"),87 /* Limit the free space to the user available one (see bug #1374134) */
89 i18n.tr("Pictures"),88 property real freediskSpace: {
90 i18n.tr("Other files"),89 return backendInfo.getFreeSpace("/home")
91 i18n.tr("Used by apps")]90 }
92 property variant spaceValues: [91
93 usedByUbuntu, // Used by Ubuntu92 property real usedByUbuntu: diskSpace -
94 backendInfo.moviesSize,93 freediskSpace -
95 backendInfo.audioSize,94 backendInfo.homeSize -
96 backendInfo.picturesSize,95 backendInfo.totalClickSize
97 otherSize, //Other Files96 property real otherSize: diskSpace -
98 backendInfo.totalClickSize]97 freediskSpace -
99 property variant spaceObjectNames: [98 usedByUbuntu -
100 "usedByUbuntuItem",99 backendInfo.totalClickSize -
101 "moviesItem",100 backendInfo.moviesSize -
102 "audioItem",101 backendInfo.picturesSize -
103 "picturesItem",102 backendInfo.audioSize
104 "otherFilesItem",103 property variant spaceColors: [
105 "usedByAppsItem"]104 UbuntuColors.orange,
106105 "red",
107 GSettings {106 "blue",
108 id: settingsId107 "green",
109 schema.id: "com.ubuntu.touch.system-settings"108 "yellow",
110 }109 UbuntuColors.lightAubergine]
111110 property variant spaceLabels: [
112 UbuntuStorageAboutPanel {111 i18n.tr("Used by Ubuntu"),
113 id: backendInfo112 i18n.tr("Videos"),
114 property bool ready: false113 i18n.tr("Audio"),
115 // All of these events come simultaneously114 i18n.tr("Pictures"),
116 onMoviesSizeChanged: ready = true115 i18n.tr("Other files"),
117 Component.onCompleted: populateSizes()116 i18n.tr("Used by apps")]
118 sortRole: settingsId.storageSortByName ?117 property variant spaceValues: [
119 ClickRoles.DisplayNameRole :118 usedByUbuntu, // Used by Ubuntu
120 ClickRoles.InstalledSizeRole119 backendInfo.moviesSize,
121120 backendInfo.audioSize,
122 }121 backendInfo.picturesSize,
123122 otherSize, //Other Files
124 Flickable {123 backendInfo.totalClickSize]
124 property variant spaceObjectNames: [
125 "usedByUbuntuItem",
126 "moviesItem",
127 "audioItem",
128 "picturesItem",
129 "otherFilesItem",
130 "usedByAppsItem"]
131
132 GSettings {
133 id: settingsId
134 schema.id: "com.ubuntu.touch.system-settings"
135 }
136
137 UbuntuStorageAboutPanel {
138 id: backendInfo
139 property bool ready: false
140 // All of these events come simultaneously
141 onMoviesSizeChanged: ready = true
142 Component.onCompleted: populateSizes()
143 sortRole: settingsId.storageSortByName ?
144 ClickRoles.DisplayNameRole :
145 ClickRoles.InstalledSizeRole
146
147 }
148
149 Flickable {
125 id: scrollWidget150 id: scrollWidget
126 anchors.fill: parent151 anchors.fill: parent
127 contentHeight: columnId.height152 contentHeight: columnId.height
@@ -202,4 +227,6 @@
202 }227 }
203 }228 }
204 }229 }
230 }
231 }
205}232}
206233
=== modified file 'plugins/about/storageabout.cpp'
--- plugins/about/storageabout.cpp 2015-07-13 18:26:10 +0000
+++ plugins/about/storageabout.cpp 2016-03-30 17:37:59 +0000
@@ -315,18 +315,41 @@
315 m_cancellable));315 m_cancellable));
316}316}
317317
318QStringList StorageAbout::getMountedVolumes() const318QStringList StorageAbout::getMountedVolumes()
319{319{
320 QStringList out;320 if (m_mountedVolumes.isEmpty())
321321 prepareMountedVolumes();
322 Q_FOREACH (const QStorageInfo &storage, QStorageInfo::mountedVolumes())322
323 if (storage.isValid() && storage.isReady())323 return m_mountedVolumes;
324 out.append(storage.rootPath());324}
325325
326 return out;326void StorageAbout::prepareMountedVolumes()
327}327{
328328 QStringList checked;
329QString StorageAbout::getDevicePath(const QString mount_point)329
330 Q_FOREACH (const QStorageInfo &storage, QStorageInfo::mountedVolumes()) {
331 if (storage.isValid() && storage.isReady()) {
332 QString drive(storage.rootPath());
333 /* Only check devices once */
334 if (checked.contains(drive))
335 continue;
336
337 checked.append(drive);
338 QString devicePath(getDevicePath(drive));
339 if (devicePath.isEmpty() || m_mountedVolumes.contains(drive))
340 continue;
341
342 /* only deal with the device's storage for now, external mounts
343 handling would require being smarter on the categories
344 computation as well and is not in the current design */
345 if (isInternal(drive)) {
346 m_mountedVolumes.append(drive);
347 }
348 }
349 }
350}
351
352QString StorageAbout::getDevicePath(const QString mount_point) const
330{353{
331 QString s_mount_point;354 QString s_mount_point;
332 GUnixMountEntry * g_mount_point = nullptr;355 GUnixMountEntry * g_mount_point = nullptr;
@@ -362,7 +385,7 @@
362 * met: http://www.gnu.org/copyleft/gpl.html.385 * met: http://www.gnu.org/copyleft/gpl.html.
363 *386 *
364 */387 */
365bool StorageAbout::isInternal(const QString &drive)388bool StorageAbout::isInternal(const QString &drive) const
366{389{
367 bool ret = false;390 bool ret = false;
368 FILE *fsDescription = setmntent(_PATH_MOUNTED, "r");391 FILE *fsDescription = setmntent(_PATH_MOUNTED, "r");
369392
=== modified file 'plugins/about/storageabout.h'
--- plugins/about/storageabout.h 2015-07-13 18:26:10 +0000
+++ plugins/about/storageabout.h 2016-03-30 17:37:59 +0000
@@ -108,11 +108,11 @@
108 quint64 getPicturesSize();108 quint64 getPicturesSize();
109 quint64 getHomeSize();109 quint64 getHomeSize();
110 Q_INVOKABLE void populateSizes();110 Q_INVOKABLE void populateSizes();
111 QStringList getMountedVolumes() const;111 QStringList getMountedVolumes();
112 Q_INVOKABLE QString getDevicePath (const QString mount_point);112 Q_INVOKABLE QString getDevicePath (const QString mount_point) const;
113 Q_INVOKABLE qint64 getFreeSpace (const QString mount_point);113 Q_INVOKABLE qint64 getFreeSpace (const QString mount_point);
114 Q_INVOKABLE qint64 getTotalSpace (const QString mount_point);114 Q_INVOKABLE qint64 getTotalSpace (const QString mount_point);
115 Q_INVOKABLE bool isInternal(const QString &drive);115 Q_INVOKABLE bool isInternal(const QString &drive) const;
116 bool getDeveloperMode();116 bool getDeveloperMode();
117 void setDeveloperMode(bool newMode);117 void setDeveloperMode(bool newMode);
118118
@@ -121,6 +121,8 @@
121 void sizeReady();121 void sizeReady();
122122
123private:123private:
124 void prepareMountedVolumes();
125 QStringList m_mountedVolumes;
124 QString m_serialNumber;126 QString m_serialNumber;
125 QString m_vendorString;127 QString m_vendorString;
126 QString m_deviceBuildDisplayID;128 QString m_deviceBuildDisplayID;

Subscribers

People subscribed via source and target branches