Merge lp:~ibelieve/ubuntu-filemanager-app/advanced-options into lp:ubuntu-filemanager-app

Proposed by Michael Spencer
Status: Merged
Approved by: Nicholas Skaggs
Approved revision: 49
Merged at revision: 56
Proposed branch: lp:~ibelieve/ubuntu-filemanager-app/advanced-options
Merge into: lp:ubuntu-filemanager-app
Diff against target: 294 lines (+198/-10)
5 files modified
FolderListPage.qml (+12/-2)
OptionsPopover.qml (+31/-7)
SettingsSheet.qml (+40/-0)
Storage.qml (+58/-0)
ubuntu-filemanager-app.qml (+57/-1)
To merge this branch: bzr merge lp:~ibelieve/ubuntu-filemanager-app/advanced-options
Reviewer Review Type Date Requested Status
Ubuntu Phone Apps Jenkins Bot continuous-integration Approve
Nicholas Skaggs (community) Approve
Arto Jalkanen Pending
Review via email: mp+175440@code.launchpad.net

Commit message

Added settings sheet and advanced option to filter files

Description of the change

Adds a settings sheet and the ability to hide/show advanced features. This allows the app to have features that advanced/power users want, while still being simple for regular users.

This also adds an advanced option to filter the files by a regex, so for example, a user can only see JPGs by using the "*.jpg" regex.

To post a comment you must log in.
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :

FAILED: Continuous integration, rev:48
No commit message was specified in the merge proposal. Click on the following link and set the commit message (if you want a jenkins rebuild you need to trigger it yourself):
https://code.launchpad.net/~mdspencer/ubuntu-filemanager-app/advanced-options/+merge/175440/+edit-commit-message

http://91.189.93.70:8080/job/ubuntu-filemanager-app-ci/8/
Executed test runs:
    SUCCESS: http://91.189.93.70:8080/job/ubuntu-filemanager-app-precise-amd64-ci/6
    SUCCESS: http://91.189.93.70:8080/job/ubuntu-filemanager-app-quantal-amd64-ci/9
    SUCCESS: http://91.189.93.70:8080/job/ubuntu-filemanager-app-raring-amd64-ci/9
    SUCCESS: http://91.189.93.70:8080/job/ubuntu-filemanager-app-saucy-amd64-ci/6

Click here to trigger a rebuild:
http://91.189.93.70:8080/job/ubuntu-filemanager-app-ci/8/rebuild

review: Needs Fixing (continuous-integration)
49. By Michael Spencer

