Debian Codegraph @

resources/qml/delegates/Reply.qml

raw ◀ ▶
1 Debian patch touch this file
1 // SPDX-FileCopyrightText: Nheko Contributors
2 //
3 // SPDX-License-Identifier: GPL-3.0-or-later
4
5 import QtQuick
6 import QtQuick.Controls
7 import QtQuick.Window
•8 import QtQuick.Layouts
9 import im.nheko
10 import "../"
11
12 AbstractButton {
13 id: r
14
15 property color userColor: "red"
16 property bool keepFullText: false
17
18 required property string eventId
19
20 property var room_: room
21
22 property string userId: eventId ? room.dataById(eventId, Room.UserId, "") : ""
23 property string userName: eventId ? room.dataById(eventId, Room.UserName, "") : ""
24 implicitHeight: replyContainer.height
•25 implicitWidth: replyContainer.implicitWidth + leftPadding + rightPadding
26
27 leftPadding: 4 + Nheko.paddingSmall
28 rightPadding: Nheko.paddingSmall
29
30 required property int maxWidth
31 property bool limitHeight: false
32
33 NhekoCursorShape {
34 anchors.fill: parent
35 cursorShape: Qt.PointingHandCursor
36 }
37
38 onClicked: {
•39 let link = timelineEvent.main.linkAt != undefined && timelineEvent.main.linkAt(pressX-colorline.width, pressY - userName_.implicitHeight);
40 if (link) {
41 Nheko.openLink(link)
42 } else {
43 room.showEvent(r.eventId)
44 }
45 }
•46 onPressAndHold: replyContextMenu.show(timelineEvent.main.copyText, timelineEvent.main.linkAt(pressX-colorline.width, pressY - userName_.implicitHeight), r.eventId)
47
48 contentItem: TimelineEvent {
49 id: timelineEvent
50
51 isStateEvent: false
52 room: r.room_
53 eventId: r.eventId
54 replyTo: ""
55 mainInset: 4 + Nheko.paddingMedium
56 maxWidth: r.maxWidth
57 limitAsReply: r.limitHeight
58
•59 data: Column {
60 id: replyContainer
•61 spacing: 0
62
63 clip: r.limitHeight
64
65 height: r.limitHeight ? Math.min( timelineEvent.main?.height, timelineView.height / 10) + Nheko.paddingSmall + usernameBtn.height : undefined
66
•67 // FIXME: I have no idea, why this name doesn't render in the reply popup on Qt 6.9.2
68 AbstractButton {
69 id: usernameBtn
70
71 visible: r.eventId
72
73 contentItem: Label {
74 visible: r.eventId
75 id: userName_
76 text: r.userName
77 color: r.userColor
78 textFormat: Text.RichText
79 width: timelineEvent.main?.width
80 }
•81 onClicked: room.openUserProfile(r.userId)
82 }
83
•84 data: [
85 usernameBtn, timelineEvent.main,
86 ]
87 }
•88
89 }
90
91 background: Rectangle {
92 id: backgroundItem
93
94 z: -1
95 property color userColor: TimelineManager.userColor(r.userId, palette.base)
96 property color bgColor: palette.base
97 color: Qt.tint(bgColor, Qt.hsla(userColor.hslHue, 0.5, userColor.hslLightness, 0.1))
•98
99 Rectangle {
100 anchors.top: parent.top
101 anchors.bottom: parent.bottom
102 anchors.left: parent.left
103
104 id: colorline
105 color: backgroundItem.userColor
106 width: 4
107 }
108 }
109
110 }