@@ -439,4 +439,14 @@ void Controller::revertToDefaultConfig()
|
|||||||
config->save();
|
config->save();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Controller::isImageShown(const QString &eventId)
|
||||||
|
{
|
||||||
|
return m_shownImages.contains(eventId);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Controller::markImageShown(const QString &eventId)
|
||||||
|
{
|
||||||
|
m_shownImages.append(eventId);
|
||||||
|
}
|
||||||
|
|
||||||
#include "moc_controller.cpp"
|
#include "moc_controller.cpp"
|
||||||
|
|||||||
@@ -116,6 +116,9 @@ public:
|
|||||||
*/
|
*/
|
||||||
Q_INVOKABLE void revertToDefaultConfig();
|
Q_INVOKABLE void revertToDefaultConfig();
|
||||||
|
|
||||||
|
Q_INVOKABLE bool isImageShown(const QString &eventId);
|
||||||
|
Q_INVOKABLE void markImageShown(const QString &eventId);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
explicit Controller(QObject *parent = nullptr);
|
explicit Controller(QObject *parent = nullptr);
|
||||||
|
|
||||||
@@ -128,6 +131,7 @@ private:
|
|||||||
QStringList m_accountsLoading;
|
QStringList m_accountsLoading;
|
||||||
QMap<QString, QPointer<NeoChatConnection>> m_connectionsLoading;
|
QMap<QString, QPointer<NeoChatConnection>> m_connectionsLoading;
|
||||||
QString m_endpoint;
|
QString m_endpoint;
|
||||||
|
QStringList m_shownImages;
|
||||||
|
|
||||||
private Q_SLOTS:
|
private Q_SLOTS:
|
||||||
void invokeLogin();
|
void invokeLogin();
|
||||||
|
|||||||
@@ -89,6 +89,10 @@
|
|||||||
<label>Show deleted messages in the timeline</label>
|
<label>Show deleted messages in the timeline</label>
|
||||||
<default>false</default>
|
<default>false</default>
|
||||||
</entry>
|
</entry>
|
||||||
|
<entry name="HideImages" type="bool">
|
||||||
|
<label>Hide images in the timeline</label>
|
||||||
|
<default>false</default>
|
||||||
|
</entry>
|
||||||
<entry name="ShowLinkPreview" type="bool">
|
<entry name="ShowLinkPreview" type="bool">
|
||||||
<label>Show preview of the links in the chat messages</label>
|
<label>Show preview of the links in the chat messages</label>
|
||||||
</entry>
|
</entry>
|
||||||
|
|||||||
@@ -193,6 +193,23 @@ FormCard.FormCardPage {
|
|||||||
NeoChatConfig.save();
|
NeoChatConfig.save();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FormCard.FormDelegateSeparator {
|
||||||
|
above: showAvatarChangeDelegate
|
||||||
|
below: hideImagesDelegate
|
||||||
|
}
|
||||||
|
|
||||||
|
FormCard.FormCheckDelegate {
|
||||||
|
id: hideImagesDelegate
|
||||||
|
text: i18nc("@label:checkbox", "Hide image and video events by default")
|
||||||
|
description: i18nc("@info", "When this option is enabled, images and videos are only shown after a button is clicked.")
|
||||||
|
checked: NeoChatConfig.hideImages
|
||||||
|
enabled: !NeoChatConfig.isHideImagesImmutable
|
||||||
|
onToggled: {
|
||||||
|
NeoChatConfig.hideImages = checked;
|
||||||
|
NeoChatConfig.save();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
FormCard.FormHeader {
|
FormCard.FormHeader {
|
||||||
title: i18nc("Chat Editor", "Editor")
|
title: i18nc("Chat Editor", "Editor")
|
||||||
|
|||||||
@@ -74,7 +74,7 @@ Item {
|
|||||||
|
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
|
|
||||||
active: !root.mediaInfo.animated
|
active: !root.mediaInfo.animated && !_private.hideImage
|
||||||
sourceComponent: Image {
|
sourceComponent: Image {
|
||||||
source: root.mediaInfo.source
|
source: root.mediaInfo.source
|
||||||
sourceSize.width: mediaSizeHelper.currentSize.width * Screen.devicePixelRatio
|
sourceSize.width: mediaSizeHelper.currentSize.width * Screen.devicePixelRatio
|
||||||
@@ -89,7 +89,7 @@ Item {
|
|||||||
|
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
|
|
||||||
active: root?.mediaInfo.animated ?? false
|
active: (root?.mediaInfo.animated ?? false) && !_private.hideImage
|
||||||
sourceComponent: AnimatedImage {
|
sourceComponent: AnimatedImage {
|
||||||
source: root.mediaInfo.source
|
source: root.mediaInfo.source
|
||||||
|
|
||||||
@@ -101,8 +101,8 @@ Item {
|
|||||||
|
|
||||||
Image {
|
Image {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
source: root?.mediaInfo.tempInfo.source ?? ""
|
source: visible ? (root?.mediaInfo.tempInfo.source ?? "") : ""
|
||||||
visible: _private.imageItem.status !== Image.Ready
|
visible: _private.imageItem && _private.imageItem.status !== Image.Ready && !_private.hideImage
|
||||||
}
|
}
|
||||||
|
|
||||||
QQC2.ToolTip.text: root.display
|
QQC2.ToolTip.text: root.display
|
||||||
@@ -124,11 +124,23 @@ Item {
|
|||||||
anchors.centerIn: parent
|
anchors.centerIn: parent
|
||||||
|
|
||||||
width: parent.width * 0.8
|
width: parent.width * 0.8
|
||||||
|
visible: !_private.hideImage
|
||||||
|
|
||||||
from: 0
|
from: 0
|
||||||
to: 1.0
|
to: 1.0
|
||||||
value: _private.imageItem.progress
|
value: _private.imageItem.progress
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
QQC2.Button {
|
||||||
|
anchors.centerIn: parent
|
||||||
|
text: i18nc("@action:button", "Show Image")
|
||||||
|
visible: _private.hideImage
|
||||||
|
onClicked: {
|
||||||
|
_private.hideImage = false;
|
||||||
|
Controller.markImageShown(root.eventId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TapHandler {
|
TapHandler {
|
||||||
@@ -180,5 +192,7 @@ Item {
|
|||||||
|
|
||||||
// The space available for the component after taking away the border
|
// The space available for the component after taking away the border
|
||||||
readonly property real downloaded: root.fileTransferInfo && root.fileTransferInfo.completed
|
readonly property real downloaded: root.fileTransferInfo && root.fileTransferInfo.completed
|
||||||
|
|
||||||
|
property bool hideImage: NeoChatConfig.hideImages && !Controller.isImageShown(root.eventId)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -93,6 +93,12 @@ Video {
|
|||||||
fillMode: VideoOutput.PreserveAspectFit
|
fillMode: VideoOutput.PreserveAspectFit
|
||||||
|
|
||||||
Component.onDestruction: root.stop()
|
Component.onDestruction: root.stop()
|
||||||
|
Component.onCompleted: {
|
||||||
|
console.warn("state", root.state)
|
||||||
|
if (NeoChatConfig.hideImages && !Controller.isImageShown(root.eventId)) {
|
||||||
|
root.state = "hidden";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
states: [
|
states: [
|
||||||
State {
|
State {
|
||||||
@@ -167,6 +173,21 @@ Video {
|
|||||||
root.play();
|
root.play();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
State {
|
||||||
|
name: "hidden"
|
||||||
|
PropertyChanges {
|
||||||
|
target: mediaThumbnail
|
||||||
|
visible: false
|
||||||
|
}
|
||||||
|
PropertyChanges {
|
||||||
|
target: videoControls
|
||||||
|
visible: false
|
||||||
|
}
|
||||||
|
PropertyChanges {
|
||||||
|
target: hidden
|
||||||
|
visible: true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -184,7 +205,7 @@ Video {
|
|||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
visible: false
|
visible: false
|
||||||
|
|
||||||
source: root.mediaInfo.tempInfo.source
|
source: visible ? root.mediaInfo.tempInfo.source : ""
|
||||||
fillMode: Image.PreserveAspectFit
|
fillMode: Image.PreserveAspectFit
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -225,6 +246,23 @@ Video {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Rectangle {
|
||||||
|
id: hidden
|
||||||
|
anchors.fill: parent
|
||||||
|
|
||||||
|
visible: false
|
||||||
|
color: "#BB000000"
|
||||||
|
|
||||||
|
QQC2.Button {
|
||||||
|
anchors.centerIn: parent
|
||||||
|
text: i18nc("@action:button", "Show Video")
|
||||||
|
onClicked: {
|
||||||
|
root.state = "notDownloaded";
|
||||||
|
Controller.markImageShown(root.eventId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
QQC2.Control {
|
QQC2.Control {
|
||||||
id: videoControls
|
id: videoControls
|
||||||
property bool stateVisible: false
|
property bool stateVisible: false
|
||||||
|
|||||||
Reference in New Issue
Block a user