Use MediaPopup to display images

This commit is contained in:
Christian Muehlhaeuser 2020-02-28 05:36:47 +01:00
parent d723eb52dc
commit e283421bf7
No known key found for this signature in database
GPG key ID: 3CF9FA45CA1EBB7E
3 changed files with 41 additions and 1 deletions

27
qml/MediaPopup.qml Normal file
View file

@ -0,0 +1,27 @@
import QtQuick 2.4
import QtQuick.Controls 2.1
import QtQuick.Controls.Material 2.1
import QtQuick.Layouts 1.3
Popup {
property var url
id: popup
modal: true
focus: true
height: image.height + 16
width: image.width + 16
anchors.centerIn: mainWindow.overlay
closePolicy: Popup.CloseOnEscape | Popup.CloseOnPressOutsideParent
Image {
id: image
height: Math.min(sourceSize.height, mainWindow.height * 0.8)
width: Math.min(sourceSize.width, mainWindow.width * 0.8)
anchors.centerIn: parent
smooth: true
fillMode: Image.PreserveAspectFit
source: url
}
}

View file

@ -285,7 +285,8 @@ ColumnLayout {
animationDuration: 200
onClicked: function() {
Qt.openUrlExternally(message.mediaurl[index])
ComponentCreator.createMediaPopup(this, message.mediaurl[index]).open();
// Qt.openUrlExternally(message.mediaurl[index])
}
}
}

View file

@ -57,3 +57,15 @@ function createAccountPopup(parent) {
}
return popup
}
function createMediaPopup(parent, model) {
var component = Qt.createComponent("MediaPopup.qml")
var popup = component.createObject(parent, {
"url": model
})
if (popup == null) {
console.log("Error creating MediaPopup")
}
return popup
}