Fix-up ImageComponent's hide media functionality

The Z-level for the "Hide media" and other overlay controls were lost
during the rich text refactor, and now restored. I also made it so the
blurhash is now used when the media is hidden, and when hiding media it
no longer allows you to jumpscare yourself by maximizing the media when
you probably didn't actually want to.

When the media doesn't have blurhash, it falls back to black.
This commit is contained in:
Joshua Goins
2026-02-20 16:02:49 -05:00
parent 5f0f9135fe
commit b7ea6f265e

View File

@@ -66,8 +66,9 @@ Item {
anchors.right: root.right anchors.right: root.right
anchors.rightMargin: root.rightAnchorMargin + Kirigami.Units.smallSpacing anchors.rightMargin: root.rightAnchorMargin + Kirigami.Units.smallSpacing
QQC2.Button { z: 10
QQC2.Button {
visible: !_private.hideImage && !root.editable visible: !_private.hideImage && !root.editable
icon.name: "view-hidden" icon.name: "view-hidden"
text: i18nc("@action:button", "Hide Image") text: i18nc("@action:button", "Hide Image")
@@ -119,6 +120,30 @@ Item {
} }
} }
Rectangle {
anchors.fill: parent
visible: (_private.imageItem?.status !== Image.Ready ?? true) || _private.hideImage
color: "#BB000000"
QQC2.ProgressBar {
anchors.centerIn: parent
width: parent.width * 0.8
visible: !_private.hideImage
from: 0
to: 1.0
value: _private.imageItem?.progress ?? 0.0
}
Image {
anchors.fill: parent
source: root?.componentAttributes.tempInfo?.source ?? ""
}
}
Loader { Loader {
id: imageLoader id: imageLoader
@@ -151,12 +176,6 @@ Item {
} }
} }
Image {
anchors.fill: parent
source: visible ? (root?.componentAttributes.tempInfo?.source ?? "") : ""
visible: _private.imageItem && _private.imageItem.status !== Image.Ready && !_private.hideImage
}
QQC2.ToolTip.text: root.display QQC2.ToolTip.text: root.display
QQC2.ToolTip.visible: hoverHandler.hovered QQC2.ToolTip.visible: hoverHandler.hovered
QQC2.ToolTip.delay: Kirigami.Units.toolTipDelay QQC2.ToolTip.delay: Kirigami.Units.toolTipDelay
@@ -165,26 +184,6 @@ Item {
id: hoverHandler id: hoverHandler
} }
Rectangle {
anchors.fill: parent
visible: _private.imageItem.status !== Image.Ready || _private.hideImage
color: "#BB000000"
QQC2.ProgressBar {
anchors.centerIn: parent
width: parent.width * 0.8
visible: !_private.hideImage
from: 0
to: 1.0
value: _private.imageItem.progress
}
}
QQC2.Button { QQC2.Button {
anchors.centerIn: parent anchors.centerIn: parent
text: i18nc("@action:button", "Show Image") text: i18nc("@action:button", "Show Image")
@@ -206,7 +205,7 @@ Item {
if (root.Message.timeline) { if (root.Message.timeline) {
root.Message.timeline.interactive = false; root.Message.timeline.interactive = false;
} }
if (!root.componentAttributes.isSticker && !root.editable) { if (!root.componentAttributes.isSticker && !root.editable && !_private.hideImage) {
RoomManager.maximizeMedia(root.eventId); RoomManager.maximizeMedia(root.eventId);
} }
} }