matrixion/resources/qml/delegates/Redacted.qml

57 lines
1.6 KiB
QML
Raw Permalink Normal View History

// SPDX-FileCopyrightText: Nheko Contributors
2021-11-29 03:59:57 +03:00
//
// SPDX-License-Identifier: GPL-3.0-or-later
import QtQuick
import QtQuick.Controls
import QtQuick.Layouts
import im.nheko
2021-11-29 03:59:57 +03:00
2023-07-28 20:30:13 +03:00
Control {
id: msgRoot
2021-11-29 03:59:57 +03:00
2023-07-28 20:30:13 +03:00
property int metadataWidth: 0
property bool fitsMetadata: false //parent.width - redactedLayout.width > metadataWidth + 4
2021-11-29 03:59:57 +03:00
2023-07-28 20:30:13 +03:00
required property string eventId
required property Room room
2023-07-28 20:30:13 +03:00
contentItem: RowLayout {
2021-11-29 03:59:57 +03:00
id: redactedLayout
2021-11-29 05:10:35 +03:00
spacing: Nheko.paddingSmall
2021-11-29 03:59:57 +03:00
Image {
id: trashImg
Layout.alignment: Qt.AlignLeft | Qt.AlignVCenter
Layout.preferredWidth: fontMetrics.font.pixelSize
Layout.preferredHeight: fontMetrics.font.pixelSize
source: "image://colorimage/:/icons/icons/ui/delete.svg?" + palette.text
2021-11-29 03:59:57 +03:00
}
Label {
id: redactedLabel
2021-11-29 05:10:35 +03:00
Layout.margins: 0
2021-11-29 03:59:57 +03:00
Layout.alignment: Qt.AlignVCenter | Qt.AlignRight
2023-07-28 20:30:13 +03:00
Layout.maximumWidth: implicitWidth + 1
2022-02-14 16:16:11 +03:00
Layout.fillWidth: true
2023-07-28 20:30:13 +03:00
property var redactedPair: room.formatRedactedEvent(msgRoot.eventId)
2021-11-29 03:59:57 +03:00
text: redactedPair["first"]
wrapMode: Label.WordWrap
ToolTip.text: redactedPair["second"]
ToolTip.visible: hh.hovered
HoverHandler {
id: hh
}
}
}
2023-07-28 20:30:13 +03:00
padding: Nheko.paddingSmall
Layout.maximumWidth: redactedLayout.Layout.maximumWidth + padding * 2
background: Rectangle {
color: palette.alternateBase
radius: fontMetrics.lineSpacing / 2 + 2 * Nheko.paddingSmall
}
2021-11-29 05:10:35 +03:00
}