aboutsummaryrefslogtreecommitdiffstats
path: root/homescreen/qml/IconItem.qml
blob: 32d37b4c2c84235d7393334a1d6b5791b755da4a (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
import QtQuick 2.0
import QtQuick.Controls 2.0

Item {
    id: main
    Image {
        id: item; parent: loc
        x: main.x + 5; y: main.y + 5
        width: main.width - 10; height: main.height - 10;

        Label {
            id: title
            y: 60
            font.pixelSize: 125
            anchors.horizontalCenter: parent.horizontalCenter
            color: "#5CFE96"
            text: model.icon == 'Blank' ? model.name.substring(0,1).toUpperCase() : ''
        }

        Label {
            id: name
            y: 245
            width: main.width - 10
            font.pixelSize: 25
            font.letterSpacing: 5
            wrapMode: Text.WordWrap
            anchors.horizontalCenter: parent.horizontalCenter
            horizontalAlignment: Text.AlignHCenter
            color: "white"
            text: model.icon == 'Blank' ? model.name.toUpperCase() : ''
        }

        source: './images/HMI_AppLauncher_%1_%2-01.png'.arg(model.icon).arg(loc.pressed && (loc.index === model.index || loc.currentId === model.id) ? 'Active' : 'Inactive')
        antialiasing: item.state !== ''
        Behavior on x { enabled: item.state !== 'active'; NumberAnimation { duration: 400; easing.type: Easing.OutCubic } }
        Behavior on y { enabled: item.state !== 'active'; NumberAnimation { duration: 400; easing.type: Easing.OutCubic } }
        SequentialAnimation on rotation {
            NumberAnimation { to:  5; duration: 100 }
            NumberAnimation { to: -5; duration: 200 }
            NumberAnimation { to:  0; duration: 100 }
            running: loc.currentId !== '' && item.state !== 'active'
            loops: Animation.Infinite; alwaysRunToEnd: true
        }
        states: [
            State {
                name: 'active'
                when: loc.currentId == model.id
                PropertyChanges { target: item; x: loc.mouseX - width/2; y: loc.mouseY - height/2; scale: 1.15; z: 10 }
            },
            State {
                when: loc.currentId !== ''
                PropertyChanges {
                    target: item
                    scale: 0.85
                    opacity: 0.75
                }
            }
        ]
        transitions: Transition { NumberAnimation { properties: 'scale, opacity, x, y'; duration: 150; easing.type: Easing.OutCubic} }
    }
}