Merge lp:~ken-vandine/ubuntu-system-settings/rtm-1385286 into lp:ubuntu-system-settings/rtm-14.09

Proposed by Ken VanDine
Status: Rejected
Rejected by: Sebastien Bacher
Proposed branch: lp:~ken-vandine/ubuntu-system-settings/rtm-1385286
Merge into: lp:ubuntu-system-settings/rtm-14.09
Diff against target: 244 lines (+40/-45)
11 files modified
plugins/about/PageComponent.qml (+1/-1)
plugins/about/Storage.qml (+2/-2)
plugins/about/StorageItem.qml (+1/-1)
plugins/about/storageabout.cpp (+0/-11)
plugins/about/storageabout.h (+0/-1)
plugins/system-update/PageComponent.qml (+5/-28)
src/CMakeLists.txt (+3/-1)
src/main.cpp (+1/-0)
src/utils.cpp (+17/-0)
src/utils.h (+8/-0)
tests/CMakeLists.txt (+2/-0)
To merge this branch: bzr merge lp:~ken-vandine/ubuntu-system-settings/rtm-1385286
Reviewer Review Type Date Requested Status
Sebastien Bacher (community) Approve
Review via email: mp+242118@code.launchpad.net

Commit message

Move formatSize into a new Utilities class in the qml context and call this from the updates panel to consistently display sizes

Description of the change

Move formatSize into a new Utilities class in the qml context and call this from the updates panel to consistently display sizes

To post a comment you must log in.
Revision history for this message
Sebastien Bacher (seb128) wrote :

Thanks

review: Approve
Revision history for this message
Sebastien Bacher (seb128) wrote :

seems like we are not doing more rtm landing, so cleaning the list a bit, that one is rather going to be including with the vivid rebase

Unmerged revisions

940. By Ken VanDine

