Changeset View
Changeset View
Standalone View
Standalone View
src/MediaAlbumView.qml
Show All 22 Lines | |||||
23 | import QtQuick.Controls.Styles 1.2 | 23 | import QtQuick.Controls.Styles 1.2 | ||
24 | import QtQml.Models 2.1 | 24 | import QtQml.Models 2.1 | ||
25 | import org.kde.elisa 1.0 | 25 | import org.kde.elisa 1.0 | ||
26 | import QtQuick.Layouts 1.2 | 26 | import QtQuick.Layouts 1.2 | ||
27 | 27 | | |||
28 | FocusScope { | 28 | FocusScope { | ||
29 | id: topListing | 29 | id: topListing | ||
30 | 30 | | |||
31 | property StackView stackView | | |||
32 | property MediaPlayList playListModel | | |||
33 | property var musicListener | 31 | property var musicListener | ||
34 | property var playerControl | | |||
35 | property var albumName | 32 | property var albumName | ||
36 | property var artistName | 33 | property var artistName | ||
37 | property var tracksCount | | |||
38 | property var albumArtUrl | 34 | property var albumArtUrl | ||
39 | property bool isSingleDiscAlbum | 35 | property bool isSingleDiscAlbum | ||
40 | property var albumData | | |||
41 | property var albumId | 36 | property var albumId | ||
37 | property alias albumModel: contentDirectoryView.model | ||||
42 | 38 | | |||
43 | signal showArtist(var name) | 39 | signal showArtist(var name) | ||
44 | 40 | signal enqueueAlbum(var album) | |||
45 | width: stackView.width | 41 | signal clearPlayList() | ||
46 | height: stackView.height | 42 | signal enqueueTrack(var track) | ||
43 | signal ensurePlay() | ||||
44 | signal goBack(); | ||||
47 | 45 | | |||
48 | SystemPalette { | 46 | SystemPalette { | ||
49 | id: myPalette | 47 | id: myPalette | ||
50 | colorGroup: SystemPalette.Active | 48 | colorGroup: SystemPalette.Active | ||
51 | } | 49 | } | ||
52 | 50 | | |||
53 | Theme { | 51 | Theme { | ||
54 | id: elisaTheme | 52 | id: elisaTheme | ||
55 | } | 53 | } | ||
56 | 54 | | |||
57 | AlbumModel { | | |||
58 | id: contentModel | | |||
59 | | ||||
60 | albumData: topListing.albumData | | |||
61 | } | | |||
62 | | ||||
63 | Connections { | 55 | Connections { | ||
64 | target: musicListener | 56 | target: musicListener | ||
65 | 57 | | |||
66 | onAlbumRemoved: | 58 | onAlbumRemoved: | ||
67 | { | 59 | { | ||
68 | if (albumId === removedAlbumId) { | 60 | if (albumId === removedAlbumId) { | ||
69 | contentModel.albumRemoved(removedAlbum) | 61 | contentModel.albumRemoved(removedAlbum) | ||
70 | } | 62 | } | ||
71 | } | 63 | } | ||
72 | } | 64 | } | ||
73 | 65 | | |||
74 | Connections { | 66 | Connections { | ||
75 | target: musicListener | 67 | target: musicListener | ||
76 | 68 | | |||
77 | onAlbumModified: | 69 | onAlbumModified: | ||
78 | { | 70 | { | ||
79 | if (albumId === modifiedAlbumId) { | 71 | if (albumId === modifiedAlbumId) { | ||
80 | albumData = modifiedAlbum | 72 | albumModel.albumData = modifiedAlbum | ||
81 | contentModel.albumModified(modifiedAlbum) | 73 | contentModel.albumModified(modifiedAlbum) | ||
82 | } | 74 | } | ||
83 | } | 75 | } | ||
84 | } | 76 | } | ||
85 | 77 | | |||
86 | ColumnLayout { | 78 | ColumnLayout { | ||
87 | anchors.fill: parent | 79 | anchors.fill: parent | ||
88 | spacing: 0 | 80 | spacing: 0 | ||
89 | 81 | | |||
90 | NavigationActionBar { | 82 | NavigationActionBar { | ||
91 | id: navBar | 83 | id: navBar | ||
92 | 84 | | |||
93 | height: elisaTheme.navigationBarHeight | 85 | height: elisaTheme.navigationBarHeight | ||
94 | 86 | | |||
95 | Layout.preferredHeight: height | 87 | Layout.preferredHeight: height | ||
96 | Layout.minimumHeight: height | 88 | Layout.minimumHeight: height | ||
97 | Layout.maximumHeight: height | 89 | Layout.maximumHeight: height | ||
98 | Layout.fillWidth: true | 90 | Layout.fillWidth: true | ||
99 | 91 | | |||
100 | parentStackView: topListing.stackView | 92 | mainTitle: (topListing.albumModel ? topListing.albumModel.author : '') | ||
101 | playList: topListing.playListModel | 93 | secondaryTitle: topListing.albumName | ||
102 | playerControl: topListing.playerControl | | |||
103 | artist: topListing.artistName | | |||
104 | album: topListing.albumName | | |||
105 | image: (topListing.albumArtUrl ? topListing.albumArtUrl : elisaTheme.defaultAlbumImage) | 94 | image: (topListing.albumArtUrl ? topListing.albumArtUrl : elisaTheme.defaultAlbumImage) | ||
106 | tracksCount: topListing.tracksCount | 95 | allowArtistNavigation: true | ||
107 | 96 | | |||
108 | enqueueAction: Action { | 97 | onEnqueue: topListing.enqueueAlbum(albumModel.albumData) | ||
109 | text: i18nc("Add whole album to play list", "Enqueue") | | |||
110 | iconName: "media-track-add-amarok" | | |||
111 | onTriggered: topListing.playListModel.enqueue(topListing.albumData) | | |||
112 | } | | |||
113 | 98 | | |||
114 | clearAndEnqueueAction: Action { | 99 | onEnqueueAndPlay: { | ||
115 | text: i18nc("Clear play list and play", "Replace and Play") | 100 | topListing.clearPlayList() | ||
116 | tooltip: i18nc("Clear play list and add whole album to play list", "Replace Play List and Play Now") | 101 | topListing.enqueueAlbum(albumModel.albumData) | ||
117 | iconName: "media-playback-start" | 102 | topListing.ensurePlay() | ||
118 | onTriggered: { | | |||
119 | topListing.playListModel.clearAndEnqueue(topListing.albumData) | | |||
120 | topListing.playerControl.ensurePlay() | | |||
121 | } | | |||
122 | } | 103 | } | ||
123 | 104 | | |||
124 | navigateToArtistAction: Action { | 105 | onGoBack: topListing.goBack() | ||
125 | text: i18nc("Button to navigate to the artist of the album", "Display Artist") | 106 | | ||
126 | iconName: "view-media-artist" | 107 | onShowArtist: topListing.showArtist((topListing.albumModel ? topListing.albumModel.author : '')) | ||
127 | onTriggered: { | | |||
128 | showArtist(topListing.artistName) | | |||
129 | } | | |||
130 | } | | |||
131 | } | 108 | } | ||
132 | 109 | | |||
133 | ScrollView { | 110 | ScrollView { | ||
134 | flickableItem.boundsBehavior: Flickable.StopAtBounds | 111 | flickableItem.boundsBehavior: Flickable.StopAtBounds | ||
135 | flickableItem.interactive: true | 112 | flickableItem.interactive: true | ||
136 | 113 | | |||
137 | Layout.fillHeight: true | 114 | Layout.fillHeight: true | ||
138 | Layout.fillWidth: true | 115 | Layout.fillWidth: true | ||
139 | 116 | | |||
140 | ListView { | 117 | ListView { | ||
141 | id: contentDirectoryView | 118 | id: contentDirectoryView | ||
142 | 119 | | |||
143 | focus: true | 120 | focus: true | ||
144 | 121 | | |||
145 | model: contentModel | | |||
146 | | ||||
147 | delegate: MediaAlbumTrackDelegate { | 122 | delegate: MediaAlbumTrackDelegate { | ||
148 | id: entry | 123 | id: entry | ||
149 | 124 | | |||
150 | height: ((model.isFirstTrackOfDisc && !isSingleDiscAlbum) ? elisaTheme.delegateHeight*2 : elisaTheme.delegateHeight) | 125 | height: ((model.isFirstTrackOfDisc && !isSingleDiscAlbum) ? elisaTheme.delegateHeight*2 : elisaTheme.delegateHeight) | ||
151 | width: contentDirectoryView.width | 126 | width: contentDirectoryView.width | ||
152 | 127 | | |||
153 | focus: true | 128 | focus: true | ||
154 | 129 | | |||
Show All 36 Lines | 164 | mediaTrack.isFirstTrackOfDisc: if (model != undefined && model.isFirstTrackOfDisc !== undefined) | |||
191 | else | 166 | else | ||
192 | false | 167 | false | ||
193 | mediaTrack.isSingleDiscAlbum: if (model != undefined && model.isSingleDiscAlbum !== undefined) | 168 | mediaTrack.isSingleDiscAlbum: if (model != undefined && model.isSingleDiscAlbum !== undefined) | ||
194 | model.isSingleDiscAlbum | 169 | model.isSingleDiscAlbum | ||
195 | else | 170 | else | ||
196 | true | 171 | true | ||
197 | 172 | | |||
198 | 173 | | |||
199 | mediaTrack.onClearPlaylist: topListing.playListModel.clearPlayList() | 174 | mediaTrack.onClearPlaylist: topListing.clearPlayList() | ||
200 | 175 | | |||
201 | mediaTrack.onEnqueueToPlaylist: topListing.playListModel.enqueue(track) | 176 | mediaTrack.onEnqueueToPlaylist: topListing.enqueueTrack(track) | ||
202 | 177 | | |||
203 | mediaTrack.onEnsurePlay: topListing.playerControl.ensurePlay() | 178 | mediaTrack.onEnsurePlay: topListing.ensurePlay() | ||
204 | 179 | | |||
205 | mediaTrack.onClicked: contentDirectoryView.currentIndex = index | 180 | mediaTrack.onClicked: contentDirectoryView.currentIndex = index | ||
206 | } | 181 | } | ||
207 | } | 182 | } | ||
208 | } | 183 | } | ||
209 | } | 184 | } | ||
210 | } | 185 | } |