~music-app-dev/music-app/remix

« back to all changes in this revision

Viewing changes to music-app.qml

* Remove lastfm, search and settings.

Approved by Ubuntu Phone Apps Jenkins Bot, Victor Thompson.

Show diffs side-by-side

added added

removed removed

Lines of Context:
30
30
import UserMetrics 0.1
31
31
import "settings.js" as Settings
32
32
import "meta-database.js" as Library
33
 
import "scrobble.js" as Scrobble
34
33
import "playlists.js" as Playlists
35
34
import "common"
36
35
 
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
558
556
        }
559
557
        Library.initialize();
560
558
 
563
561
 
564
562
        // everything else
565
563
        loading.visible = true
566
 
        scrobble = Settings.getSetting("scrobble") == "1" // scrobble state
567
 
        lastfmusername = Settings.getSetting("lastfmusername") // lastfm username
568
 
        lastfmpassword = Settings.getSetting("lastfmpassword") // lastfm password
569
564
 
570
565
        // push the page to view
571
566
        mainPageStack.push(tabs)
590
585
    // VARIABLES
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
760
751
        id: player
761
752
    }
762
753
 
763
 
    // Model to send the data
764
 
    XmlListModel {
765
 
        id: scrobblemodel
766
 
        query: "/"
767
 
 
768
 
        function rpcRequest(request,handler) {
769
 
            var http = new XMLHttpRequest()
770
 
 
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))
777
 
            }
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)
783
 
                }
784
 
            }
785
 
            http.send(request)
786
 
        }
787
 
 
788
 
        function callHandler(response) {
789
 
            xml = response
790
 
        }
791
 
 
792
 
        function call(cmd,params) {
793
 
            console.debug("Debug: XmlRpc.call(",cmd,params,")")
794
 
            var request = ""
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>"
803
 
                }
804
 
                if (typeof(params[i])=="number") {
805
 
                    request += "<int>" + params[i] + "</int>"
806
 
                }
807
 
                request += "</value></param>"
808
 
            }
809
 
            request += "</params>"
810
 
            request += "</methodCall>"
811
 
            rpcRequest(request,callHandler)
812
 
        }
813
 
    }
814
 
 
815
754
    // TODO: Used by playlisttracks move to U1DB
816
755
    LibraryListModel {
817
756
        id: albumTracksModel
869
808
        }
870
809
    }
871
810
 
872
 
    // load sheets (after model)
873
 
    MusicSearch {
874
 
        id: searchSheet
875
 
    }
876
 
 
877
 
    // Popover for tracks, queue and add to playlist, for example
878
 
    Component {  // TODO: needed anymore? remove?
879
 
        id: trackPopoverComponent
880
 
        Popover {
881
 
            id: trackPopover
882
 
            Column {
883
 
                id: containerLayout
884
 
                anchors {
885
 
                    left: parent.left
886
 
                    top: parent.top
887
 
                    right: parent.right
888
 
                }
889
 
                ListItem.Standard {
890
 
                    Label {
891
 
                        text: i18n.tr("Add to queue")
892
 
                        color: styleMusic.popover.labelColor
893
 
                        fontSize: "large"
894
 
                        anchors.horizontalCenter: parent.horizontalCenter
895
 
                        anchors.verticalCenter: parent.verticalCenter
896
 
                    }
897
 
                    onClicked: {
898
 
                        console.debug("Debug: Add track to queue: " + JSON.stringify(chosenElements))
899
 
                        PopupUtils.close(trackPopover)
900
 
 
901
 
                        for (var i=0; i < chosenElements.length; i++) {
902
 
                            trackQueue.append(chosenElements[i])
903
 
                        }
904
 
                    }
905
 
                }
906
 
                ListItem.Standard {
907
 
                    Label {
908
 
                        text: i18n.tr("Add to playlist")
909
 
                        color: styleMusic.popover.labelColor
910
 
                        fontSize: "large"
911
 
                        anchors.horizontalCenter: parent.horizontalCenter
912
 
                        anchors.verticalCenter: parent.verticalCenter
913
 
                    }
914
 
                    onClicked: {
915
 
                        console.debug("Debug: Add track to playlist")
916
 
                        PopupUtils.close(trackPopover)
917
 
 
918
 
                        mainPageStack.push(addtoPlaylist)
919
 
                    }
920
 
                }
921
 
            }
922
 
        }
923
 
    }
924
 
 
925
811
    // New playlist dialog
926
812
    Component {
927
813
        id: newPlaylistDialog
1187
1073
        // Overlay to show when no tracks detected on the device
1188
1074
        Rectangle {
1189
1075
            id: libraryEmpty
1190
 
            anchors.fill: parent
1191
 
            anchors.topMargin: -emptyPage.header.height
 
1076
            anchors {
 
1077
                fill: parent
 
1078
                topMargin: -emptyPage.header.height
 
1079
            }
1192
1080
            color: mainView.backgroundColor
1193
1081
            visible: emptyPage.noMusic
1194
1082
 
1215
1103
        // Overlay to show when no playlists are on the device
1216
1104
        Rectangle {
1217
1105
            id: playlistsEmpty
1218
 
            anchors.fill: parent
1219
 
            anchors.topMargin: -emptyPage.header.height
 
1106
            anchors {
 
1107
                fill: parent
 
1108
                topMargin: -emptyPage.header.height
 
1109
            }
1220
1110
            color: mainView.backgroundColor
1221
1111
            visible: emptyPage.noPlaylists && !emptyPage.noMusic && tabs.selectedTab.index === 4
1222
1112
 
1243
1133
        // Overlay to show when no recent items are on the device
1244
1134
        Rectangle {
1245
1135
            id: recentEmpty
1246
 
            anchors.fill: parent
1247
 
            anchors.topMargin: -emptyPage.header.height
 
1136
            anchors {
 
1137
                fill: parent
 
1138
                topMargin: -emptyPage.header.height
 
1139
            }
1248
1140
            color: mainView.backgroundColor
1249
1141
            visible: emptyPage.noRecent && !emptyPage.noMusic && tabs.selectedTab.index === 0
1250
1142