summary refs log tree commit diff
path: root/resources/qml/StatusIndicator.qml
blob: 0b18b8880227efe357e8c23cb4d27be15f653d21 (plain) (blame)
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
import QtQuick 2.5
import QtQuick.Controls 2.1
import im.nheko 1.0

Rectangle {
    id: indicator

    property int state: 0

    color: "transparent"
    width: 16
    height: 16
    ToolTip.visible: ma.containsMouse && state != MtxEvent.Empty
    ToolTip.text: {
        switch (state) {
        case MtxEvent.Failed:
            return qsTr("Failed");
        case MtxEvent.Sent:
            return qsTr("Sent");
        case MtxEvent.Received:
            return qsTr("Received");
        case MtxEvent.Read:
            return qsTr("Read");
        default:
            return "";
        }
    }

    MouseArea {
        id: ma

        anchors.fill: parent
        hoverEnabled: true
    }

    Image {
        id: stateImg

        // Workaround, can't get icon.source working for now...
        anchors.fill: parent
        source: {
            switch (indicator.state) {
            case MtxEvent.Failed:
                return "image://colorimage/:/icons/icons/ui/remove-symbol.png?" + colors.buttonText;
            case MtxEvent.Sent:
                return "image://colorimage/:/icons/icons/ui/clock.png?" + colors.buttonText;
            case MtxEvent.Received:
                return "image://colorimage/:/icons/icons/ui/checkmark.png?" + colors.buttonText;
            case MtxEvent.Read:
                return "image://colorimage/:/icons/icons/ui/double-tick-indicator.png?" + colors.buttonText;
            default:
                return "";
            }
        }
    }

}