| 1 |
// SPDX-FileCopyrightText: Nheko Contributors |
| 2 |
// |
| 3 |
// SPDX-License-Identifier: GPL-3.0-or-later |
| 4 |
|
| 5 |
import "./ui" |
| 6 |
import "./dialogs" |
| 7 |
import QtQuick 2.15 |
| 8 |
import QtQuick.Controls 2.15 |
| 9 |
import QtQuick.Layouts 1.2 |
| 10 |
import QtQuick.Window 2.13 |
| 11 |
import im.nheko 1.0 |
| 12 |
|
| 13 |
Item { |
| 14 |
id: chatRoot |
| 15 |
|
| 16 |
property int availableWidth: width |
| 17 |
property int padding: Nheko.paddingMedium |
| 18 |
property string searchString: "" |
| 19 |
property Room roommodel: room |
| 20 |
|
| 21 |
// HACK: https://bugreports.qt.io/browse/QTBUG-83972, qtwayland cannot auto hide menu |
| 22 |
Connections { |
| 23 |
function onHideMenu() { |
| 24 |
messageContextMenuC.close(); |
| 25 |
replyContextMenuC.close(); |
| 26 |
} |
| 27 |
|
| 28 |
target: MainWindow |
| 29 |
} |
| 30 |
|
| 31 |
Connections { |
| 32 |
function onScrollToIndex(index) { |
| 33 |
chat.positionViewAtIndex(index, ListView.Center); |
| 34 |
chat.updateLastScroll(); |
| 35 |
} |
| 36 |
|
| 37 |
target: room |
| 38 |
} |
| 39 |
|
| 40 |
ScrollBar { |
| 41 |
id: scrollbar |
| 42 |
|
| 43 |
anchors.bottom: parent.bottom |
| 44 |
anchors.right: parent.right |
| 45 |
anchors.top: parent.top |
| 46 |
parent: chat.parent |
| 47 |
} |
| 48 |
ListView { |
| 49 |
id: chat |
| 50 |
|
| 51 |
property int delegateMaxWidth: ((Settings.timelineMaxWidth > 100 && Settings.timelineMaxWidth < chatRoot.availableWidth) ? Settings.timelineMaxWidth : chatRoot.availableWidth) - chatRoot.padding * 2 - (scrollbar.interactive ? scrollbar.width : 0) |
| 52 |
readonly property alias filteringInProgress: filteredTimeline.filteringInProgress |
| 53 |
|
| 54 |
ScrollBar.vertical: scrollbar |
| 55 |
anchors.fill: parent |
| 56 |
anchors.rightMargin: scrollbar.interactive ? scrollbar.width : 0 |
| 57 |
// reuseItems still has a few bugs, see https://bugreports.qt.io/browse/QTBUG-95105 https://bugreports.qt.io/browse/QTBUG-95107 |
| 58 |
//onModelChanged: if (room) room.sendReset() |
| 59 |
//reuseItems: true |
| 60 |
boundsBehavior: Flickable.StopAtBounds |
| 61 |
displayMarginBeginning: height / 4 |
| 62 |
displayMarginEnd: height / 4 |
| 63 |
model: (filteredTimeline.filterByThread || filteredTimeline.filterByContent) ? filteredTimeline : room |
| 64 |
//pixelAligned: true |
| 65 |
spacing: 2 |
| 66 |
verticalLayoutDirection: ListView.BottomToTop |
| 67 |
|
| 68 |
property int lastScrollPos: 0 |
| 69 |
|
| 70 |
// Fixup the scroll position when the height changes. Without this, the view is kept around the center of the currently visible content, while we usually want to stick to the bottom. |
| 71 |
function updateLastScroll() { |
| 72 |
lastScrollPos = (contentY+height); |
| 73 |
} |
| 74 |
onMovementEnded: updateLastScroll() |
| 75 |
onModelChanged: updateLastScroll() |
| 76 |
onHeightChanged: contentY = (lastScrollPos-height) |
| 77 |
|
| 78 |
Component { |
| 79 |
id: defaultMessageStyle |
| 80 |
|
| 81 |
TimelineDefaultMessageStyle { |
| 82 |
messageActions: messageActionsC |
| 83 |
messageContextMenu: messageContextMenuC |
| 84 |
replyContextMenu: replyContextMenuC |
| 85 |
scrolledToThis: eventId === room.scrollTarget && (y + height > chat.y + chat.contentY && y < chat.y + chat.height + chat.contentY) |
| 86 |
data: [ |
| 87 |
Connections { |
| 88 |
function onMovementEnded() { |
| 89 |
if (y + height + 2 * chat.spacing > chat.contentY + chat.height && y < chat.contentY + chat.height) { |
| 90 |
room.currentIndex = index; |
| 91 |
} |
| 92 |
} |
| 93 |
target: chat |
| 94 |
} |
| 95 |
] |
| 96 |
} |
| 97 |
} |
| 98 |
Component { |
| 99 |
id: bubbleMessageStyle |
| 100 |
|
| 101 |
TimelineBubbleMessageStyle { |
| 102 |
messageActions: messageActionsC |
| 103 |
messageContextMenu: messageContextMenuC |
| 104 |
replyContextMenu: replyContextMenuC |
| 105 |
scrolledToThis: eventId === room.scrollTarget && (y + height > chat.y + chat.contentY && y < chat.y + chat.height + chat.contentY) |
| 106 |
data: [ |
| 107 |
Connections { |
| 108 |
function onMovementEnded() { |
| 109 |
if (y + height + 2 * chat.spacing > chat.contentY + chat.height && y < chat.contentY + chat.height) { |
| 110 |
room.currentIndex = index; |
| 111 |
} |
| 112 |
} |
| 113 |
target: chat |
| 114 |
} |
| 115 |
] |
| 116 |
} |
| 117 |
} |
| 118 |
|
| 119 |
delegate: Settings.bubbles ? bubbleMessageStyle : defaultMessageStyle |
| 120 |
footer: Item { |
| 121 |
width: chat.delegateMaxWidth |
| 122 |
// hacky, but works |
| 123 |
height: loadingSpinner.height + 2 * Nheko.paddingLarge |
| 124 |
visible: (room && room.paginationInProgress) || chat.filteringInProgress |
| 125 |
|
| 126 |
Spinner { |
| 127 |
id: loadingSpinner |
| 128 |
|
| 129 |
anchors.centerIn: parent |
| 130 |
anchors.margins: Nheko.paddingLarge |
| 131 |
foreground: palette.mid |
| 132 |
running: (room && room.paginationInProgress) || chat.filteringInProgress |
| 133 |
z: 3 |
| 134 |
} |
| 135 |
} |
| 136 |
|
| 137 |
Window.onActiveChanged: readTimer.running = Window.active |
| 138 |
onCountChanged: { |
| 139 |
// Mark timeline as read |
| 140 |
if (atYEnd && room) |
| 141 |
model.currentIndex = 0; |
| 142 |
} |
| 143 |
|
| 144 |
TimelineFilter { |
| 145 |
id: filteredTimeline |
| 146 |
|
| 147 |
filterByContent: chatRoot.searchString |
| 148 |
filterByThread: room ? room.thread : "" |
| 149 |
source: room |
| 150 |
} |
| 151 |
Control { |
| 152 |
id: messageActionsC |
| 153 |
|
| 154 |
property Item attached: null |
| 155 |
// use comma to update on scroll |
| 156 |
property alias model: row.model |
| 157 |
|
| 158 |
hoverEnabled: true |
| 159 |
padding: Nheko.paddingSmall |
| 160 |
visible: Settings.buttonsInTimeline && !!attached && (attached.hovered || hovered) |
| 161 |
z: 10 |
| 162 |
parent: chat.contentItem |
| 163 |
anchors.bottom: attached?.top |
| 164 |
anchors.right: attached?.right |
| 165 |
|
| 166 |
background: Rectangle { |
| 167 |
border.color: palette.buttonText |
| 168 |
border.width: 1 |
| 169 |
color: palette.window |
| 170 |
radius: padding |
| 171 |
} |
| 172 |
contentItem: RowLayout { |
| 173 |
id: row |
| 174 |
|
| 175 |
property var model |
| 176 |
|
| 177 |
spacing: messageActionsC.padding |
| 178 |
|
| 179 |
Repeater { |
| 180 |
model: Settings.recentReactions |
| 181 |
visible: room ? room.permissions.canSend(MtxEvent.Reaction) : false |
| 182 |
|
| 183 |
delegate: AbstractButton { |
| 184 |
id: button |
| 185 |
|
| 186 |
property color buttonTextColor: palette.buttonText |
| 187 |
property color highlightColor: palette.highlight |
| 188 |
required property string modelData |
| 189 |
property bool showImage: modelData.startsWith("mxc://") |
| 190 |
|
| 191 |
//Layout.preferredHeight: fontMetrics.height |
| 192 |
Layout.alignment: Qt.AlignBottom |
| 193 |
focusPolicy: Qt.NoFocus |
| 194 |
height: showImage ? 16 : buttonText.implicitHeight |
| 195 |
implicitHeight: showImage ? 16 : buttonText.implicitHeight |
| 196 |
implicitWidth: showImage ? 16 : buttonText.implicitWidth |
| 197 |
width: showImage ? 16 : buttonText.implicitWidth |
| 198 |
|
| 199 |
onClicked: { |
| 200 |
room.input.reaction(row.model.eventId, modelData); |
| 201 |
TimelineManager.focusMessageInput(); |
| 202 |
} |
| 203 |
|
| 204 |
Label { |
| 205 |
id: buttonText |
| 206 |
|
| 207 |
anchors.centerIn: parent |
| 208 |
color: button.hovered ? button.highlightColor : button.buttonTextColor |
| 209 |
font.family: Settings.emojiFont != "" ? Settings.emojiFont : undefined |
| 210 |
horizontalAlignment: Text.AlignHCenter |
| 211 |
padding: 0 |
| 212 |
text: TimelineManager.htmlEscape(button.modelData) |
| 213 |
verticalAlignment: Text.AlignVCenter |
| 214 |
visible: !button.showImage |
| 215 |
} |
| 216 |
Image { |
| 217 |
// Workaround, can't get icon.source working for now... |
| 218 |
anchors.fill: parent |
| 219 |
fillMode: Image.PreserveAspectFit |
| 220 |
source: button.showImage ? (button.modelData.replace("mxc://", "image://MxcImage/") + "?scale") : "" |
| 221 |
sourceSize.height: button.height |
| 222 |
sourceSize.width: button.width |
| 223 |
} |
| 224 |
NhekoCursorShape { |
| 225 |
anchors.fill: parent |
| 226 |
cursorShape: Qt.PointingHandCursor |
| 227 |
} |
| 228 |
Ripple { |
| 229 |
color: Qt.rgba(buttonTextColor.r, buttonTextColor.g, buttonTextColor.b, 0.5) |
| 230 |
} |
| 231 |
} |
| 232 |
} |
| 233 |
ImageButton { |
| 234 |
ToolTip.delay: Nheko.tooltipDelay |
| 235 |
ToolTip.text: qsTr("Edit") |
| 236 |
ToolTip.visible: hovered |
| 237 |
buttonTextColor: palette.buttonText |
| 238 |
hoverEnabled: true |
| 239 |
image: ":/icons/icons/ui/edit.svg" |
| 240 |
visible: !!row.model && row.model.isEditable |
| 241 |
Layout.preferredWidth: 16 |
| 242 |
|
| 243 |
onClicked: { |
| 244 |
if (row.model.isEditable) |
| 245 |
room.edit = row.model.eventId; |
| 246 |
} |
| 247 |
} |
| 248 |
ImageButton { |
| 249 |
id: reactButton |
| 250 |
|
| 251 |
ToolTip.delay: Nheko.tooltipDelay |
| 252 |
ToolTip.text: qsTr("React") |
| 253 |
ToolTip.visible: hovered |
| 254 |
hoverEnabled: true |
| 255 |
image: ":/icons/icons/ui/smile-add.svg" |
| 256 |
visible: room ? room.permissions.canSend(MtxEvent.Reaction) : false |
| 257 |
Layout.preferredWidth: 16 |
| 258 |
|
| 259 |
onClicked: emojiPopup.visible ? emojiPopup.close() : emojiPopup.show(reactButton, room.roomId, function (plaintext, markdown) { |
| 260 |
var event_id = row.model ? row.model.eventId : ""; |
| 261 |
room.input.reaction(event_id, plaintext); |
| 262 |
TimelineManager.focusMessageInput(); |
| 263 |
}) |
| 264 |
} |
| 265 |
ImageButton { |
| 266 |
ToolTip.delay: Nheko.tooltipDelay |
| 267 |
ToolTip.text: (row.model && row.model.threadId) ? qsTr("Reply in thread") : qsTr("New thread") |
| 268 |
ToolTip.visible: hovered |
| 269 |
hoverEnabled: true |
| 270 |
image: (row.model && row.model.threadId) ? ":/icons/icons/ui/thread.svg" : ":/icons/icons/ui/new-thread.svg" |
| 271 |
visible: room ? room.permissions.canSend(MtxEvent.TextMessage) : false |
| 272 |
Layout.preferredWidth: 16 |
| 273 |
|
| 274 |
onClicked: room.thread = (row.model.threadId || row.model.eventId) |
| 275 |
} |
| 276 |
ImageButton { |
| 277 |
ToolTip.delay: Nheko.tooltipDelay |
| 278 |
ToolTip.text: qsTr("Reply") |
| 279 |
ToolTip.visible: hovered |
| 280 |
hoverEnabled: true |
| 281 |
image: ":/icons/icons/ui/reply.svg" |
| 282 |
visible: room ? room.permissions.canSend(MtxEvent.TextMessage) : false |
| 283 |
Layout.preferredWidth: 16 |
| 284 |
|
| 285 |
onClicked: room.reply = row.model.eventId |
| 286 |
} |
| 287 |
ImageButton { |
| 288 |
ToolTip.delay: Nheko.tooltipDelay |
| 289 |
ToolTip.text: qsTr("Go to message") |
| 290 |
ToolTip.visible: hovered |
| 291 |
buttonTextColor: palette.buttonText |
| 292 |
hoverEnabled: true |
| 293 |
image: ":/icons/icons/ui/go-to.svg" |
| 294 |
visible: !!row.model && filteredTimeline.filterByContent |
| 295 |
Layout.preferredWidth: 16 |
| 296 |
|
| 297 |
onClicked: { |
| 298 |
topBar.searchString = ""; |
| 299 |
room.showEvent(row.model.eventId); |
| 300 |
} |
| 301 |
} |
| 302 |
ImageButton { |
| 303 |
id: optionsButton |
| 304 |
|
| 305 |
ToolTip.delay: Nheko.tooltipDelay |
| 306 |
ToolTip.text: qsTr("Options") |
| 307 |
ToolTip.visible: hovered |
| 308 |
hoverEnabled: true |
| 309 |
image: ":/icons/icons/ui/options.svg" |
| 310 |
Layout.preferredWidth: 16 |
| 311 |
|
| 312 |
onClicked: messageContextMenuC.show(row.model.eventId, row.model.threadId, row.model.type, row.model.isSender, row.model.isEncrypted, row.model.isEditable, "", row.model.body, optionsButton) |
| 313 |
} |
| 314 |
} |
| 315 |
} |
| 316 |
Shortcut { |
| 317 |
sequences: [StandardKey.MoveToPreviousPage] |
| 318 |
|
| 319 |
onActivated: { |
| 320 |
chat.contentY = chat.contentY - chat.height * 0.9; |
| 321 |
chat.returnToBounds(); |
| 322 |
} |
| 323 |
} |
| 324 |
Shortcut { |
| 325 |
sequences: [StandardKey.MoveToNextPage] |
| 326 |
|
| 327 |
onActivated: { |
| 328 |
chat.contentY = chat.contentY + chat.height * 0.9; |
| 329 |
chat.returnToBounds(); |
| 330 |
} |
| 331 |
} |
| 332 |
Shortcut { |
| 333 |
sequences: [StandardKey.Cancel] |
| 334 |
|
| 335 |
onActivated: { |
| 336 |
if (room.input.uploads.length > 0) |
| 337 |
room.input.declineUploads(); |
| 338 |
else if (room.reply) |
| 339 |
room.reply = undefined; |
| 340 |
else if (room.edit) |
| 341 |
room.edit = undefined; |
| 342 |
else |
| 343 |
room.thread = undefined; |
| 344 |
TimelineManager.focusMessageInput(); |
| 345 |
} |
| 346 |
} |
| 347 |
|
| 348 |
// These shortcuts use the room timeline because switching to threads and out is annoying otherwise. |
| 349 |
// Better solution welcome. |
| 350 |
Shortcut { |
| 351 |
sequence: "Alt+Up" |
| 352 |
|
| 353 |
onActivated: room.reply = room.indexToId(room.reply ? room.idToIndex(room.reply) + 1 : 0) |
| 354 |
} |
| 355 |
Shortcut { |
| 356 |
sequence: "Alt+Down" |
| 357 |
|
| 358 |
onActivated: { |
| 359 |
var idx = room.reply ? room.idToIndex(room.reply) - 1 : -1; |
| 360 |
room.reply = idx >= 0 ? room.indexToId(idx) : null; |
| 361 |
} |
| 362 |
} |
| 363 |
Shortcut { |
| 364 |
sequence: "Alt+F" |
| 365 |
|
| 366 |
onActivated: { |
| 367 |
if (room.reply) { |
| 368 |
var forwardMess = forwardCompleterComponent.createObject(timelineRoot); |
| 369 |
forwardMess.setMessageEventId(room.reply); |
| 370 |
forwardMess.open(); |
| 371 |
room.reply = null; |
| 372 |
timelineRoot.destroyOnClose(forwardMess); |
| 373 |
} |
| 374 |
} |
| 375 |
} |
| 376 |
Shortcut { |
| 377 |
sequence: "Ctrl+E" |
| 378 |
|
| 379 |
onActivated: { |
| 380 |
room.edit = room.reply; |
| 381 |
} |
| 382 |
} |
| 383 |
Timer { |
| 384 |
id: readTimer |
| 385 |
|
| 386 |
interval: 1000 |
| 387 |
|
| 388 |
// force current read index to update |
| 389 |
onTriggered: { |
| 390 |
if (room) |
| 391 |
room.setCurrentIndex(room.currentIndex); |
| 392 |
} |
| 393 |
} |
| 394 |
} |
| 395 |
Menu { |
| 396 |
id: messageContextMenuC |
| 397 |
|
| 398 |
property string eventId |
| 399 |
property int eventType |
| 400 |
property bool isEditable |
| 401 |
property bool isEncrypted |
| 402 |
property bool isSender |
| 403 |
property string link |
| 404 |
property string text |
| 405 |
property string threadId |
| 406 |
|
| 407 |
function show(eventId_, threadId_, eventType_, isSender_, isEncrypted_, isEditable_, link_, text_, showAt_) { |
| 408 |
eventId = eventId_; |
| 409 |
threadId = threadId_; |
| 410 |
eventType = eventType_; |
| 411 |
isEncrypted = isEncrypted_; |
| 412 |
isEditable = isEditable_; |
| 413 |
isSender = isSender_; |
| 414 |
if (text_) |
| 415 |
text = text_; |
| 416 |
else |
| 417 |
text = ""; |
| 418 |
if (link_) |
| 419 |
link = link_; |
| 420 |
else |
| 421 |
link = ""; |
| 422 |
|
| 423 |
messageActionsCFilter.updateTarget(); |
| 424 |
|
| 425 |
if (showAt_) |
| 426 |
popup(showAt_); |
| 427 |
else |
| 428 |
popup(); |
| 429 |
} |
| 430 |
|
| 431 |
Component { |
| 432 |
id: removeReason |
| 433 |
|
| 434 |
InputDialog { |
| 435 |
id: removeReasonDialog |
| 436 |
|
| 437 |
property string eventId |
| 438 |
|
| 439 |
prompt: qsTr("Enter reason for removal or hit enter for no reason:") |
| 440 |
title: qsTr("Reason for removal") |
| 441 |
|
| 442 |
onAccepted: function (text) { |
| 443 |
room.redactEvent(eventId, text); |
| 444 |
} |
| 445 |
} |
| 446 |
} |
| 447 |
Component { |
| 448 |
id: reportDialog |
| 449 |
|
| 450 |
ReportMessage {} |
| 451 |
} |
| 452 |
|
| 453 |
Component.onCompleted: { |
| 454 |
if (messageContextMenuC.popupType != undefined) { |
| 455 |
messageContextMenuC.popupType = 2; // Popup.Native with fallback on older Qt (<6.8.0) |
| 456 |
} |
| 457 |
} |
| 458 |
|
| 459 |
NhekoMenuVisibilityFilter on contentData { |
| 460 |
id: messageActionsCFilter |
| 461 |
|
| 462 |
Component { |
| 463 |
MenuItem { |
| 464 |
text: qsTr("Go to &message") |
| 465 |
visible: filteredTimeline.filterByContent |
| 466 |
|
| 467 |
onTriggered: function () { |
| 468 |
topBar.searchString = ""; |
| 469 |
room.showEvent(messageContextMenuC.eventId); |
| 470 |
} |
| 471 |
} |
| 472 |
} |
| 473 |
Component { |
| 474 |
MenuItem { |
| 475 |
text: qsTr("&Copy") |
| 476 |
visible: messageContextMenuC.text |
| 477 |
|
| 478 |
onTriggered: Clipboard.text = messageContextMenuC.text |
| 479 |
} |
| 480 |
} |
| 481 |
Component { |
| 482 |
MenuItem { |
| 483 |
text: qsTr("Copy &link location") |
| 484 |
visible: messageContextMenuC.link |
| 485 |
|
| 486 |
onTriggered: Clipboard.text = messageContextMenuC.link |
| 487 |
} |
| 488 |
} |
| 489 |
Component { |
| 490 |
MenuItem { |
| 491 |
id: reactionOption |
| 492 |
|
| 493 |
text: qsTr("Re&act") |
| 494 |
visible: room ? room.permissions.canSend(MtxEvent.Reaction) : false |
| 495 |
|
| 496 |
onTriggered: emojiPopup.visible ? emojiPopup.close() : emojiPopup.show(null, room.roomId, function (plaintext, markdown) { |
| 497 |
room.input.reaction(messageContextMenuC.eventId, plaintext); |
| 498 |
TimelineManager.focusMessageInput(); |
| 499 |
}) |
| 500 |
} |
| 501 |
} |
| 502 |
Component { |
| 503 |
MenuItem { |
| 504 |
text: qsTr("Repl&y") |
| 505 |
visible: room ? room.permissions.canSend(MtxEvent.TextMessage) : false |
| 506 |
|
| 507 |
onTriggered: room.reply = (messageContextMenuC.eventId) |
| 508 |
} |
| 509 |
} |
| 510 |
Component { |
| 511 |
MenuItem { |
| 512 |
text: qsTr("&Edit") |
| 513 |
visible: messageContextMenuC.isEditable && (room ? room.permissions.canSend(MtxEvent.TextMessage) : false) |
| 514 |
|
| 515 |
onTriggered: room.edit = (messageContextMenuC.eventId) |
| 516 |
} |
| 517 |
} |
| 518 |
Component { |
| 519 |
MenuItem { |
| 520 |
text: qsTr("&Thread") |
| 521 |
visible: (room ? room.permissions.canSend(MtxEvent.TextMessage) : false) |
| 522 |
|
| 523 |
onTriggered: room.thread = (messageContextMenuC.threadId || messageContextMenuC.eventId) |
| 524 |
} |
| 525 |
} |
| 526 |
Component { |
| 527 |
MenuItem { |
| 528 |
text: visible && room.pinnedMessages.includes(messageContextMenuC.eventId) ? qsTr("Un&pin") : qsTr("&Pin") |
| 529 |
visible: (room ? room.permissions.canChange(MtxEvent.PinnedEvents) : false) |
| 530 |
|
| 531 |
onTriggered: visible && room.pinnedMessages.includes(messageContextMenuC.eventId) ? room.unpin(messageContextMenuC.eventId) : room.pin(messageContextMenuC.eventId) |
| 532 |
} |
| 533 |
} |
| 534 |
Component { |
| 535 |
MenuItem { |
| 536 |
text: qsTr("&Read receipts") |
| 537 |
|
| 538 |
onTriggered: room.showReadReceipts(messageContextMenuC.eventId) |
| 539 |
} |
| 540 |
} |
| 541 |
Component { |
| 542 |
MenuItem { |
| 543 |
text: qsTr("&Forward") |
| 544 |
visible: messageContextMenuC.eventType == MtxEvent.ImageMessage || messageContextMenuC.eventType == MtxEvent.VideoMessage || messageContextMenuC.eventType == MtxEvent.AudioMessage || messageContextMenuC.eventType == MtxEvent.FileMessage || messageContextMenuC.eventType == MtxEvent.Sticker || messageContextMenuC.eventType == MtxEvent.TextMessage || messageContextMenuC.eventType == MtxEvent.LocationMessage || messageContextMenuC.eventType == MtxEvent.EmoteMessage || messageContextMenuC.eventType == MtxEvent.NoticeMessage |
| 545 |
|
| 546 |
onTriggered: { |
| 547 |
var forwardMess = forwardCompleterComponent.createObject(timelineRoot); |
| 548 |
forwardMess.setMessageEventId(messageContextMenuC.eventId); |
| 549 |
forwardMess.open(); |
| 550 |
timelineRoot.destroyOnClose(forwardMess); |
| 551 |
} |
| 552 |
} |
| 553 |
} |
| 554 |
Component { |
| 555 |
MenuItem { |
| 556 |
text: qsTr("&Mark as read") |
| 557 |
} |
| 558 |
} |
| 559 |
Component { |
| 560 |
MenuItem { |
| 561 |
text: qsTr("View raw message") |
| 562 |
|
| 563 |
onTriggered: room.viewRawMessage(messageContextMenuC.eventId) |
| 564 |
} |
| 565 |
} |
| 566 |
Component { |
| 567 |
MenuItem { |
| 568 |
text: qsTr("View decrypted raw message") |
| 569 |
// TODO(Nico): Fix this still being iterated over, when using keyboard to select options |
| 570 |
visible: messageContextMenuC.isEncrypted |
| 571 |
|
| 572 |
onTriggered: room.viewDecryptedRawMessage(messageContextMenuC.eventId) |
| 573 |
} |
| 574 |
} |
| 575 |
Component { |
| 576 |
MenuItem { |
| 577 |
text: qsTr("Remo&ve message") |
| 578 |
visible: (room ? room.permissions.canRedact() : false) || messageContextMenuC.isSender |
| 579 |
|
| 580 |
onTriggered: function () { |
| 581 |
var dialog = removeReason.createObject(timelineRoot); |
| 582 |
dialog.eventId = messageContextMenuC.eventId; |
| 583 |
dialog.show(); |
| 584 |
dialog.forceActiveFocus(); |
| 585 |
timelineRoot.destroyOnClose(dialog); |
| 586 |
} |
| 587 |
} |
| 588 |
} |
| 589 |
Component { |
| 590 |
MenuItem { |
| 591 |
text: qsTr("Report message") |
| 592 |
onTriggered: function () { |
| 593 |
var dialog = reportDialog.createObject(timelineRoot, {"eventId": messageContextMenuC.eventId}); |
| 594 |
dialog.show(); |
| 595 |
dialog.forceActiveFocus(); |
| 596 |
timelineRoot.destroyOnClose(dialog); |
| 597 |
} |
| 598 |
} |
| 599 |
} |
| 600 |
Component { |
| 601 |
MenuItem { |
| 602 |
text: qsTr("&Save as") |
| 603 |
visible: messageContextMenuC.eventType == MtxEvent.ImageMessage || messageContextMenuC.eventType == MtxEvent.VideoMessage || messageContextMenuC.eventType == MtxEvent.AudioMessage || messageContextMenuC.eventType == MtxEvent.FileMessage || messageContextMenuC.eventType == MtxEvent.Sticker |
| 604 |
|
| 605 |
onTriggered: room.saveMedia(messageContextMenuC.eventId) |
| 606 |
} |
| 607 |
} |
| 608 |
Component { |
| 609 |
MenuItem { |
| 610 |
text: qsTr("&Open in external program") |
| 611 |
visible: messageContextMenuC.eventType == MtxEvent.ImageMessage || messageContextMenuC.eventType == MtxEvent.VideoMessage || messageContextMenuC.eventType == MtxEvent.AudioMessage || messageContextMenuC.eventType == MtxEvent.FileMessage || messageContextMenuC.eventType == MtxEvent.Sticker |
| 612 |
|
| 613 |
onTriggered: room.openMedia(messageContextMenuC.eventId) |
| 614 |
} |
| 615 |
} |
| 616 |
Component { |
| 617 |
MenuItem { |
| 618 |
text: qsTr("Copy link to eve&nt") |
| 619 |
visible: messageContextMenuC.eventId |
| 620 |
|
| 621 |
onTriggered: room.copyLinkToEvent(messageContextMenuC.eventId) |
| 622 |
} |
| 623 |
} |
| 624 |
} |
| 625 |
} |
| 626 |
Component { |
| 627 |
id: forwardCompleterComponent |
| 628 |
|
| 629 |
ForwardCompleter { |
| 630 |
} |
| 631 |
} |
| 632 |
Menu { |
| 633 |
id: replyContextMenuC |
| 634 |
|
| 635 |
property string eventId |
| 636 |
property string link |
| 637 |
property string text |
| 638 |
|
| 639 |
function show(text_, link_, eventId_) { |
| 640 |
text = text_; |
| 641 |
link = link_; |
| 642 |
eventId = eventId_; |
| 643 |
|
| 644 |
replyContextMenuCFilter.updateTarget(); |
| 645 |
popup(); |
| 646 |
} |
| 647 |
|
| 648 |
Component.onCompleted: { |
| 649 |
if (replyContextMenuC.popupType != undefined) { |
| 650 |
replyContextMenuC.popupType = 2; // Popup.Native with fallback on older Qt (<6.8.0) |
| 651 |
} |
| 652 |
} |
| 653 |
|
| 654 |
|
| 655 |
NhekoMenuVisibilityFilter on contentData { |
| 656 |
id: replyContextMenuCFilter |
| 657 |
|
| 658 |
Component { |
| 659 |
MenuItem { |
| 660 |
text: qsTr("&Copy") |
| 661 |
visible: replyContextMenuC.text |
| 662 |
|
| 663 |
onTriggered: Clipboard.text = replyContextMenuC.text |
| 664 |
} |
| 665 |
} |
| 666 |
Component { |
| 667 |
MenuItem { |
| 668 |
text: qsTr("Copy &link location") |
| 669 |
visible: replyContextMenuC.link |
| 670 |
|
| 671 |
onTriggered: Clipboard.text = replyContextMenuC.link |
| 672 |
} |
| 673 |
} |
| 674 |
Component { |
| 675 |
MenuItem { |
| 676 |
text: qsTr("&Go to quoted message") |
| 677 |
visible: true |
| 678 |
|
| 679 |
onTriggered: room.showEvent(replyContextMenuC.eventId) |
| 680 |
} |
| 681 |
} |
| 682 |
} |
| 683 |
} |
| 684 |
RoundButton { |
| 685 |
id: toEndButton |
| 686 |
|
| 687 |
property int fullWidth: 40 |
| 688 |
|
| 689 |
flat: true |
| 690 |
height: width |
| 691 |
hoverEnabled: true |
| 692 |
radius: width / 2 |
| 693 |
width: 0 |
| 694 |
|
| 695 |
background: Rectangle { |
| 696 |
border.color: toEndButton.hovered ? palette.highlight : palette.buttonText |
| 697 |
border.width: 1 |
| 698 |
color: toEndButton.down ? palette.highlight : palette.button |
| 699 |
opacity: enabled ? 1 : 0.3 |
| 700 |
radius: toEndButton.radius |
| 701 |
} |
| 702 |
states: [ |
| 703 |
State { |
| 704 |
name: "" |
| 705 |
|
| 706 |
PropertyChanges { |
| 707 |
toEndButton.width: 0 |
| 708 |
} |
| 709 |
}, |
| 710 |
State { |
| 711 |
name: "shown" |
| 712 |
when: !chat.atYEnd |
| 713 |
|
| 714 |
PropertyChanges { |
| 715 |
toEndButton.width: toEndButton.fullWidth |
| 716 |
} |
| 717 |
} |
| 718 |
] |
| 719 |
transitions: Transition { |
| 720 |
from: "" |
| 721 |
reversible: true |
| 722 |
to: "shown" |
| 723 |
|
| 724 |
SequentialAnimation { |
| 725 |
PauseAnimation { |
| 726 |
duration: 500 |
| 727 |
} |
| 728 |
PropertyAnimation { |
| 729 |
duration: 200 |
| 730 |
easing.type: Easing.InOutQuad |
| 731 |
properties: "width" |
| 732 |
target: toEndButton |
| 733 |
} |
| 734 |
} |
| 735 |
} |
| 736 |
|
| 737 |
onClicked: function () { |
| 738 |
chat.positionViewAtBeginning(); |
| 739 |
TimelineManager.focusMessageInput(); |
| 740 |
chat.updateLastScroll(); |
| 741 |
} |
| 742 |
|
| 743 |
anchors { |
| 744 |
bottom: parent.bottom |
| 745 |
bottomMargin: Nheko.paddingMedium + (fullWidth - width) / 2 |
| 746 |
right: scrollbar.left |
| 747 |
rightMargin: Nheko.paddingMedium + (fullWidth - width) / 2 |
| 748 |
} |
| 749 |
Image { |
| 750 |
anchors.fill: parent |
| 751 |
anchors.margins: Nheko.paddingMedium |
| 752 |
fillMode: Image.PreserveAspectFit |
| 753 |
source: "image://colorimage/:/icons/icons/ui/download.svg?" + (toEndButton.down ? palette.highlightedText : palette.buttonText) |
| 754 |
} |
| 755 |
} |
| 756 |
} |