matrixion/qml/delegates/Redacted.qml

53 lines
1.7 KiB
QML
Raw Normal View History

2021-11-29 03:59:57 +03:00
// SPDX-FileCopyrightText: 2021 Nheko Contributors
// SPDX-FileCopyrightText: 2022 Nheko Contributors
2021-11-29 03:59:57 +03:00
// SPDX-License-Identifier: GPL-3.0-or-later
import QtQuick 2.15
import QtQuick.Controls 2.15
import QtQuick.Layouts 1.15
import im.nheko
2021-11-29 03:59:57 +03:00
2022-04-16 03:13:01 +03:00
Rectangle {
property bool fitsMetadata: parent.width - redactedLayout.width > metadataWidth + 4
property int metadataWidth
2021-11-29 03:59:57 +03:00
2022-04-16 03:13:01 +03:00
color: timelineRoot.palette.alternateBase
2021-11-29 05:10:35 +03:00
height: redactedLayout.implicitHeight + Nheko.paddingSmall
implicitWidth: redactedLayout.implicitWidth + 2 * Nheko.paddingMedium
2021-11-29 03:59:57 +03:00
radius: fontMetrics.lineSpacing / 2 + 2 * Nheko.paddingSmall
2022-04-16 03:13:01 +03:00
width: Math.min(parent.width, implicitWidth + 1)
2021-11-29 03:59:57 +03:00
RowLayout {
id: redactedLayout
anchors.centerIn: parent
2021-11-29 05:10:35 +03:00
spacing: Nheko.paddingSmall
2022-04-16 03:13:01 +03:00
width: parent.width - 2 * Nheko.paddingMedium
2021-11-29 05:10:35 +03:00
2021-11-29 03:59:57 +03:00
Image {
id: trashImg
Layout.alignment: Qt.AlignLeft | Qt.AlignVCenter
Layout.preferredHeight: fontMetrics.font.pixelSize
2022-04-16 03:13:01 +03:00
Layout.preferredWidth: fontMetrics.font.pixelSize
2022-04-11 05:18:16 +03:00
source: "image://colorimage/:/icons/icons/ui/delete.svg?" + timelineRoot.palette.text
2021-11-29 03:59:57 +03:00
}
Label {
id: redactedLabel
2022-04-16 03:13:01 +03:00
property var redactedPair: room.formatRedactedEvent(eventId)
2021-11-29 03:59:57 +03:00
Layout.alignment: Qt.AlignVCenter | Qt.AlignRight
2022-02-14 16:16:11 +03:00
Layout.fillWidth: true
2022-04-16 03:13:01 +03:00
Layout.margins: 0
Layout.preferredWidth: implicitWidth
ToolTip.text: redactedPair["second"]
ToolTip.visible: hh.hovered
color: timelineRoot.palette.text
2021-11-29 03:59:57 +03:00
text: redactedPair["first"]
wrapMode: Label.WordWrap
HoverHandler {
id: hh
}
}
}
2021-11-29 05:10:35 +03:00
}