summaryrefslogtreecommitdiff
path: root/kodereviewer/qml/CommentDelegate.qml
diff options
context:
space:
mode:
Diffstat (limited to 'kodereviewer/qml/CommentDelegate.qml')
-rw-r--r--kodereviewer/qml/CommentDelegate.qml77
1 files changed, 77 insertions, 0 deletions
diff --git a/kodereviewer/qml/CommentDelegate.qml b/kodereviewer/qml/CommentDelegate.qml
new file mode 100644
index 0000000..bac75d0
--- /dev/null
+++ b/kodereviewer/qml/CommentDelegate.qml
@@ -0,0 +1,77 @@
+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
+ }
+ QQC2.Label {
+ Layout.fillWidth: true
+ text: root.body
+ textFormat: Text.MarkdownText
+ wrapMode: Text.WordWrap
+ }
+ }
+ }
+}