BabeAlbum.qml 6.32 KB
Newer Older
Camilo Higuita's avatar
Camilo Higuita committed
1 2 3 4
import QtQuick 2.9
import QtGraphicalEffects 1.0
import QtQuick.Controls 2.2
import QtQuick.Layouts 1.3
5
import AlbumsList 1.0
6

7
ItemDelegate
Camilo Higuita's avatar
Camilo Higuita committed
8
{
9 10
    id: babeAlbumRoot

camilo higuita's avatar
camilo higuita committed
11 12
    property int itemWidth : albumSize
    property int itemHeight: albumSize
13
    property int albumSize : iconSizes.huge
Camilo Higuita's avatar
Camilo Higuita committed
14 15
    property int albumRadius : 0
    property bool albumCard : true
camilo higuita's avatar
camilo higuita committed
16
    property string fillColor : Qt.darker(backgroundColor, 1.1)
Camilo Higuita's avatar
Camilo Higuita committed
17
    property bool hide : false
18 19 20
    property bool showLabels : true
    property bool showIndicator :  false
    property bool isCurrentListItem : ListView.isCurrentItem
camilo higuita's avatar
camilo higuita committed
21
    property bool hideRepeated : false
22
    property bool increaseCurrentItem : false
Camilo Higuita's avatar
Camilo Higuita committed
23

24
    property color labelColor : GridView.isCurrentItem  || hovered || down ? highlightColor : textColor
25
    //    height: typeof album === 'undefined' ? parseInt(albumSize+(albumSize*0.3)) : parseInt(albumSize+(albumSize*0.4))
Camilo Higuita's avatar
Camilo Higuita committed
26

camilo higuita's avatar
camilo higuita committed
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
    readonly property bool sameAlbum :
    {
        if(hideRepeated)
        {
            if(albumsRollRoot.model.get(index-1))
            {
                if(albumsRollRoot.model.get(index-1).album === album && albumsRollRoot.model.get(index-1).artist === artist)
                    true
                else
                    false
            }else false
        }else false
    }

    height: visible ? itemHeight : 0
    width : visible ? itemWidth : 0

    visible: !sameAlbum
45 46 47 48 49 50 51
    hoverEnabled: !isMobile
    //    spacing: 0

    background: Rectangle
    {
        color: "transparent"
    }
Camilo Higuita's avatar
Camilo Higuita committed
52

53 54 55 56
    ColumnLayout
    {
        anchors.fill: parent
        anchors.centerIn: parent
57

58
        Item
Camilo Higuita's avatar
Camilo Higuita committed
59
        {
60 61 62 63 64
            Layout.fillHeight: true
            Layout.fillWidth: true
            Layout.alignment: Qt.AlignHCenter
            Layout.maximumHeight: albumSize
            Layout.minimumHeight: albumSize
camilo higuita's avatar
camilo higuita committed
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
            DropShadow
            {
                anchors.fill: card
                visible: card.visible
                horizontalOffset: 0
                verticalOffset: 3
                radius: 8.0
                samples: 17
                color: "#80000000"
                source: card
            }

            Rectangle
            {
                id: card
                z: -999
                visible: albumCard
                anchors.centerIn: img
                anchors.fill: img

                color: fillColor
                radius: albumRadius
            }

90 91 92
            Image
            {
                id: img
93 94
                width: increaseCurrentItem ? albumSize * (isCurrentListItem ? 1 : 0.85) : albumSize
                height: width
Camilo Higuita's avatar
Camilo Higuita committed
95

96
                anchors.centerIn: parent
Camilo Higuita's avatar
Camilo Higuita committed
97

98 99
                sourceSize.width: parent.width
                sourceSize.height: parent.height
100 101 102

                fillMode: Image.PreserveAspectFit
                cache: true
103 104 105
                antialiasing: true
                smooth: true
                asynchronous: true
106 107

                source:
Camilo Higuita's avatar
Camilo Higuita committed
108
                {
109 110 111 112
                    if(artwork)
                        (artwork.length > 0 && artwork !== "NONE")? "file://"+encodeURIComponent(artwork) : "qrc:/assets/cover.png"
                    else "qrc:/assets/cover.png"
                }
Camilo higuita's avatar
Camilo higuita committed
113
                layer.enabled: albumRadius
114 115 116
                layer.effect: OpacityMask
                {
                    maskSource: Item
Camilo Higuita's avatar
Camilo Higuita committed
117
                    {
118 119
                        width: img.width
                        height: img.height
Camilo higuita's avatar
Camilo higuita committed
120

121 122 123 124 125 126
                        Rectangle
                        {
                            anchors.centerIn: parent
                            width: img.adapt ? img.width : Math.min(img.width, img.height)
                            height: img.adapt ? img.height : width
                            radius: albumRadius
Camilo higuita's avatar
Camilo higuita committed
127
                            border.color: borderColor
128
                        }
Camilo Higuita's avatar
Camilo Higuita committed
129 130
                    }
                }
Camilo Higuita's avatar
Camilo Higuita committed
131
            }
132 133 134

            Rectangle
            {
camilo higuita's avatar
camilo higuita committed
135
                visible : showIndicator && currentTrackIndex === index
136

camilo higuita's avatar
camilo higuita committed
137 138
                height: img.height * 0.1
                width: img.width * 0.1
139 140 141 142 143 144 145 146 147 148 149 150 151 152 153
                anchors.bottom: parent.bottom
                anchors.bottomMargin: space.big
                anchors.horizontalCenter:parent.horizontalCenter
                radius: Math.min(width, height)
                color: "#f84172"

                AnimatedImage
                {
                    source: "qrc:/assets/heart_indicator_white.gif"
                    anchors.centerIn: parent
                    height: parent.height * 0.6
                    width: parent.width * 0.6
                    playing: parent.visible
                }
            }
Camilo Higuita's avatar
Camilo Higuita committed
154 155
        }

156
        Item
157
        {
158
            visible: showLabels
159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178
            Layout.fillWidth: true
            Layout.fillHeight: true
            Layout.alignment: Qt.AlignHCenter
            Layout.margins: 0

            ColumnLayout
            {
                anchors.fill: parent
                spacing: space.tiny

                Item
                {
                    Layout.fillWidth: true
                    Layout.alignment: Qt.AlignHCenter
                    //            Layout.margins: space.medium

                    Label
                    {
                        width: parent.width * 0.8
                        anchors.centerIn: parent
179
                        text: list.query === Albums.ALBUMS ? model.album : model.artist
180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199
                        visible: true
                        horizontalAlignment: Qt.AlignHCenter
                        elide: Text.ElideRight
                        font.pointSize: fontSizes.default
                        font.bold: true
                        font.weight: Font.Bold
                        color: labelColor
                    }
                }

                Item
                {
                    Layout.fillWidth: true
                    Layout.alignment: Qt.AlignTop

                    Label
                    {
                        width: parent.width*0.8
                        anchors.centerIn: parent

200 201
                        text: list.query === Albums.ALBUMS ? model.artist : undefined
                        visible: text
202 203 204 205 206 207 208
                        horizontalAlignment: Qt.AlignHCenter
                        elide: Text.ElideRight
                        font.pointSize: fontSizes.medium
                        color: labelColor
                    }
                }
            }
Camilo Higuita's avatar
Camilo Higuita committed
209 210

        }
211
    }
Camilo Higuita's avatar
Camilo Higuita committed
212
}