harbour-fernschreiber/qml/components/messageContent/MessageLocation.qml

92 lines
2.9 KiB
QML
Raw Permalink Normal View History

/*
Copyright (C) 2020 Sebastian J. Wolf and other contributors
This file is part of Fernschreiber.
Fernschreiber is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Fernschreiber is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Fernschreiber. If not, see <http://www.gnu.org/licenses/>.
*/
2020-10-31 22:49:03 +03:00
import QtQuick 2.6
import QtGraphicalEffects 1.0
import Sailfish.Silica 1.0
import "../"
MessageContentBase {
2021-01-20 00:41:06 +03:00
id: contentItem
height: width * 0.66666666;
2021-01-20 00:41:06 +03:00
property var locationData : rawMessage.content.location
property string fileExtra;
onClicked: {
Qt.openUrlExternally("geo:" + locationData.latitude + "," + locationData.longitude);
}
2021-01-20 00:41:06 +03:00
onLocationDataChanged: updatePicture()
onWidthChanged: updatePicture()
function updatePicture() {
if (locationData) {
2021-01-20 00:41:06 +03:00
fileExtra = "location:" + locationData.latitude + ":" + locationData.longitude + ":" + Math.round(contentItem.width) + ":" + Math.round(contentItem.height);
tdLibWrapper.getMapThumbnailFile(rawMessage.chat_id, locationData.latitude, locationData.longitude, Math.round(contentItem.width), Math.round(contentItem.height), fileExtra);
}
}
Connections {
target: tdLibWrapper
onFileUpdated: {
2021-01-20 00:41:06 +03:00
if(fileInformation["@extra"] === contentItem.fileExtra) {
if(fileInformation.id !== image.file.fileId) {
image.fileInformation = fileInformation
}
}
}
}
AppNotification {
id: imageNotification
}
2021-01-20 00:41:06 +03:00
TDLibImage {
id: image
anchors.fill: parent
cache: false
2021-01-20 02:57:31 +03:00
highlighted: contentItem.highlighted
Item {
anchors.centerIn: parent
width: markerImage.width
height: markerImage.height * 1.75 // 0.875 (vertical pin point) * 2
2021-01-20 00:41:06 +03:00
Icon {
id: markerImage
source: 'image://theme/icon-m-location'
}
DropShadow {
anchors.fill: markerImage
horizontalOffset: 3
verticalOffset: 3
radius: 8.0
samples: 17
color: Theme.colorScheme ? Theme.lightPrimaryColor : Theme.darkPrimaryColor
source: markerImage
}
}
}
BackgroundImage {
2021-01-20 00:41:06 +03:00
visible: image.status !== Image.Ready
}
2021-01-20 00:41:06 +03:00
Component.onCompleted: {
updatePicture();
}
}