summaryrefslogtreecommitdiff
path: root/kodereviewer/qml/CommentDelegate.qml
blob: 3b2681b67ed589367fcbc6d8bb2e2c7cc674a523 (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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
import QtQml
import QtQuick 6.7
import QtQuick.Layouts 6.7
import QtQuick.Controls 6.7 as QQC2

import org.kde.kirigami as Kirigami
import org.kde.kirigamiaddons.components as KirigamiComponents

Kirigami.AbstractCard {
    id: root
    required property url avatarUrl
    required property string createdAt
    required property string username
    required property string body

    header: RowLayout {
        KirigamiComponents.Avatar {
            name: root.username
            source: root.avatarUrl
            Layout.preferredWidth: Kirigami.Units.iconSizes.smallMedium
            Layout.preferredHeight: Kirigami.Units.iconSizes.smallMedium
        }
        Kirigami.Heading {
            Layout.fillWidth: true
            id: commentHeading
            level: 3
            text: `@${root.username}`
        }
        QQC2.Label {
            text: new Date(root.createdAt).toLocaleString(Qt.locale(), Locale.ShortFormat)
        }
        Kirigami.ActionToolBar {
            Layout.fillWidth: false
            actions: [
                Kirigami.Action {
                    icon.name: "overflow-menu"

                    Kirigami.Action {
                        text: "Edit"
                        icon.name: "edit-comment"
                    }

                    Kirigami.Action {
                        text: "Delete"
                        icon.name: "delete-comment"
                    }
                }
            ]

            position: QQC2.ToolBar.Header
        }
    }

    contentItem: Item {
        implicitWidth: delegateLayout.implicitWidth
        implicitHeight: delegateLayout.implicitHeight
        ColumnLayout {
            id: delegateLayout
            spacing: Kirigami.Units.largeSpacing
            anchors {
                top: parent.top
                left: parent.left
                right: parent.right
            }

            Kirigami.Separator {
                Layout.fillWidth: true
            }
            MarkdownLabel {
                Layout.fillWidth: true
                text: root.body
            }
        }
    }
}