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

7
import org.kde.kirigami 2.2 as Kirigami
8
//import QtQuick.Controls.Imagine 2.3
9

Camilo Higuita's avatar
Camilo Higuita committed
10
import "utils"
11

Camilo Higuita's avatar
Camilo Higuita committed
12
import "widgets"
13
import "widgets/MyBeatView"
14 15
import "widgets/PlaylistsView"
import "widgets/MainPlaylist"
16
import "widgets/SettingsView"
17
import "widgets/SearchView"
18

19
import "view_models"
20
import "view_models/BabeDialog"
21
import "services/web"
Camilo Higuita's avatar
Camilo Higuita committed
22

23 24
import "db/Queries.js" as Q
import "utils/Player.js" as Player
25
import "utils/Help.js" as H
26

27
Kirigami.ApplicationWindow
Camilo Higuita's avatar
Camilo Higuita committed
28
{
Camilo Higuita's avatar
Camilo Higuita committed
29
    id: root
Camilo Higuita's avatar
Camilo Higuita committed
30
    visible: true
31
    width: !isMobile ? wideSize : 400
32
    minimumWidth: !isMobile ? columnWidth : 0
33
    minimumHeight:  !isMobile ? columnWidth+64 : 0
Camilo Higuita's avatar
Camilo Higuita committed
34 35
    height: 500
    title: qsTr("Babe")
36
    //    wideScreen: root.width > coverSize
Camilo Higuita's avatar
Camilo Higuita committed
37

38 39 40 41 42 43
    /*ALIASES*/
    property alias playIcon: playIcon
    property alias babeBtnIcon: babeBtnIcon
    property alias progressBar : progressBar
    property alias animFooter : animFooter
    property alias mainPlaylist : mainPlaylist
44

45
    /*PLAYBACK*/
Camilo Higuita's avatar
Camilo Higuita committed
46
    property bool isShuffle : false
Camilo Higuita's avatar
Camilo Higuita committed
47
    property var currentTrack : ({babe: "0", stars: "0"})
48 49
    property int currentTrackIndex : 0
    property int prevTrackIndex : 0
50
    property string currentArtwork : !mainlistEmpty ? mainPlaylist.list.model.get(0).artwork : ""
Camilo Higuita's avatar
Camilo Higuita committed
51
    property bool currentBabe : currentTrack.babe == "0" ? false : true
52 53
    property string durationTimeLabel : "00:00"
    property string progressTimeLabel : "00:00"
54
    property bool isPlaying : false
Camilo Higuita's avatar
Camilo Higuita committed
55
    property bool autoplay : bae.loadSetting("AUTOPLAY", "BABE", false) === "true" ? true : false
56 57
    property int onQueue : 0

58

59
    /*THEMING*/
60 61
    property string babeColor : bae.babeColor()
    property string babeAltColor : bae.babeAltColor()
62
    property string backgroundColor : isMobile ? bae.backgroundColor() : Kirigami.Theme.backgroundColor
Camilo Higuita's avatar
Camilo Higuita committed
63
    property string viewBackgroundColor : isMobile ? bae.altColor() : Kirigami.Theme.viewBackgroundColor
64 65 66 67
    property string foregroundColor : isMobile ? bae.foregroundColor() : Kirigami.Theme.textColor
    property string textColor : isMobile ? bae.textColor() : Kirigami.Theme.textColor
    property string babeHighlightColor : isMobile ? bae.highlightColor() : Kirigami.Theme.highlightColor
    property string highlightTextColor : isMobile ? bae.highlightTextColor() : Kirigami.Theme.highlightedTextColor
68
    property string midColor : bae.midColor()
69
    property string midLightColor : isMobile? bae.midLightColor() : Kirigami.Theme.buttonBackgroundColor
70 71
    property string darkColor : bae.darkColor()
    property string baseColor : bae.baseColor()
Camilo Higuita's avatar
Camilo Higuita committed
72 73
    property string altColor : isMobile ? bae.altColor() : Kirigami.Theme.viewBackgroundColor
    property string shadowColor : bae.shadowColor()
74

75
    readonly property string darkBackgroundColor : "#303030"
76 77 78 79
    readonly property string darkForegroundColor : "#FAFAFA"
    readonly property string darkTextColor : darkForegroundColor
    readonly property string darkBabeHighlightColor : "#29B6F6"
    readonly property string darkHighlightTextColor : darkForegroundColor
80 81 82
    readonly property string darkMidColor : "#1d1d1d"
    readonly property string darkMidLightColor : "#282828"
    readonly property string darkDarkColor : "#191919"
83
    readonly property string darkBaseColor : "#212121"
84 85
    readonly property string darkAltColor : darkDarkColor
    readonly property string darkShadowColor : darkAltColor
86

87
    Material.theme: Material.Light
88
    Material.accent: babeColor
89
    Material.background: viewBackgroundColor
90 91 92 93
    Material.primary: backgroundColor
    Material.foreground: foregroundColor

    /*READONLY PROPS*/
94
    readonly property var iconSizes : ({ "small" : 16, "medium" : isMobile ? 24 : 22, "big" : 32, "large" : 48 })
95
    readonly property var fontSizes : ({"tiny": isMobile ? 7.5 : 7, "small" : isMobile ? 9.5 : 8.5, "medium" : isMobile ? 11 :  10, "big" : isMobile ? 11.5 : 10.5, "large" : isMobile ? 12 : 11.5})
96
    readonly property real opacityLevel : 0.8
Camilo Higuita's avatar
Camilo Higuita committed
97
    readonly property bool isMobile: bae.isMobile()
98
    readonly property int wideSize : bae.screenGeometry("width")*0.5
99
    readonly property int rowHeight: isMobile ? 60 : 52
100
    readonly property int rowHeightAlt: isMobile ? 48 : 32
101
    readonly property int headerHeight: rowHeight
102
    readonly property int contentMargins : isMobile ? 8 : 10
103
    readonly property var viewsIndex : ({
104 105 106 107
                                            "tracks" : 0,
                                            "albums" : 1,
                                            "artists" : 2,
                                            "playlists" : 3,
108 109
                                            "babeit": 4,
                                            "search" : 5,
110
                                            "youtube" : 6
111
                                        })
112

113
    property bool mainlistEmpty : !mainPlaylist.table.count > 0
114

115
    /*PROPS*/
116
    property int toolBarIconSize: bae.loadSetting("ICON_SIZE", "BABE", iconSizes.medium)
117
    property int toolBarHeight : isMobile ? 48 : toolBarIconSize *2
Camilo Higuita's avatar
Camilo Higuita committed
118
    property int miniArtSize : isMobile ? 36 : 30
119

120 121
    property int columnWidth: Kirigami.Units.gridUnit * 19
    property int coverSize: isMobile ? Math.sqrt(root.width*root.height)*0.4 : columnWidth * 0.6
122
    property int currentView : viewsIndex.tracks
123

124 125 126
    /*USEFUL PROPS*/
    property string syncPlaylist : ""
    property bool sync : false
127
    property string infoMsg : ""
128
    property bool infoLabels : bae.loadSetting("PLAYBACKINFO", "BABE", false) == "true" ? true : false
129

130 131 132 133
    /*SIGNALS*/
    signal missingAlert(var track)

    /*CONF*/
134 135
    pageStack.defaultColumnWidth: columnWidth
    pageStack.initialPage: [mainPlaylist, views]
136 137
    pageStack.interactive: isMobile
    pageStack.separatorVisible: pageStack.wideMode
Camilo Higuita's avatar
Camilo Higuita committed
138

139 140
    overlay.modal: Rectangle
    {
141 142 143 144
        color: isMobile ? darkColor : "transparent"
        opacity: 0.5
        height: root.height - playbackControls.height - toolbar.height
        y: toolbar.height
145 146 147 148 149 150
    }

    overlay.modeless: Rectangle
    {
        color: "transparent"
    }
Camilo Higuita's avatar
Camilo Higuita committed
151

152 153
    /*HANDLE EVENTS*/
    onWidthChanged: if(isMobile)
Camilo Higuita's avatar
Camilo Higuita committed
154
                    {
155
                        if(width > height)
Camilo Higuita's avatar
Camilo Higuita committed
156 157 158
                            mainPlaylist.cover.visible = false
                        else  mainPlaylist.cover.visible = true
                    }
Camilo Higuita's avatar
Camilo Higuita committed
159

Camilo Higuita's avatar
Camilo Higuita committed
160
    onClosing: Player.savePlaylist()
161

Camilo Higuita's avatar
Camilo Higuita committed
162 163 164 165 166 167 168 169 170 171 172 173
    //    pageStack.onCurrentIndexChanged:
    //    {
    //        if(pageStack.currentIndex === 0 && isMobile && !pageStack.wideMode)
    //        {
    //            bae.androidStatusBarColor(babeColor)
    //            Material.background = babeColor
    //        }else
    //        {
    //            bae.androidStatusBarColor(babeAltColor)
    //            Material.background = babeAltColor
    //        }
    //    }
174

175 176 177 178 179 180 181 182
    onMissingAlert:
    {
        missingDialog.message = track.title +" by "+track.artist+" is missing"
        missingDialog.messageBody = "Do you want to remove it from your collection?"
        missingDialog.open()
    }

    /*COMPONENTS*/
Camilo Higuita's avatar
Camilo Higuita committed
183
    BabeNotify { id: babeNotify }
184

185
    BabeMessage
186 187
    {
        id: missingDialog
188
        width: isMobile ? parent.width *0.9 : parent.width*0.4
189 190 191
        title: "Missing file"
        onAccepted:
        {
192
            bae.removeTrack(currentTrack.url)
193
            mainPlaylist.table.model.remove(mainPlaylist.table.currentIndex)
194 195

        }
Camilo Higuita's avatar
Camilo Higuita committed
196
    }
197 198

    /* UI */
Camilo Higuita's avatar
Camilo Higuita committed
199 200
    header: BabeBar
    {
201
        id: toolbar
Camilo Higuita's avatar
Camilo Higuita committed
202
        //        height: toolBarHeight
Camilo Higuita's avatar
Camilo Higuita committed
203

Camilo Higuita's avatar
Camilo Higuita committed
204
        visible: true
Camilo Higuita's avatar
Camilo Higuita committed
205
        currentIndex: currentView
206
        onSettingsViewClicked: settingsDrawer.visible ? settingsDrawer.close() : settingsDrawer.open()
207

208 209 210
        onTracksViewClicked:
        {
            pageStack.currentIndex = 1
211
            currentView = viewsIndex.tracks
212
        }
213

214 215 216
        onAlbumsViewClicked:
        {
            pageStack.currentIndex = 1
217
            currentView = viewsIndex.albums
218
        }
219

220 221 222
        onArtistsViewClicked:
        {
            pageStack.currentIndex = 1
223
            currentView = viewsIndex.artists
224
        }
225

226 227 228
        onPlaylistsViewClicked:
        {
            pageStack.currentIndex = 1
229
            currentView = viewsIndex.playlists
230
        }
231

232 233 234
        onBabeViewClicked:
        {
            pageStack.currentIndex = 1
235
            currentView = viewsIndex.babeit
236
        }
237 238 239 240

        onSearchViewClicked:
        {
            pageStack.currentIndex = 1
241
            currentView = viewsIndex.search
242
            searchView.searchInput.forceActiveFocus()
243
        }
Camilo Higuita's avatar
Camilo Higuita committed
244 245
    }

246
    footer: Item
247
    {
248
        id: playbackControls
249
        height: visible ? headerHeight : 0
250
        width: root.width
251
        visible: true
252
        focus: true
253

254 255
        FastBlur
        {
256
            anchors.fill: parent
257 258 259 260 261 262
            source: mainPlaylist.artwork
            radius: 100
            transparentBorder: false
            cached: true
            z: -999
        }
263

264
        Rectangle
265
        {
266
            id: footerBg
267
            anchors.fill: parent
268
            color: darkDarkColor
269 270
            opacity: opacityLevel
            z: -999
Camilo Higuita's avatar
Camilo Higuita committed
271

272 273 274 275 276 277 278 279
            SequentialAnimation
            {
                id: animFooter
                PropertyAnimation
                {
                    target: footerBg
                    property: "color"
                    easing.type: Easing.InOutQuad
Camilo Higuita's avatar
Camilo Higuita committed
280
                    from: darkBaseColor
281
                    to: darkDarkColor
282 283 284
                    duration: 500
                }
            }
285 286 287 288 289
        }

        Slider
        {
            id: progressBar
290

291
            height: 10
292
            width: parent.width
293
            z: 999
294 295 296
            anchors.left: parent.left
            anchors.right: parent.right
            anchors.top: parent.top
297
            padding: 0
298 299 300 301
            from: 0
            to: 1000
            value: 0
            spacing: 0
302
            focus: true
303 304 305 306

            onMoved: player.seek(player.duration() / 1000 * value);

            background: Rectangle
307
            {
308
                x: progressBar.leftPadding
Camilo Higuita's avatar
Camilo Higuita committed
309
                y: progressBar.y
310
                implicitWidth: 200
311
                implicitHeight: 10
312 313
                width: progressBar.availableWidth
                height: implicitHeight
Camilo Higuita's avatar
Camilo Higuita committed
314
                color: "transparent"
315

316 317 318
                Rectangle
                {
                    width: progressBar.visualPosition * parent.width
Camilo Higuita's avatar
Camilo Higuita committed
319
                    height: 4
320 321
                    color: babeColor
                }
322 323
            }

324
            handle: Rectangle
325
            {
326
                x: progressBar.leftPadding + progressBar.visualPosition * (progressBar.availableWidth - width)
Camilo Higuita's avatar
Camilo Higuita committed
327
                y: progressBar.y-(height/2)
328 329 330
                implicitWidth: progressBar.pressed ? 16 : 0
                implicitHeight: progressBar.pressed ? 16 : 0
                radius:  progressBar.pressed ? 16 : 0
331
                color: babeColor
332
            }
333

334
        }
335

336 337

        GridLayout
338 339 340
        {
            anchors.fill: parent
            height: parent.height
341
            width: parent.width
Camilo Higuita's avatar
Camilo Higuita committed
342

343 344 345
            rowSpacing: 0
            columnSpacing: 0
            rows: 2
346
            columns: 2
347 348


349 350
            Item
            {
351
                Layout.alignment: Qt.AlignLeft
352 353 354 355 356 357 358 359
                Layout.fillHeight: true
                Layout.maximumWidth: miniArtwork.visible ? headerHeight : 0
                Layout.minimumWidth: miniArtwork.visible ? headerHeight : 0
                Layout.minimumHeight: miniArtwork.visible ? headerHeight : 0
                Layout.maximumHeight: miniArtwork.visible ? headerHeight : 0
                Layout.row: 1
                Layout.rowSpan: 2
                Layout.column: 1
360

361 362 363 364
                Rectangle
                {
                    visible: miniArtwork.visible
                    anchors.centerIn: parent
365 366 367
                    height: miniArtSize+4
                    width: miniArtSize+4

368 369 370 371 372 373 374 375 376 377 378
                    color: darkForegroundColor
                    z: -999
                    radius: Math.min(width, height)
                }

                RotationAnimator on rotation
                {
                    from: 0;
                    to: 360;
                    duration: 5000
                    loops: Animation.Infinite
379
                    running: miniArtwork.visible && isPlaying
380
                }
381

382 383
                Image
                {
384
                    id: miniArtwork
385
                    visible: ((!pageStack.wideMode && pageStack.currentIndex !== 0) || !mainPlaylist.cover.visible) && !mainlistEmpty
386
                    focus: true
387 388
                    height: miniArtSize
                    width: miniArtSize
389 390
                    //                    anchors.left: parent.left
                    anchors.centerIn: parent
391 392 393 394 395 396 397 398 399
                    source:
                    {
                        if(currentArtwork)
                            (currentArtwork.length > 0 && currentArtwork !== "NONE")? "file://"+encodeURIComponent(currentArtwork) : "qrc:/assets/cover.png"
                        else "qrc:/assets/cover.png"
                    }
                    fillMode:  Image.PreserveAspectFit
                    cache: false
                    antialiasing: true
Camilo Higuita's avatar
Camilo Higuita committed
400 401 402 403 404 405 406 407 408 409 410

                    MouseArea
                    {
                        anchors.fill: parent
                        onClicked:
                        {
                            if(!isMobile && pageStack.wideMode)
                                root.width = columnWidth
                            pageStack.currentIndex = 0
                        }
                    }
411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428

                    layer.enabled: true
                    layer.effect: OpacityMask
                    {
                        maskSource: Item
                        {
                            width: miniArtwork.width
                            height: miniArtwork.height
                            Rectangle
                            {
                                anchors.centerIn: parent
                                width: miniArtwork.adapt ? miniArtwork.width : Math.min(miniArtwork.width, miniArtwork.height)
                                height: miniArtwork.adapt ? miniArtwork.height : width
                                radius: Math.min(width, height)

                            }
                        }
                    }
429 430
                }
            }
Camilo Higuita's avatar
Camilo Higuita committed
431

432
            Item
433
            {
434
                Layout.alignment: Qt.AlignCenter
435
                Layout.fillWidth: true
436 437 438 439
                Layout.fillHeight: true
                Layout.row: 2
                Layout.column: 2
                Layout.maximumHeight: playbackInfo.visible ? playbackInfo.font.pointSize*2 : 0
440

441
                Label
442
                {
443
                    id: playbackInfo
444

445
                    visible: !mainlistEmpty && infoLabels
446 447 448 449
                    //                anchors.top: playIcon.bottom
                    //                anchors.horizontalCenter: playIcon.horizontalCenter
                    width: parent.width
                    height: parent.height
450 451
                    horizontalAlignment: Qt.AlignHCenter
                    verticalAlignment: Qt.AlignVCenter
452
                    text: progressTimeLabel  + "  /  " + (currentTrack ? (currentTrack.title ? currentTrack.title + " - " + currentTrack.artist : "--- - "+currentTrack.artist) : "") + "  /  " + durationTimeLabel
453
                    color: darkForegroundColor
454
                    font.pointSize: fontSizes.tiny
455 456
                    elide: Text.ElideRight
                }
457
            }
458

459 460 461 462 463 464 465
            RowLayout
            {
                Layout.fillWidth: true
                Layout.fillHeight: true
                Layout.alignment: Qt.AlignCenter
                Layout.row: 1
                Layout.column: 2
466

467 468 469 470
                BabeButton
                {
                    id: babeBtnIcon
                    iconName: "love"
471
                    iconColor: currentBabe ? babeColor : darkForegroundColor
Camilo Higuita's avatar
Camilo Higuita committed
472 473 474 475 476 477
                    onClicked: if(!mainlistEmpty)
                               {
                                   var value = mainPlaylist.contextMenu.babeIt(currentTrackIndex)
                                   currentBabe = value
                               }

478
                }
479

480 481 482
                BabeButton
                {
                    id: previousBtn
483
                    iconColor: darkForegroundColor
484 485 486 487
                    iconName: "media-skip-backward"
                    onClicked: Player.previousTrack()
                    onPressAndHold: Player.playAt(prevTrackIndex)
                }
488

489 490 491
                BabeButton
                {
                    id: playIcon
492
                    iconColor: darkForegroundColor
493

494
                    iconName: isPlaying ? "media-playback-pause" : "media-playback-start"
495
                    onClicked:
496
                    {
497 498
                        if(isPlaying) Player.pauseTrack()
                        else Player.resumeTrack()
499
                    }
500
                }
501

502 503 504
                BabeButton
                {
                    id: nextBtn
505
                    iconColor: darkForegroundColor
506

507 508
                    iconName: "media-skip-forward"
                    onClicked: Player.nextTrack()
509

510
                    onPressAndHold: Player.playAt(Player.shuffle())
511
                }
512

513 514 515
                BabeButton
                {
                    id: shuffleBtn
516 517
                    iconColor: darkForegroundColor

Camilo Higuita's avatar
Camilo Higuita committed
518 519
                    iconName: isShuffle ? "media-playlist-shuffle" : "media-playlist-repeat"
                    onClicked: isShuffle = !isShuffle
520 521
                }

522 523
            }

524

525

526
        }
527 528
    }

Camilo Higuita's avatar
Camilo Higuita committed
529
    background: Rectangle
530 531
    {
        anchors.fill: parent
532
        color: altColor
533 534 535
        z: -999
    }

536 537 538 539 540 541
    globalDrawer: SettingsView
    {
        id: settingsDrawer
        //        contentItem.implicitWidth: columnWidth
        onIconSizeChanged: toolBarIconSize = size
    }
542

543 544 545
    Item
    {
        id: message
546
        visible: infoMsg.length > 0 && sync
547 548 549 550 551 552 553 554
        anchors.bottom: parent.bottom
        width: pageStack.wideMode ? columnWidth : parent.width
        height: toolBarIconSize
        z:999

        Rectangle
        {
            id: infoBg
555

556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590
            anchors.fill: parent
            z: -999
            color: altColor
            opacity: opacityLevel

            SequentialAnimation
            {
                id: animBg
                PropertyAnimation
                {
                    target: infoBg
                    property: "color"
                    easing.type: Easing.InOutQuad
                    to: babeColor
                    duration: 250
                }

                PropertyAnimation
                {
                    target: infoBg
                    property: "color"
                    easing.type: Easing.InOutQuad
                    to: altColor
                    duration: 500
                }
            }
        }

        Label
        {
            id: infoTxt
            anchors.centerIn: parent
            anchors.fill: parent
            height: parent.height
            width: parent.width
591
            font.pointSize: fontSizes.medium
592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619
            text: infoMsg
            horizontalAlignment: Qt.AlignHCenter
            verticalAlignment: Qt.AlignVCenter
            color: foregroundColor

            SequentialAnimation
            {
                id: animTxt
                PropertyAnimation
                {
                    target: infoTxt
                    property: "color"
                    easing.type: Easing.InOutQuad
                    to: "white"
                    duration: 250
                }

                PropertyAnimation
                {
                    target: infoTxt
                    property: "color"
                    easing.type: Easing.InOutQuad
                    to: foregroundColor
                    duration: 500
                }
            }
        }
    }
620 621 622 623

    MainPlaylist
    {
        id: mainPlaylist
624 625
        anchors.fill: parent
        clip: true
626

627 628 629 630 631 632 633 634
        Connections
        {
            target: mainPlaylist
            onCoverPressed: Player.appendAll(tracks)
            onCoverDoubleClicked: Player.playAll(tracks)
        }
    }

Camilo Higuita's avatar
Camilo Higuita committed
635
    Page
Camilo Higuita's avatar
Camilo Higuita committed
636
    {
637
        id: views
Camilo Higuita's avatar
Camilo Higuita committed
638
        anchors.fill: parent
639
        clip: true
640 641
        //        focusPolicy: Qt.WheelFocus
        //        visualFocus: true
Camilo Higuita's avatar
Camilo Higuita committed
642

643
        Column
Camilo Higuita's avatar
Camilo Higuita committed
644
        {
645
            anchors.fill: parent
Camilo Higuita's avatar
Camilo Higuita committed
646

647
            SwipeView
Camilo Higuita's avatar
Camilo Higuita committed
648
            {
649 650
                id: swipeView
                width: parent.width
651 652
                height: parent.height

653
                Component.onCompleted: contentItem.interactive = isMobile
654

655
                currentIndex: currentView
656

657 658
                onCurrentItemChanged: currentItem.forceActiveFocus()

659 660 661
                onCurrentIndexChanged:
                {
                    currentView = currentIndex
662 663 664
                    if(pageStack.currentIndex === 0) mainPlaylist.list.forceActiveFocus()
                    else if(currentView === viewsIndex.tracks) tracksView.forceActiveFocus()
                    else if(currentView === viewsIndex.search) searchView.forceActiveFocus()
665

666 667
                    if(!babeitView.isConnected && currentIndex === viewsIndex.babeit)
                        babeitView.logginDialog.open()
668
                }
669

670

671 672
                TracksView
                {
673
                    id: tracksView
674 675 676 677 678
                    Connections
                    {
                        target: tracksView
                        onRowClicked: Player.addTrack(tracksView.model.get(index))
                        onQuickPlayTrack: Player.quickPlay(tracksView.model.get(index))
Camilo Higuita's avatar
Camilo Higuita committed
679 680
                        onPlayAll: Player.playAll(bae.get(Q.GET.allTracks))
                        onAppendAll: Player.appendAll(bae.get(Q.GET.allTracks))
681
                        onQueueTrack: Player.queueTracks([tracksView.model.get(index)])
682

683
                    }
684
                }
Camilo Higuita's avatar
Camilo Higuita committed
685

Camilo Higuita's avatar
Camilo Higuita committed
686
                AlbumsView
Camilo Higuita's avatar
Camilo Higuita committed
687
                {
688
                    id: albumsView
689 690 691 692
                    Connections
                    {
                        target: albumsView
                        onRowClicked: Player.addTrack(track)
693 694
                        onPlayAlbum: Player.playAll(tracks)
                        onAppendAlbum: Player.appendAll(tracks)
695 696
                        onPlayTrack: Player.quickPlay(track)
                    }
Camilo Higuita's avatar
Camilo Higuita committed
697
                }
Camilo Higuita's avatar
Camilo Higuita committed
698

Camilo Higuita's avatar
Camilo Higuita committed
699 700
                ArtistsView
                {
701
                    id: artistsView
702 703 704 705 706

                    Connections
                    {
                        target: artistsView
                        onRowClicked: Player.addTrack(track)
707 708
                        onPlayAlbum: Player.playAll(tracks)
                        onAppendAlbum: Player.appendAll(tracks)
709 710
                        onPlayTrack: Player.quickPlay(track)
                    }
Camilo Higuita's avatar
Camilo Higuita committed
711
                }
712

713 714 715 716 717 718 719 720
                PlaylistsView
                {
                    id: playlistsView
                    Connections
                    {
                        target: playlistsView
                        onRowClicked: Player.addTrack(track)
                        onQuickPlayTrack: Player.quickPlay(track)
Camilo Higuita's avatar
Camilo Higuita committed
721 722
                        onPlayAll: Player.playAll(tracks)
                        onAppendAll: Player.appendAll(tracks)
723 724 725 726 727 728
                        onPlaySync:
                        {
                            var tracks = bae.get(Q.GET.playlistTracks_.arg(playlist))
                            Player.playAll(tracks)
                            root.sync = true
                            root.syncPlaylist = playlist
729
                            root.infoMsg = "Syncing to "+ playlist
730 731
                            console.log("ALLOW PLAYLIOST SYNC FOR: " ,root.syncPlaylist = playlist)
                        }
732 733
                    }
                }
Camilo Higuita's avatar
Camilo Higuita committed
734

735 736 737 738 739
                BabeitView
                {
                    id: babeitView
                }

Camilo Higuita's avatar
Camilo Higuita committed
740 741 742
                SearchTable
                {
                    id: searchView
743

744 745
                    Connections
                    {
746 747 748
                        target: searchView.searchTable
                        onRowClicked: Player.addTrack(searchView.searchTable.model.get(index))
                        onQuickPlayTrack: Player.quickPlay(searchView.searchTable.model.get(index))
749 750
                        onPlayAll: Player.playAll(searchView.searchRes)
                        onAppendAll: Player.appendAll(searchView.searchRes)
751 752
                        onArtworkDoubleClicked:
                        {
753 754
                            var query = Q.GET.albumTracks_.arg(searchView.searchTable.model.get(index).album)
                            query = query.arg(searchView.searchTable.model.get(index).artist)
755 756 757 758

                            Player.playAll(bae.get(query))

                        }
759
                    }
Camilo Higuita's avatar
Camilo Higuita committed
760 761
                }

762
                YouTube
763 764 765 766
                {
                    id: youtubeView
                }

767 768


Camilo Higuita's avatar
Camilo Higuita committed
769 770 771
            }
        }
    }
Camilo Higuita's avatar
Camilo Higuita committed
772
    /*animations*/
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

    pageStack.layers.popEnter: Transition {
        PauseAnimation {
            duration: Kirigami.Units.longDuration
        }
    }
    pageStack.layers.popExit: Transition {
        YAnimator {
            from: 0
            to: pageStack.layers.height
            duration: Kirigami.Units.longDuration
            easing.type: Easing.OutCubic
        }
    }

    pageStack.layers.pushEnter: Transition {
        YAnimator {
            from: pageStack.layers.height
            to: 0
            duration: Kirigami.Units.longDuration
            easing.type: Easing.OutCubic
        }
    }

    pageStack.layers.pushExit: Transition {
        PauseAnimation {
            duration: Kirigami.Units.longDuration
        }
    }

    pageStack.layers.replaceEnter: Transition {
        YAnimator {
            from: pageStack.layers.width
            to: 0
            duration: Kirigami.Units.longDuration
            easing.type: Easing.OutCubic
        }
    }

    pageStack.layers.replaceExit: Transition {
        PauseAnimation {
            duration: Kirigami.Units.longDuration
        }
    }
817 818 819 820 821 822 823 824

    /*FUNCTIONS*/
    function infoMsgAnim()
    {
        animBg.running = true
        animTxt.running = true
    }

825 826
    Component.onCompleted:
    {
Camilo Higuita's avatar
Camilo Higuita committed
827 828
        //        if(isMobile) settingsDrawer.switchColorScheme(bae.loadSetting("THEME", "BABE", "Dark"))
        //        console.log(Imagine.url, Imagine.path)
829
        bae.androidStatusBarColor(viewBackgroundColor)
830 831 832
    }

    /*CONNECTIONS*/
833

834

835

836 837 838 839 840 841
    Connections
    {
        target: player
        onPos: progressBar.value = pos
        onTiming: progressTimeLabel = time
        onDurationChanged: durationTimeLabel = time
Camilo Higuita's avatar
Camilo Higuita committed
842 843 844

        onFinished: if(!mainlistEmpty)
                    {
Camilo Higuita's avatar
Camilo Higuita committed
845 846 847
                        if(currentTrack.url)
                            bae.playedTrack(currentTrack.url)

Camilo Higuita's avatar
Camilo Higuita committed
848 849 850
                        Player.nextTrack()
                    }

851 852 853 854 855 856 857 858

        onIsPlaying: isPlaying = playing
    }


    Connections
    {
        target: bae
Camilo Higuita's avatar
Camilo Higuita committed
859

860 861
        onRefreshTables: H.refreshCollection(size)

Camilo Higuita's avatar
Camilo Higuita committed
862 863 864 865
        onRefreshTracks: H.refreshTracks()
        onRefreshAlbums: H.refreshAlbums()
        onRefreshArtists: H.refreshArtists()

866 867 868 869 870 871 872 873 874
        onTrackLyricsReady:
        {
            if(url === currentTrack.url)
                Player.setLyrics(lyrics)
        }

        onSkipTrack: Player.nextTrack()
        onBabeIt: Player.babeTrack()
    }
Camilo Higuita's avatar
Camilo Higuita committed
875
}