~danielholm/musicapp/trunk

« back to all changes in this revision

Viewing changes to MusicTracks.qml

  • Committer: Daniel Holm
  • Date: 2013-05-17 11:49:30 UTC
  • Revision ID: admin@danielholm.se-20130517114930-noc4gn344hj6qx1u
Added setting and database to save users music dir. Now uses that setting, too.

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
import Ubuntu.Components.ListItems 0.1
23
23
import Ubuntu.Components.Popups 0.1
24
24
import Ubuntu.Components.ListItems 0.1 as ListItem
25
 
//import Qt.labs.folderlistmodel 1.0 // change from this
26
 
import org.nemomobile.folderlistmodel 1.0 //change to this
 
25
import Qt.labs.folderlistmodel 1.0
27
26
import QtMultimedia 5.0
28
27
import QtQuick.LocalStorage 2.0
 
28
import "storage.js" as Storage
29
29
 
30
30
 
31
31
PageStack {
32
32
    id: singleTracksPageStack
33
33
    anchors.fill: parent
34
34
 
 
35
    Component.onCompleted: {
 
36
        Storage.initialize()
 
37
        console.debug("INITIALIZED")
 
38
        if (Storage.getSetting("initialized") !== "true") {
 
39
            // initialize settings
 
40
            console.debug("reset settings")
 
41
            Storage.setSetting("initialized", "true")
 
42
            Storage.setSetting("currentfolder", "/")
 
43
        }
 
44
        else {
 
45
            musicDir = Storage.getSetting("currentfolder")
 
46
            console.debug("Debug: Music dir set to: "+Storage.getSetting("currentfolder"))
 
47
        }
 
48
    }
 
49
 
35
50
//    property int  headerHeight:  units.gu(10); // needed?
36
51
 
37
52
    width: units.gu(50)
40
55
    // set the folder from where the music is
41
56
    FolderListModel {
42
57
        id: folderModel
43
 
        path: homePath()+"/Musik/"
44
 
        showDirectories: false
 
58
        folder: musicDir
 
59
        showDirs: false
45
60
        nameFilters: ["*.ogg","*.mp3","*.oga","*.wav"]
46
61
    }
47
62
 
51
66
        // toolbar
52
67
        tools: defaultToolbar
53
68
 
54
 
        ListView {
55
 
            id: singeTrackList
56
 
            width: units.gu(40)
57
 
            height: units.gu(50)
58
 
            model: folderModel
59
 
            delegate: ListItem.Standard {
60
 
                //text: artist+" - "+title
61
 
                id: file
62
 
                text: fileName
 
69
        Column {
 
70
            anchors.centerIn: parent
 
71
            anchors.fill: parent
 
72
            ListView {
 
73
                id: musicFolder
 
74
                width: parent.width
 
75
                height: parent.height
 
76
                model: folderModel
 
77
                delegate: ListItem.Subtitled {
 
78
                    text: fileName
 
79
                    subText: "Artist: "
 
80
                    onClicked: {
 
81
                        playMusic.source = musicDir+"/"+fileName
 
82
                        playMusic.play()
 
83
                        console.debug('Debug: User pressed '+musicDir+"/"+fileName)
 
84
                        trackInfo.text = playMusic.metaData.albumArtist+" - "+playMusic.metaData.title // show track meta data
 
85
                        // cool animation
 
86
                    }
 
87
                    onPressAndHold: {
 
88
                        console.debug('Debug: '+fileName+' added to queue.')
 
89
                        trackQueue.append({"title": playMusic.metaData.title, "artist": playMusic.metaData.albumArtist, "file": fileName})
 
90
                        // cool animation
 
91
                    }
 
92
                }
63
93
            }
64
94
        }
65
95