~carla-sella/music-app/show_albums_sheet

5 by Daniel Holm
Tracks tab now lists set dirs music tracks; plays single file; paus and resume works; show track and artist of current track; code changes.
1
/*
100.2.1 by Daniel Holm
Inital move of settings to a Sheet and added the new stuff.
2
 * Copyright (C) 2013 Andrew Hayzen <ahayzen@gmail.com>
26.1.2 by Victor Thompson
Remove About from Settings and add copyright to all files.
3
 *                    Daniel Holm <d.holmen@gmail.com>
100.2.1 by Daniel Holm
Inital move of settings to a Sheet and added the new stuff.
4
 *                    Victor Thompson <victor.thompson@gmail.com>
5 by Daniel Holm
Tracks tab now lists set dirs music tracks; plays single file; paus and resume works; show track and artist of current track; code changes.
5
 *
6
 * This program is free software; you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation; version 3.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
17
 */
18
19
import QtQuick 2.0
20
import Ubuntu.Components 0.1
8 by Daniel Holm
Play, pause function is now working properly.
21
import Ubuntu.Components.ListItems 0.1 as ListItem
5 by Daniel Holm
Tracks tab now lists set dirs music tracks; plays single file; paus and resume works; show track and artist of current track; code changes.
22
import Ubuntu.Components.Popups 0.1
16 by Daniel Holm
Added setting and database to save users music dir. Now uses that setting, too.
23
import QtQuick.LocalStorage 2.0
17 by Daniel Holm
Added database for meta data and some code for it. Changed storage to settings to have seperate databases.
24
import "settings.js" as Settings
29.2.7 by Daniel Holm
More code for Last.fm; request functions; import playlists from last.fm
25
import "scrobble.js" as Scrobble
105.3.3 by Daniel Holm
Turned some unused stuff to non-visible; made switches stick to the right.
26
import "playlists.js" as Playlists
5 by Daniel Holm
Tracks tab now lists set dirs music tracks; plays single file; paus and resume works; show track and artist of current track; code changes.
27
100.2.1 by Daniel Holm
Inital move of settings to a Sheet and added the new stuff.
28
ComposerSheet {
29
    id: musicSettings
30
    title: i18n.tr("Settings")
100.2.8 by Daniel Holm
Sheet now fills parent.
31
    contentsHeight: parent.height;
100.2.1 by Daniel Holm
Inital move of settings to a Sheet and added the new stuff.
32
133.1.1 by Andrew Hayzen
* Custom toolbar created
33
    onVisibleChanged: {
34
        if (visible === true)
35
        {
36
            musicToolbar.disableToolbar()
37
        }
38
        else
39
        {
40
            musicToolbar.enableToolbar()
41
        }
42
    }
43
100.2.1 by Daniel Holm
Inital move of settings to a Sheet and added the new stuff.
44
    onCancelClicked: PopupUtils.close(musicSettings)
45
    onConfirmClicked: {
46
        PopupUtils.close(musicSettings)
47
        console.debug("Debug: Save settings")
48
        Settings.initialize()
100.2.2 by Daniel Holm
Settings now in order and some inital settings save.
49
50
        // Equaliser
100.2.5 by Daniel Holm
Disabled some stuff which aren't suppose to work untill 1.+ anyway
51
        // ACTIVATE IN 1.+ Settings.setSetting("eqialiser",equaliser.index)
100.2.2 by Daniel Holm
Settings now in order and some inital settings save.
52
53
        // snap track
54
        Settings.setSetting("snaptrack",snapSwitch.checked)
55
56
        // ACCOUNTS
57
        // Last.fm
58
59
        // MUSIC STREAMING
60
        // Ubuntu one
100.2.5 by Daniel Holm
Disabled some stuff which aren't suppose to work untill 1.+ anyway
61
        /* READY THIS LATER IN 1.+
100.2.2 by Daniel Holm
Settings now in order and some inital settings save.
62
        if (ubuntuaccount === activated) {
63
            Settings.setSetting("wifiswitch",wifiSwitch.checked)
64
        }*/
65
66
        // -- random = shuffleSwitch.checked // set shuffle state variable
67
        //console.debug("Debug: Shuffle: "+ shuffleSwitch.checked)
68
69
        // MOVE TO scrobble Settings.setSetting("scrobble", scrobbleSwitch.checked) // save shuffle state
70
        //scrobble = scrobbleSwitch.checked // set scrobble state variable
71
        //console.debug("Debug: Scrobble: "+ scrobbleSwitch.checked)
100.2.1 by Daniel Holm
Inital move of settings to a Sheet and added the new stuff.
72
    }
73
159.2.40 by Andrew Hayzen
* Third round of bug fixes
74
    // Activate in 1.+
75
    ListItem.ItemSelector {
76
        id: equaliser
77
        anchors.top: parent.top
78
        anchors.left: parent.left
79
        anchors.right: parent.right
80
        enabled: false
81
        text: i18n.tr("Equaliser")
82
        model: [i18n.tr("Default"),
83
              i18n.tr("Accoustic"),
84
              i18n.tr("Classical"),
85
              i18n.tr("Electronic"),
86
              i18n.tr("Flat"),
87
              i18n.tr("Hip Hop"),
88
              i18n.tr("Jazz"),
89
              i18n.tr("Metal"),
90
              i18n.tr("Pop"),
91
              i18n.tr("Rock"),
92
              i18n.tr("Custom")]
93
        onDelegateClicked: {
94
            customdebug("Value changed to "+index)
95
            //equaliserChange(index)
96
        }
97
    }
98
99
    // Snap to current track
100
    Rectangle {
101
        id: snapRow
102
        color: "transparent"
103
        width: parent.width
104
        anchors.top: equaliser.bottom
105
        anchors.topMargin: units.gu(2)
106
        anchors.left: parent.left
107
        anchors.right: parent.right
108
        anchors.leftMargin: units.gu(2)
109
        Label {
110
            id: snapLabel
111
            anchors.verticalCenter: snapSwitch.verticalCenter
112
            text: i18n.tr("Snap to current song \nwhen opening toolbar")
113
        }
114
        Switch {
115
            id: snapSwitch
116
            checked: Settings.getSetting("snaptrack") === "1"
117
            anchors.right: parent.right
118
        }
119
    }
120
    // Accounts
121
    Rectangle {
122
        id: accounts
123
        anchors.top: equaliser.bottom
124
        anchors.topMargin: units.gu(12)
125
        anchors.bottom: streaming.top
126
        anchors.bottomMargin: units.gu(2)
127
        color: "transparent"
128
        width: parent.width
129
130
        Label {
131
            id: accountLabel
132
            text: i18n.tr("Accounts")
133
            anchors.top: parent.top
134
            anchors.topMargin: units.gu(2)
135
        }
136
137
        // lastfm
138
        ListItem.Subtitled {
139
            id: lastfmProg
140
            anchors.top: parent.top
141
            anchors.topMargin: units.gu(5)
142
            anchors.left: parent.left
143
            anchors.right: parent.right
144
            anchors.bottomMargin: units.gu(8)
145
            text: i18n.tr("Last.fm")
146
            subText: i18n.tr("Login to scrobble and import playlists")
147
            width: parent.width
148
            progression: true
149
            enabled: false
150
            onClicked: {
151
                PopupUtils.open(Qt.resolvedUrl("LoginLastFM.qml"), mainView,
152
                {
153
                    title: i18n.tr("Last.fm")
154
                } )
155
                PopupUtils.close(musicSettings)
156
            }
157
        }
158
    }
159
160
    // Music Streaming
161
    // Activate in 1.+
162
    Rectangle {
163
        id: streaming
164
        anchors.top: equaliser.bottom
165
        anchors.topMargin: units.gu(24)
166
        color: "transparent"
167
        width: parent.width
168
        Label {
169
            text: i18n.tr("Music Streaming")
170
            visible: true
171
        }
172
        // Ubuntu One
173
        ListItem.Subtitled {
174
            id: musicStreamProg
149.1.1 by Daniel Holm
Populate settings again.
175
            anchors.top: parent.bottom
159.2.40 by Andrew Hayzen
* Third round of bug fixes
176
            anchors.topMargin: units.gu(2)
149.1.1 by Daniel Holm
Populate settings again.
177
            anchors.left: parent.left
178
            anchors.right: parent.right
159.2.40 by Andrew Hayzen
* Third round of bug fixes
179
            text: i18n.tr("Ubuntu One")
180
            subText: i18n.tr("Sign in to stream your cloud music")
100.2.8 by Daniel Holm
Sheet now fills parent.
181
            enabled: false
159.2.40 by Andrew Hayzen
* Third round of bug fixes
182
            progression: true
183
            onClicked: {
184
                customdebug("I'm Ron Burgendy...?")
100.2.1 by Daniel Holm
Inital move of settings to a Sheet and added the new stuff.
185
            }
186
        }
187
159.2.37 by Andrew Hayzen
* Round of bug fixes
188
        Rectangle {
159.2.40 by Andrew Hayzen
* Third round of bug fixes
189
            id: wifiRow
190
            anchors.top: parent.top
191
            anchors.topMargin: units.gu(10)
159.2.37 by Andrew Hayzen
* Round of bug fixes
192
            color: "transparent"
105.3.3 by Daniel Holm
Turned some unused stuff to non-visible; made switches stick to the right.
193
            width: parent.width
100.2.1 by Daniel Holm
Inital move of settings to a Sheet and added the new stuff.
194
            Label {
159.2.40 by Andrew Hayzen
* Third round of bug fixes
195
                id: streamwifiLabel
196
                text: i18n.tr("Stream only on Wi-Fi")
197
                enabled: false // check if account is connected
198
                anchors.left: parent.left
199
                anchors.leftMargin: units.gu(2)
200
                anchors.verticalCenter: wifiSwitch.verticalCenter
100.2.1 by Daniel Holm
Inital move of settings to a Sheet and added the new stuff.
201
            }
202
            Switch {
159.2.40 by Andrew Hayzen
* Third round of bug fixes
203
                id: wifiSwitch
204
                checked: Settings.getSetting("wifiswitch") === "1"
205
                enabled: false // check if account is connected
206
                anchors.right: parent.right
207
            }
208
        }
209
    }
210
211
    /* MOVE THIS STUFF
212
    // import playlists from lastfm
213
    Row {
214
        spacing: units.gu(2)
100.2.5 by Daniel Holm
Disabled some stuff which aren't suppose to work untill 1.+ anyway
215
        Button {
159.2.40 by Andrew Hayzen
* Third round of bug fixes
216
            id: lastfmPlaylists
217
            text: i18n.tr("Import playlists from last.fm")
218
            width: units.gu(30)
219
            color: "#c94212"
220
            enabled: Settings.getSetting("scrobble") === "1" // only if scrobble is activated.
100.2.1 by Daniel Holm
Inital move of settings to a Sheet and added the new stuff.
221
            onClicked: {
159.2.40 by Andrew Hayzen
* Third round of bug fixes
222
                console.debug("Debug: import playlists from last.fm")
223
                Scrobble.getPlaylists(Settings.getSetting("lastfmusername"))
100.2.1 by Daniel Holm
Inital move of settings to a Sheet and added the new stuff.
224
            }
100.2.5 by Daniel Holm
Disabled some stuff which aren't suppose to work untill 1.+ anyway
225
        }
159.2.40 by Andrew Hayzen
* Third round of bug fixes
226
    } */
227
228
    // developer button - KILLS YOUR CAT!
229
    Button {
230
        text: i18n.tr("Clean everything!")
231
        color: "red"
232
        visible: args.values.debug
233
        onClicked: {
234
            Settings.reset()
235
            Playlists.reset()
236
        }
100.2.1 by Daniel Holm
Inital move of settings to a Sheet and added the new stuff.
237
    }
5 by Daniel Holm
Tracks tab now lists set dirs music tracks; plays single file; paus and resume works; show track and artist of current track; code changes.
238
}