Debian Codegraph @

resources/qml/ReplyPopup.qml

raw
1 // SPDX-FileCopyrightText: Nheko Contributors
2 //
3 // SPDX-License-Identifier: GPL-3.0-or-later
4
5 import "./delegates/"
6 import QtQuick 2.9
7 import QtQuick.Controls 2.3
8 import QtQuick.Layouts 1.2
9 import im.nheko 1.0
10
11 Rectangle {
12 id: replyPopup
13
14 Layout.fillWidth: true
15 color: palette.window
16 // Height of child, plus margins, plus border
17 implicitHeight: (room && room.reply ? replyPreview.height : Math.max(closeEditButton.height, closeThreadButton.height)) + Nheko.paddingSmall
18 visible: room && (room.reply || room.edit || room.thread)
19 z: 3
20
21 Reply {
22 id: replyPreview
23
24 property var modelData: room ? room.getDump(room.reply, room.id) : {}
25
26 anchors.left: parent.left
27 anchors.leftMargin: replyPopup.width < 450 ? Nheko.paddingSmall : (CallManager.callsSupported ? 2 * (22 + 16) : 1 * (22 + 16))
28 anchors.right: parent.right
29 anchors.rightMargin: replyPopup.width < 450 ? 2 * (22 + 16) : 3 * (22 + 16)
30 anchors.top: parent.top
31 anchors.topMargin: Nheko.paddingSmall
32 eventId: room?.reply ?? ""
33 userColor: TimelineManager.userColor(modelData.userId, palette.window)
34 visible: room && room.reply
35 maxWidth: parent.width - anchors.leftMargin - anchors.rightMargin
36 limitHeight: true
37 }
38 ImageButton {
39 id: closeReplyButton
40
41 ToolTip.text: qsTr("Close")
42 ToolTip.visible: closeReplyButton.hovered
43 anchors.margins: Nheko.paddingSmall
44 anchors.right: replyPreview.right
45 anchors.top: replyPreview.top
46 height: 16
47 hoverEnabled: true
48 image: ":/icons/icons/ui/dismiss.svg"
49 visible: room && room.reply
50 width: 16
51
52 onClicked: room.reply = undefined
53 }
54 ImageButton {
55 id: closeEditButton
56
57 ToolTip.text: qsTr("Cancel Edit")
58 ToolTip.visible: closeEditButton.hovered
59 anchors.margins: 8
60 anchors.right: closeThreadButton.left
61 anchors.top: parent.top
62 height: 22
63 hoverEnabled: true
64 image: ":/icons/icons/ui/dismiss_edit.svg"
65 visible: room && room.edit
66 width: 22
67
68 onClicked: room.edit = undefined
69 }
70 ImageButton {
71 id: closeThreadButton
72
73 ToolTip.text: qsTr("Cancel Thread")
74 ToolTip.visible: closeThreadButton.hovered
75 anchors.margins: 8
76 anchors.right: parent.right
77 anchors.top: parent.top
78 buttonTextColor: room ? TimelineManager.userColor(room.thread, palette.base) : palette.buttonText
79 height: 22
80 hoverEnabled: true
81 image: ":/icons/icons/ui/dismiss_thread.svg"
82 visible: room && room.thread
83 width: 22
84
85 onClicked: room.thread = undefined
86 }
87 }