blob: 536fada972642f7ee86de4599aa3fdb89dab33db (
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
76
77
78
79
80
81
82
83
84
85
86
87
|
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
signal quote(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: i18n("Quote")
icon.name: "format-text-blockquote-symbolic"
onTriggered: {
root.quote(root.quoteText())
}
}
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
}
}
}
function quoteText() {
return root.body.split("\n").map((line) => "> " + line).join("\n")
}
}
|