Merge lp:~vthompson/music-app/fix-toolbar-issues-and-auto-populate-library into lp:music-app/trusty

Proposed by Victor Thompson
Status: Merged
Approved by: Daniel Holm
Approved revision: 42
Merged at revision: 41
Proposed branch: lp:~vthompson/music-app/fix-toolbar-issues-and-auto-populate-library
Merge into: lp:music-app/trusty
Diff against target: 521 lines (+254/-115)
7 files modified
LoginLastFM.qml (+0/-4)
MusicAlbums.qml (+45/-0)
MusicArtists.qml (+45/-0)
MusicPlaylists.qml (+60/-0)
MusicSettings.qml (+23/-16)
MusicTracks.qml (+6/-24)
music-app.qml (+75/-71)
To merge this branch: bzr merge lp:~vthompson/music-app/fix-toolbar-issues-and-auto-populate-library
Reviewer Review Type Date Requested Status
Daniel Holm Approve
Ubuntu Phone Apps Jenkins Bot continuous-integration Approve
Review via email: mp+173803@code.launchpad.net

Commit message

Fix some of the toolbar issues when switching tabs and populate music library on every run of the app. Fixes Bug #1198773 and Bug #1193633.

Description of the change

Fix some of the toolbar issues when switching tabs and populate music library on every run of the app. Fixes Bug #1198773 and Bug #1193633.

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: Approve (continuous-integration)
42. By Victor Thompson

Reset music folder when a previous version had a different path.

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
David Planella (dpm) wrote :

Thanks a lot Victor!

For the next merge proposal, I'd suggest sending a separate merge request for each new feature or fix. This makes it much easier to review self-contained branches: it's less error-prone and takes less reviewer time to understand the changes in a smaller branch that does just one thing.

Revision history for this message
Daniel Holm (danielholm) wrote :

