Merge lp:~ahayzen/music-app/move-to-use-settings into lp:music-app/remix

Proposed by Andrew Hayzen
Status: Merged
Approved by: Victor Thompson
Approved revision: 692
Merged at revision: 692
Proposed branch: lp:~ahayzen/music-app/move-to-use-settings
Merge into: lp:music-app/remix
Diff against target: 275 lines (+9/-127)
10 files modified
MusicArtists.qml (+0/-1)
MusicNowPlaying.qml (+0/-1)
MusicStart.qml (+0/-1)
MusicToolbar.qml (+0/-1)
MusicTracks.qml (+0/-1)
Player.qml (+8/-10)
Style.qml (+0/-4)
debian/control (+1/-1)
music-app.qml (+0/-23)
settings.js (+0/-84)
To merge this branch: bzr merge lp:~ahayzen/music-app/move-to-use-settings
Reviewer Review Type Date Requested Status
Victor Thompson Approve
Ubuntu Phone Apps Jenkins Bot continuous-integration Approve
Review via email: mp+239229@code.launchpad.net

Commit message

* Move to using Qt.labs.settings and remove settings.js

Description of the change

* Move to using Qt.labs.settings and remove settings.js

To post a comment you must log in.
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Needs Fixing (continuous-integration)
692. By Andrew Hayzen

* Fix for packaging

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
Victor Thompson (vthompson) wrote :