Move formatSize into a new Utilities class in the qml context and call this from the updates panel to consistently display sizes

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'plugins/about/PageComponent.qml'
2--- plugins/about/PageComponent.qml 2014-11-12 16:03:25 +0000
3+++ plugins/about/PageComponent.qml 2014-11-18 19:44:46 +0000
4@@ -143,7 +143,7 @@
5 objectName: "storageItem"
6 text: i18n.tr("Storage")
7 /* TRANSLATORS: that's the free disk space, indicated in the most appropriate storage unit */
8- value: i18n.tr("%1 free").arg(backendInfos.formatSize(storageInfo.availableDiskSpace("/home")))
9+ value: i18n.tr("%1 free").arg(Utilities.formatSize(storageInfo.availableDiskSpace("/home")))
10 progression: true
11 onClicked: pageStack.push(Qt.resolvedUrl("Storage.qml"))
12 }
13
14=== modified file 'plugins/about/Storage.qml'
15--- plugins/about/Storage.qml 2014-09-26 08:35:34 +0000
16+++ plugins/about/Storage.qml 2014-11-18 19:44:46 +0000
17@@ -138,7 +138,7 @@
18 id: diskItem
19 objectName: "diskItem"
20 text: i18n.tr("Total storage")
21- value: backendInfo.formatSize(diskSpace)
22+ value: Utilities.formatSize(diskSpace)
23 showDivider: false
24 }
25
26@@ -199,7 +199,7 @@
27 iconFrame: iconPath // no frame for invalid icons, since these aren't app icons
28 text: displayName
29 value: installedSize ?
30- backendInfo.formatSize(installedSize) :
31+ Utilities.formatSize(installedSize) :
32 i18n.tr("N/A")
33 }
34 }
35
36=== modified file 'plugins/about/StorageItem.qml'
37--- plugins/about/StorageItem.qml 2014-01-27 10:41:38 +0000
38+++ plugins/about/StorageItem.qml 2014-11-18 19:44:46 +0000
39@@ -25,7 +25,7 @@
40 id: sizelabel
41 objectName: "sizeLabel"
42 anchors.right: parent.right
43- text: backendInfo.formatSize(value)
44+ text: Utilities.formatSize(value)
45 visible: ready
46 }
47 ActivityIndicator {
48
49=== modified file 'plugins/about/storageabout.cpp'
50--- plugins/about/storageabout.cpp 2014-10-02 16:35:40 +0000
51+++ plugins/about/storageabout.cpp 2014-11-18 19:44:46 +0000
52@@ -290,17 +290,6 @@
53 return m_homeSize;
54 }
55
56-QString StorageAbout::formatSize(quint64 size) const
57-{
58- guint64 g_size = size;
59-
60- gchar * formatted_size = g_format_size (g_size);
61- QString q_formatted_size = QString::fromLocal8Bit(formatted_size);
62- g_free (formatted_size);
63-
64- return q_formatted_size;
65-}
66-
67 void StorageAbout::populateSizes()
68 {
69 quint32 *running = new quint32(0);
70
71=== modified file 'plugins/about/storageabout.h'
72--- plugins/about/storageabout.h 2014-09-24 12:29:57 +0000
73+++ plugins/about/storageabout.h 2014-11-18 19:44:46 +0000
74@@ -109,7 +109,6 @@
75 quint64 getAudioSize();
76 quint64 getPicturesSize();
77 quint64 getHomeSize();
78- Q_INVOKABLE QString formatSize (quint64 size) const;
79 Q_INVOKABLE void populateSizes();
80 Q_INVOKABLE QString getDevicePath (const QString mount_point);
81 bool getDeveloperMode();
82
83=== modified file 'plugins/system-update/PageComponent.qml'
84--- plugins/system-update/PageComponent.qml 2014-10-20 20:53:02 +0000
85+++ plugins/system-update/PageComponent.qml 2014-11-18 19:44:46 +0000
86@@ -535,11 +535,11 @@
87 fontSize: "small"
88 text: {
89 if (!labelUpdateStatus.visible)
90- return convert_bytes_to_size(modelData.binaryFilesize);
91+ return Utilities.formatSize(modelData.binaryFilesize);
92
93 return i18n.tr("%1 of %2").arg(
94- convert_bytes_to_size(modelData.binaryFilesize * (progress.value * 0.01))).arg(
95- convert_bytes_to_size(modelData.binaryFilesize)
96+ Utilities.formatSize(modelData.binaryFilesize * (progress.value * 0.01))).arg(
97+ Utilities.formatSize(modelData.binaryFilesize)
98 );
99 }
100 }
101@@ -640,12 +640,12 @@
102 elide: Text.ElideRight
103 fontSize: "small"
104 }
105-
106+
107 Label {
108 id: labelSize
109 objectName: "labelSize"
110 anchors.right: parent.right
111- text: convert_bytes_to_size(modelData.binaryFilesize)
112+ text: Utilities.formatSize(modelData.binaryFilesize)
113 fontSize: "small"
114 visible: !labelUpdateStatus.visible && !installing && !installed
115 }
116@@ -773,27 +773,4 @@
117 onClicked: pageStack.push(Qt.resolvedUrl("Configuration.qml"))
118 }
119 }
120-
121- function convert_bytes_to_size(bytes) {
122- var SIZE_IN_GIB = 1024.0 * 1024.0 * 1024.0;
123- var SIZE_IN_MIB = 1024.0 * 1024.0;
124- var SIZE_IN_KIB = 1024.0;
125-
126- var result = "";
127- var size = 0;
128- if (bytes < SIZE_IN_KIB) {
129- result = bytes + i18n.tr(" bytes");
130- } else if (bytes < SIZE_IN_MIB) {
131- size = (bytes / SIZE_IN_KIB).toFixed(1);
132- result = size + i18n.tr(" KiB");
133- } else if (bytes < SIZE_IN_GIB) {
134- size = (bytes / SIZE_IN_MIB).toFixed(1);
135- result = size + i18n.tr(" MiB");
136- } else {
137- size = (bytes / SIZE_IN_GIB).toFixed(1);
138- result = size + i18n.tr(" GiB");
139- }
140-
141- return result;
142- }
143 }
144
145=== modified file 'src/CMakeLists.txt'
146--- src/CMakeLists.txt 2014-11-12 16:03:25 +0000
147+++ src/CMakeLists.txt 2014-11-18 19:44:46 +0000
148@@ -1,3 +1,5 @@
149+include_directories(${GLIB_INCLUDE_DIRS})
150+
151 add_definitions(-DI18N_DIRECTORY="${CMAKE_INSTALL_PREFIX}/share/locale")
152 add_definitions(-DI18N_DOMAIN="ubuntu-system-settings")
153 add_definitions(-DPLUGIN_PRIVATE_MODULE_DIR="${PLUGIN_PRIVATE_MODULE_DIR}")
154@@ -30,7 +32,7 @@
155
156 add_executable(system-settings ${USS_SOURCES} ${QML_SOURCES} ${system-settings-resources})
157 qt5_use_modules(system-settings Core Gui Quick Qml)
158-target_link_libraries(system-settings SystemSettings)
159+target_link_libraries(system-settings SystemSettings ${GLIB_LDFLAGS})
160 install(TARGETS system-settings RUNTIME DESTINATION bin)
161
162 add_library(uss-accountsservice SHARED accountsservice.h accountsservice.cpp)
163
164=== modified file 'src/main.cpp'
165--- src/main.cpp 2014-10-21 15:20:07 +0000
166+++ src/main.cpp 2014-11-18 19:44:46 +0000
167@@ -85,6 +85,7 @@
168 Qt::QueuedConnection);
169 qmlRegisterType<QAbstractItemModel>();
170 qmlRegisterType<SystemSettings::PluginManager>("SystemSettings", 1, 0, "PluginManager");
171+ view.engine()->rootContext()->setContextProperty("Utilities", new Utilities());
172 view.setResizeMode(QQuickView::SizeRootObjectToView);
173 view.engine()->addImportPath(PLUGIN_PRIVATE_MODULE_DIR);
174 view.engine()->addImportPath(PLUGIN_QML_DIR);
175
176=== modified file 'src/utils.cpp'
177--- src/utils.cpp 2014-07-23 13:29:15 +0000
178+++ src/utils.cpp 2014-11-18 19:44:46 +0000
179@@ -21,6 +21,7 @@
180 #include "utils.h"
181 #include "debug.h"
182
183+#include <glib.h>
184 #include <QUrl>
185 #include <QUrlQuery>
186
187@@ -59,4 +60,20 @@
188 }
189 }
190
191+Utilities::Utilities(QObject *parent) :
192+ QObject(parent)
193+{
194+}
195+
196+QString Utilities::formatSize(quint64 size) const
197+{
198+ guint64 g_size = size;
199+
200+ gchar * formatted_size = g_format_size (g_size);
201+ QString q_formatted_size = QString::fromLocal8Bit(formatted_size);
202+ g_free (formatted_size);
203+
204+ return q_formatted_size;
205+}
206+
207 } // namespace
208
209=== modified file 'src/utils.h'
210--- src/utils.h 2013-09-30 09:29:34 +0000
211+++ src/utils.h 2014-11-18 19:44:46 +0000
212@@ -29,6 +29,14 @@
213 void parsePluginOptions(const QStringList &arguments, QString &defaultPlugin,
214 QVariantMap &pluginOptions);
215
216+class Utilities : public QObject {
217+ Q_OBJECT
218+
219+public:
220+ explicit Utilities(QObject *parent = 0);
221+ Q_INVOKABLE QString formatSize(quint64) const;
222+};
223+
224 } // namespace
225
226 #endif // SYSTEM_SETTINGS_UTILS_H
227
228=== modified file 'tests/CMakeLists.txt'
229--- tests/CMakeLists.txt 2014-09-03 15:38:36 +0000
230+++ tests/CMakeLists.txt 2014-11-18 19:44:46 +0000
231@@ -1,4 +1,5 @@
232 include_directories(${CMAKE_CURRENT_BINARY_DIR} ../src)
233+include_directories(${GLIB_INCLUDE_DIRS})
234 add_definitions(-DI18N_DOMAIN="ubuntu-system-settings")
235 add_definitions(-DPLUGIN_PRIVATE_MODULE_DIR="${PLUGIN_PRIVATE_MODULE_DIR}")
236 add_definitions(-DPLUGIN_MANIFEST_DIR="${CMAKE_CURRENT_SOURCE_DIR}/data")
237@@ -36,6 +37,7 @@
238 set_tests_properties(tst-plugins PROPERTIES ENVIRONMENT "QT_QPA_PLATFORM=minimal")
239
240 qt5_use_modules(tst-arguments Core Test)
241+target_link_libraries(tst-arguments ${GLIB_LDFLAGS})
242 add_test(tst-arguments tst-arguments)
243
244 add_executable(tst-pagelist tst_pagelist.cpp ../wizard/PageList.cpp)

Subscribers

People subscribed via source and target branches