aboutsummaryrefslogtreecommitdiffstats
path: root/HomeScreenNG/qml/ShortcutArea.qml
blob: a98bec241862d120f1f9b21cc0dd3aff33538969 (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
import QtQuick 2.7
import QtQuick.Layouts 1.1
import HomeScreen 1.0

Item {
    id: root
    width: 785
    height: 218

    ApplicationLauncher {
        id: launcher
    }

    ListModel {
        id: applicationModel
        ListElement {
            name: 'Home'
            application: 'launcher'
        }
        ListElement {
            name: 'Multimedia'
            application: 'musicplayer'
        }
        ListElement {
            name: 'HVAC'
            application: 'hvac'
        }
        ListElement {
            name: 'Navigation'
            application: 'navigation'
        }
    }

    property int currentIndex: -1 // TODO: to be moved to whereever right

    RowLayout {
        anchors.fill: parent
        spacing: 2
        Repeater {
            model: applicationModel
            delegate: ShortcutIcon {
                Layout.fillWidth: true
                Layout.fillHeight: true
                name: model.name
                active: model.index === root.currentIndex
                onClicked: {
                    root.currentIndex = active ? -1 : model.index
                    launcher.launch(model.application)
                }
            }
        }
    }
}