2020-11-16 12:32:56 +00:00
|
|
|
import QtQuick 2.13
|
|
|
|
import QtQuick.Window 2.2
|
|
|
|
import QtQuick.Controls 2.13
|
|
|
|
import QtQuick.Layouts 1.13
|
|
|
|
import QtGraphicalEffects 1.13
|
2021-09-28 15:04:06 +00:00
|
|
|
|
|
|
|
import utils 1.0
|
2021-10-27 21:27:49 +00:00
|
|
|
import shared 1.0
|
2023-05-19 16:07:50 +00:00
|
|
|
import shared.views.chat 1.0
|
2020-11-16 12:32:56 +00:00
|
|
|
|
|
|
|
Popup {
|
|
|
|
id: root
|
2021-08-16 09:11:43 +00:00
|
|
|
|
2023-05-19 16:07:50 +00:00
|
|
|
property var store
|
2023-09-05 16:04:58 +00:00
|
|
|
property var image
|
|
|
|
property string url: ""
|
2021-08-16 09:11:43 +00:00
|
|
|
|
2020-11-16 12:32:56 +00:00
|
|
|
modal: true
|
|
|
|
Overlay.modal: Rectangle {
|
|
|
|
color: "#40000000"
|
|
|
|
}
|
|
|
|
parent: Overlay.overlay
|
|
|
|
closePolicy: Popup.CloseOnEscape | Popup.CloseOnPressOutside
|
|
|
|
x: Math.round(((parent ? parent.width : 0) - width) / 2)
|
|
|
|
y: Math.round(((parent ? parent.height : 0) - height) / 2)
|
|
|
|
background: Rectangle {
|
|
|
|
color: "transparent"
|
|
|
|
}
|
|
|
|
padding: 0
|
|
|
|
|
2023-09-05 16:04:58 +00:00
|
|
|
onOpened: {
|
|
|
|
messageImage.source = root.image.source;
|
2021-12-08 21:20:43 +00:00
|
|
|
const maxHeight = Global.applicationWindow.height - 80
|
|
|
|
const maxWidth = Global.applicationWindow.width - 80
|
2020-11-16 12:32:56 +00:00
|
|
|
|
2023-09-05 16:04:58 +00:00
|
|
|
if (root.image.sourceSize.width >= maxWidth || root.image.sourceSize.height >= maxHeight) {
|
2020-11-16 12:32:56 +00:00
|
|
|
this.width = maxWidth
|
|
|
|
this.height = maxHeight
|
|
|
|
} else {
|
2020-11-17 19:43:52 +00:00
|
|
|
this.width = image.sourceSize.width
|
|
|
|
this.height = image.sourceSize.height
|
2020-11-16 12:32:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-05-16 21:44:34 +00:00
|
|
|
contentItem: AnimatedImage {
|
2020-11-16 12:32:56 +00:00
|
|
|
id: messageImage
|
|
|
|
asynchronous: true
|
|
|
|
fillMode: Image.PreserveAspectFit
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
mipmap: true
|
|
|
|
smooth: false
|
2020-12-15 20:16:49 +00:00
|
|
|
|
2022-05-16 21:44:34 +00:00
|
|
|
onStatusChanged: playing = (status == AnimatedImage.Ready)
|
2020-12-15 20:16:49 +00:00
|
|
|
MouseArea {
|
|
|
|
anchors.fill: parent
|
2021-08-16 09:11:43 +00:00
|
|
|
acceptedButtons: Qt.LeftButton | Qt.RightButton
|
|
|
|
onClicked: {
|
2023-05-19 16:07:50 +00:00
|
|
|
if (mouse.button === Qt.LeftButton)
|
|
|
|
root.close()
|
|
|
|
if (mouse.button === Qt.RightButton)
|
|
|
|
Global.openMenu(imageContextMenu,
|
|
|
|
messageImage,
|
2023-09-05 16:04:58 +00:00
|
|
|
{ imageSource: messageImage.source, url: root.url})
|
2023-05-19 16:07:50 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Component {
|
|
|
|
id: imageContextMenu
|
|
|
|
|
|
|
|
ImageContextMenu {
|
|
|
|
onClosed: {
|
|
|
|
destroy()
|
2021-08-16 09:11:43 +00:00
|
|
|
}
|
2020-12-15 20:16:49 +00:00
|
|
|
}
|
2020-11-16 12:32:56 +00:00
|
|
|
}
|
|
|
|
}
|