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
|
2020-11-16 12:32:56 +00:00
|
|
|
|
|
|
|
Popup {
|
|
|
|
id: root
|
2021-08-16 09:11:43 +00:00
|
|
|
|
|
|
|
signal clicked(var button)
|
|
|
|
property string imageSource: messageImage.source
|
|
|
|
|
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
|
|
|
|
|
|
|
|
function setPopupData(image) {
|
2020-11-17 19:43:52 +00:00
|
|
|
messageImage.source = 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
|
|
|
|
|
|
|
|
2020-11-17 19:43:52 +00:00
|
|
|
if (image.sourceSize.width >= maxWidth || 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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function openPopup(image) {
|
|
|
|
setPopupData(image);
|
|
|
|
root.open();
|
|
|
|
}
|
|
|
|
|
|
|
|
contentItem: Image {
|
|
|
|
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
|
|
|
|
|
|
|
MouseArea {
|
|
|
|
anchors.fill: parent
|
2021-08-16 09:11:43 +00:00
|
|
|
acceptedButtons: Qt.LeftButton | Qt.RightButton
|
|
|
|
onClicked: {
|
|
|
|
root.clicked(mouse.button)
|
|
|
|
}
|
2020-12-15 20:16:49 +00:00
|
|
|
}
|
2020-11-16 12:32:56 +00:00
|
|
|
}
|
|
|
|
}
|