mirror of
https://github.com/status-im/status-desktop.git
synced 2025-01-22 04:21:44 +00:00
4ee21ada05
Introduced Style.svg() Style.png() Style.emoji() and Style.icon() in Style.qml. Those should be used to set the source in Images instead of using relative paths. Usage: Image { source: Style.svg("check) .... Also moved all Singletons inside a new "utils" folder and made it a QML module, to use import utils 1.0 instead of relative paths Closes #3678
67 lines
1.7 KiB
QML
67 lines
1.7 KiB
QML
import QtQuick 2.13
|
|
import QtQuick.Window 2.2
|
|
import QtQuick.Controls 2.13
|
|
import QtQuick.Layouts 1.13
|
|
import QtGraphicalEffects 1.13
|
|
|
|
import utils 1.0
|
|
import "../../shared"
|
|
|
|
Popup {
|
|
id: root
|
|
|
|
signal clicked(var button)
|
|
property string imageSource: messageImage.source
|
|
|
|
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) {
|
|
messageImage.source = image.source;
|
|
const maxHeight = applicationWindow.height - 80
|
|
const maxWidth = applicationWindow.width - 80
|
|
|
|
|
|
if (image.sourceSize.width >= maxWidth || image.sourceSize.height >= maxHeight) {
|
|
this.width = maxWidth
|
|
this.height = maxHeight
|
|
} else {
|
|
this.width = image.sourceSize.width
|
|
this.height = image.sourceSize.height
|
|
}
|
|
}
|
|
|
|
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
|
|
|
|
MouseArea {
|
|
anchors.fill: parent
|
|
acceptedButtons: Qt.LeftButton | Qt.RightButton
|
|
onClicked: {
|
|
root.clicked(mouse.button)
|
|
}
|
|
}
|
|
}
|
|
}
|