Add button for hiding images and videos
This commit is contained in:
committed by
Tobias Fella
parent
b972703f34
commit
598a1c28ac
@@ -407,4 +407,9 @@ void Controller::markImageShown(const QString &eventId)
|
|||||||
m_shownImages.append(eventId);
|
m_shownImages.append(eventId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Controller::markImageHidden(const QString &eventId)
|
||||||
|
{
|
||||||
|
m_shownImages.removeAll(eventId);
|
||||||
|
}
|
||||||
|
|
||||||
#include "moc_controller.cpp"
|
#include "moc_controller.cpp"
|
||||||
|
|||||||
@@ -99,6 +99,7 @@ public:
|
|||||||
|
|
||||||
Q_INVOKABLE bool isImageShown(const QString &eventId);
|
Q_INVOKABLE bool isImageShown(const QString &eventId);
|
||||||
Q_INVOKABLE void markImageShown(const QString &eventId);
|
Q_INVOKABLE void markImageShown(const QString &eventId);
|
||||||
|
Q_INVOKABLE void markImageHidden(const QString &eventId);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
explicit Controller(QObject *parent = nullptr);
|
explicit Controller(QObject *parent = nullptr);
|
||||||
|
|||||||
@@ -54,6 +54,24 @@ Item {
|
|||||||
implicitWidth: mediaSizeHelper.currentSize.width
|
implicitWidth: mediaSizeHelper.currentSize.width
|
||||||
implicitHeight: mediaSizeHelper.currentSize.height
|
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 {
|
Loader {
|
||||||
id: imageLoader
|
id: imageLoader
|
||||||
|
|
||||||
@@ -103,7 +121,7 @@ Item {
|
|||||||
Rectangle {
|
Rectangle {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
|
|
||||||
visible: _private.imageItem.status !== Image.Ready
|
visible: _private.imageItem.status !== Image.Ready || _private.hideImage
|
||||||
|
|
||||||
color: "#BB000000"
|
color: "#BB000000"
|
||||||
|
|
||||||
|
|||||||
@@ -94,7 +94,7 @@ Video {
|
|||||||
},
|
},
|
||||||
State {
|
State {
|
||||||
name: "downloading"
|
name: "downloading"
|
||||||
when: root.fileTransferInfo.active && !root.fileTransferInfo.completed
|
when: root.fileTransferInfo.active && !root.fileTransferInfo.completed && (Controller.isImageShown(root.eventId) || !NeoChatConfig.hideImages)
|
||||||
PropertyChanges {
|
PropertyChanges {
|
||||||
target: downloadBar
|
target: downloadBar
|
||||||
visible: true
|
visible: true
|
||||||
@@ -102,7 +102,7 @@ Video {
|
|||||||
},
|
},
|
||||||
State {
|
State {
|
||||||
name: "paused"
|
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 {
|
PropertyChanges {
|
||||||
target: videoControls
|
target: videoControls
|
||||||
stateVisible: true
|
stateVisible: true
|
||||||
@@ -118,7 +118,7 @@ Video {
|
|||||||
},
|
},
|
||||||
State {
|
State {
|
||||||
name: "playing"
|
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 {
|
PropertyChanges {
|
||||||
target: videoControls
|
target: videoControls
|
||||||
stateVisible: true
|
stateVisible: true
|
||||||
@@ -131,7 +131,7 @@ Video {
|
|||||||
},
|
},
|
||||||
State {
|
State {
|
||||||
name: "stopped"
|
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 {
|
PropertyChanges {
|
||||||
target: videoControls
|
target: videoControls
|
||||||
stateVisible: true
|
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 {
|
Image {
|
||||||
id: mediaThumbnail
|
id: mediaThumbnail
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
|
|||||||
Reference in New Issue
Block a user