2020-09-28 23:58:11 +03:00
|
|
|
/*
|
2020-10-19 20:34:47 +03:00
|
|
|
Copyright (C) 2020 Sebastian J. Wolf and other contributors
|
2020-09-28 23:58:11 +03:00
|
|
|
|
|
|
|
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
|
2020-09-28 23:58:11 +03:00
|
|
|
import QtGraphicalEffects 1.0
|
|
|
|
import Sailfish.Silica 1.0
|
2021-01-15 12:21:23 +03:00
|
|
|
import "../"
|
2020-09-28 23:58:11 +03:00
|
|
|
|
2021-01-15 12:21:23 +03:00
|
|
|
MessageContentBase {
|
2021-01-20 00:41:06 +03:00
|
|
|
id: contentItem
|
2021-01-17 23:19:29 +03:00
|
|
|
height: width * 0.66666666;
|
2020-09-28 23:58:11 +03:00
|
|
|
|
2021-01-20 00:41:06 +03:00
|
|
|
property var locationData : rawMessage.content.location
|
|
|
|
property string fileExtra;
|
|
|
|
|
2021-01-15 12:21:23 +03:00
|
|
|
onClicked: {
|
2022-04-26 23:26:54 +03:00
|
|
|
Qt.openUrlExternally("geo:" + locationData.latitude + "," + locationData.longitude);
|
2020-12-04 22:22:21 +03:00
|
|
|
}
|
2021-01-20 00:41:06 +03:00
|
|
|
onLocationDataChanged: updatePicture()
|
|
|
|
onWidthChanged: updatePicture()
|
|
|
|
|
2020-09-28 23:58:11 +03:00
|
|
|
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);
|
2020-09-28 23:58:11 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
|
}
|
2021-01-10 04:06:41 +03:00
|
|
|
}
|
2020-09-28 23:58:11 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
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
|
2020-09-28 23:58:11 +03:00
|
|
|
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 {
|
2020-09-28 23:58:11 +03:00
|
|
|
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
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-10-26 17:15:53 +03:00
|
|
|
BackgroundImage {
|
2021-01-20 00:41:06 +03:00
|
|
|
visible: image.status !== Image.Ready
|
2020-09-28 23:58:11 +03:00
|
|
|
}
|
|
|
|
|
2021-01-20 00:41:06 +03:00
|
|
|
Component.onCompleted: {
|
|
|
|
updatePicture();
|
|
|
|
}
|
2020-09-28 23:58:11 +03:00
|
|
|
}
|