BabeGrid.qml 2.49 KB
Newer Older
Camilo Higuita's avatar
Camilo Higuita committed
1 2
import QtQuick.Controls 2.2
import QtQuick 2.9
3
import ".."
4
import org.kde.kirigami 2.0 as Kirigami
Camilo Higuita's avatar
Camilo Higuita committed
5
import org.kde.mauikit 1.0 as Maui
Camilo Higuita's avatar
Camilo Higuita committed
6

7 8 9
import BaseModel 1.0
import AlbumsList 1.0

10
Maui.Page
Camilo Higuita's avatar
Camilo Higuita committed
11
{
12
    id: gridPage
13
    //    readonly property int screenSize : bae.screenGeometry("width")*bae.screenGeometry("height");
14
    //    property int hintSize : Math.sqrt(root.width*root.height)*0.3
15

16
    property int albumCoverSize: Math.min(iconSizes.enormous, width * 0.3)
17
    readonly property int albumSpacing: albumCoverSize * 0.3 + space.small
18

19
    property int albumCoverRadius :  radiusV
Camilo Higuita's avatar
Camilo Higuita committed
20
    property bool albumCardVisible : true
21 22 23 24

    property alias list: _albumsList
    property alias listModel: _albumsModel

25
    property alias grid: grid
26
    property alias holder: holder
Camilo higuita's avatar
Camilo higuita committed
27
    property alias count: grid.count
28

Camilo Higuita's avatar
Camilo Higuita committed
29
    signal albumCoverClicked(string album, string artist)
30
    signal albumCoverPressed(string album, string artist)
31
    signal bgClicked()
32

33 34
//    margins: space.medium
//    topMargin: space.big
Camilo Higuita's avatar
Camilo Higuita committed
35

36 37 38 39 40 41
    MouseArea
    {
        anchors.fill: parent
        onClicked: bgClicked()
    }

42
    Maui.Holder
43
    {
44
        id: holder
45 46 47
        visible: grid.count === 0
    }

48 49 50 51 52 53 54 55 56 57
    Albums
    {
        id: _albumsList
    }

    BaseModel
    {
        id: _albumsModel
        list: _albumsList
    }
Camilo Higuita's avatar
Camilo Higuita committed
58

Camilo higuita's avatar
Camilo higuita committed
59
    Maui.GridView
Camilo Higuita's avatar
Camilo Higuita committed
60 61
    {
        id: grid
Camilo higuita's avatar
Camilo higuita committed
62 63
        onAreaClicked: bgClicked()
        adaptContent: true
64 65
        anchors.fill: parent
        anchors.topMargin: space.big
66

Camilo higuita's avatar
Camilo higuita committed
67 68
        itemSize: albumCoverSize
        spacing: albumSpacing
69

Camilo higuita's avatar
Camilo higuita committed
70 71
        cellWidth: albumCoverSize + spacing
        cellHeight:  albumCoverSize + spacing*2
72

73
        model: _albumsModel
Camilo Higuita's avatar
Camilo Higuita committed
74 75
        delegate: BabeAlbum
        {
76
            id: albumDelegate
77

78
            albumSize : grid.itemSize
79
            albumRadius: albumCoverRadius
Camilo Higuita's avatar
Camilo Higuita committed
80
            albumCard: albumCardVisible
81

82 83 84
            height: grid.cellHeight
            width: grid.cellWidth

Camilo Higuita's avatar
Camilo Higuita committed
85 86
            Connections
            {
87
                target: albumDelegate
88
                onClicked:
Camilo Higuita's avatar
Camilo Higuita committed
89
                {
90 91
                    var album = _albumsList.get(index).album
                    var artist = _albumsList.get(index).artist
Camilo Higuita's avatar
Camilo Higuita committed
92
                    albumCoverClicked(album, artist)
93
                    grid.currentIndex = index
Camilo Higuita's avatar
Camilo Higuita committed
94
                }
95

96
                onPressAndHold:
97 98 99 100
                {
                    var album = grid.model.get(index).album
                    var artist = grid.model.get(index).artist
                    albumCoverPressed(album, artist)
101
                }
Camilo Higuita's avatar
Camilo Higuita committed
102 103 104 105
            }
        }
    }
}