main.qml 33.5 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 39
import BaseModel 1.0
import TracksList 1.0

40
Maui.ApplicationWindow
41 42
{

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

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

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

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

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

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

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

78
    /***************************************************/
79 80 81 82 83
    /******************** HANDLERS ********************/
    /*************************************************/

    property int currentView: viewsIndex.tracks

84
    readonly property var viewsIndex: ({
85 86 87 88 89
                                           tracks: 0,
                                           albums: 1,
                                           artists: 2,
                                           playlists: 3,
                                           search: 4,
Camilo higuita's avatar
Camilo higuita committed
90
                                           folders: 5,
91 92 93
                                           //                                           cloud: 6,
                                           //                                           vvave: 7,
                                           //                                           linking: 8,
94
                                           youtube: 6,
95
                                           //                                           spotify: 10
96

97
                                       })
98 99 100

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

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

105 106
    //    property bool isLinked: false
    //    property bool isServing: false
107

108
    //    property bool focusMode : false
Camilo higuita's avatar
Camilo higuita committed
109
    property bool selectionMode : false
110 111 112 113

    /***************************************************/
    /******************** UI COLORS *******************/
    /*************************************************/
114
    readonly property color babeColor: "#f84172"
115

116 117 118
    /*SIGNALS*/
    signal missingAlert(var track)

119

120
    /*HANDLE EVENTS*/
121
    onClosing: Player.savePlaylist()
122 123
    onMissingAlert:
    {
124 125 126 127
        var message = track.title + " by " + track.artist + " is missing"
        var messageBody = "Do you want to remove it from your collection?"
        notify("alert", message, messageBody, function ()
        {
128
            //            bae.removeTrack(currentTrack.url) //todo
Camilo higuita's avatar
Camilo higuita committed
129
            mainPlaylist.table.model.remove(mainPlaylist.table.currentIndex)
130
        })
131 132 133
    }

    /*COMPONENTS*/
134 135 136 137 138

    Player
    {
        id: player
        volume: 100
139
        onFinishedChanged: if (!mainlistEmpty)
Camilo higuita's avatar
Camilo higuita committed
140 141 142
                           {
                               if (currentTrack.url)
                                   mainPlaylist.list.countUp(currentTrackIndex)
143

Camilo higuita's avatar
Camilo higuita committed
144 145
                               Player.nextTrack()
                           }
146 147
    }

Camilo higuita's avatar
Camilo higuita committed
148 149 150 151
    //    BabeNotify
    //    {
    //        id: babeNotify //todo
    //    }
152

153 154

    /* UI */
camilo higuita's avatar
camilo higuita committed
155
    //    accentColor: babeColor
156 157 158
    //    headBarFGColor: altColorText
    //    headBarBGColor: "#212121"
    //    altColorText: darkTextColor
Camilo higuita's avatar
Camilo higuita committed
159

camilo higuita's avatar
camilo higuita committed
160
    //    headBar.spacing: space.big
161 162
    headBar.middleContent : Kirigami.ActionToolBar
    {
camilo higuita's avatar
camilo higuita committed
163
        display: isWide ? ToolButton.TextBesideIcon : ToolButton.IconOnly
camilo higuita's avatar
camilo higuita committed
164
        position: ToolBar.Header
camilo higuita's avatar
camilo higuita committed
165
        Layout.fillWidth: true
166
        hiddenActions: [
167

168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183
            Kirigami.Action
            {
                text: qsTr("Folders")
                icon.name: "folder"
                checked: currentView === viewsIndex.folders
                checkable: false
                onTriggered: currentView = viewsIndex.folders
            },

            Kirigami.Action
            {
                text: qsTr("YouTube")
                checkable: false
                icon.name: "internet-services"
                checked: currentView === viewsIndex.youtube
                onTriggered: currentView = viewsIndex.youtube
184

185
            }
186

187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212
        ]
        actions: [
            Kirigami.Action
            {
                icon.name: "view-media-track"
                checked: currentView === viewsIndex.tracks
                //            showIndicator: true
                //            icon.color: active ? babeColor : altColorText
                onTriggered: currentView = viewsIndex.tracks
                text: qsTr("Tracks")
                checkable: false
                //            colorScheme.highlightColor: babeColor
                //            spacing: 0

            },

            Kirigami.Action
            {
                text: qsTr("Albums")
                checkable: false
                checked: currentView === viewsIndex.albums
                icon.name: /*"album"*/ "view-media-album-cover"
                //            icon.color: currentView === viewsIndex.albums ? babeColor : altColorText
                onTriggered: currentView = viewsIndex.albums
                //            colorScheme.highlightColor: babeColor
                //            showIndicator: true
213

214 215 216 217 218 219 220 221
            },

            Kirigami.Action
            {
                text: qsTr("Artists")
                checkable: false
                checked: currentView === viewsIndex.artists
                icon.name: "view-media-artist"
camilo higuita's avatar
camilo higuita committed
222
                //                Kirigami.Theme.textColor:  currentView === viewsIndex.artists ? babeColor : altColorText
223 224 225 226 227 228 229 230 231 232 233 234 235 236 237
                onTriggered: currentView = viewsIndex.artists
                //            colorScheme.highlightColor: babeColor
                //            showIndicator: true
            },

            Kirigami.Action
            {
                text: qsTr("Playlists")
                checkable: false
                checked: currentView === viewsIndex.playlists
                icon.name: "view-media-playlist"
                //            icon.color: currentView === viewsIndex.playlists ? babeColor : altColorText
                onTriggered: currentView = viewsIndex.playlists
                //            colorScheme.highlightColor: babeColor
                //            showIndicator: true
238

239 240 241 242
            }

        ]
    }
243

244
    footBar.visible: !mainlistEmpty
Camilo higuita's avatar
Camilo higuita committed
245
    footBar.implicitHeight: footBar.visible ? toolBarHeight * 1.2 : 0
246
    footer: ColumnLayout
Camilo higuita's avatar
Camilo higuita committed
247 248
    {
        id: _footerLayout
Camilo higuita's avatar
Camilo higuita committed
249

Camilo higuita's avatar
Camilo higuita committed
250 251 252
        height: footBar.height
        width: root.width
        spacing: 0
Camilo higuita's avatar
Camilo higuita committed
253

Camilo higuita's avatar
Camilo higuita committed
254 255 256 257 258 259 260 261 262 263 264 265 266
        Slider
        {
            id: progressBar
            Layout.preferredHeight: unit * (isMobile ?  6 : 8)
            Layout.fillWidth: true

            padding: 0
            from: 0
            to: 1000
            value: player.pos
            spacing: 0
            focus: true
            onMoved:
Camilo higuita's avatar
Camilo higuita committed
267
            {
Camilo higuita's avatar
Camilo higuita committed
268
                player.pos = value
Camilo higuita's avatar
Camilo higuita committed
269 270
            }

Camilo higuita's avatar
Camilo higuita committed
271 272 273 274 275 276 277
            background: Rectangle
            {
                implicitWidth: progressBar.width
                implicitHeight: progressBar.height
                width: progressBar.availableWidth
                height: implicitHeight
                color: "transparent"
Camilo higuita's avatar
Camilo higuita committed
278

Camilo higuita's avatar
Camilo higuita committed
279 280 281 282 283 284 285 286 287
                Rectangle
                {
                    width: progressBar.visualPosition * parent.width
                    height: progressBar.height
                    color: babeColor
                }
            }

            handle: Rectangle
Camilo higuita's avatar
Camilo higuita committed
288
            {
Camilo higuita's avatar
Camilo higuita committed
289 290 291 292 293 294 295
                x: progressBar.leftPadding + progressBar.visualPosition
                   * (progressBar.availableWidth - width)
                y: -(progressBar.height * 0.8)
                implicitWidth: progressBar.pressed ? iconSizes.medium : 0
                implicitHeight: progressBar.pressed ? iconSizes.medium : 0
                radius: progressBar.pressed ? iconSizes.medium : 0
                color: babeColor
Camilo higuita's avatar
Camilo higuita committed
296
            }
Camilo higuita's avatar
Camilo higuita committed
297
        }
Camilo higuita's avatar
Camilo higuita committed
298

camilo higuita's avatar
camilo higuita committed
299 300 301 302 303
        //        Kirigami.Separator
        //        {
        //            Layout.fillWidth: true
        ////            color: borderColor
        //        }
Camilo higuita's avatar
Camilo higuita committed
304

Camilo higuita's avatar
Camilo higuita committed
305
        Maui.ToolBar
Camilo higuita's avatar
Camilo higuita committed
306
        {
Camilo higuita's avatar
Camilo higuita committed
307 308 309
            Layout.fillHeight: true
            Layout.fillWidth: true

310
            position: ToolBar.Footer
camilo higuita's avatar
camilo higuita committed
311 312 313 314 315 316 317 318 319 320
            //            leftContent:  ToolButton
            //            {
            //                icon.name: "headphones"
            //                visible: _drawer.modal
            //                checked: _drawer.visible
            //                icon.color: _drawer.visible ? babeColor : Kirigami.Theme.textColor
            //                onClicked: _drawer.visible = !_drawer.visible
            //                Kirigami.Theme.highlightColor: babeColor
            //                //                text: qsTr("Now")
            //            }
321

Camilo higuita's avatar
Camilo higuita committed
322
            middleContent: [
camilo higuita's avatar
camilo higuita committed
323
                ToolButton
Camilo higuita's avatar
Camilo higuita committed
324 325
                {
                    id: babeBtnIcon
camilo higuita's avatar
camilo higuita committed
326 327
                    icon.name: "love"
                    enabled: currentTrackIndex >= 0
328
                    icon.color: currentBabe ? babeColor : Kirigami.Theme.textColor
Camilo higuita's avatar
Camilo higuita committed
329
                    onClicked: if (!mainlistEmpty)
camilo higuita's avatar
camilo higuita committed
330 331 332 333
                               {
                                   mainPlaylist.list.fav(currentTrackIndex, !(mainPlaylist.list.get(currentTrackIndex).fav == "1"))
                                   currentBabe = mainPlaylist.list.get(currentTrackIndex).fav == "1"
                               }
Camilo higuita's avatar
Camilo higuita committed
334 335
                },

camilo higuita's avatar
camilo higuita committed
336
                ToolButton
Camilo higuita's avatar
Camilo higuita committed
337
                {
camilo higuita's avatar
camilo higuita committed
338
                    icon.name: "media-skip-backward"
339
                    icon.color: Kirigami.Theme.textColor
Camilo higuita's avatar
Camilo higuita committed
340 341 342 343
                    onClicked: Player.previousTrack()
                    onPressAndHold: Player.playAt(prevTrackIndex)
                },

camilo higuita's avatar
camilo higuita committed
344
                ToolButton
Camilo higuita's avatar
Camilo higuita committed
345 346
                {
                    id: playIcon
camilo higuita's avatar
camilo higuita committed
347
                    enabled: currentTrackIndex >= 0
348
                    icon.color: Kirigami.Theme.textColor
camilo higuita's avatar
camilo higuita committed
349
                    icon.name: isPlaying ? "media-playback-pause" : "media-playback-start"
350
                    onClicked: player.playing = !player.playing
Camilo higuita's avatar
Camilo higuita committed
351 352
                },

camilo higuita's avatar
camilo higuita committed
353
                ToolButton
Camilo higuita's avatar
Camilo higuita committed
354 355
                {
                    id: nextBtn
356
                    icon.color: Kirigami.Theme.textColor
camilo higuita's avatar
camilo higuita committed
357
                    icon.name: "media-skip-forward"
Camilo higuita's avatar
Camilo higuita committed
358 359 360 361
                    onClicked: Player.nextTrack()
                    onPressAndHold: Player.playAt(Player.shuffle())
                },

camilo higuita's avatar
camilo higuita committed
362
                ToolButton
Camilo higuita's avatar
Camilo higuita committed
363 364
                {
                    id: shuffleBtn
camilo higuita's avatar
camilo higuita committed
365 366
                    icon.color: babeColor
                    icon.name: isShuffle ? "media-playlist-shuffle" : "media-playlist-normal"
Camilo higuita's avatar
Camilo higuita committed
367 368 369
                    onClicked:
                    {
                        isShuffle = !isShuffle
370
                        Maui.FM.saveSettings("SHUFFLE", isShuffle, "PLAYBACK")
Camilo higuita's avatar
Camilo higuita committed
371 372 373
                    }
                }
            ]
Camilo higuita's avatar
Camilo higuita committed
374
        }
Camilo higuita's avatar
Camilo higuita committed
375 376
    }

377

378
    //    leftIcon.icon.color: currentView === viewsIndex.search ? babeColor : altColorText
379 380 381 382 383 384
    onSearchButtonClicked:
    {
        currentView = viewsIndex.search
        searchView.searchInput.forceActiveFocus()
    }

385 386 387 388 389 390 391
    InfoView
    {
        id: infoView
        maxWidth: parent.width * 0.8
        maxHeight: parent.height * 0.9
    }

392 393 394 395 396
    Maui.ShareDialog
    {
        id: shareDialog
    }

397 398 399 400 401
    Maui.FileDialog
    {
        id: fmDialog
    }

402 403 404 405 406
    SourcesDialog
    {
        id: sourcesDialog
    }

Camilo higuita's avatar
Camilo higuita committed
407
    mainMenu: [
408

Camilo higuita's avatar
Camilo higuita committed
409 410
        //        Maui.MenuItem
        //        {
411 412
        //            text: "Vvave Stream"
        //            icon.name: "headphones"
Camilo higuita's avatar
Camilo higuita committed
413 414 415
        //            onTriggered:
        //            {
        //                pageStack.currentIndex = 1
416
        //                currentView = viewsIndex.vvave
Camilo higuita's avatar
Camilo higuita committed
417 418
        //            }
        //        },
419

420 421 422 423 424 425 426 427 428 429 430 431 432

        //        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
433

434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458

        //        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
459

460
        MenuItem
461 462 463 464
        {
            text: qsTr("Sources...")
            icon.name: "folder-add"
            onTriggered: sourcesDialog.open()
Camilo higuita's avatar
Camilo higuita committed
465 466
        },

467
        MenuItem
Camilo higuita's avatar
Camilo higuita committed
468 469 470 471 472 473
        {
            text: qsTr("Open...")
            icon.name: "folder-add"
            onTriggered:
            {
                fmDialog.onlyDirs = false
474
                fmDialog.filterType = Maui.FMList.AUDIO
Camilo higuita's avatar
Camilo higuita committed
475 476 477 478 479
                fmDialog.show(function(paths)
                {
                    vvave.openUrls(paths)
                })
            }
480
        }/*,
481

482 483 484 485
                Menu
                {
                    title: qsTr("Collection")
                    //            icon.name: "settings-configure"
Camilo higuita's avatar
Camilo higuita committed
486

487 488 489 490 491
                    MenuItem
                    {
                        text: qsTr("Re-Scan")
                        onTriggered: bae.refreshCollection();
                    }
Camilo higuita's avatar
Camilo higuita committed
492

493 494 495 496 497
                    MenuItem
                    {
                        text: qsTr("Refresh...")
                        onTriggered: H.refreshCollection();
                    }
Camilo higuita's avatar
Camilo higuita committed
498

499 500 501 502 503 504
                    MenuItem
                    {
                        text: qsTr("Clean")
                        onTriggered: bae.removeMissingTracks();
                    }
                }*/
Camilo higuita's avatar
Camilo higuita committed
505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554

        //        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")
        //                }
        //            }
        //        }
555
    ]
556

557 558
    Item
    {
559
        id: message
560
        visible: infoMsg.length && sync
561
        anchors.bottom: parent.bottom
562
        width: parent.width
563
        height: iconSize
564
        z: 999
565

566 567
        Rectangle
        {
568
            id: infoBg
569

570 571 572
            anchors.fill: parent
            z: -999
            color: altColor
573
            opacity: 0.8
574

575 576
            SequentialAnimation
            {
577
                id: animBg
578 579
                PropertyAnimation
                {
580 581 582 583 584 585 586
                    target: infoBg
                    property: "color"
                    easing.type: Easing.InOutQuad
                    to: babeColor
                    duration: 250
                }

587 588
                PropertyAnimation
                {
589 590 591 592 593 594 595 596 597
                    target: infoBg
                    property: "color"
                    easing.type: Easing.InOutQuad
                    to: altColor
                    duration: 500
                }
            }
        }

598 599
        Label
        {
600 601 602 603 604
            id: infoTxt
            anchors.centerIn: parent
            anchors.fill: parent
            height: parent.height
            width: parent.width
605
            font.pointSize: fontSizes.medium
606 607 608
            text: infoMsg
            horizontalAlignment: Qt.AlignHCenter
            verticalAlignment: Qt.AlignVCenter
609
            color: Kirigami.Theme.textColor
610

611 612
            SequentialAnimation
            {
613
                id: animTxt
614 615
                PropertyAnimation
                {
616 617 618 619 620 621 622
                    target: infoTxt
                    property: "color"
                    easing.type: Easing.InOutQuad
                    to: "white"
                    duration: 250
                }

623 624
                PropertyAnimation
                {
625 626 627
                    target: infoTxt
                    property: "color"
                    easing.type: Easing.InOutQuad
628
                    to: Kirigami.Theme.textColor
629 630 631 632 633
                    duration: 500
                }
            }
        }
    }
634

635 636 637 638 639
    PlaylistDialog
    {
        id: playlistDialog
    }

Camilo higuita's avatar
Camilo higuita committed
640
    globalDrawer: Maui.GlobalDrawer
641
    {
Camilo higuita's avatar
Camilo higuita committed
642
        id: _drawer
camilo higuita's avatar
camilo higuita committed
643
        width: Math.min(Kirigami.Units.gridUnit * 18, root.width)
Camilo higuita's avatar
Camilo higuita committed
644
        height: root.height - root.headBar.implicitHeight - root.footBar.implicitHeight
camilo higuita's avatar
camilo higuita committed
645
        modal: !isWide
camilo higuita's avatar
camilo higuita committed
646
        handleVisible: false
647
        closePolicy: Popup.NoAutoClose
camilo higuita's avatar
camilo higuita committed
648 649 650 651 652 653

        handleClosedIcon.source: "headphones"
        handleOpenIcon.source: "headphones"
        handleOpenIcon.color: babeColor
        handleClosedIcon.color: babeColor

Camilo higuita's avatar
Camilo higuita committed
654
        contentItem: MainPlaylist
655
        {
Camilo higuita's avatar
Camilo higuita committed
656 657 658 659 660 661
            id: mainPlaylist
            Connections
            {
                target: mainPlaylist
                onCoverPressed: Player.appendAll(tracks)
                onCoverDoubleClicked: Player.playAll(tracks)
camilo higuita's avatar
camilo higuita committed
662
            }
663 664 665
        }
    }

Camilo higuita's avatar
Camilo higuita committed
666
    ColumnLayout
667
    {
Camilo higuita's avatar
Camilo higuita committed
668
        anchors.fill: parent
669

Camilo higuita's avatar
Camilo higuita committed
670
        SwipeView
671
        {
Camilo higuita's avatar
Camilo higuita committed
672 673 674 675 676 677 678 679 680 681 682
            id: swipeView
            Layout.fillHeight: true
            Layout.fillWidth: true
            interactive: isMobile
            currentIndex: currentView

            onCurrentItemChanged: currentItem.forceActiveFocus()

            onCurrentIndexChanged:
            {
                currentView = currentIndex
683 684
                //                if (!babeitView.isConnected && currentIndex === viewsIndex.vvave)
                //                    babeitView.logginDialog.open()
Camilo higuita's avatar
Camilo higuita committed
685
            }
Camilo Higuita's avatar
Camilo Higuita committed
686

687

Camilo higuita's avatar
Camilo higuita committed
688
            TracksView
689
            {
Camilo higuita's avatar
Camilo higuita committed
690 691
                id: tracksView
                Connections
692
                {
Camilo higuita's avatar
Camilo higuita committed
693 694 695 696 697 698
                    target: tracksView
                    onRowClicked: Player.addTrack(tracksView.list.get(index))
                    onQuickPlayTrack: Player.quickPlay(tracksView.list.get(index))
                    onPlayAll:
                    {
                        var query = Q.GET.allTracks
699

Camilo higuita's avatar
Camilo higuita committed
700 701 702 703 704
                        mainPlaylist.list.clear()
                        mainPlaylist.list.query = query
                        Player.playAll()
                    }
                    onAppendAll:
705
                    {
Camilo higuita's avatar
Camilo higuita committed
706 707
                        mainPlaylist.list.appendQuery(Q.GET.allTracks)
                        mainPlaylist.listView.positionViewAtEnd()
708
                    }
Camilo higuita's avatar
Camilo higuita committed
709 710

                    onQueueTrack: Player.queueTracks([tracksView.list.get(index)], index)
711
                }
Camilo higuita's avatar
Camilo higuita committed
712
            }
Camilo Higuita's avatar
Camilo Higuita committed
713

Camilo higuita's avatar
Camilo higuita committed
714 715 716 717 718 719 720 721 722
            AlbumsView
            {
                id: albumsView

                holder.emoji: "qrc:/assets/MusicBox.png"
                holder.isMask: false
                holder.title : "No Albums!"
                holder.body: "Add new music sources"
                holder.emojiSize: iconSizes.huge
723
                title: count + qsTr(" albums")
724
                list.query: Albums.ALBUMS
Camilo higuita's avatar
Camilo higuita committed
725 726 727
                list.sortBy: Albums.ALBUM

                Connections
728
                {
Camilo higuita's avatar
Camilo higuita committed
729 730 731 732 733 734 735
                    target: albumsView
                    onRowClicked: Player.addTrack(track)
                    onPlayTrack: Player.quickPlay(track)

                    onAlbumCoverClicked: albumsView.populateTable(album, artist)

                    onAlbumCoverPressedAndHold:
736
                    {
Camilo higuita's avatar
Camilo higuita committed
737 738 739 740
                        var query = Q.GET.albumTracks_.arg(album)
                        query = query.arg(artist)

                        mainPlaylist.list.clear()
Camilo higuita's avatar
Camilo higuita committed
741
                        mainPlaylist.list.sortBy = Tracks.NONE
Camilo higuita's avatar
Camilo higuita committed
742
                        mainPlaylist.list.query = query
Camilo higuita's avatar
Camilo higuita committed
743
                        Player.playAll()
744
                    }
745

Camilo higuita's avatar
Camilo higuita committed
746
                    onPlayAll:
747
                    {
Camilo higuita's avatar
Camilo higuita committed
748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763
                        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()
764
                    }
Camilo Higuita's avatar
Camilo Higuita committed
765
                }
Camilo higuita's avatar
Camilo higuita committed
766
            }
767

camilo higuita's avatar
camilo higuita committed
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 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 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923
            AlbumsView
            {
                id: artistsView

                holder.emoji: "qrc:/assets/MusicBox.png"
                holder.isMask: false
                holder.title : qsTr("No Artists!")
                holder.body: qsTr("Add new music sources")
                holder.emojiSize: iconSizes.huge
                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
                    }
                }
            }


            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(
                                    searchView.searchTable.model.get(
                                        index).album)
                        query = query.arg(searchView.searchTable.model.get(
                                              index).artist)

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

            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)
                }
            }
