main.qml 29.3 KB
Newer Older
Camilo Higuita's avatar
Camilo Higuita committed
1
import QtQuick 2.9
Camilo higuita's avatar
Camilo higuita committed
2
import QtQuick.Controls 2.3
Camilo Higuita's avatar
Camilo Higuita committed
3
import QtQuick.Layouts 1.3
4
import QtGraphicalEffects 1.0
Camilo Higuita's avatar
Camilo Higuita committed
5
import QtQuick.Controls.Material 2.1
6

7
import "utils"
8

Camilo Higuita's avatar
Camilo Higuita committed
9
import "widgets"
10 11
import "widgets/PlaylistsView"
import "widgets/MainPlaylist"
12
import "widgets/SettingsView"
13
import "widgets/SearchView"
14
//import "widgets/CloudView"
15

16
import "view_models"
17
import "view_models/BabeTable"
18 19

import "services/local"
20
import "services/web"
21
//import "services/web/Spotify"
Camilo Higuita's avatar
Camilo Higuita committed
22

23 24
import "view_models/BabeGrid"

25 26
import "widgets/InfoView"

27
import "db/Queries.js" as Q
28
import "utils/Help.js" as H
29
import "utils/Player.js" as Player
30

31
import org.kde.kirigami 2.7 as Kirigami
Camilo Higuita's avatar
Camilo Higuita committed
32
import org.kde.mauikit 1.0 as Maui
33
import Player 1.0
camilo higuita's avatar
camilo higuita committed
34 35
import AlbumsList 1.0
import TracksList 1.0
36

37 38
import TracksList 1.0

