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
|
2023-12-06 15:53:31 +00:00
|
|
|
import StatusQ.Popups.Dialog 0.1
|
2024-05-15 09:36:56 +00:00
|
|
|
import StatusQ.Components 0.1
|
|
|
|
import StatusQ.Core.Theme 0.1
|
2021-09-28 15:04:06 +00:00
|
|
|
|
|
|
|
import utils 1.0
|
2021-10-27 21:27:49 +00:00
|
|
|
import shared 1.0
|
2024-05-15 09:36:56 +00:00
|
|
|
import shared.popups 1.0
|
2020-11-16 12:32:56 +00:00
|
|
|
|
2023-12-06 15:53:31 +00:00
|
|
|
StatusDialog {
|
2020-11-16 12:32:56 +00:00
|
|
|
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: ""
|
2024-05-15 09:36:56 +00:00
|
|
|
property bool plain: false
|
2021-08-16 09:11:43 +00:00
|
|
|
|
2024-05-15 09:36:56 +00:00
|
|
|
width: Math.min(root.image.sourceSize.width, d.maxWidth)
|
|
|
|
height: Math.min(root.image.sourceSize.height, d.maxHeight)
|
2023-12-06 15:53:31 +00:00
|
|
|
|
|
|
|
padding: 0
|
|
|
|
background: null
|
|
|
|
standardButtons: Dialog.NoButton
|
2020-11-16 12:32:56 +00:00
|
|
|
closePolicy: Popup.CloseOnEscape | Popup.CloseOnPressOutside
|
2023-12-06 15:53:31 +00:00
|
|
|
|
|
|
|
QtObject {
|
|
|
|
id: d
|
|
|
|
|
|
|
|
property int maxHeight: Global.applicationWindow.height - 80
|
|
|
|
property int maxWidth: Global.applicationWindow.width - 80
|
2024-05-15 09:36:56 +00:00
|
|
|
readonly property int radius: Style.current.radius
|
2020-11-16 12:32:56 +00:00
|
|
|
}
|
|
|
|
|
2024-05-15 09:36:56 +00:00
|
|
|
onOpened: imageLoader.source = root.image.source;
|
|
|
|
onClosed: imageLoader.source = ""
|
|
|
|
|
|
|
|
contentItem: Loader {
|
|
|
|
id: imageLoader
|
|
|
|
|
|
|
|
readonly property bool isError: status === Loader.Error || (imageLoader.item && imageLoader.item.status === Image.Error)
|
|
|
|
readonly property bool isLoading: status === Loader.Loading || (imageLoader.item && imageLoader.item.status === Image.Loading)
|
|
|
|
property string source
|
2020-11-16 12:32:56 +00:00
|
|
|
|
2023-12-06 15:53:31 +00:00
|
|
|
anchors.fill: parent
|
2024-05-15 09:36:56 +00:00
|
|
|
active: true
|
|
|
|
sourceComponent: root.plain ? plainImage : animatedImage
|
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()
|
2024-05-15 09:36:56 +00:00
|
|
|
if (imageLoader.isError || imageLoader.isLoading || mouse.button !== Qt.RightButton)
|
|
|
|
return
|
|
|
|
const isGif = (!root.plain && imageLoader.item && imageLoader.item.playing)
|
|
|
|
Global.openMenu(imageContextMenu,
|
|
|
|
imageLoader.item,
|
|
|
|
{ imageSource: imageLoader.source, url: root.url, isGif: isGif})
|
2023-05-19 16:07:50 +00:00
|
|
|
}
|
|
|
|
}
|
2024-05-15 09:36:56 +00:00
|
|
|
|
|
|
|
Loader {
|
|
|
|
anchors.centerIn: parent
|
|
|
|
width: Math.min(root.width, 300)
|
|
|
|
height: Math.min(root.height, 300)
|
|
|
|
active: imageLoader.isError
|
|
|
|
sourceComponent: LoadingErrorComponent { radius: d.radius }
|
|
|
|
}
|
|
|
|
|
|
|
|
Loader {
|
|
|
|
anchors.fill: parent
|
|
|
|
active: imageLoader.isLoading
|
|
|
|
sourceComponent: LoadingComponent {radius: d.radius}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Component {
|
|
|
|
id: animatedImage
|
|
|
|
AnimatedImage {
|
|
|
|
asynchronous: true
|
|
|
|
fillMode: Image.PreserveAspectFit
|
|
|
|
mipmap: true
|
|
|
|
smooth: false
|
|
|
|
onStatusChanged: playing = (status == AnimatedImage.Ready)
|
|
|
|
source: imageLoader.source
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Component {
|
|
|
|
id: plainImage
|
|
|
|
Image {
|
|
|
|
asynchronous: true
|
|
|
|
fillMode: Image.PreserveAspectFit
|
|
|
|
mipmap: true
|
|
|
|
smooth: false
|
|
|
|
source: imageLoader.source
|
|
|
|
}
|
2023-05-19 16:07:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Component {
|
|
|
|
id: imageContextMenu
|
|
|
|
|
|
|
|
ImageContextMenu {
|
2024-05-15 09:36:56 +00:00
|
|
|
isVideo: false
|
2023-05-19 16:07:50 +00:00
|
|
|
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
|
|
|
}
|
|
|
|
}
|