Merge lp:~ahayzen/music-app/toolbar-refactor into lp:music-app/remix

Proposed by Andrew Hayzen
Status: Rejected
Rejected by: Andrew Hayzen
Proposed branch: lp:~ahayzen/music-app/toolbar-refactor
Merge into: lp:music-app/remix
Diff against target: 818 lines (+321/-344)
6 files modified
MusicToolbar.qml (+244/-313)
MusicaddtoPlaylist.qml (+1/-1)
common/AlbumsPage.qml (+1/-1)
common/MusicPage.qml (+2/-2)
common/SongsPage.qml (+2/-2)
music-app.qml (+71/-25)
To merge this branch: bzr merge lp:~ahayzen/music-app/toolbar-refactor
Reviewer Review Type Date Requested Status
Victor Thompson Needs Information
Ubuntu Phone Apps Jenkins Bot continuous-integration Approve
Review via email: mp+247208@code.launchpad.net

Commit message

* Refactor MusicToolbar.qml to remove legacy code
* Move pagestack helpers into mainPageStack

Description of the change

* Refactor MusicToolbar.qml to remove legacy code
* Move pagestack helpers into mainPageStack

This removes the use of Panel (which we don't use anymore), removes various properties that aren't needed. The helpers inside the toolbar have been moved to mainPageStack and anything todo with the pagestack now uses mainPageStack instead of musicToolbar.

This greatly simplifies the toolbar and was started as very early prep work for bottom edge.

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)
Revision history for this message
Victor Thompson (vthompson) wrote :

2 inline comments.

Also, I notice that if you pause a song and go to the Queue, the progress indicator isn't shown until you play the song again.

I still need to review further.

review: Needs Fixing
Revision history for this message
Victor Thompson (vthompson) wrote :

Actually, that last thing is a bug in the current app as well.

Revision history for this message
Victor Thompson (vthompson) wrote :

I proposed a separate fix for the issue I had mentioned [1]

1 - https://code.launchpad.net/~vthompson/music-app/fix-queue-progress-hint/+merge/247383

803. By Andrew Hayzen

* Use styleMusic for the background colour
* Change property for workaround name

804. By Andrew Hayzen

* Merge of trunk

805. By Andrew Hayzen

* Load the toolbar in async

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
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Victor Thompson (vthompson) wrote :

So far I haven't found anything that might cause a regression. However, should we target this for a separate 'refactor' series and merge back in to trunk as necessary?

review: Needs Information
Revision history for this message
Andrew Hayzen (ahayzen) wrote :

Agreed, i'll rebase it against the other series.

Unmerged revisions

808. By Andrew Hayzen

* Change actualCurrentPage to currentMusicPage

807. By Andrew Hayzen

* Merge of trunk

806. By Andrew Hayzen

* Merge of trunk

805. By Andrew Hayzen

* Load the toolbar in async

804. By Andrew Hayzen

* Merge of trunk

803. By Andrew Hayzen

* Use styleMusic for the background colour
* Change property for workaround name

802. By Andrew Hayzen

