summaryrefslogtreecommitdiff
path: root/qml/DesktopGridView.qml
blob: c5bf5882d94cb2f3bb02564257c17f20fde60644 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
import QtQuick
import QtQuick.Controls
import org.kazoe.xdg

ListView {
    id: desktopgridview
    property string category
    property int nbrow
    clip: true
    orientation: ListView.Horizontal
    anchors.margins: 5
    height: 150
    spacing: 15


    model: DesktopFilter {
        id: filtermodel
        model: xdgEntries
        category: desktopgridview.category
        onRowsInserted: {
            desktopgridview.nbrow = rowCount()
        }

        onRowsRemoved: {
            desktopgridview.nbrow = rowCount()
        }

        Component.onCompleted: {
            desktopgridview.nbrow = rowCount()
        }
    }

    delegate: Rectangle {
        property string applicationIcon: appIcon
        property string applicationTitle: name
        property string xdgPath: path
        property alias highlighted: btn.highlighted
        id: entryItem
        width: desktopgridview.height * 0.8
        height: desktopgridview.height * 0.8
        highlighted: keywords.includes("running")
        color: (btn.highlighted)?(currentTheme.highlight):(currentTheme.window)
        radius: 4

        Button {
            id: btn
            icon.source: "file://" + entryItem.applicationIcon
            icon.name: entryItem.applicationIcon
            icon.width: btn.width
            icon.height: btn.height

            font.pixelSize: 12
            font.bold: true
            height: entryItem.height * 0.5
            width: entryItem.width * 0.5
            anchors.top: parent.top
            anchors.topMargin: 10
            anchors.horizontalCenter: parent.horizontalCenter

            background: Rectangle {
                color: "transparent"
            }
        }

        Text {
            anchors.top: btn.bottom
            anchors.left: parent.left
            anchors.right: parent.right
            height: entryItem.height * 0.4
            text: entryItem.applicationTitle
            font: btn.font
            fontSizeMode: Text.Fit
            opacity: enabled ? 1.0 : 0.3
            color: (btn.highlighted)?("white"):("grey")
            horizontalAlignment: Text.AlignHCenter
            verticalAlignment: Text.AlignVCenter
            elide: Text.ElideRight
        }

        MouseArea {
            id: zone
            anchors.fill: parent
            enabled: parent.enabled
            property bool locked: false

            onClicked: {
                if(zone.locked)
                    zone.locked = false
                else
                    xdgEntries.start(entryItem.xdgPath)
            }


            Timer {
                id: longPressTimer

                interval: 1000
                repeat: false
                running: false

                onTriggered: {
                    xdgEntries.stop(entryItem.xdgPath)
                    zone.locked = true
                }
            }

            onPressedChanged: {
                if ( pressed ) {
                    longPressTimer.running = true;
                } else {
                    longPressTimer.running = false;
                }
            }
        }
    }
}