summary refs log tree commit diff
path: root/resources/qml/ReplyPopup.qml
blob: 6fceb4e5d62b3a0c099c58c51dd03afefe5287ae (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
// SPDX-FileCopyrightText: Nheko Contributors
//
// SPDX-License-Identifier: GPL-3.0-or-later

import "./delegates/"
import QtQuick 2.9
import QtQuick.Controls 2.3
import QtQuick.Layouts 1.2
import im.nheko 1.0

Rectangle {
    id: replyPopup

    Layout.fillWidth: true
    visible: room && (room.reply || room.edit || room.thread)
    // Height of child, plus margins, plus border
    implicitHeight: (room && room.reply ? replyPreview.height : Math.max(closeEditButton.height, closeThreadButton.height)) + Nheko.paddingSmall
    color: palette.window
    z: 3

    Reply {
        id: replyPreview

        property var modelData: room ? room.getDump(room.reply, room.id) : {
        }

        visible: room && room.reply
        anchors.left: parent.left
        anchors.leftMargin: replyPopup.width < 450? Nheko.paddingSmall : (CallManager.callsSupported? 2*(22+16) : 1*(22+16))
        anchors.right: parent.right
        anchors.rightMargin: replyPopup.width < 450? 2*(22+16) : 3*(22+16)
        anchors.top: parent.top
        anchors.topMargin: Nheko.paddingSmall
        userColor: TimelineManager.userColor(modelData.userId, palette.window)
        blurhash: modelData.blurhash ?? ""
        body: modelData.body ?? ""
        formattedBody: modelData.formattedBody ?? ""
        eventId: modelData.eventId ?? ""
        filename: modelData.filename ?? ""
        filesize: modelData.filesize ?? ""
        proportionalHeight: modelData.proportionalHeight ?? 1
        type: modelData.type ?? MtxEvent.UnknownMessage
        typeString: modelData.typeString ?? ""
        url: modelData.url ?? ""
        originalWidth: modelData.originalWidth ?? 0
        isOnlyEmoji: modelData.isOnlyEmoji ?? false
        userId: modelData.userId ?? ""
        userName: modelData.userName ?? ""
        encryptionError: modelData.encryptionError ?? 0
        width: parent.width
    }

    ImageButton {
        id: closeReplyButton

        visible: room && room.reply
        anchors.right: replyPreview.right
        anchors.top: replyPreview.top
        anchors.margins: Nheko.paddingSmall
        hoverEnabled: true
        width: 16
        height: 16
        image: ":/icons/icons/ui/dismiss.svg"
        ToolTip.visible: closeReplyButton.hovered
        ToolTip.text: qsTr("Close")
        onClicked: room.reply = undefined
    }

    ImageButton {
        id: closeEditButton

        visible: room && room.edit
        anchors.right: closeThreadButton.left
        anchors.margins: 8
        anchors.top: parent.top
        hoverEnabled: true
        image: ":/icons/icons/ui/dismiss_edit.svg"
        width: 22
        height: 22
        ToolTip.visible: closeEditButton.hovered
        ToolTip.text: qsTr("Cancel Edit")
        onClicked: room.edit = undefined
    }

    ImageButton {
        id: closeThreadButton

        visible: room && room.thread
        anchors.right: parent.right
        anchors.margins: 8
        anchors.top: parent.top
        hoverEnabled: true
        buttonTextColor: room ? TimelineManager.userColor(room.thread, palette.base) : palette.buttonText
        image: ":/icons/icons/ui/dismiss_thread.svg"
        width: 22
        height: 22
        ToolTip.visible: closeThreadButton.hovered
        ToolTip.text: qsTr("Cancel Thread")
        onClicked: room.thread = undefined
    }

}