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

import "./components"
import "./delegates"
import "./emoji"
import "./ui"
import "./dialogs"
import Qt.labs.platform 1.1 as Platform
import QtQuick
import QtQuick.Controls
import QtQuick.Layouts
import QtQuick.Window
import im.nheko

RowLayout {
    id: metadata

    property int iconSize: Math.floor(fontMetrics.ascent * scaling)
    required property double scaling

    required property string eventId
    required property int status
    required property int trustlevel
    required property bool isEdited
    required property bool isEncrypted
    required property string threadId
    required property date timestamp
    required property Room room

    spacing: 2

    StatusIndicator {
        Layout.alignment: Qt.AlignRight | Qt.AlignVCenter
        eventId: metadata.eventId
        height: parent.iconSize
        status: metadata.status
        width: parent.iconSize
    }
    Image {
        Layout.alignment: Qt.AlignRight | Qt.AlignVCenter
        ToolTip.delay: Nheko.tooltipDelay
        ToolTip.text: qsTr("Edited")
        ToolTip.visible: editHovered.hovered
        height: parent.iconSize
        source: "image://colorimage/:/icons/icons/ui/edit.svg?" + ((metadata.eventId == metadata.room.edit) ? palette.highlight : palette.buttonText)
        sourceSize.height: parent.iconSize * Screen.devicePixelRatio
        sourceSize.width: parent.iconSize * Screen.devicePixelRatio
        visible: metadata.isEdited || metadata.eventId == metadata.room.edit
        width: parent.iconSize
        Layout.preferredWidth: parent.iconSize
        Layout.preferredHeight: parent.iconSize
        HoverHandler {
            id: editHovered

        }
    }
    ImageButton {
        Layout.alignment: Qt.AlignRight | Qt.AlignVCenter
        ToolTip.delay: Nheko.tooltipDelay
        ToolTip.text: qsTr("Part of a thread")
        ToolTip.visible: hovered
        buttonTextColor: TimelineManager.userColor(metadata.threadId, palette.base)
        height: parent.iconSize
        image: ":/icons/icons/ui/thread.svg"
        visible: metadata.threadId
        width: parent.iconSize

        onClicked: metadata.room.thread = threadId
    }
    EncryptionIndicator {
        Layout.alignment: Qt.AlignRight | Qt.AlignVCenter
        encrypted: metadata.isEncrypted
        height: parent.iconSize
        sourceSize.height: parent.iconSize * Screen.devicePixelRatio
        sourceSize.width: parent.iconSize * Screen.devicePixelRatio
        trust: metadata.trustlevel
        visible: metadata.room.isEncrypted
        width: parent.iconSize
        Layout.preferredWidth: parent.iconSize
        Layout.preferredHeight: parent.iconSize
    }
    Label {
        id: ts

        Layout.alignment: Qt.AlignRight | Qt.AlignTop
        Layout.preferredWidth: implicitWidth
        ToolTip.delay: Nheko.tooltipDelay
        ToolTip.text: Qt.formatDateTime(metadata.timestamp, Qt.DefaultLocaleLongDate)
        ToolTip.visible: ma.hovered
        color: palette.inactive.text
        font.pointSize: fontMetrics.font.pointSize * parent.scaling
        text: metadata.timestamp.toLocaleTimeString(Locale.ShortFormat)

        HoverHandler {
            id: ma

        }
    }
}