FloatingDisk.qml 3.07 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11
import QtQuick 2.9
import QtQuick.Controls 2.2
import QtQuick.Layouts 1.3
import QtGraphicalEffects 1.0

Item
{
    height:  miniArtSize * 1.1
    width: height

    x: contentMargins
12
    y: parent.height - (root.footBar.height*0.5)
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90

    property bool isHovered : false

    ToolTip.delay: 1000
    ToolTip.timeout: 5000
    ToolTip.visible: isHovered && !isMobile
    ToolTip.text: currentTrack.title + " - " + currentTrack.artist

    DropShadow
    {
        anchors.fill: diskBg
        visible: diskBg.visible
        horizontalOffset: 3
        verticalOffset: 5
        radius: 8.0
        samples: 17
        color: "#80000000"
        source: diskBg
    }

    Rectangle
    {
        id: diskBg
        visible: miniArtwork.visible
        anchors.centerIn: parent
        height: parent.height
        width: height

        color: darkTextColor
        opacity: opacityLevel

        z: -999
        radius: Math.min(width, height)
    }



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

    Image
    {
        id: miniArtwork
        visible: ((!pageStack.wideMode
                   && pageStack.currentIndex !== 0)
                  || !mainPlaylist.cover.visible) && !mainlistEmpty
        focus: true
        height: miniArtSize
        width: miniArtSize
        //                    anchors.left: parent.left
        anchors.centerIn: parent
        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

        layer.enabled: true
        layer.effect: OpacityMask
        {
            maskSource: Item
            {
                width: miniArtwork.width
                height: miniArtwork.height
91 92
                Rectangle
                {
93 94 95 96 97 98 99 100 101
                    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)
                }
            }
        }
102 103


104 105 106 107 108 109 110 111
    }

    MouseArea
    {
        anchors.fill: parent
        drag.target: parent
        drag.axis: Drag.XAndYAxis
        drag.minimumX: 0
112
        drag.maximumX: root.footBar.width - parent.width
113 114

        drag.minimumY: 0
115
        drag.maximumY: pageStack.height
116 117 118 119 120 121 122 123
        onClicked:
        {
            if (!isMobile && pageStack.wideMode)
                root.width = columnWidth
            pageStack.currentIndex = 0
        }


124
        hoverEnabled: true
125 126 127 128
        onEntered: isHovered = true
        onExited: isHovered = false
    }
}