summary refs log tree commit diff
path: root/resources/qml/StatusIndicator.qml
blob: 739cc0072dc0b95d05722d965cb2c89aa81158fa (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
// SPDX-FileCopyrightText: 2021 Nheko Contributors
//
// SPDX-License-Identifier: GPL-3.0-or-later

import QtQuick 2.5
import QtQuick.Controls 2.1
import im.nheko 1.0

ImageButton {
    id: indicator

    width: 16
    height: 16
    hoverEnabled: true
    changeColorOnHover: (model.state == MtxEvent.Read)
    cursor: (model.state == MtxEvent.Read) ? Qt.PointingHandCursor : Qt.ArrowCursor
    ToolTip.visible: hovered && model.state != MtxEvent.Empty
    ToolTip.text: {
        switch (model.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 "";
        }
    }
    onClicked: {
        if (model.state == MtxEvent.Read)
            room.readReceiptsAction(model.id);

    }
    image: {
        switch (model.state) {
        case MtxEvent.Failed:
            return ":/icons/icons/ui/remove-symbol.png";
        case MtxEvent.Sent:
            return ":/icons/icons/ui/clock.png";
        case MtxEvent.Received:
            return ":/icons/icons/ui/checkmark.png";
        case MtxEvent.Read:
            return ":/icons/icons/ui/double-tick-indicator.png";
        default:
            return "";
        }
    }
}