* Refactor MusicToolbar.qml to remove legacy code
* Move pagestack helpers into mainPageStack

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'MusicToolbar.qml'
--- MusicToolbar.qml 2015-01-23 07:22:52 +0000
+++ MusicToolbar.qml 2015-01-23 13:45:46 +0000
@@ -18,335 +18,266 @@
18 */18 */
1919
20import QtQuick 2.320import QtQuick 2.3
21import QtQuick.LocalStorage 2.0
22import QtMultimedia 5.021import QtMultimedia 5.0
23import Ubuntu.Components 1.122import Ubuntu.Components 1.1
24import Ubuntu.Components.Popups 1.0
25import "common"23import "common"
2624
27Item {25Rectangle {
28 anchors {26 anchors {
29 bottom: parent.bottom27 bottom: parent.bottom
30 left: parent.left28 left: parent.left
31 right: parent.right29 right: parent.right
32 }30 }
3331 color: styleMusic.common.black
34 // Properties storing the current page info32 height: units.gu(7.25)
35 property var currentPage: null33 objectName: "musicToolbarObject"
36 property var currentTab: null34
3735 // Hack for autopilot otherwise MusicToolbar appears as QQuickRectangle
38 // Properties and signals for the toolbar36 // due to bug 1341671 it is required that there is a property so that
39 property alias currentHeight: musicToolbarPanel.height37 // qml doesn't optimise using the parent type
40 property alias opened: musicToolbarPanel.opened38 property bool bug1341671workaround: true
4139
42 property bool popping: false40 /* Toolbar controls */
4341 Item {
44 /* Helper functions */42 id: toolbarControls
45
46 // Back button has been pressed, jump up pageStack or back to parent page
47 function goBack()
48 {
49 if (mainPageStack !== null && mainPageStack.depth > 1) {
50 mainPageStack.pop(currentPage)
51 }
52 }
53
54 // Pop a specific page in the stack
55 function popPage(page)
56 {
57 var tmpPages = []
58
59 popping = true
60
61 while (mainPageStack.currentPage !== page && mainPageStack.depth > 0) {
62 tmpPages.push(mainPageStack.currentPage)
63 mainPageStack.pop()
64 }
65
66 if (mainPageStack.depth > 0) {
67 mainPageStack.pop()
68 }
69
70 for (var i=tmpPages.length - 1; i > -1; i--) {
71 mainPageStack.push(tmpPages[i])
72 }
73
74 popping = false
75 }
76
77 // Set the current page, and any parent/stacks
78 function setPage(childPage)
79 {
80 if (!popping) {
81 currentPage = childPage;
82 }
83 }
84
85 Panel {
86 id: musicToolbarPanel
87 anchors {43 anchors {
88 left: parent.left44 fill: parent
89 right: parent.right45 }
90 bottom: parent.bottom46 state: trackQueue.model.count === 0 ? "disabled" : "enabled"
91 }47 states: [
92 height: units.gu(7.25)48 State {
93 locked: true49 name: "disabled"
94 opened: true50 PropertyChanges {
9551 target: disabledPlayerControlsGroup
96 /* Expanded toolbar */52 visible: true
97 Item {53 }
98 id: musicToolbarExpandedContainer54 PropertyChanges {
99 anchors {55 target: enabledPlayerControlsGroup
100 fill: parent56 visible: false
101 }57 }
58 },
59 State {
60 name: "enabled"
61 PropertyChanges {
62 target: disabledPlayerControlsGroup
63 visible: false
64 }
65 PropertyChanges {
66 target: enabledPlayerControlsGroup
67 visible: true
68 }
69 }
70 ]
71
72 /* Disabled (empty state) controls */
73 Item {
74 id: disabledPlayerControlsGroup
75 anchors {
76 bottom: playerControlsProgressBar.top
77 left: parent.left
78 right: parent.right
79 top: parent.top
80 }
81
82 Label {
83 id: noSongsInQueueLabel
84 anchors {
85 left: parent.left
86 leftMargin: units.gu(2)
87 right: disabledPlayerControlsPlayButton.left
88 rightMargin: units.gu(2)
89 verticalCenter: parent.verticalCenter
90 }
91 color: styleMusic.playerControls.labelColor
92 text: i18n.tr("Tap to shuffle music")
93 fontSize: "large"
94 visible: !emptyPage.noMusic
95 wrapMode: Text.WordWrap
96 maximumLineCount: 2
97 }
98
99 /* Play/Pause button */
100 Icon {
101 id: disabledPlayerControlsPlayButton
102 anchors {
103 right: parent.right
104 rightMargin: units.gu(3)
105 verticalCenter: parent.verticalCenter
106 }
107 color: "#FFF"
108 height: units.gu(2.5)
109 name: player.playbackState === MediaPlayer.PlayingState ?
110 "media-playback-pause" : "media-playback-start"
111 objectName: "disabledSmallPlayShape"
112 width: height
113 }
114
115 /* Click to shuffle music */
116 MouseArea {
117 anchors {
118 fill: parent
119 }
120 onClicked: {
121 if (emptyPage.noMusic) {
122 return;
123 }
124
125 if (trackQueue.model.count === 0) {
126 playRandomSong();
127 }
128 else {
129 player.toggle();
130 }
131 }
132 }
133 }
134
135 /* Enabled (queue > 0) controls */
136 Item {
137 id: enabledPlayerControlsGroup
138 anchors {
139 bottom: playerControlsProgressBar.top
140 left: parent.left
141 right: parent.right
142 top: parent.top
143 }
144
145 /* Album art in player controls */
146 CoverGrid {
147 id: playerControlsImage
148 anchors {
149 bottom: parent.bottom
150 left: parent.left
151 top: parent.top
152 }
153 covers: [{art: player.currentMetaArt, author: player.currentMetaArtist, album: player.currentMetaArt}]
154 size: parent.height
155 }
156
157 /* Column of meta labels */
158 Column {
159 id: playerControlsLabels
160 anchors {
161 left: playerControlsImage.right
162 leftMargin: units.gu(1.5)
163 right: playerControlsPlayButton.left
164 rightMargin: units.gu(1)
165 verticalCenter: parent.verticalCenter
166 }
167
168 /* Title of track */
169 Label {
170 id: playerControlsTitle
171 anchors {
172 left: parent.left
173 right: parent.right
174 }
175 color: "#FFF"
176 elide: Text.ElideRight
177 fontSize: "small"
178 font.weight: Font.DemiBold
179 text: player.currentMetaTitle === ""
180 ? player.source : player.currentMetaTitle
181 }
182
183 /* Artist of track */
184 Label {
185 id: playerControlsArtist
186 anchors {
187 left: parent.left
188 right: parent.right
189 }
190 color: "#FFF"
191 elide: Text.ElideRight
192 fontSize: "small"
193 opacity: 0.4
194 text: player.currentMetaArtist
195 }
196 }
197
198 /* Play/Pause button */
199 Icon {
200 id: playerControlsPlayButton
201 anchors {
202 right: parent.right
203 rightMargin: units.gu(3)
204 verticalCenter: parent.verticalCenter
205 }
206 color: "#FFF"
207 height: units.gu(2.5)
208 name: player.playbackState === MediaPlayer.PlayingState ?
209 "media-playback-pause" : "media-playback-start"
210 objectName: "playShape"
211 width: height
212 }
213
214 /* Mouse area to jump to now playing */
215 MouseArea {
216 anchors {
217 fill: parent
218 }
219 objectName: "jumpNowPlaying"
220
221 onClicked: tabs.pushNowPlaying()
222 }
223
224 /* Mouse area for the play button (ontop of the jump to now playing) */
225 MouseArea {
226 anchors {
227 bottom: parent.bottom
228 horizontalCenter: playerControlsPlayButton.horizontalCenter
229 top: parent.top
230 }
231 onClicked: player.toggle()
232 width: units.gu(8)
233
234 Rectangle {
235 anchors {
236 fill: parent
237 }
238 color: "#FFF"
239 opacity: parent.pressed ? 0.1 : 0
240
241 Behavior on opacity {
242 UbuntuNumberAnimation {
243 duration: UbuntuAnimation.FastDuration
244 }
245 }
246 }
247 }
248 }
249
250 /* Object which provides the progress bar when toolbar is minimized */
251 Rectangle {
252 id: playerControlsProgressBar
253 anchors {
254 bottom: parent.bottom
255 left: parent.left
256 right: parent.right
257 }
258 color: styleMusic.common.black
259 height: units.gu(0.25)
102260
103 Rectangle {261 Rectangle {
104 id: musicToolbarPlayerControls262 id: playerControlsProgressBarHint
105 anchors {263 anchors {
106 fill: parent264 left: parent.left
107 }265 top: parent.top
108 color: "#000"266 }
109 state: trackQueue.model.count === 0 ? "disabled" : "enabled"267 color: UbuntuColors.blue
110 states: [268 height: parent.height
111 State {269 width: player.duration > 0 ? (player.position / player.duration) * playerControlsProgressBar.width : 0
112 name: "disabled"270
113 PropertyChanges {271 Connections {
114 target: disabledPlayerControlsGroup272 target: player
115 visible: true273 onPositionChanged: {
116 }274 playerControlsProgressBarHint.width = (player.position / player.duration) * playerControlsProgressBar.width
117 PropertyChanges {275 }
118 target: enabledPlayerControlsGroup276 onStopped: {
119 visible: false277 playerControlsProgressBarHint.width = 0;
120 }
121 },
122 State {
123 name: "enabled"
124 PropertyChanges {
125 target: disabledPlayerControlsGroup
126 visible: false
127 }
128 PropertyChanges {
129 target: enabledPlayerControlsGroup
130 visible: true
131 }
132 }
133 ]
134
135 /* Disabled (empty state) controls */
136 Item {
137 id: disabledPlayerControlsGroup
138 anchors {
139 bottom: playerControlsProgressBar.top
140 left: parent.left
141 right: parent.right
142 top: parent.top
143 }
144
145 Label {
146 id: noSongsInQueueLabel
147 anchors {
148 left: parent.left
149 leftMargin: units.gu(2)
150 right: disabledPlayerControlsPlayButton.left
151 rightMargin: units.gu(2)
152 verticalCenter: parent.verticalCenter
153 }
154 color: styleMusic.playerControls.labelColor
155 text: i18n.tr("Tap to shuffle music")
156 fontSize: "large"
157 visible: !emptyPage.noMusic
158 wrapMode: Text.WordWrap
159 maximumLineCount: 2
160 }
161
162 /* Play/Pause button */
163 Icon {
164 id: disabledPlayerControlsPlayButton
165 anchors {
166 right: parent.right
167 rightMargin: units.gu(3)
168 verticalCenter: parent.verticalCenter
169 }
170 color: "#FFF"
171 height: units.gu(2.5)
172 name: player.playbackState === MediaPlayer.PlayingState ?
173 "media-playback-pause" : "media-playback-start"
174 objectName: "disabledSmallPlayShape"
175 width: height
176 }
177
178 /* Click to shuffle music */
179 MouseArea {
180 anchors {
181 fill: parent
182 }
183 onClicked: {
184 if (emptyPage.noMusic) {
185 return;
186 }
187
188 if (trackQueue.model.count === 0) {
189 playRandomSong();
190 }
191 else {
192 player.toggle();
193 }
194 }
195 }
196 }
197
198 /* Enabled (queue > 0) controls */
199 Item {
200 id: enabledPlayerControlsGroup
201 anchors {
202 bottom: playerControlsProgressBar.top
203 left: parent.left
204 right: parent.right
205 top: parent.top
206 }
207
208 /* Album art in player controls */
209 CoverGrid {
210 id: playerControlsImage
211 anchors {
212 bottom: parent.bottom
213 left: parent.left
214 top: parent.top
215 }
216 covers: [{art: player.currentMetaArt, author: player.currentMetaArtist, album: player.currentMetaArt}]
217 size: parent.height
218 }
219
220 /* Column of meta labels */
221 Column {
222 id: playerControlsLabels
223 anchors {
224 left: playerControlsImage.right
225 leftMargin: units.gu(1.5)
226 right: playerControlsPlayButton.left
227 rightMargin: units.gu(1)
228 verticalCenter: parent.verticalCenter
229 }
230
231 /* Title of track */
232 Label {
233 id: playerControlsTitle
234 anchors {
235 left: parent.left
236 right: parent.right
237 }
238 color: "#FFF"
239 elide: Text.ElideRight
240 fontSize: "small"
241 font.weight: Font.DemiBold
242 text: player.currentMetaTitle === ""
243 ? player.source : player.currentMetaTitle
244 }
245
246 /* Artist of track */
247 Label {
248 id: playerControlsArtist
249 anchors {
250 left: parent.left
251 right: parent.right
252 }
253 color: "#FFF"
254 elide: Text.ElideRight
255 fontSize: "small"
256 opacity: 0.4
257 text: player.currentMetaArtist
258 }
259 }
260
261 /* Play/Pause button */
262 Icon {
263 id: playerControlsPlayButton
264 anchors {
265 right: parent.right
266 rightMargin: units.gu(3)
267 verticalCenter: parent.verticalCenter
268 }
269 color: "#FFF"
270 height: units.gu(2.5)
271 name: player.playbackState === MediaPlayer.PlayingState ?
272 "media-playback-pause" : "media-playback-start"
273 objectName: "playShape"
274 width: height
275 }
276
277 MouseArea {
278 anchors {
279 bottom: parent.bottom
280 horizontalCenter: playerControlsPlayButton.horizontalCenter
281 top: parent.top
282 }
283 onClicked: player.toggle()
284 width: units.gu(8)
285
286 Rectangle {
287 anchors {
288 fill: parent
289 }
290 color: "#FFF"
291 opacity: parent.pressed ? 0.1 : 0
292
293 Behavior on opacity {
294 UbuntuNumberAnimation {
295 duration: UbuntuAnimation.FastDuration
296 }
297 }
298 }
299 }
300
301 /* Mouse area to jump to now playing */
302 Item {
303 anchors {
304 bottom: parent.bottom
305 left: parent.left
306 right: playerControlsLabels.right
307 top: parent.top
308 }
309 objectName: "jumpNowPlaying"
310 function trigger() {
311 tabs.pushNowPlaying();
312 }
313 }
314 }
315
316 /* Object which provides the progress bar when toolbar is minimized */
317 Rectangle {
318 id: playerControlsProgressBar
319 anchors {
320 bottom: parent.bottom
321 left: parent.left
322 right: parent.right
323 }
324 color: styleMusic.common.black
325 height: units.gu(0.25)
326
327 Rectangle {
328 id: playerControlsProgressBarHint
329 anchors {
330 left: parent.left
331 top: parent.top
332 }
333 color: UbuntuColors.blue
334 height: parent.height
335 width: player.duration > 0 ? (player.position / player.duration) * playerControlsProgressBar.width : 0
336
337 Connections {
338 target: player
339 onPositionChanged: {
340 playerControlsProgressBarHint.width = (player.position / player.duration) * playerControlsProgressBar.width
341 }
342 onStopped: {
343 playerControlsProgressBarHint.width = 0;
344 }
345 }
346 }278 }
347 }279 }
348 }280 }
349 }281 }
350 }282 }
351}283}
352
353284
=== modified file 'MusicaddtoPlaylist.qml'
--- MusicaddtoPlaylist.qml 2015-01-21 00:10:33 +0000
+++ MusicaddtoPlaylist.qml 2015-01-23 13:45:46 +0000
@@ -132,7 +132,7 @@
132 page.covers = Playlists.getPlaylistCovers(name)132 page.covers = Playlists.getPlaylistCovers(name)
133 }133 }
134134
135 musicToolbar.goBack(); // go back to the previous page135 mainPageStack.goBack(); // go back to the previous page
136 }136 }
137 }137 }
138 }138 }
139139
=== modified file 'common/AlbumsPage.qml'
--- common/AlbumsPage.qml 2015-01-17 12:44:57 +0000
+++ common/AlbumsPage.qml 2015-01-23 13:45:46 +0000
@@ -137,7 +137,7 @@
137 store: musicStore137 store: musicStore
138 onStatusChanged: {138 onStatusChanged: {
139 if (albumsModel.status === SongsModel.Ready && loaded && albumsModel.count === 0) {139 if (albumsModel.status === SongsModel.Ready && loaded && albumsModel.count === 0) {
140 musicToolbar.popPage(albumStackPage)140 mainPageStack.popPage(albumStackPage)
141 }141 }
142 }142 }
143 }143 }
144144
=== modified file 'common/MusicPage.qml'
--- common/MusicPage.qml 2015-01-10 19:22:08 +0000
+++ common/MusicPage.qml 2015-01-23 13:45:46 +0000
@@ -25,7 +25,7 @@
25Page {25Page {
26 id: thisPage26 id: thisPage
27 anchors {27 anchors {
28 bottomMargin: musicToolbar.visible ? musicToolbar.currentHeight : 028 bottomMargin: musicToolbar.visible ? musicToolbar.height : 0
29 fill: parent29 fill: parent
30 }30 }
3131
@@ -56,7 +56,7 @@
5656
57 onVisibleChanged: {57 onVisibleChanged: {
58 if (visible) {58 if (visible) {
59 musicToolbar.setPage(thisPage);59 mainPageStack.setPage(thisPage);
60 }60 }
61 }61 }
62}62}
6363
=== modified file 'common/SongsPage.qml'
--- common/SongsPage.qml 2015-01-18 16:46:48 +0000
+++ common/SongsPage.qml 2015-01-23 13:45:46 +0000
@@ -239,7 +239,7 @@
239 store: musicStore239 store: musicStore
240 onStatusChanged: {240 onStatusChanged: {
241 if (songsModel.status === SongsModel.Ready && loaded && songsModel.count === 0) {241 if (songsModel.status === SongsModel.Ready && loaded && songsModel.count === 0) {
242 musicToolbar.popPage(songStackPage)242 mainPageStack.popPage(songStackPage)
243 }243 }
244 }244 }
245 }245 }
@@ -598,7 +598,7 @@
598 songStackPage.page = undefined598 songStackPage.page = undefined
599 PopupUtils.close(dialogRemovePlaylist)599 PopupUtils.close(dialogRemovePlaylist)
600600
601 musicToolbar.goBack()601 mainPageStack.goBack()
602 }602 }
603 }603 }
604 Button {604 Button {
605605
=== modified file 'music-app.qml'
--- music-app.qml 2015-01-21 13:31:57 +0000
+++ music-app.qml 2015-01-23 13:45:46 +0000
@@ -55,10 +55,10 @@
55 focus: true55 focus: true
56 Keys.onPressed: {56 Keys.onPressed: {
57 if(event.key === Qt.Key_Escape) {57 if(event.key === Qt.Key_Escape) {
58 if (musicToolbar.currentPage.searchable && musicToolbar.currentPage.state === "search") {58 if (mainPageStack.actualCurrentPage.searchable && mainPageStack.actualCurrentPage.state === "search") {
59 musicToolbar.currentPage.state = "default"59 mainPageStack.actualCurrentPage.state = "default"
60 } else {60 } else {
61 musicToolbar.goBack(); // Esc Go back61 mainPageStack.goBack(); // Esc Go back
62 }62 }
63 }63 }
64 else if(event.modifiers === Qt.AltModifier) {64 else if(event.modifiers === Qt.AltModifier) {
@@ -95,8 +95,8 @@
95 player.repeat = !player.repeat95 player.repeat = !player.repeat
96 break;96 break;
97 case Qt.Key_F: // Ctrl+F Show Search popup97 case Qt.Key_F: // Ctrl+F Show Search popup
98 if (musicToolbar.currentPage.searchable && musicToolbar.currentPage.state === "default") {98 if (mainPageStack.actualCurrentPage.searchable && mainPageStack.actualCurrentPage.state === "default") {
99 musicToolbar.currentPage.state = "search"99 mainPageStack.actualCurrentPage.state = "search"
100 header.show()100 header.show()
101 }101 }
102102
@@ -159,7 +159,7 @@
159 id: backAction159 id: backAction
160 text: i18n.tr("Back")160 text: i18n.tr("Back")
161 keywords: i18n.tr("Go back to last page")161 keywords: i18n.tr("Go back to last page")
162 onTriggered: musicToolbar.goBack();162 onTriggered: mainPageStack.goBack();
163 }163 }
164164
165 // With a default Quit action only the first 4 actions are displayed165 // With a default Quit action only the first 4 actions are displayed
@@ -897,7 +897,7 @@
897897
898 if (trackQueue.model.count === 1) {898 if (trackQueue.model.count === 1) {
899 player.stop()899 player.stop()
900 musicToolbar.goBack()900 mainPageStack.goBack()
901 } else if (index === player.currentIndex) {901 } else if (index === player.currentIndex) {
902 player.nextSong(player.isPlaying);902 player.nextSong(player.isPlaying);
903 }903 }
@@ -936,7 +936,7 @@
936 if (trackQueue.model.count === 0) {936 if (trackQueue.model.count === 0) {
937 // Nothing in the queue so stop and pop the queue937 // Nothing in the queue so stop and pop the queue
938 player.stop()938 player.stop()
939 musicToolbar.goBack()939 mainPageStack.goBack()
940 } else if (items.indexOf(player.currentIndex) > -1) {940 } else if (items.indexOf(player.currentIndex) > -1) {
941 // Current track was removed941 // Current track was removed
942942
@@ -1053,24 +1053,85 @@
1053 }1053 }
1054 }1054 }
10551055
1056 MusicToolbar {1056 Loader {
1057 id: musicToolbar1057 id: musicToolbar
1058 anchors {
1059 bottom: parent.bottom
1060 left: parent.left
1061 right: parent.right
1062 }
1063 asynchronous: true
1064 source: "MusicToolbar.qml"
1058 visible: mainPageStack.currentPage.title !== i18n.tr("Now playing") &&1065 visible: mainPageStack.currentPage.title !== i18n.tr("Now playing") &&
1059 mainPageStack.currentPage.title !== i18n.tr("Queue") &&1066 mainPageStack.currentPage.title !== i18n.tr("Queue") &&
1060 !firstRun1067 !firstRun
1061 objectName: "musicToolbarObject"
1062 z: 200 // put on top of everything else1068 z: 200 // put on top of everything else
1063 }1069 }
10641070
1065 PageStack {1071 PageStack {
1066 id: mainPageStack1072 id: mainPageStack
10671073
1074 // Properties storing the current page info
1075 property Page actualCurrentPage: null
1076 property bool popping: false
1077
1078 /* Helper functions */
1079
1080 // Go back up the stack if possible
1081 function goBack() {
1082 if (depth > 1) {
1083 pop()
1084 }
1085 }
1086
1087 // Pop a specific page in the stack
1088 function popPage(page) {
1089 var tmpPages = []
1090
1091 popping = true
1092
1093 while (currentPage !== page && depth > 0) {
1094 tmpPages.push(currentPage)
1095 pop()
1096 }
1097
1098 if (depth > 0) {
1099 pop()
1100 }
1101
1102 for (var i=tmpPages.length - 1; i > -1; i--) {
1103 push(tmpPages[i])
1104 }
1105
1106 popping = false
1107 }
1108
1109 // Set the current page, and any parent/stacks
1110 function setPage(childPage) {
1111 if (!popping) {
1112 actualCurrentPage = childPage;
1113 }
1114 }
1115
1068 Tabs {1116 Tabs {
1069 id: tabs1117 id: tabs
1070 anchors {1118 anchors {
1071 fill: parent1119 fill: parent
1072 }1120 }
10731121
1122 property Tab lastTab: selectedTab
1123
1124 onSelectedTabChanged: {
1125 // pause loading of the models in the old tab
1126 if (lastTab !== null && lastTab !== selectedTab) {
1127 allowLoading(lastTab, false);
1128 }
1129
1130 lastTab = selectedTab;
1131
1132 ensurePopulated(selectedTab);
1133 }
1134
1074 onSelectedTabIndexChanged: {1135 onSelectedTabIndexChanged: {
1075 if (loadedUI) { // store the tab index if changed by the user1136 if (loadedUI) { // store the tab index if changed by the user
1076 startupSettings.tabIndex = selectedTabIndex1137 startupSettings.tabIndex = selectedTabIndex
@@ -1275,21 +1336,6 @@
1275 mainPageStack.currentPage.isListView = false; // ensure full view1336 mainPageStack.currentPage.isListView = false; // ensure full view
1276 }1337 }
1277 }1338 }
1278
1279 Component.onCompleted: musicToolbar.currentTab = selectedTab
1280
1281 onSelectedTabChanged: {
1282 // pause loading of the models in the old tab
1283 if (musicToolbar.currentTab !== selectedTab &&
1284 musicToolbar.currentTab !== null)
1285 {
1286 allowLoading(musicToolbar.currentTab, false);
1287 }
1288
1289 musicToolbar.currentTab = selectedTab;
1290
1291 ensurePopulated(selectedTab);
1292 }
1293 } // end of tabs1339 } // end of tabs
1294 }1340 }
12951341

Subscribers

People subscribed via source and target branches