| 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 im.nheko |
| 9 |
import "../" |
| 10 |
|
| 11 |
AbstractButton { |
| 12 |
id: r |
| 13 |
|
| 14 |
property color userColor: "red" |
| 15 |
property bool keepFullText: false |
| 16 |
|
| 17 |
required property string eventId |
| 18 |
|
| 19 |
property var room_: room |
| 20 |
|
| 21 |
property string userId: eventId ? room.dataById(eventId, Room.UserId, "") : "" |
| 22 |
property string userName: eventId ? room.dataById(eventId, Room.UserName, "") : "" |
| 23 |
implicitHeight: replyContainer.height |
| 24 |
implicitWidth: replyContainer.implicitWidth |
| 25 |
required property int maxWidth |
| 26 |
property bool limitHeight: false |
| 27 |
|
| 28 |
NhekoCursorShape { |
| 29 |
anchors.fill: parent |
| 30 |
cursorShape: Qt.PointingHandCursor |
| 31 |
} |
| 32 |
|
| 33 |
onClicked: { |
| 34 |
let link = reply.child.linkAt != undefined && reply.child.linkAt(pressX-colorline.width, pressY - userName_.implicitHeight); |
| 35 |
if (link) { |
| 36 |
Nheko.openLink(link) |
| 37 |
} else { |
| 38 |
room.showEvent(r.eventId) |
| 39 |
} |
| 40 |
} |
| 41 |
onPressAndHold: replyContextMenu.show(reply.child.copyText, reply.child.linkAt(pressX-colorline.width, pressY - userName_.implicitHeight), r.eventId) |
| 42 |
|
| 43 |
contentItem: TimelineEvent { |
| 44 |
id: timelineEvent |
| 45 |
|
| 46 |
isStateEvent: false |
| 47 |
room: r.room_ |
| 48 |
eventId: r.eventId |
| 49 |
replyTo: "" |
| 50 |
mainInset: 4 + Nheko.paddingMedium |
| 51 |
maxWidth: r.maxWidth |
| 52 |
limitAsReply: r.limitHeight |
| 53 |
|
| 54 |
//height: replyContainer.implicitHeight |
| 55 |
data: Row { |
| 56 |
id: replyContainer |
| 57 |
|
| 58 |
spacing: Nheko.paddingSmall |
| 59 |
|
| 60 |
clip: r.limitHeight |
| 61 |
|
| 62 |
height: r.limitHeight ? Math.min( timelineEvent.main?.height, timelineView.height / 10) + Nheko.paddingSmall + usernameBtn.height : undefined |
| 63 |
|
| 64 |
Rectangle { |
| 65 |
id: colorline |
| 66 |
|
| 67 |
width: 4 |
| 68 |
height: content.height |
| 69 |
|
| 70 |
color: TimelineManager.userColor(r.userId, palette.base) |
| 71 |
} |
| 72 |
|
| 73 |
Column { |
| 74 |
id: content |
| 75 |
spacing: 0 |
| 76 |
|
| 77 |
AbstractButton { |
| 78 |
id: usernameBtn |
| 79 |
|
| 80 |
|
| 81 |
contentItem: Label { |
| 82 |
id: userName_ |
| 83 |
text: r.userName |
| 84 |
color: r.userColor |
| 85 |
textFormat: Text.RichText |
| 86 |
width: timelineEvent.main?.width |
| 87 |
} |
| 88 |
onClicked: room.openUserProfile(r.userId) |
| 89 |
} |
| 90 |
|
| 91 |
data: [ |
| 92 |
usernameBtn, timelineEvent.main, |
| 93 |
] |
| 94 |
} |
| 95 |
|
| 96 |
} |
| 97 |
} |
| 98 |
|
| 99 |
background: Rectangle { |
| 100 |
id: backgroundItem |
| 101 |
|
| 102 |
z: -1 |
| 103 |
property color userColor: TimelineManager.userColor(r.userId, palette.base) |
| 104 |
property color bgColor: palette.base |
| 105 |
color: Qt.tint(bgColor, Qt.hsla(userColor.hslHue, 0.5, userColor.hslLightness, 0.1)) |
| 106 |
} |
| 107 |
|
| 108 |
} |