39
Maui.ApplicationWindow
40 41
{

42
    id: root
43
    title: qsTr("vvave")
44 45 46
    /***************************************************/
    /******************** ALIASES ********************/
    /*************************************************/
47
    property alias mainPlaylist: mainPlaylist
48
    property alias selectionBar: _selectionBar
Camilo higuita's avatar
Camilo higuita committed
49
    property alias progressBar: progressBar
50
    property alias dialog : _dialogLoader.item
51

camilo higuita's avatar
camilo higuita committed
52 53
    Maui.App.iconName: "qrc:/assets/vvave.svg"
    Maui.App.description: qsTr("VVAVE will handle your whole music collection by retreaving semantic information from the web. Just relax, enjoy and discover your new music ")
54 55 56
    /***************************************************/
    /******************** PLAYBACK ********************/
    /*************************************************/
Camilo higuita's avatar
Camilo higuita committed
57
    property bool isShuffle: Maui.FM.loadSettings("SHUFFLE","PLAYBACK", false)
58
    property var currentTrack: ({
59
                                    fav: "0",
60 61 62
                                    stars: "0"
                                })

63
    property int currentTrackIndex: -1
64
    property int prevTrackIndex: 0
65

66
    property string currentArtwork: !mainlistEmpty ? mainPlaylist.list.get(0).artwork : ""
67
    property bool currentBabe: currentTrack.fav == "0" ? false : true
68

69
    property alias durationTimeLabel: player.duration
70
    property string progressTimeLabel: player.transformTime(player.position/1000)
71

72
    property alias isPlaying: player.playing
73
    property int onQueue: 0
74

75
    property bool mainlistEmpty: !mainPlaylist.table.count > 0
76

77
    /***************************************************/
78 79
    /******************** HANDLERS ********************/
    /*************************************************/
camilo higuita's avatar
camilo higuita committed
80
    readonly property var viewsIndex: ({ tracks: 0,
81 82 83
                                           albums: 1,
                                           artists: 2,
                                           playlists: 3,
camilo higuita's avatar
camilo higuita committed
84 85 86
                                           folders: 4,
                                           youtube: 5,
                                           search: 6})
87 88 89

    property string syncPlaylist: ""
    property bool sync: false
90

91
    property string infoMsg: ""
Camilo higuita's avatar
Camilo higuita committed
92
    property bool infoLabels: Maui.FM.loadSettings("LABELS", "PLAYBACK", false) == "true" ? true : false
93

94 95
    //    property bool isLinked: false
    //    property bool isServing: false
96

97
    //    property bool focusMode : false
Camilo higuita's avatar
Camilo higuita committed
98
    property bool selectionMode : false
99 100 101 102

    /***************************************************/
    /******************** UI COLORS *******************/
    /*************************************************/
103
    readonly property color babeColor: "#f84172"
104

105 106 107
    /*SIGNALS*/
    signal missingAlert(var track)

108

109
    /*HANDLE EVENTS*/
110
    onClosing: Player.savePlaylist()
111 112
    onMissingAlert:
    {
113 114 115
        var message = qsTr("Missing file...")
        var messageBody = track.title + " by " + track.artist + " is missing.\nDo you want to remove it from your collection?"
        notify("dialog-question", message, messageBody, function ()
116
        {
117
            mainPlaylist.list.remove(mainPlaylist.table.currentIndex)
118
        })
119 120 121
    }

    /*COMPONENTS*/
122 123 124 125 126

    Player
    {
        id: player
        volume: 100
127
        onFinishedChanged: if (!mainlistEmpty)
Camilo higuita's avatar
Camilo higuita committed
128 129 130
                           {
                               if (currentTrack.url)
                                   mainPlaylist.list.countUp(currentTrackIndex)
131

Camilo higuita's avatar
Camilo higuita committed
132 133
                               Player.nextTrack()
                           }
134 135
    }

camilo higuita's avatar
camilo higuita committed
136 137
    headBar.middleContent : Maui.ActionGroup
    {
camilo higuita's avatar
camilo higuita committed
138 139 140 141 142
        id: _actionGroup
        Layout.fillWidth: true
        Layout.fillHeight: true
        Layout.minimumWidth: implicitWidth
        currentIndex : swipeView.currentIndex
camilo higuita's avatar
camilo higuita committed
143 144

        hiddenActions: [
camilo higuita's avatar
camilo higuita committed
145
            Action
camilo higuita's avatar
camilo higuita committed
146 147 148 149 150
            {
                text: qsTr("Folders")
                icon.name: "folder"
            },

camilo higuita's avatar
camilo higuita committed
151
            Action
camilo higuita's avatar
camilo higuita committed
152 153 154
            {
                text: qsTr("YouTube")
                icon.name: "internet-services"
camilo higuita's avatar
camilo higuita committed
155
            }
camilo higuita's avatar
camilo higuita committed
156
        ]
camilo higuita's avatar
camilo higuita committed
157

camilo higuita's avatar
camilo higuita committed
158
        Action
camilo higuita's avatar
camilo higuita committed
159 160 161 162
        {
            icon.name: "view-media-track"
            text: qsTr("Tracks")
        }
camilo higuita's avatar
camilo higuita committed
163

camilo higuita's avatar
camilo higuita committed
164 165 166 167 168
        Action
        {
            text: qsTr("Albums")
            icon.name: /*"album"*/ "view-media-album-cover"
        }
camilo higuita's avatar
camilo higuita committed
169

camilo higuita's avatar
camilo higuita committed
170 171 172 173 174
        Action
        {
            text: qsTr("Artists")
            icon.name: "view-media-artist"
        }
camilo higuita's avatar
camilo higuita committed
175

camilo higuita's avatar
camilo higuita committed
176 177 178 179 180
        Action
        {
            text: qsTr("Playlists")
            icon.name: "view-media-playlist"
        }
camilo higuita's avatar
camilo higuita committed
181
    }
182

183
    footer: ColumnLayout
Camilo higuita's avatar
Camilo higuita committed
184 185
    {
        id: _footerLayout
186 187
visible: !mainlistEmpty
        height: visible ? Maui.Style.toolBarHeight * 1.2 : 0
Camilo higuita's avatar
Camilo higuita committed
188 189
        width: root.width
        spacing: 0
Camilo higuita's avatar
Camilo higuita committed
190

camilo higuita's avatar
camilo higuita committed
191 192 193 194 195
        Kirigami.Separator
        {
            Layout.fillWidth: true
        }

Camilo higuita's avatar
Camilo higuita committed
196 197 198
        Slider
        {
            id: progressBar
199
            Layout.preferredHeight: Maui.Style.unit * (isMobile ?  6 : 8)
Camilo higuita's avatar
Camilo higuita committed
200 201 202 203 204 205 206 207 208
            Layout.fillWidth: true

            padding: 0
            from: 0
            to: 1000
            value: player.pos
            spacing: 0
            focus: true
            onMoved:
Camilo higuita's avatar
Camilo higuita committed
209
            {
Camilo higuita's avatar
Camilo higuita committed
210
                player.pos = value
Camilo higuita's avatar
Camilo higuita committed
211 212
            }

Camilo higuita's avatar
Camilo higuita committed
213 214 215 216 217 218 219
            background: Rectangle
            {
                implicitWidth: progressBar.width
                implicitHeight: progressBar.height
                width: progressBar.availableWidth
                height: implicitHeight
                color: "transparent"
Camilo higuita's avatar
Camilo higuita committed
220

Camilo higuita's avatar
Camilo higuita committed
221 222 223 224
                Rectangle
                {
                    width: progressBar.visualPosition * parent.width
                    height: progressBar.height
camilo higuita's avatar
camilo higuita committed
225
                    color: Kirigami.Theme.highlightColor
Camilo higuita's avatar
Camilo higuita committed
226 227 228 229
                }
            }

            handle: Rectangle
Camilo higuita's avatar
Camilo higuita committed
230
            {
Camilo higuita's avatar
Camilo higuita committed
231 232 233
                x: progressBar.leftPadding + progressBar.visualPosition
                   * (progressBar.availableWidth - width)
                y: -(progressBar.height * 0.8)
234 235 236
                implicitWidth: progressBar.pressed ? Maui.Style.iconSizes.medium : 0
                implicitHeight: progressBar.pressed ? Maui.Style.iconSizes.medium : 0
                radius: progressBar.pressed ? Maui.Style.iconSizes.medium : 0
camilo higuita's avatar
camilo higuita committed
237
                color: Kirigami.Theme.highlightColor
Camilo higuita's avatar
Camilo higuita committed
238
            }
Camilo higuita's avatar
Camilo higuita committed
239
        }
Camilo higuita's avatar
Camilo higuita committed
240

Camilo higuita's avatar
Camilo higuita committed
241
        Maui.ToolBar
Camilo higuita's avatar
Camilo higuita committed
242
        {
Camilo higuita's avatar
Camilo higuita committed
243 244 245
            Layout.fillHeight: true
            Layout.fillWidth: true

246
            position: ToolBar.Footer
247 248 249 250 251 252 253 254 255 256 257
            leftContent:  ToolButton
            {
                icon.name: "headphones"
                checked: _drawer.visible
                icon.color: _drawer.visible ? babeColor : Kirigami.Theme.textColor
                onClicked:
                {
                    _drawer.visible = !_drawer.visible
                }

                Kirigami.Theme.highlightColor: babeColor
258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283

                Connections
                {
                    target: mainPlaylist.table
                    onCountChanged: anim.start()
                }

                NumberAnimation on x
                {
                    property int count : 0
                    id: anim
                    to: 10
                    duration: 100
                    onStopped:
                    {
                        if(anim.to===10) { anim.from=10; anim.to=0; } else { anim.from=0; anim.to=10 }
                        count++;
                        if(count < 5)
                            start()
                        else
                        {
                            anim.to = 0
                            count = 0
                        }
                    }
                }
284
            }
285

Camilo higuita's avatar
Camilo higuita committed
286
            middleContent: [
camilo higuita's avatar
camilo higuita committed
287
                ToolButton
Camilo higuita's avatar
Camilo higuita committed
288 289
                {
                    id: babeBtnIcon
camilo higuita's avatar
camilo higuita committed
290 291
                    icon.name: "love"
                    enabled: currentTrackIndex >= 0
292
                    icon.color: currentBabe ? babeColor : Kirigami.Theme.textColor
Camilo higuita's avatar
Camilo higuita committed
293
                    onClicked: if (!mainlistEmpty)
camilo higuita's avatar
camilo higuita committed
294 295 296 297
                               {
                                   mainPlaylist.list.fav(currentTrackIndex, !(mainPlaylist.list.get(currentTrackIndex).fav == "1"))
                                   currentBabe = mainPlaylist.list.get(currentTrackIndex).fav == "1"
                               }
Camilo higuita's avatar
Camilo higuita committed
298 299
                },

camilo higuita's avatar
camilo higuita committed
300
                ToolButton
Camilo higuita's avatar
Camilo higuita committed
301
                {
camilo higuita's avatar
camilo higuita committed
302
                    icon.name: "media-skip-backward"
303
                    icon.color: Kirigami.Theme.textColor
Camilo higuita's avatar
Camilo higuita committed
304 305 306 307
                    onClicked: Player.previousTrack()
                    onPressAndHold: Player.playAt(prevTrackIndex)
                },

camilo higuita's avatar
camilo higuita committed
308
                ToolButton
Camilo higuita's avatar
Camilo higuita committed
309 310
                {
                    id: playIcon
camilo higuita's avatar
camilo higuita committed
311
                    enabled: currentTrackIndex >= 0
312
                    icon.color: Kirigami.Theme.textColor
camilo higuita's avatar
camilo higuita committed
313
                    icon.name: isPlaying ? "media-playback-pause" : "media-playback-start"
314
                    onClicked: player.playing = !player.playing
Camilo higuita's avatar
Camilo higuita committed
315 316
                },

camilo higuita's avatar
camilo higuita committed
317
                ToolButton
Camilo higuita's avatar
Camilo higuita committed
318 319
                {
                    id: nextBtn
320
                    icon.color: Kirigami.Theme.textColor
camilo higuita's avatar
camilo higuita committed
321
                    icon.name: "media-skip-forward"
Camilo higuita's avatar
Camilo higuita committed
322 323 324 325
                    onClicked: Player.nextTrack()
                    onPressAndHold: Player.playAt(Player.shuffle())
                },

camilo higuita's avatar
camilo higuita committed
326
                ToolButton
Camilo higuita's avatar
Camilo higuita committed
327 328
                {
                    id: shuffleBtn
camilo higuita's avatar
camilo higuita committed
329 330
                    icon.color: babeColor
                    icon.name: isShuffle ? "media-playlist-shuffle" : "media-playlist-normal"
Camilo higuita's avatar
Camilo higuita committed
331 332 333
                    onClicked:
                    {
                        isShuffle = !isShuffle
334
                        Maui.FM.saveSettings("SHUFFLE", isShuffle, "PLAYBACK")
Camilo higuita's avatar
Camilo higuita committed
335 336 337
                    }
                }
            ]
Camilo higuita's avatar
Camilo higuita committed
338
        }
Camilo higuita's avatar
Camilo higuita committed
339 340
    }

341 342 343

    onSearchButtonClicked:
    {
camilo higuita's avatar
camilo higuita committed
344
        _actionGroup.currentIndex = viewsIndex.search
345 346 347
        searchView.searchInput.forceActiveFocus()
    }

348 349 350 351 352
    Loader
    {
        id: _dialogLoader
    }

353 354 355 356 357 358 359
    InfoView
    {
        id: infoView
        maxWidth: parent.width * 0.8
        maxHeight: parent.height * 0.9
    }

360 361

    Component
362
    {
363 364
        id: _shareDialogComponent
        Maui.ShareDialog {}
365 366
    }

367
    Component
368
    {
369 370
        id: _fmDialogComponent
        Maui.FileDialog { }
371 372
    }

373 374 375 376 377
    SourcesDialog
    {
        id: sourcesDialog
    }

Camilo higuita's avatar
Camilo higuita committed
378
    mainMenu: [
379

Camilo higuita's avatar
Camilo higuita committed
380 381
        //        Maui.MenuItem
        //        {
382 383
        //            text: "Vvave Stream"
        //            icon.name: "headphones"
Camilo higuita's avatar
Camilo higuita committed
384 385 386
        //            onTriggered:
        //            {
        //                pageStack.currentIndex = 1
387
        //                currentView = viewsIndex.vvave
Camilo higuita's avatar
Camilo higuita committed
388 389
        //            }
        //        },
390

391 392 393 394 395 396 397 398 399 400 401 402 403

        //        Maui.MenuItem
        //        {
        //            text: qsTr("Linking")
        //            icon.name: "view-links"
        //            onTriggered:
        //            {
        //                pageStack.currentIndex = 1
        //                currentView = viewsIndex.linking
        //                if(!isLinked) linkingView.linkingConf.open()
        //            }
        //        },

Camilo higuita's avatar
Camilo higuita committed
404

405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429

        //        Maui.MenuItem
        //        {
        //            text: qsTr("Cloud")
        //            icon.name: "folder-cloud"
        //            onTriggered:
        //            {
        //                pageStack.currentIndex = 1
        //                currentView = viewsIndex.cloud
        //            }
        //        },


        //        Maui.MenuItem
        //        {
        //            text: qsTr("Spotify")
        //            icon.name: "internet-services"
        //            onTriggered:
        //            {
        //                pageStack.currentIndex = 1
        //                currentView = viewsIndex.spotify
        //            }
        //        },

        MenuSeparator{},
Camilo higuita's avatar
Camilo higuita committed
430

431
        MenuItem
432 433 434 435
        {
            text: qsTr("Sources...")
            icon.name: "folder-add"
            onTriggered: sourcesDialog.open()
Camilo higuita's avatar
Camilo higuita committed
436 437
        },

438
        MenuItem
Camilo higuita's avatar
Camilo higuita committed
439 440 441 442 443
        {
            text: qsTr("Open...")
            icon.name: "folder-add"
            onTriggered:
            {
444 445 446 447
                _dialogLoader.sourceComponent = _fmDialogComponent
                root.dialog.settings.onlyDirs = false
                root.dialog.settings.filterType = Maui.FMList.AUDIO
                root.dialog.show(function(paths)
Camilo higuita's avatar
Camilo higuita committed
448 449 450 451
                {
                    vvave.openUrls(paths)
                })
            }
452
        }/*,
453

454 455 456 457
                Menu
                {
                    title: qsTr("Collection")
                    //            icon.name: "settings-configure"
Camilo higuita's avatar
Camilo higuita committed
458

459 460 461 462 463
                    MenuItem
                    {
                        text: qsTr("Re-Scan")
                        onTriggered: bae.refreshCollection();
                    }
Camilo higuita's avatar
Camilo higuita committed
464

465 466 467 468 469
                    MenuItem
                    {
                        text: qsTr("Refresh...")
                        onTriggered: H.refreshCollection();
                    }
Camilo higuita's avatar
Camilo higuita committed
470

471 472 473 474 475 476
                    MenuItem
                    {
                        text: qsTr("Clean")
                        onTriggered: bae.removeMissingTracks();
                    }
                }*/
Camilo higuita's avatar
Camilo higuita committed
477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526

        //        Maui.Menu
        //        {
        //            title: qsTr("Settings...")
        //            //            Kirigami.Action
        //            //            {
        //            //                text: "Brainz"

        //            //                Kirigami.Action
        //            //                {
        //            //                    id: brainzToggle
        //            //                    text: checked ? "Turn OFF" : "Turn ON"
        //            //                    checked: bae.brainzState()
        //            //                    checkable: true
        //            //                    onToggled:
        //            //                    {
        //            //                        checked = !checked
        //            //                        bae.saveSetting("AUTO", checked, "BRAINZ")
        //            ////                        bae.brainz(checked)
        //            //                    }
        //            //                }
        //            //            }



        //            Maui.MenuItem
        //            {
        //                text: "Info label" + checked ? "ON" : "OFF"
        //                checked: infoLabels
        //                checkable: true
        //                onToggled:
        //                {
        //                    infoLabels = checked
        //                    bae.saveSetting("LABELS", infoLabels ? true : false, "PLAYBACK")

        //                }
        //            }

        //            Maui.MenuItem
        //            {
        //                text: "Autoplay"
        //                checked: autoplay
        //                checkable: true
        //                onToggled:
        //                {
        //                    autoplay = checked
        //                    bae.saveSetting("AUTOPLAY", autoplay ? true : false, "BABE")
        //                }
        //            }
        //        }
527
    ]
528

529 530
    Item
    {
531
        id: message
532
        visible: infoMsg.length && sync
533
        anchors.bottom: parent.bottom
534
        width: parent.width
camilo higuita's avatar
camilo higuita committed
535
        height: Maui.Style.rowHeight
536
        z: 999
537

538 539
        Rectangle
        {
540
            id: infoBg
541

542 543
            anchors.fill: parent
            z: -999
camilo higuita's avatar
camilo higuita committed
544
            color: "#333"
545
            opacity: 0.8
546

547 548
            SequentialAnimation
            {
549
                id: animBg
550 551
                PropertyAnimation
                {
552 553 554 555 556 557 558
                    target: infoBg
                    property: "color"
                    easing.type: Easing.InOutQuad
                    to: babeColor
                    duration: 250
                }

559 560
                PropertyAnimation
                {
561 562 563
                    target: infoBg
                    property: "color"
                    easing.type: Easing.InOutQuad
camilo higuita's avatar
camilo higuita committed
564
                    to: "#333"
565 566 567 568 569
                    duration: 500
                }
            }
        }

570 571
        Label
        {
572 573 574 575 576
            id: infoTxt
            anchors.centerIn: parent
            anchors.fill: parent
            height: parent.height
            width: parent.width
577
            font.pointSize: Maui.Style.fontSizes.medium
578 579 580
            text: infoMsg
            horizontalAlignment: Qt.AlignHCenter
            verticalAlignment: Qt.AlignVCenter
581
            color: Kirigami.Theme.textColor
582

583 584
            SequentialAnimation
            {
585
                id: animTxt
586 587
                PropertyAnimation
                {
588 589 590 591 592 593 594
                    target: infoTxt
                    property: "color"
                    easing.type: Easing.InOutQuad
                    to: "white"
                    duration: 250
                }

595 596
                PropertyAnimation
                {
597 598 599
                    target: infoTxt
                    property: "color"
                    easing.type: Easing.InOutQuad
600
                    to: Kirigami.Theme.textColor
601 602 603 604 605
                    duration: 500
                }
            }
        }
    }
606

607 608 609 610 611
    PlaylistDialog
    {
        id: playlistDialog
    }

612
    sideBar: Maui.AbstractSideBar
613
    {
Camilo higuita's avatar
Camilo higuita committed
614
        id: _drawer
615
        width: visible ? Math.min(Kirigami.Units.gridUnit * 18, root.width) : 0
camilo higuita's avatar
camilo higuita committed
616
        modal: !isWide
617 618

        MainPlaylist
619
        {
Camilo higuita's avatar
Camilo higuita committed
620
            id: mainPlaylist
621
            anchors.fill: parent
Camilo higuita's avatar
Camilo higuita committed
622 623 624 625 626
            Connections
            {
                target: mainPlaylist
                onCoverPressed: Player.appendAll(tracks)
                onCoverDoubleClicked: Player.playAll(tracks)
camilo higuita's avatar
camilo higuita committed
627
            }
628 629 630
        }
    }

Camilo higuita's avatar
Camilo higuita committed
631
    ColumnLayout
632
    {
Camilo higuita's avatar
Camilo higuita committed
633
        anchors.fill: parent
634

Camilo higuita's avatar
Camilo higuita committed
635
        SwipeView
636
        {
Camilo higuita's avatar
Camilo higuita committed
637 638 639 640
            id: swipeView
            Layout.fillHeight: true
            Layout.fillWidth: true
            interactive: isMobile
camilo higuita's avatar
camilo higuita committed
641
            currentIndex: _actionGroup.currentIndex
642 643
            onCurrentIndexChanged: _actionGroup.currentIndex = currentIndex

camilo higuita's avatar
camilo higuita committed
644 645
            clip: true
            onCurrentItemChanged: currentItem.forceActiveFocus()
646 647


Camilo higuita's avatar
Camilo higuita committed
648
            TracksView
649
            {
Camilo higuita's avatar
Camilo higuita committed
650 651
                id: tracksView
                Connections
652
                {
Camilo higuita's avatar
Camilo higuita committed
653 654 655 656 657 658
                    target: tracksView
                    onRowClicked: Player.addTrack(tracksView.list.get(index))
                    onQuickPlayTrack: Player.quickPlay(tracksView.list.get(index))
                    onPlayAll:
                    {
                        var query = Q.GET.allTracks
659

Camilo higuita's avatar
Camilo higuita committed
660 661 662 663 664
                        mainPlaylist.list.clear()
                        mainPlaylist.list.query = query
                        Player.playAll()
                    }
                    onAppendAll:
665
                    {
Camilo higuita's avatar
Camilo higuita committed
666 667
                        mainPlaylist.list.appendQuery(Q.GET.allTracks)
                        mainPlaylist.listView.positionViewAtEnd()
668
                    }
Camilo higuita's avatar
Camilo higuita committed
669 670

                    onQueueTrack: Player.queueTracks([tracksView.list.get(index)], index)
671
                }
Camilo higuita's avatar
Camilo higuita committed
672
            }
Camilo Higuita's avatar
Camilo Higuita committed
673

Camilo higuita's avatar
Camilo higuita committed
674 675 676 677 678 679 680 681
            AlbumsView
            {
                id: albumsView

                holder.emoji: "qrc:/assets/MusicBox.png"
                holder.isMask: false
                holder.title : "No Albums!"
                holder.body: "Add new music sources"
682
                holder.emojiSize: Maui.Style.iconSizes.huge
683
                title: count + qsTr(" albums")
684
                list.query: Albums.ALBUMS
Camilo higuita's avatar
Camilo higuita committed
685 686 687
                list.sortBy: Albums.ALBUM

                Connections
688
                {
Camilo higuita's avatar
Camilo higuita committed
689 690 691 692 693 694 695
                    target: albumsView
                    onRowClicked: Player.addTrack(track)
                    onPlayTrack: Player.quickPlay(track)

                    onAlbumCoverClicked: albumsView.populateTable(album, artist)

                    onAlbumCoverPressedAndHold:
696
                    {
Camilo higuita's avatar
Camilo higuita committed
697 698 699 700
                        var query = Q.GET.albumTracks_.arg(album)
                        query = query.arg(artist)

                        mainPlaylist.list.clear()
Camilo higuita's avatar
Camilo higuita committed
701
                        mainPlaylist.list.sortBy = Tracks.NONE
Camilo higuita's avatar
Camilo higuita committed
702
                        mainPlaylist.list.query = query
Camilo higuita's avatar
Camilo higuita committed
703
                        Player.playAll()
704
                    }
705

Camilo higuita's avatar
Camilo higuita committed
706
                    onPlayAll:
707
                    {
Camilo higuita's avatar
Camilo higuita committed
708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723
                        var query = Q.GET.albumTracks_.arg(album)
                        query = query.arg(artist)
                        query = query.arg(data.artist)

                        mainPlaylist.list.clear()
                        mainPlaylist.list.query = query
                        Player.playAll()
                    }

                    onAppendAll:
                    {
                        var query = Q.GET.albumTracks_.arg(album)
                        query = query.arg(artist)

                        mainPlaylist.list.appendQuery(query)
                        mainPlaylist.listView.positionViewAtEnd()
724
                    }
Camilo Higuita's avatar
Camilo Higuita committed
725
                }
Camilo higuita's avatar
Camilo higuita committed
726
            }
727

camilo higuita's avatar
camilo higuita committed
728 729 730 731 732 733 734 735
            AlbumsView
            {
                id: artistsView

                holder.emoji: "qrc:/assets/MusicBox.png"
                holder.isMask: false
                holder.title : qsTr("No Artists!")
                holder.body: qsTr("Add new music sources")
736
                holder.emojiSize: Maui.Style.iconSizes.huge
camilo higuita's avatar
camilo higuita committed
737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818
                title: count + qsTr(" artists")
                list.query: Albums.ARTISTS
                list.sortBy: Albums.ARTIST
                table.list.sortBy:  Tracks.NONE

                Connections
                {
                    target: artistsView
                    onRowClicked: Player.addTrack(track)
                    onPlayTrack: Player.quickPlay(track)
                    onAlbumCoverClicked: artistsView.populateTable(undefined, artist)

                    onAlbumCoverPressedAndHold:
                    {
                        var query = Q.GET.artistTracks_.arg(artist)
                        mainPlaylist.list.clear()
                        mainPlaylist.list.sortBy = Tracks.NONE
                        mainPlaylist.list.query = query
                        Player.playAll()
                    }

                    onPlayAll:
                    {
                        var query = Q.GET.artistTracks_.arg(artist)
                        query = query.arg(data.artist)

                        mainPlaylist.list.clear()
                        mainPlaylist.list.sortBy = Tracks.NONE
                        mainPlaylist.list.query = query
                        Player.playAll()
                    }

                    onAppendAll:
                    {
                        var query = Q.GET.artistTracks_.arg(artist)

                        mainPlaylist.list.appendQuery(query)
                        mainPlaylist.listView.positionViewAtEnd()
                    }
                }
            }

            PlaylistsView
            {
                id: playlistsView

                Connections
                {
                    target: playlistsView
                    onRowClicked: Player.addTrack(track)
                    onQuickPlayTrack: Player.quickPlay(track)

                    onPlayAll:
                    {
                        var query = playlistsView.playlistQuery
                        mainPlaylist.list.clear()
                        mainPlaylist.list.sortBy = Tracks.NONE
                        mainPlaylist.list.query = query
                        Player.playAll()
                    }

                    onAppendAll:
                    {
                        var query = playlistsView.playlistQuery

                        mainPlaylist.list.appendQuery(query)
                        mainPlaylist.listView.positionViewAtEnd()
                    }

                    onPlaySync:
                    {
                        var query = playlistsView.playlistQuery
                        mainPlaylist.list.appendQuery(query)
                        Player.playAll()

                        root.sync = true
                        root.syncPlaylist = playlist
                        root.infoMsg = qsTr("Syncing to ") + playlist
                    }
                }
            }

camilo higuita's avatar
camilo higuita committed
819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851
            FoldersView
            {
                id: foldersView

                Connections
                {
                    target: foldersView.list

                    onRowClicked: Player.addTrack(foldersView.list.model.get(index))
                    onQuickPlayTrack: Player.quickPlay(foldersView.list.model.get(index))
                    onPlayAll:
                    {
                        mainPlaylist.list.clear()
                        //                        mainPlaylist.list.sortBy = Tracks.NONE
                        mainPlaylist.list.query = foldersView.list.list.query
                        Player.playAll()
                    }

                    onAppendAll:
                    {
                        var query = foldersView.list.list.query
                        mainPlaylist.list.appendQuery(query)
                        mainPlaylist.listView.positionViewAtEnd()
                    }

                    onQueueTrack: Player.queueTracks([foldersView.list.model.get(index)], index)
                }
            }

            YouTube
            {
                id: youtubeView
            }
camilo higuita's avatar
camilo higuita committed
852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875

            SearchTable
            {
                id: searchView

                Connections
                {
                    target: searchView
                    onRowClicked: Player.addTrack(searchView.list.get(index))
                    onQuickPlayTrack: Player.quickPlay(searchView.list.get(index))
                    onPlayAll:
                    {
                        mainPlaylist.list.clear()
                        var tracks = searchView.list.getAll()
                        for(var i in tracks)
                            Player.appendTrack(tracks[i])

                        Player.playAll()
                    }

                    onAppendAll: Player.appendAll(searchView.list.getAll())
                    onArtworkDoubleClicked:
                    {
                        var query = Q.GET.albumTracks_.arg(
876
                                    searchView.list.get(
camilo higuita's avatar
camilo higuita committed
877
                                        index).album)
878
                        query = query.arg(searchView.list.get(index).artist)
camilo higuita's avatar
camilo higuita committed
879 880 881 882 883 884 885 886

                        mainPlaylist.list.clear()
                        mainPlaylist.list.sortBy = Tracks.NONE
                        mainPlaylist.list.query = query
                        Player.playAll()
                    }
                }
            }
Camilo higuita's avatar
Camilo higuita committed
887 888 889 890
        }

        Maui.SelectionBar
        {
891 892
            id: _selectionBar
            property alias listView: _selectionBar.selectionList
Camilo higuita's avatar
Camilo higuita committed
893
            Layout.fillWidth: true
894 895 896
            Layout.margins: Maui.Style.space.big
            Layout.topMargin: Maui.Style.space.small
            Layout.bottomMargin: Maui.Style.space.big
897
            onIconClicked: _contextMenu.popup()
898 899 900 901 902
            onExitClicked:
            {
                root.selectionMode = false
                clear()
            }
903 904 905 906 907

            SelectionBarMenu
            {
                id: _contextMenu
            }
908 909
        }
    }
910 911


912
    /*animations*/
913

914 915

    /*FUNCTIONS*/
916 917
    function infoMsgAnim()
    {
918 919 920 921
        animBg.running = true
        animTxt.running = true
    }

922 923 924 925 926 927 928 929

    function toggleMaximized()
    {
        if (root.visibility === Window.Maximized) {
            root.showNormal();
        } else {
            root.showMaximized();
        }
Camilo higuita's avatar
Camilo higuita committed
930
    }
931

932

933
    /*CONNECTIONS*/
934

935 936
    Connections
    {
937
        target: vvave
938

939
        onRefreshTables: H.refreshCollection(size)
camilo higuita's avatar
camilo higuita committed
940 941 942
        //        onRefreshTracks: H.refreshTracks()
        //        onRefreshAlbums: H.refreshAlbums()
        //        onRefreshArtists: H.refreshArtists()
943

944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963
        //        onCoverReady:
        //        {
        //            root.currentArtwork = path
        //            currentTrack.artwork = currentArtwork
        //            mainPlaylist.list.update(currentTrack, currentTrackIndex);
        //        }

        //        onTrackLyricsReady:
        //        {
        //            console.log(lyrics)
        //            if (url === currentTrack.url)
        //                Player.setLyrics(lyrics)
        //        }

        //        onSkipTrack: Player.nextTrack()
        //        onBabeIt: if (!mainlistEmpty)
        //                  {
        //                      mainPlaylist.list.fav(currentTrackIndex, !(mainPlaylist.list.get(currentTrackIndex).fav == "1"))
        //                      currentBabe = mainPlaylist.list.get(currentTrackIndex).fav == "1"
        //                  }
964

Camilo higuita's avatar
Camilo higuita committed
965 966 967 968 969
        onOpenFiles:
        {
            Player.appendTracksAt(tracks, 0)
            Player.playAt(0)
        }
970
    }
camilo higuita's avatar
camilo higuita committed
971 972 973 974 975 976 977 978 979

    Component.onCompleted:
    {
        if(isAndroid)
        {
            Maui.Android.statusbarColor(Kirigami.Theme.backgroundColor, true)
            Maui.Android.navBarColor(Kirigami.Theme.backgroundColor, true)
        }
    }
Camilo Higuita's avatar
Camilo Higuita committed
980
}