Looks great. Thanks

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'LoginLastFM.qml'
2--- LoginLastFM.qml 2013-06-17 21:14:56 +0000
3+++ LoginLastFM.qml 2013-07-09 20:38:25 +0000
4@@ -163,10 +163,6 @@
5 text: i18n.tr("Close")
6 onClicked: {
7 PopupUtils.close(lastfmroot)
8- PopupUtils.open(Qt.resolvedUrl("MusicSettings.qml"), mainView,
9- {
10- title: i18n.tr("Settings")
11- } )
12 }
13 }
14 }
15
16=== modified file 'MusicAlbums.qml'
17--- MusicAlbums.qml 2013-06-19 12:08:44 +0000
18+++ MusicAlbums.qml 2013-07-09 20:38:25 +0000
19@@ -30,6 +30,51 @@
20 Page {
21 title: i18n.tr("Albums")
22
23+ tools: ToolbarItems {
24+ // Add playlist
25+ ToolbarButton {
26+ id: playlistAction
27+ objectName: "playlistaction"
28+ iconSource: Qt.resolvedUrl("images/playlist.png")
29+ text: i18n.tr("Add Playlist")
30+ onTriggered: {
31+ console.debug("Debug: User pressed add playlist")
32+ // show new playlist dialog
33+ PopupUtils.open(MusicPlaylists.addPlaylistDialog, mainView)
34+ }
35+ }
36+
37+ // Settings dialog
38+ ToolbarButton {
39+ objectName: "settingsaction"
40+ iconSource: Qt.resolvedUrl("images/settings.png")
41+ text: i18n.tr("Settings")
42+
43+ onTriggered: {
44+ console.debug('Debug: Show settings')
45+ PopupUtils.open(Qt.resolvedUrl("MusicSettings.qml"), mainView,
46+ {
47+ title: i18n.tr("Settings")
48+ } )
49+ }
50+ }
51+
52+ // Queue dialog
53+ ToolbarButton {
54+ objectName: "queuesaction"
55+ iconSource: Qt.resolvedUrl("images/folder.png") // change this icon later
56+ text: i18n.tr("Queue")
57+
58+ onTriggered: {
59+ console.debug('Debug: Show queue')
60+ PopupUtils.open(Qt.resolvedUrl("QueueDialog.qml"), mainView,
61+ {
62+ title: i18n.tr("Queue")
63+ } )
64+ }
65+ }
66+ }
67+
68 GridView {
69 id: albumlist
70 width: parent.width
71
72=== modified file 'MusicArtists.qml'
73--- MusicArtists.qml 2013-07-04 07:25:42 +0000
74+++ MusicArtists.qml 2013-07-09 20:38:25 +0000
75@@ -30,6 +30,51 @@
76 Page {
77 title: i18n.tr("Artists")
78
79+ tools: ToolbarItems {
80+ // Add playlist
81+ ToolbarButton {
82+ id: playlistAction
83+ objectName: "playlistaction"
84+ iconSource: Qt.resolvedUrl("images/playlist.png")
85+ text: i18n.tr("Add Playlist")
86+ onTriggered: {
87+ console.debug("Debug: User pressed add playlist")
88+ // show new playlist dialog
89+ PopupUtils.open(MusicPlaylists.addPlaylistDialog, mainView)
90+ }
91+ }
92+
93+ // Settings dialog
94+ ToolbarButton {
95+ objectName: "settingsaction"
96+ iconSource: Qt.resolvedUrl("images/settings.png")
97+ text: i18n.tr("Settings")
98+
99+ onTriggered: {
100+ console.debug('Debug: Show settings')
101+ PopupUtils.open(Qt.resolvedUrl("MusicSettings.qml"), mainView,
102+ {
103+ title: i18n.tr("Settings")
104+ } )
105+ }
106+ }
107+
108+ // Queue dialog
109+ ToolbarButton {
110+ objectName: "queuesaction"
111+ iconSource: Qt.resolvedUrl("images/folder.png") // change this icon later
112+ text: i18n.tr("Queue")
113+
114+ onTriggered: {
115+ console.debug('Debug: Show queue')
116+ PopupUtils.open(Qt.resolvedUrl("QueueDialog.qml"), mainView,
117+ {
118+ title: i18n.tr("Queue")
119+ } )
120+ }
121+ }
122+ }
123+
124 Component {
125 id: highlight
126 Rectangle {
127
128=== modified file 'MusicPlaylists.qml'
129--- MusicPlaylists.qml 2013-07-04 07:25:42 +0000
130+++ MusicPlaylists.qml 2013-07-09 20:38:25 +0000
131@@ -39,6 +39,66 @@
132 }
133
134 title: i18n.tr("Playlists")
135+
136+ tools: ToolbarItems {
137+ // import playlist from lastfm
138+ ToolbarButton {
139+ objectName: "lastfmplaylistaction"
140+
141+ iconSource: Qt.resolvedUrl("images/lastfm.png")
142+ text: i18n.tr("Get from Last.fm")
143+
144+ onTriggered: {
145+ console.debug("Debug: User pressed action to import playlist from lastfm")
146+ Scrobble.getPlaylists(Settings.getSetting("lastfmusername"))
147+ }
148+ }
149+
150+ // Add playlist
151+ ToolbarButton {
152+ id: playlistAction
153+ objectName: "playlistaction"
154+ iconSource: Qt.resolvedUrl("images/playlist.png")
155+ text: i18n.tr("Add Playlist")
156+ onTriggered: {
157+ console.debug("Debug: User pressed add playlist")
158+ // show new playlist dialog
159+ PopupUtils.open(MusicPlaylists.addPlaylistDialog, mainView)
160+ }
161+ }
162+
163+ // Settings dialog
164+ ToolbarButton {
165+ objectName: "settingsaction"
166+ iconSource: Qt.resolvedUrl("images/settings.png")
167+ text: i18n.tr("Settings")
168+
169+ onTriggered: {
170+ console.debug('Debug: Show settings')
171+ PopupUtils.open(Qt.resolvedUrl("MusicSettings.qml"), mainView,
172+ {
173+ title: i18n.tr("Settings")
174+ } )
175+ }
176+ }
177+
178+ // Queue dialog
179+ ToolbarButton {
180+ objectName: "queuesaction"
181+ iconSource: Qt.resolvedUrl("images/folder.png") // change this icon later
182+ text: i18n.tr("Queue")
183+
184+ onTriggered: {
185+ console.debug('Debug: Show queue')
186+ PopupUtils.open(Qt.resolvedUrl("QueueDialog.qml"), mainView,
187+ {
188+ title: i18n.tr("Queue")
189+ } )
190+ }
191+ }
192+ }
193+
194+
195 Component.onCompleted: {
196 random = Settings.getSetting("shuffle") == "1" // shuffle state
197 scrobble = Settings.getSetting("scrobble") == "1" // scrobble state
198
199=== modified file 'MusicSettings.qml'
200--- MusicSettings.qml 2013-06-19 14:13:22 +0000
201+++ MusicSettings.qml 2013-07-09 20:38:25 +0000
202@@ -29,20 +29,21 @@
203 Dialog {
204 id: root
205
206- Row {
207- spacing: units.gu(2)
208- Button {
209- id: selectdirectory
210- text: i18n.tr("Select Music folder")
211- width: units.gu(30)
212- color: "#c94212"
213- onClicked: {
214- folderScannerModel.nameFilters = [""]
215- pageStack.push(Qt.resolvedUrl("LibraryLoader.qml"))
216- PopupUtils.close(root)
217- }
218- }
219- }
220+// Row {
221+// spacing: units.gu(2)
222+// Button {
223+// id: selectdirectory
224+// text: i18n.tr("Select Music folder")
225+// width: units.gu(30)
226+// color: "#c94212"
227+// onClicked: {
228+// folderScannerModel.nameFilters = [""]
229+// console.debug('Debug: Show settings')
230+// pageStack.push(Qt.resolvedUrl("LibraryLoader.qml"))
231+// PopupUtils.close(root)
232+// }
233+// }
234+// }
235
236 // Shuffle or not
237 Row {
238@@ -50,6 +51,7 @@
239 Label {
240 text: i18n.tr("Shuffle")
241 width: units.gu(20)
242+ color: "white"
243 }
244 Switch {
245 id: shuffleSwitch
246@@ -63,6 +65,7 @@
247 Label {
248 text: i18n.tr("Scrobble to Last.FM")
249 width: units.gu(20)
250+ color: "white"
251 }
252 Switch {
253 id: scrobbleSwitch
254@@ -79,8 +82,10 @@
255 color: "#c94212"
256 enabled: Settings.getSetting("scrobble") === "1" // only if scrobble is activated.
257 onClicked: {
258- pageStack.push(Qt.resolvedUrl("LoginLastFM.qml"))
259- PopupUtils.close(root)
260+ PopupUtils.open(Qt.resolvedUrl("LoginLastFM.qml"), mainView,
261+ {
262+ title: i18n.tr("Last.fm")
263+ } )
264 }
265 }
266 }
267@@ -107,6 +112,8 @@
268 Label {
269 text: i18n.tr("Pause when when headphones are un-plugged.")
270 width: units.gu(20)
271+ wrapMode: "WordWrap"
272+ color: "white"
273 }
274 Switch {
275 checked: true
276
277=== modified file 'MusicTracks.qml'
278--- MusicTracks.qml 2013-07-09 09:55:02 +0000
279+++ MusicTracks.qml 2013-07-09 20:38:25 +0000
280@@ -66,9 +66,9 @@
281 onTriggered: {
282 console.debug('Debug: Show settings')
283 PopupUtils.open(Qt.resolvedUrl("MusicSettings.qml"), mainView,
284- {
285- title: i18n.tr("Settings")
286- } )
287+ {
288+ title: i18n.tr("Settings")
289+ } )
290 }
291 }
292
293@@ -81,9 +81,9 @@
294 onTriggered: {
295 console.debug('Debug: Show queue')
296 PopupUtils.open(Qt.resolvedUrl("QueueDialog.qml"), mainView,
297- {
298- title: i18n.tr("Queue")
299- } )
300+ {
301+ title: i18n.tr("Queue")
302+ } )
303 }
304 }
305 }
306@@ -91,24 +91,6 @@
307 title: i18n.tr("Music")
308 Component.onCompleted: {
309 pageStack.push(mainpage)
310- Settings.initialize()
311- Library.initialize()
312- console.debug("INITIALIZED in tracks")
313- if (Settings.getSetting("initialized") !== "true") {
314- // initialize settings
315- console.debug("reset settings")
316- Settings.setSetting("initialized", "true") // setting to make sure the DB is there
317- //Settings.setSetting("scrobble", "0") // default state of shuffle
318- //Settings.setSetting("scrobble", "0") // default state of scrobble
319- Settings.setSetting("currentfolder", folderModel.homePath() + "/Music")
320- }
321- // initialize playlist
322- Playlists.initializePlaylists()
323- // everything else
324- random = Settings.getSetting("shuffle") == "1" // shuffle state
325- scrobble = Settings.getSetting("scrobble") == "1" // scrobble state
326- lastfmusername = Settings.getSetting("lastfmusername") // lastfm username
327- lastfmpassword = Settings.getSetting("lastfmpassword") // lastfm password
328 }
329
330 Component {
331
332=== modified file 'music-app.qml'
333--- music-app.qml 2013-07-09 01:06:04 +0000
334+++ music-app.qml 2013-07-09 20:38:25 +0000
335@@ -38,9 +38,31 @@
336 width: units.gu(50)
337 height: units.gu(75)
338 Component.onCompleted: {
339- libraryModel.populate()
340- albumModel.filterAlbums()
341- artistModel.populate()
342+ Settings.initialize()
343+ Library.initialize()
344+ console.debug("INITIALIZED in tracks")
345+ if (Settings.getSetting("initialized") !== "true") {
346+ // initialize settings
347+ console.debug("reset settings")
348+ Settings.setSetting("initialized", "true") // setting to make sure the DB is there
349+ //Settings.setSetting("scrobble", "0") // default state of shuffle
350+ //Settings.setSetting("scrobble", "0") // default state of scrobble
351+ Settings.setSetting("currentfolder", folderModel.homePath() + "/Music")
352+ }
353+ Library.reset()
354+ Library.initialize()
355+ Settings.setSetting("currentfolder", folderModel.path)
356+ folderScannerModel.path = folderModel.path
357+ folderScannerModel.nameFilters = ["*.mp3","*.ogg","*.flac","*.wav","*.oga"]
358+ timer.start()
359+
360+ // initialize playlist
361+ Playlists.initializePlaylists()
362+ // everything else
363+ random = Settings.getSetting("shuffle") == "1" // shuffle state
364+ scrobble = Settings.getSetting("scrobble") == "1" // scrobble state
365+ lastfmusername = Settings.getSetting("lastfmusername") // lastfm username
366+ lastfmpassword = Settings.getSetting("lastfmpassword") // lastfm password
367 }
368
369
370@@ -226,7 +248,7 @@
371 showDirectories: true
372 filterDirectories: false
373 nameFilters: ["*.mp3","*.ogg","*.flac","*.wav","*.oga"] // file types supported.
374- path: Settings.getSetting("initialized") === "true" && Settings.getSetting("currentfolder") !== "" ? Settings.getSetting("currentfolder") : homePath() + "/Music"
375+ path: homePath() + "/Music"
376 onPathChanged: {
377 console.log("Path changed: " + folderModel.path)
378 }
379@@ -260,6 +282,55 @@
380 id: singleTracks
381 }
382
383+ Column {
384+ Repeater {
385+ id: filelist
386+ width: parent.width
387+ height: parent.height - units.gu(8)
388+ anchors.top: parent.top
389+ model: folderScannerModel
390+
391+ Component {
392+ id: fileScannerDelegate
393+ Rectangle {
394+ Component.onCompleted: {
395+ if (!model.isDir) {
396+ console.log("Debug: Scanner fileDelegate onComplete")
397+ if ("" === trackCover) {
398+ Library.setMetadata(filePath, trackTitle, trackArtist, trackAlbum, "", trackYear, trackNumber, trackLength)
399+ } else {
400+ Library.setMetadata(filePath, trackTitle, trackArtist, trackAlbum, "image://cover-art/" + filePath, trackYear, trackNumber, trackLength)
401+ }
402+ }
403+ }
404+ }
405+ }
406+ }
407+ }
408+
409+ Timer {
410+ id: timer
411+ interval: 200; repeat: true
412+ running: false
413+ triggeredOnStart: false
414+ property int counted: 0
415+
416+ onTriggered: {
417+ console.log("Counted: " + counted)
418+ console.log("filelist.count: " + filelist.count)
419+ if (counted === filelist.count) {
420+ console.log("MOVING ON")
421+ libraryModel.populate()
422+ albumModel.filterAlbums()
423+ artistModel.populate()
424+ PlayingList.clear()
425+ itemnum = 0
426+ timer.stop()
427+ }
428+ counted = filelist.count
429+ }
430+ }
431+
432 Tabs {
433 id: tabs
434 anchors.fill: parent
435@@ -287,24 +358,6 @@
436 // tab content
437 page: MusicArtists {
438 id: musicArtistsPage
439-
440- tools: ToolbarItems {
441- // Queue dialog
442- ToolbarButton {
443- objectName: "queuesaction"
444-
445- iconSource: Qt.resolvedUrl("images/folder.png") // change this icon later
446- text: i18n.tr("Queue")
447-
448- onTriggered: {
449- console.debug('Debug: Show queue')
450- PopupUtils.open(Qt.resolvedUrl("QueueDialog.qml"), mainView,
451- {
452- title: i18n.tr("Queue")
453- } )
454- }
455- }
456- }
457 }
458 }
459
460@@ -318,24 +371,6 @@
461 // Tab content begins here
462 page: MusicAlbums {
463 id: musicAlbumsPage
464-
465- tools: ToolbarItems {
466- // Queue dialog
467- ToolbarButton {
468- objectName: "queuesaction"
469-
470- iconSource: Qt.resolvedUrl("images/folder.png") // change this icon later
471- text: i18n.tr("Queue")
472-
473- onTriggered: {
474- console.debug('Debug: Show queue')
475- PopupUtils.open(Qt.resolvedUrl("QueueDialog.qml"), mainView,
476- {
477- title: i18n.tr("Queue")
478- } )
479- }
480- }
481- }
482 }
483 }
484
485@@ -349,37 +384,6 @@
486 // Tab content begins here
487 page: MusicPlaylists {
488 id: musicPlaylistPage
489-
490- tools: ToolbarItems {
491- // import playlist from lastfm
492- ToolbarButton {
493- objectName: "lastfmplaylistaction"
494-
495- iconSource: Qt.resolvedUrl("images/lastfm.png")
496- text: i18n.tr("Get from Last.fm")
497-
498- onTriggered: {
499- console.debug("Debug: User pressed action to import playlist from lastfm")
500- Scrobble.getPlaylists(Settings.getSetting("lastfmusername"))
501- }
502- }
503-
504- // Queue dialog
505- ToolbarButton {
506- objectName: "queuesaction"
507-
508- iconSource: Qt.resolvedUrl("images/folder.png") // change this icon later
509- text: i18n.tr("Queue")
510-
511- onTriggered: {
512- console.debug('Debug: Show queue')
513- PopupUtils.open(Qt.resolvedUrl("QueueDialog.qml"), mainView,
514- {
515- title: i18n.tr("Queue")
516- } )
517- }
518- }
519- }
520 }
521 }
522

Subscribers

People subscribed via source and target branches

to status/vote changes: