nheko/resources/qml/ReplyPopup.qml

88 lines
2.7 KiB
QML
Raw Normal View History

// SPDX-FileCopyrightText: Nheko Contributors
//
2021-03-05 00:35:15 +01:00
// 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
2023-06-02 01:45:24 +02:00
color: palette.window
// Height of child, plus margins, plus border
2022-09-30 03:27:05 +02:00
implicitHeight: (room && room.reply ? replyPreview.height : Math.max(closeEditButton.height, closeThreadButton.height)) + Nheko.paddingSmall
2023-06-02 01:45:24 +02:00
visible: room && (room.reply || room.edit || room.thread)
z: 3
Reply {
id: replyPreview
2023-06-02 01:45:24 +02:00
property var modelData: room ? room.getDump(room.reply, room.id) : {}
anchors.left: parent.left
2023-06-02 01:45:24 +02:00
anchors.leftMargin: replyPopup.width < 450 ? Nheko.paddingSmall : (CallManager.callsSupported ? 2 * (22 + 16) : 1 * (22 + 16))
2022-03-11 21:32:32 +01:00
anchors.right: parent.right
2023-06-02 01:45:24 +02:00
anchors.rightMargin: replyPopup.width < 450 ? 2 * (22 + 16) : 3 * (22 + 16)
2022-03-11 21:32:32 +01:00
anchors.top: parent.top
anchors.topMargin: Nheko.paddingSmall
2023-10-18 22:43:45 +02:00
eventId: room?.reply ?? ""
2023-06-02 01:45:24 +02:00
userColor: TimelineManager.userColor(modelData.userId, palette.window)
visible: room && room.reply
2023-08-25 21:03:05 +02:00
maxWidth: parent.width - anchors.leftMargin - anchors.rightMargin
2023-11-01 22:28:58 +01:00
limitHeight: true
}
ImageButton {
id: closeReplyButton
2023-06-02 01:45:24 +02:00
ToolTip.text: qsTr("Close")
ToolTip.visible: closeReplyButton.hovered
anchors.margins: Nheko.paddingSmall
2022-03-11 21:32:32 +01:00
anchors.right: replyPreview.right
anchors.top: replyPreview.top
height: 16
2023-06-02 01:45:24 +02:00
hoverEnabled: true
2021-11-14 02:23:10 +01:00
image: ":/icons/icons/ui/dismiss.svg"
2023-06-02 01:45:24 +02:00
visible: room && room.reply
width: 16
onClicked: room.reply = undefined
}
2022-03-11 21:32:32 +01:00
ImageButton {
id: closeEditButton
2023-06-02 01:45:24 +02:00
ToolTip.text: qsTr("Cancel Edit")
ToolTip.visible: closeEditButton.hovered
2022-03-11 21:32:32 +01:00
anchors.margins: 8
2023-06-02 01:45:24 +02:00
anchors.right: closeThreadButton.left
anchors.top: parent.top
2023-06-02 01:45:24 +02:00
height: 22
2022-03-11 21:32:32 +01:00
hoverEnabled: true
image: ":/icons/icons/ui/dismiss_edit.svg"
2023-06-02 01:45:24 +02:00
visible: room && room.edit
2022-03-11 21:32:32 +01:00
width: 22
2023-06-02 01:45:24 +02:00
onClicked: room.edit = undefined
}
2022-09-30 03:27:05 +02:00
ImageButton {
id: closeThreadButton
2023-06-02 01:45:24 +02:00
ToolTip.text: qsTr("Cancel Thread")
ToolTip.visible: closeThreadButton.hovered
2022-09-30 03:27:05 +02:00
anchors.margins: 8
2023-06-02 01:45:24 +02:00
anchors.right: parent.right
2022-09-30 03:27:05 +02:00
anchors.top: parent.top
buttonTextColor: room ? TimelineManager.userColor(room.thread, palette.base) : palette.buttonText
2023-06-02 01:45:24 +02:00
height: 22
hoverEnabled: true
2022-09-30 03:27:05 +02:00
image: ":/icons/icons/ui/dismiss_thread.svg"
2023-06-02 01:45:24 +02:00
visible: room && room.thread
2022-09-30 03:27:05 +02:00
width: 22
2023-06-02 01:45:24 +02:00
2022-09-30 03:27:05 +02:00
onClicked: room.thread = undefined
}
}