LGTM!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'MusicArtists.qml'
2--- MusicArtists.qml 2014-10-14 15:46:07 +0000
3+++ MusicArtists.qml 2014-10-22 16:25:28 +0000
4@@ -25,7 +25,6 @@
5 import Ubuntu.Thumbnailer 0.1
6 import QtMultimedia 5.0
7 import QtQuick.LocalStorage 2.0
8-import "settings.js" as Settings
9 import "meta-database.js" as Library
10 import "playlists.js" as Playlists
11 import "common"
12
13=== modified file 'MusicNowPlaying.qml'
14--- MusicNowPlaying.qml 2014-10-22 14:53:42 +0000
15+++ MusicNowPlaying.qml 2014-10-22 16:25:28 +0000
16@@ -24,7 +24,6 @@
17 import Ubuntu.Thumbnailer 0.1
18 import "common"
19 import "common/ListItemActions"
20-import "settings.js" as Settings
21 import "playlists.js" as Playlists
22
23 MusicPage {
24
25=== modified file 'MusicStart.qml'
26--- MusicStart.qml 2014-10-21 15:22:44 +0000
27+++ MusicStart.qml 2014-10-22 16:25:28 +0000
28@@ -25,7 +25,6 @@
29 import Ubuntu.Thumbnailer 0.1
30 import QtMultimedia 5.0
31 import QtQuick.LocalStorage 2.0
32-import "settings.js" as Settings
33 import "meta-database.js" as Library
34 import "playlists.js" as Playlists
35 import "common"
36
37=== modified file 'MusicToolbar.qml'
38--- MusicToolbar.qml 2014-10-21 20:11:35 +0000
39+++ MusicToolbar.qml 2014-10-22 16:25:28 +0000
40@@ -23,7 +23,6 @@
41 import Ubuntu.Components 1.1
42 import Ubuntu.Components.Popups 1.0
43 import "common"
44-import "settings.js" as Settings
45
46 Item {
47 anchors {
48
49=== modified file 'MusicTracks.qml'
50--- MusicTracks.qml 2014-10-21 21:49:49 +0000
51+++ MusicTracks.qml 2014-10-22 16:25:28 +0000
52@@ -23,7 +23,6 @@
53 import Ubuntu.Thumbnailer 0.1
54 import QtMultimedia 5.0
55 import QtQuick.LocalStorage 2.0
56-import "settings.js" as Settings
57 import "playlists.js" as Playlists
58 import "common"
59 import "common/ListItemActions"
60
61=== modified file 'Player.qml'
62--- Player.qml 2014-10-01 20:41:29 +0000
63+++ Player.qml 2014-10-22 16:25:28 +0000
64@@ -20,7 +20,7 @@
65 import QtQuick 2.3
66 import QtMultimedia 5.0
67 import QtQuick.LocalStorage 2.0
68-import "settings.js" as Settings
69+import Qt.labs.settings 1.0
70
71 /*
72 * This file should *only* manage the media playing and the relevant settings
73@@ -42,21 +42,19 @@
74 property bool isPlaying: player.playbackState === MediaPlayer.PlayingState
75 property alias playbackState: mediaPlayer.playbackState
76 property alias position: mediaPlayer.position
77- property bool repeat: Settings.getSetting("repeat") === "1"
78- property bool shuffle: Settings.getSetting("shuffle") === "1"
79+ property alias repeat: settings.repeat
80+ property alias shuffle: settings.shuffle
81 property alias source: mediaPlayer.source
82 property alias volume: mediaPlayer.volume
83
84 signal stopped()
85
86- onRepeatChanged: {
87- Settings.setSetting("repeat", repeat ? "1" : "0")
88- console.debug("Repeat:", Settings.getSetting("repeat") === "1")
89- }
90+ Settings {
91+ id: settings
92+ category: "PlayerSettings"
93
94- onShuffleChanged: {
95- Settings.setSetting("shuffle", shuffle ? "1" : "0")
96- console.debug("Shuffle:", Settings.getSetting("shuffle") === "1")
97+ property bool repeat: true
98+ property bool shuffle: false
99 }
100
101 Connections {
102
103=== modified file 'Style.qml'
104--- Style.qml 2014-09-30 12:55:03 +0000
105+++ Style.qml 2014-10-22 16:25:28 +0000
106@@ -66,10 +66,6 @@
107 property color headerColor: "#57365E";
108 }
109
110- property QtObject musicSettings: QtObject {
111- property color labelColor: UbuntuColors.coolGrey;
112- }
113-
114 property QtObject nowPlaying: QtObject {
115 property color backgroundColor: "#1d1d1d"
116 property color foregroundColor: "#454545"
117
118=== modified file 'debian/control'
119--- debian/control 2014-09-08 13:24:22 +0000
120+++ debian/control 2014-10-22 16:25:28 +0000
121@@ -17,6 +17,7 @@
122 gstreamer0.10-fluendo-mp3,
123 gstreamer1.0-fluendo-mp3,
124 qmlscene,
125+ qml-module-qt-labs-settings,
126 qtdeclarative5-ubuntu-content0.1,
127 qtdeclarative5-localstorage-plugin,
128 qtdeclarative5-particles-plugin,
129@@ -27,7 +28,6 @@
130 qtdeclarative5-ubuntu-ui-toolkit-plugin,
131 qtdeclarative5-usermetrics0.1,
132 qtdeclarative5-window-plugin,
133- qtdeclarative5-xmllistmodel-plugin,
134 thumbnailer-service,
135 suru-icon-theme | ubuntu-mobile-icons,
136 ${misc:Depends},
137
138=== modified file 'music-app.qml'
139--- music-app.qml 2014-10-22 14:53:42 +0000
140+++ music-app.qml 2014-10-22 16:25:28 +0000
141@@ -25,10 +25,8 @@
142 import Ubuntu.MediaScanner 0.1
143 import QtMultimedia 5.0
144 import QtQuick.LocalStorage 2.0
145-import QtQuick.XmlListModel 2.0
146 import QtGraphicalEffects 1.0
147 import UserMetrics 0.1
148-import "settings.js" as Settings
149 import "meta-database.js" as Library
150 import "playlists.js" as Playlists
151 import "common"
152@@ -177,17 +175,6 @@
153 onTriggered: player.stop()
154 }
155
156- // TODO: Currently there are no settings, so do not display the Action
157- Action {
158- id: settingsAction
159- text: i18n.tr("Settings")
160- keywords: i18n.tr("Music Settings")
161- onTriggered: {
162- customdebug('Show settings')
163- musicSettings.visible = true
164- }
165- }
166-
167 actions: [searchAction, nextAction, playsAction, prevAction, stopAction, backAction]
168
169 // signal to open new URIs
170@@ -544,16 +531,6 @@
171
172 customdebug("Arguments on startup: Debug: "+args.values.debug+ " and file: ")
173
174- Settings.initialize()
175- console.debug("INITIALIZED in tracks")
176- if (Settings.getSetting("initialized") !== "true") {
177- // initialize settings
178- console.debug("reset settings")
179- Settings.setSetting("initialized", "true") // setting to make sure the DB is there
180- Settings.setSetting("snaptrack", "1") // default state of snaptrack
181- Settings.setSetting("shuffle", "0") // default state of shuffle
182- Settings.setSetting("repeat", "0") // default state of repeat
183- }
184 Library.initialize();
185
186 // initialize playlists
187
188=== removed file 'settings.js'
189--- settings.js 2013-06-18 12:36:19 +0000
190+++ settings.js 1970-01-01 00:00:00 +0000
191@@ -1,84 +0,0 @@
192-/*
193- * Copyright (C) 2013 Victor Thompson <victor.thompson@gmail.com>
194- * Daniel Holm <d.holmen@gmail.com>
195- *
196- * This program is free software; you can redistribute it and/or modify
197- * it under the terms of the GNU General Public License as published by
198- * the Free Software Foundation; version 3.
199- *
200- * This program is distributed in the hope that it will be useful,
201- * but WITHOUT ANY WARRANTY; without even the implied warranty of
202- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
203- * GNU General Public License for more details.
204- *
205- * You should have received a copy of the GNU General Public License
206- * along with this program. If not, see <http://www.gnu.org/licenses/>.
207- */
208-
209-// First, let's create a short helper function to get the database connection
210-function getDatabase() {
211- return LocalStorage.openDatabaseSync("music-app-settings", "1.0", "StorageDatabase", 1000000);
212-}
213-
214-// At the start of the application, we can initialize the tables we need if they haven't been created yet
215-function initialize() {
216- var db = getDatabase();
217- db.transaction(
218- function(tx) {
219- // Create the settings table if it doesn't already exist
220- // If the table exists, this is skipped
221- //tx.executeSql('DROP TABLE settings');
222- tx.executeSql('CREATE TABLE IF NOT EXISTS settings(setting TEXT UNIQUE, value TEXT)');
223- });
224-}
225-
226-// This function is used to write a setting into the database
227-function setSetting(setting, value) {
228- // setting: string representing the setting name (eg: “username”)
229- // value: string representing the value of the setting (eg: “myUsername”)
230- var db = getDatabase();
231- var res = "";
232- db.transaction(function(tx) {
233- var rs = tx.executeSql('INSERT OR REPLACE INTO settings VALUES (?,?);', [setting,value]);
234- //console.log(rs.rowsAffected)
235- if (rs.rowsAffected > 0) {
236- res = "OK";
237- } else {
238- res = "Error";
239- }
240- }
241- );
242- // The function returns “OK” if it was successful, or “Error” if it wasn't
243- return res;
244-}
245-// This function is used to retrieve a setting from the database
246-function getSetting(setting) {
247- var db = getDatabase();
248- var res="";
249-
250- try {
251- db.transaction(function(tx) {
252- var rs = tx.executeSql('SELECT value FROM settings WHERE setting=?;', [setting]);
253- if (rs.rows.length > 0) {
254- res = rs.rows.item(0).value;
255- } else {
256- res = "Unknown";
257- }
258- })
259- } catch(e) {
260- return "";
261- }
262-
263- // The function returns “Unknown” if the setting was not found in the database
264- // For more advanced projects, this should probably be handled through error codes
265- return res
266-}
267-
268-// be carefull, this will drop the settings (db
269-function reset() {
270- var db = getDatabase();
271- db.transaction(
272- function(tx) {
273- tx.executeSql('DROP TABLE settings');
274- });
275-}

Subscribers

People subscribed via source and target branches