Add button for hiding images and videos

This commit is contained in:
Tobias Fella
2025-06-11 23:28:54 +02:00
committed by Tobias Fella
parent b972703f34
commit 598a1c28ac
4 changed files with 47 additions and 5 deletions

View File

@@ -407,4 +407,9 @@ void Controller::markImageShown(const QString &eventId)
m_shownImages.append(eventId);
}
void Controller::markImageHidden(const QString &eventId)
{
m_shownImages.removeAll(eventId);
}
#include "moc_controller.cpp"

View File

@@ -99,6 +99,7 @@ public:
Q_INVOKABLE bool isImageShown(const QString &eventId);
Q_INVOKABLE void markImageShown(const QString &eventId);
Q_INVOKABLE void markImageHidden(const QString &eventId);
private:
explicit Controller(QObject *parent = nullptr);

View File

@@ -54,6 +54,24 @@ Item {
implicitWidth: mediaSizeHelper.currentSize.width
implicitHeight: mediaSizeHelper.currentSize.height
QQC2.Button {
anchors.right: parent.right
anchors.top: parent.top
visible: !_private.hideImage
icon.name: "view-hidden"
text: i18nc("@action:button", "Hide Image")
display: QQC2.Button.IconOnly
z: 10
onClicked: {
_private.hideImage = true;
Controller.markImageHidden(root.eventId)
}
QQC2.ToolTip.text: text
QQC2.ToolTip.visible: hovered
QQC2.ToolTip.delay: Kirigami.Units.toolTipDelay
}
Loader {
id: imageLoader
@@ -103,7 +121,7 @@ Item {
Rectangle {
anchors.fill: parent
visible: _private.imageItem.status !== Image.Ready
visible: _private.imageItem.status !== Image.Ready || _private.hideImage
color: "#BB000000"

View File

@@ -94,7 +94,7 @@ Video {
},
State {
name: "downloading"
when: root.fileTransferInfo.active && !root.fileTransferInfo.completed
when: root.fileTransferInfo.active && !root.fileTransferInfo.completed && (Controller.isImageShown(root.eventId) || !NeoChatConfig.hideImages)
PropertyChanges {
target: downloadBar
visible: true
@@ -102,7 +102,7 @@ Video {
},
State {
name: "paused"
when: root.fileTransferInfo.completed && root.playbackState === MediaPlayer.PausedState
when: root.fileTransferInfo.completed && root.playbackState === MediaPlayer.PausedState && (Controller.isImageShown(root.eventId) || !NeoChatConfig.hideImages)
PropertyChanges {
target: videoControls
stateVisible: true
@@ -118,7 +118,7 @@ Video {
},
State {
name: "playing"
when: root.fileTransferInfo.completed && root.playbackState === MediaPlayer.PlayingState
when: root.fileTransferInfo.completed && root.playbackState === MediaPlayer.PlayingState && (Controller.isImageShown(root.eventId) || !NeoChatConfig.hideImages)
PropertyChanges {
target: videoControls
stateVisible: true
@@ -131,7 +131,7 @@ Video {
},
State {
name: "stopped"
when: root.fileTransferInfo.completed && root.playbackState === MediaPlayer.StoppedState
when: root.fileTransferInfo.completed && root.playbackState === MediaPlayer.StoppedState && (Controller.isImageShown(root.eventId) || !NeoChatConfig.hideImages)
PropertyChanges {
target: videoControls
stateVisible: true
@@ -179,6 +179,24 @@ Video {
}
}
QQC2.Button {
anchors.right: parent.right
anchors.top: parent.top
visible: root.state !== "hidden"
icon.name: "view-hidden"
text: i18nc("@action:button", "Hide Image")
display: QQC2.Button.IconOnly
z: 10
onClicked: {
root.state = "hidden"
Controller.markImageHidden(root.eventId)
}
QQC2.ToolTip.text: text
QQC2.ToolTip.visible: hovered
QQC2.ToolTip.delay: Kirigami.Units.toolTipDelay
}
Image {
id: mediaThumbnail
anchors.fill: parent