Camilo higuita's avatar
Camilo higuita committed
924

925 926 927 928 929
            //            CloudView
            //            {
            //                id: cloudView
            //                onQuickPlayTrack: Player.quickPlay(cloudView.list.get(index))
            //            }
Camilo higuita's avatar
Camilo higuita committed
930

931 932 933 934
            //            BabeitView
            //            {
            //                id: babeitView
            //            }
Camilo higuita's avatar
Camilo higuita committed
935

936 937 938 939
            //            LinkingView
            //            {
            //                id: linkingView
            //            }
Camilo higuita's avatar
Camilo higuita committed
940 941 942 943 944 945

            YouTube
            {
                id: youtubeView
            }

946 947 948 949
            //            Spotify
            //            {
            //                id: spotifyView
            //            }
Camilo higuita's avatar
Camilo higuita committed
950 951 952 953
        }

        Maui.SelectionBar
        {
954 955
            id: _selectionBar
            property alias listView: _selectionBar.selectionList
Camilo higuita's avatar
Camilo higuita committed
956
            Layout.fillWidth: true
Camilo higuita's avatar
Camilo higuita committed
957
            Layout.margins: space.big
Camilo higuita's avatar
Camilo higuita committed
958 959
            Layout.topMargin: space.small
            Layout.bottomMargin: space.big
960
            onIconClicked: _contextMenu.popup()
Camilo higuita's avatar
Camilo higuita committed
961
            onExitClicked: clear()
camilo higuita's avatar
camilo higuita committed
962
            //            Kirigami.Theme.backgroundColor: "#212121"
963

camilo higuita's avatar
camilo higuita committed
964 965 966 967
            //            model: BaseModel
            //            {
            //                list: _selectionBarModelList
            //            }
968

camilo higuita's avatar
camilo higuita committed
969 970 971 972
            //            Tracks
            //            {
            //                id: _selectionBarModelList
            //            }
973 974 975 976 977

            SelectionBarMenu
            {
                id: _contextMenu
            }
Camilo higuita's avatar
Camilo higuita committed
978

camilo higuita's avatar
camilo higuita committed
979 980 981
            //            function append(item)
            //            {
            //                _selectionBar.append(item)
Camilo higuita's avatar
Camilo higuita committed
982

camilo higuita's avatar
camilo higuita committed
983 984 985 986
            ////                if(selectedPaths.indexOf(item.path) < 0)
            ////                {
            ////                    selectedItems.push(item)
            ////                    selectedPaths.push(item.path)
Camilo higuita's avatar
Camilo higuita committed
987

camilo higuita's avatar
camilo higuita committed
988 989 990 991 992 993
            ////                    //             for(var i = 0; i < selectionList.count ; i++ )
            ////                    //                 if(selectionList.model.get(i).path === item.path)
            ////                    //                 {
            ////                    //                     selectionList.model.remove(i)
            ////                    //                     return
            ////                    //                 }
Camilo higuita's avatar
Camilo higuita committed
994

camilo higuita's avatar
camilo higuita committed
995 996
            ////                    selectionList.model.list.append(item)
            ////                    selectionList.positionViewAtEnd()
997

camilo higuita's avatar
camilo higuita committed
998 999
            ////                }
            //            }
1000 1001
        }
    }
1002 1003


1004
    /*animations*/
1005

1006 1007

    /*FUNCTIONS*/
1008 1009
    function infoMsgAnim()
    {
1010 1011 1012 1013
        animBg.running = true
        animTxt.running = true
    }

1014 1015 1016 1017 1018 1019 1020 1021

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

1024

1025
    /*CONNECTIONS*/
1026

1027 1028
    Connections
    {
1029
        target: vvave
1030

camilo higuita's avatar
camilo higuita committed
1031 1032 1033 1034
        //        onRefreshTables: H.refreshCollection(size)
        //        onRefreshTracks: H.refreshTracks()
        //        onRefreshAlbums: H.refreshAlbums()
        //        onRefreshArtists: H.refreshArtists()
1035

1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055
        //        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"
        //                  }
1056

Camilo higuita's avatar
Camilo higuita committed
1057 1058 1059 1060 1061
        onOpenFiles:
        {
            Player.appendTracksAt(tracks, 0)
            Player.playAt(0)
        }
1062
    }
Camilo Higuita's avatar
Camilo Higuita committed
1063
}