Merged in changes from master branch

Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Nicholas Skaggs (nskaggs) :
review: Approve
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'FolderListPage.qml'
2--- FolderListPage.qml 2013-07-26 20:37:32 +0000
3+++ FolderListPage.qml 2013-08-06 15:23:35 +0000
4@@ -330,13 +330,13 @@
5 }
6
7 ToolbarButton {
8- text: i18n.tr("Settings")
9+ text: i18n.tr("Options")
10 iconSource: "icons/settings.png"
11
12 onTriggered: {
13 print(text)
14
15- PopupUtils.open(Qt.resolvedUrl("SettingsPopover.qml"), caller)
16+ PopupUtils.open(Qt.resolvedUrl("OptionsPopover.qml"), caller)
17 }
18 }
19
20@@ -350,6 +350,16 @@
21 PopupUtils.open(Qt.resolvedUrl("PlacesPopover.qml"), caller)
22 }
23 }
24+
25+ ToolbarButton {
26+ text: i18n.tr("Settings")
27+ iconSource: "icons/settings.png"
28+ onTriggered: {
29+ print(text)
30+
31+ showSettings()
32+ }
33+ }
34 }
35
36 Column {
37
38=== renamed file 'SettingsPopover.qml' => 'OptionsPopover.qml'
39--- SettingsPopover.qml 2013-06-27 02:10:00 +0000
40+++ OptionsPopover.qml 2013-08-06 15:23:35 +0000
41@@ -47,11 +47,11 @@
42 }
43
44 ValueSelector {
45- text: "Sort By"
46+ text: i18n.tr("Sort By")
47 selectedIndex: values.indexOf(fileView.sortingMethod)
48 values: [
49- "Name",
50- "Date"
51+ i18n.tr("Name"),
52+ i18n.tr("Date")
53 ]
54
55 onSelectedIndexChanged: {
56@@ -60,15 +60,39 @@
57 }
58
59 ValueSelector {
60- text: "Sort Order"
61+ text: i18n.tr("Sort Order")
62 selectedIndex: sortAccending ? 0 : 1
63 values: [
64- "Ascending",
65- "Descending"
66+ i18n.tr("Ascending"),
67+ i18n.tr("Descending")
68 ]
69
70 onSelectedIndexChanged: {
71- fileView.sortAccending = (values[selectedIndex] === "Ascending")
72+ fileView.sortAccending = (values[selectedIndex] === i18n.tr("Ascending"))
73+ }
74+ }
75+
76+ Standard {
77+ visible: showAdvancedFeatures
78+ text: i18n.tr("Filter")
79+
80+ TextField {
81+ id: filterField
82+ anchors {
83+ verticalCenter: parent.verticalCenter
84+ right: parent.right
85+ margins: units.gu(1)
86+ }
87+
88+ inputMethodHints: Qt.ImhNoAutoUppercase
89+
90+ text: pageModel.nameFilters
91+
92+ onAccepted: goButton.clicked()
93+ onTextChanged: {
94+ if (text !== pageModel.nameFilters)
95+ pageModel.nameFilters = [text]
96+ }
97 }
98 }
99 }
100
101=== added file 'SettingsSheet.qml'
102--- SettingsSheet.qml 1970-01-01 00:00:00 +0000
103+++ SettingsSheet.qml 2013-08-06 15:23:35 +0000
104@@ -0,0 +1,40 @@
105+import QtQuick 2.0
106+import Ubuntu.Components 0.1
107+import Ubuntu.Components.ListItems 0.1
108+import Ubuntu.Components.Popups 0.1
109+
110+/*
111+ * The Settings sheet holds global settings/preferences.
112+ *
113+ * TODO: Make sure this fits with the UI guidelines if
114+ * they are updated to include About/Settings info.
115+ */
116+ComposerSheet {
117+ id: root
118+
119+ title: i18n.tr("Settings")
120+
121+ contentsHeight: parent.height
122+
123+ Column {
124+ anchors.fill: parent
125+
126+ Standard {
127+ text: i18n.tr("Show Advanced Features")
128+ control: CheckBox {
129+ id: showAdvancedFeaturesCheckBox
130+ checked: showAdvancedFeatures
131+ }
132+ }
133+ }
134+
135+ onConfirmClicked: {
136+ saveSetting("showAdvancedFeatures", showAdvancedFeaturesCheckBox.checked ? "true" : "false");
137+
138+ // ... Handling of other settings here ...
139+
140+ refreshSettings()
141+
142+ PopupUtils.close(root)
143+ }
144+}
145
146=== added file 'Storage.qml'
147--- Storage.qml 1970-01-01 00:00:00 +0000
148+++ Storage.qml 2013-08-06 15:23:35 +0000
149@@ -0,0 +1,58 @@
150+import QtQuick.LocalStorage 2.0
151+import QtQuick 2.0
152+
153+Item {
154+ property var db: null
155+
156+ function openDB() {
157+ if(db !== null) return;
158+
159+ db = LocalStorage.openDatabaseSync("ubuntu-filemanager-app", "", "Default Ubuntu file manager app", 100000);
160+
161+ if (db.version === "") {
162+ db.changeVersion("", "0.1",
163+ function(tx) {
164+ tx.executeSql('CREATE TABLE IF NOT EXISTS settings(key TEXT UNIQUE, value TEXT)');
165+ console.log('Database created');
166+ });
167+ // reopen database with new version number
168+ db = LocalStorage.openDatabaseSync("ubuntu-filemanager-app", "", "Default Ubuntu file manager app", 100000);
169+ }
170+ }
171+
172+ function saveSetting(key, value) {
173+ openDB();
174+ db.transaction( function(tx){
175+ tx.executeSql('INSERT OR REPLACE INTO settings VALUES(?, ?)', [key, value]);
176+ });
177+ }
178+
179+ function getSettings(callback) {
180+ openDB();
181+ var settings = {};
182+ db.readTransaction(
183+ function(tx){
184+ var rs = tx.executeSql('SELECT key, value FROM Settings');
185+ for(var i = 0; i < rs.rows.length; i++) {
186+ var row = rs.rows.item(i);
187+ settings[row.key] = row.value;
188+ }
189+ callback(settings);
190+ }
191+ );
192+ }
193+
194+ function clearSetting(name) {
195+ openDB();
196+ db.transaction(function(tx){
197+ tx.executeSql('DELETE FROM Settings WHERE key = ?', [name]);
198+ });
199+ }
200+
201+ function clearDB() { // for dev purposes
202+ openDB();
203+ db.transaction(function(tx){
204+ tx.executeSql('DELETE FROM Settings WHERE 1');
205+ });
206+ }
207+}
208
209=== modified file 'ubuntu-filemanager-app.qml'
210--- ubuntu-filemanager-app.qml 2013-06-27 16:46:45 +0000
211+++ ubuntu-filemanager-app.qml 2013-08-06 15:23:35 +0000
212@@ -18,6 +18,7 @@
213 import QtQuick 2.0
214 import Ubuntu.Components 0.1
215 import org.nemomobile.folderlistmodel 1.0
216+import Ubuntu.Components.Popups 0.1
217
218 /*!
219 \brief MainView with Tabs element.
220@@ -30,7 +31,7 @@
221 // objectName for functional testing purposes (autopilot-qt5)
222 objectName: "filemanager"
223 applicationName: "ubuntu-filemanager-app"
224-
225+
226 width: units.gu(50)
227 height: units.gu(75)
228
229@@ -38,10 +39,65 @@
230
231 property bool wideAspect: width >= units.gu(80)
232
233+ // Default settings
234+ property var settings: {"showAdvancedFeatures": false}
235+
236+ property bool needsRefreshSettings: true
237+
238+ // Individual settings, used for bindings
239+ property bool showAdvancedFeatures: false
240+
241 FolderListPage {
242 id: folderPage
243 objectName: "folderPage"
244
245 folder: homeFolder
246 }
247+
248+ Component {
249+ id: settingsSheet
250+
251+ SettingsSheet {
252+ objectName: "settingsSheet"
253+ }
254+ }
255+
256+ Storage {
257+ id: storage
258+ }
259+
260+ function showSettings() {
261+ PopupUtils.open(settingsSheet)
262+ }
263+
264+ function reloadSettings() {
265+ showAdvancedFeatures = settings["showAdvancedFeatures"] === "true" ? true : false
266+ print("showAdvancedFeatures <=", showAdvancedFeatures)
267+ }
268+
269+ function refreshSettings() {
270+ if (needsRefreshSettings) {
271+ storage.getSettings(function(storedSettings) {
272+ for(var settingName in storedSettings) {
273+ print(settingName, "=", storedSettings[settingName])
274+ settings[settingName] = storedSettings[settingName]
275+ }
276+
277+ reloadSettings()
278+ })
279+
280+ needsRefreshSettings = false
281+ }
282+ }
283+
284+ function saveSetting(name, value) {
285+ // Check if the setting was changed
286+ if(settings[name] !== value) {
287+ print(name, "=>", value)
288+ storage.saveSetting(name, value)
289+ needsRefreshSettings = true
290+ }
291+ }
292+
293+ Component.onCompleted: refreshSettings();
294 }

Subscribers

People subscribed via source and target branches