554
553
Settings.setSetting("snaptrack", "1") // default state of snaptrack
555
554
Settings.setSetting("shuffle", "0") // default state of shuffle
556
555
Settings.setSetting("repeat", "0") // default state of repeat
557
//Settings.setSetting("scrobble", "0") // default state of scrobble
559
557
Library.initialize();
591
586
property string musicName: i18n.tr("Music")
592
587
property string appVersion: '1.2'
593
property bool scrobble: false
594
property string lastfmusername
595
property string lastfmpassword
596
property string timestamp // used to scrobble
597
588
property var chosenElements: []
598
589
property bool toolbarShown: musicToolbar.visible
599
590
property bool selectedAlbum: false
763
// Model to send the data
768
function rpcRequest(request,handler) {
769
var http = new XMLHttpRequest()
771
http.open("POST",scrobble_url,true)
772
http.setRequestHeader("User-Agent", "Music-App/"+appVersion)
773
http.setRequestHeader("Content-type", "text/xml")
774
http.setRequestHeader("Content-length", request.length)
775
if (root.authenticate) {
776
http.setRequestHeader("Authorization", "Basic " + Qt.btoa(lastfmusername+":"+lastfmusername))
778
http.setRequestHeader("Connection", "close")
779
http.onreadystatechange = function() {
780
if(http.readyState == 4 && http.status == 200) {
781
console.debug("Debug: XmlRpc::rpcRequest.onreadystatechange()")
782
handler(http.responseText)
788
function callHandler(response) {
792
function call(cmd,params) {
793
console.debug("Debug: XmlRpc.call(",cmd,params,")")
795
request += "<?xml version='1.0'?>"
796
request += "<methodCall>"
797
request += "<methodName>" + cmd + "</methodName>"
798
request += "<params>"
799
for (var i=0; i<params.length; i++) {
800
request += "<param><value>"
801
if (typeof(params[i])=="string") {
802
request += "<string>" + params[i] + "</string>"
804
if (typeof(params[i])=="number") {
805
request += "<int>" + params[i] + "</int>"
807
request += "</value></param>"
809
request += "</params>"
810
request += "</methodCall>"
811
rpcRequest(request,callHandler)
815
754
// TODO: Used by playlisttracks move to U1DB
816
755
LibraryListModel {
817
756
id: albumTracksModel
872
// load sheets (after model)
877
// Popover for tracks, queue and add to playlist, for example
878
Component { // TODO: needed anymore? remove?
879
id: trackPopoverComponent
891
text: i18n.tr("Add to queue")
892
color: styleMusic.popover.labelColor
894
anchors.horizontalCenter: parent.horizontalCenter
895
anchors.verticalCenter: parent.verticalCenter
898
console.debug("Debug: Add track to queue: " + JSON.stringify(chosenElements))
899
PopupUtils.close(trackPopover)
901
for (var i=0; i < chosenElements.length; i++) {
902
trackQueue.append(chosenElements[i])
908
text: i18n.tr("Add to playlist")
909
color: styleMusic.popover.labelColor
911
anchors.horizontalCenter: parent.horizontalCenter
912
anchors.verticalCenter: parent.verticalCenter
915
console.debug("Debug: Add track to playlist")
916
PopupUtils.close(trackPopover)
918
mainPageStack.push(addtoPlaylist)
925
811
// New playlist dialog
927
813
id: newPlaylistDialog
1187
1073
// Overlay to show when no tracks detected on the device
1189
1075
id: libraryEmpty
1190
anchors.fill: parent
1191
anchors.topMargin: -emptyPage.header.height
1078
topMargin: -emptyPage.header.height
1192
1080
color: mainView.backgroundColor
1193
1081
visible: emptyPage.noMusic
1215
1103
// Overlay to show when no playlists are on the device
1217
1105
id: playlistsEmpty
1218
anchors.fill: parent
1219
anchors.topMargin: -emptyPage.header.height
1108
topMargin: -emptyPage.header.height
1220
1110
color: mainView.backgroundColor
1221
1111
visible: emptyPage.noPlaylists && !emptyPage.noMusic && tabs.selectedTab.index === 4
1243
1133
// Overlay to show when no recent items are on the device
1245
1135
id: recentEmpty
1246
anchors.fill: parent
1247
anchors.topMargin: -emptyPage.header.height
1138
topMargin: -emptyPage.header.height
1248
1140
color: mainView.backgroundColor
1249
1141
visible: emptyPage.noRecent && !emptyPage.noMusic && tabs.selectedTab.index === 0