From 6d36f509fe3cb4e67e58260d536844fb3f60632e Mon Sep 17 00:00:00 2001 From: Yoann Lopes Date: Thu, 3 Nov 2011 15:05:23 +0100 Subject: The current playing track can now be added to a playlist from the player --- qml/FullControls.qml | 25 ++++++++++++++++++++--- qml/MainPage.qml | 38 +++++++++++++++++++++++++++++++++++ qml/TrackMenu.qml | 57 +++++++++------------------------------------------- 3 files changed, 70 insertions(+), 50 deletions(-) (limited to 'qml') diff --git a/qml/FullControls.qml b/qml/FullControls.qml index 16735ec..8cdfd2b 100644 --- a/qml/FullControls.qml +++ b/qml/FullControls.qml @@ -422,12 +422,31 @@ Column { Item { width: parent.width - height: favIcon.height + height: 40 Image { - id: favIcon + id: addIcon anchors.left: parent.left anchors.verticalCenter: parent.verticalCenter + opacity: enabled ? (addArea.pressed ? 0.4 : 1.0) : 0.2 + source: "image://theme/icon-m-toolbar-add-white"; + enabled: !spotifySession.offlineMode + + MouseArea { + id: addArea + anchors.fill: parent + anchors.margins: -15 + onClicked: { + mainPage.playlistSelection.track = spotifySession.currentTrack; + mainPage.playlistSelection.selectedIndex = -1; + mainPage.playlistSelection.open(); + } + } + } + Image { + id: favIcon + x: 136 + anchors.verticalCenter: parent.verticalCenter opacity: enabled ? (starArea.pressed ? 0.4 : 1.0) : 0.2 source: spotifySession.currentTrack ? (spotifySession.currentTrack.isStarred ? "image://theme/icon-m-toolbar-favorite-mark-white" : "image://theme/icon-m-toolbar-favorite-unmark-white") @@ -442,7 +461,7 @@ Column { } } Image { - anchors.horizontalCenter: parent.horizontalCenter + x: 272 anchors.verticalCenter: parent.verticalCenter source: spotifySession.shuffle ? "images/icon-m-toolbar-shuffle-white-selected.png" : "image://theme/icon-m-toolbar-shuffle-white"; opacity: shuffleArea.pressed ? 0.4 : 1.0 diff --git a/qml/MainPage.qml b/qml/MainPage.qml index d00ead0..283db68 100644 --- a/qml/MainPage.qml +++ b/qml/MainPage.qml @@ -51,11 +51,49 @@ Page { property alias tabs: tabGroup property alias searchTabAlias: searchTab + property alias playlistSelection: playlistSelectionDialog NotificationBanner { id: errorBanner } + MySelectionDialog { + id: playlistSelectionDialog + + property variant track: null + + titleText: "Playlists" + onAccepted: { + var playlistItem = model.get(playlistSelectionDialog.selectedIndex); + if (playlistItem.object) { + errorBanner.text = "Track added to " + playlistItem.name; + playlistItem.object.add(track); + } else { + if (spotifySession.user.createPlaylistFromTrack(track)) { + errorBanner.text = "Track added to new playlist"; + } else { + errorBanner.text = "Could not add track to new playlist"; + } + } + errorBanner.show(); + } + } + + property variant playlists: spotifySession.user ? spotifySession.user.playlists : null + onPlaylistsChanged: { + playlistSelectionDialog.model.clear(); + + if (playlists === null) + return; + + for (var i in mainPage.playlists) { + if (mainPage.playlists[i].type == SpotifyPlaylist.Playlist && spotifySession.user.canModifyPlaylist(mainPage.playlists[i])) + playlistSelectionDialog.model.append({"name": mainPage.playlists[i].name, "object": mainPage.playlists[i] }) + } + + playlistSelectionDialog.model.append({"name": "New playlist" }); + } + Connections { target: spotifySession onConnectionErrorChanged: { diff --git a/qml/TrackMenu.qml b/qml/TrackMenu.qml index 06c1e9a..da6596a 100644 --- a/qml/TrackMenu.qml +++ b/qml/TrackMenu.qml @@ -5,22 +5,22 @@ ** Contact: Yoann Lopes (yoann.lopes@nokia.com) ** ** This file is part of the MeeSpot project. -** +** ** Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions ** are met: -** +** ** Redistributions of source code must retain the above copyright notice, ** this list of conditions and the following disclaimer. -** +** ** Redistributions in binary form must reproduce the above copyright ** notice, this list of conditions and the following disclaimer in the ** documentation and/or other materials provided with the distribution. -** +** ** Neither the name of Nokia Corporation and its Subsidiary(-ies) nor the names of its ** contributors may be used to endorse or promote products derived from ** this software without specific prior written permission. -** +** ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS @@ -52,36 +52,8 @@ MyMenu { property bool albumVisible: true property bool markSeenVisible: false - property variant playlists: spotifySession.user ? spotifySession.user.playlists : null - layoutContentHeight: layout.height - NotificationBanner { - id: banner - } - - MySelectionDialog { - id: selectionDialog - - titleText: "Playlists" - parent: trackMenu.parent - model: ListModel { } - onAccepted: { - var playlistItem = model.get(selectionDialog.selectedIndex); - if (playlistItem.object) { - banner.text = "Track added to " + playlistItem.name; - playlistItem.object.add(track); - } else { - if (spotifySession.user.createPlaylistFromTrack(track)) { - banner.text = "Track added to new playlist"; - } else { - banner.text = "Could not add track to new playlist"; - } - } - banner.show(); - } - } - QueryDialog { id: confirmDeleteDialog parent: trackMenu.parent @@ -127,7 +99,11 @@ MyMenu { MyMenuItem { text: "Add to playlist"; visible: !spotifySession.offlineMode - onClicked: { selectionDialog.selectedIndex = -1; selectionDialog.open(); } + onClicked: { + mainPage.playlistSelection.track = trackMenu.track; + mainPage.playlistSelection.selectedIndex = -1; + mainPage.playlistSelection.open(); + } } MyMenuItem { text: "Delete"; @@ -136,19 +112,6 @@ MyMenu { } } - onPlaylistsChanged: { - selectionDialog.model.clear(); - - if (playlists === null) - return; - - for (var i in trackMenu.playlists) { - if (trackMenu.playlists[i].type == SpotifyPlaylist.Playlist && spotifySession.user.canModifyPlaylist(trackMenu.playlists[i])) - selectionDialog.model.append({"name": trackMenu.playlists[i].name, "object": trackMenu.playlists[i] }) - } - selectionDialog.model.append({"name": "New playlist" }); - } - onStatusChanged: { if (status == DialogStatus.Opening && track) { starItem.text = track.isStarred ? "Unstar" : "Star"; -- cgit v1.2.3