Display extra content in message overlay
This commit is contained in:
parent
2830f50a35
commit
541036d796
8 changed files with 75 additions and 29 deletions
|
@ -25,13 +25,14 @@ Item {
|
||||||
id: audioMessageComponent
|
id: audioMessageComponent
|
||||||
|
|
||||||
property ListItem messageListItem
|
property ListItem messageListItem
|
||||||
property var rawMessage: messageListItem.myMessage
|
property MessageOverlayFlickable overlayFlickable
|
||||||
|
property var rawMessage: messageListItem ? messageListItem.myMessage : overlayFlickable.overlayMessage
|
||||||
|
|
||||||
property var audioData: ( rawMessage.content['@type'] === "messageVoiceNote" ) ? rawMessage.content.voice_note : ( ( rawMessage.content['@type'] === "messageAudio" ) ? rawMessage.content.audio : "");
|
property var audioData: ( rawMessage.content['@type'] === "messageVoiceNote" ) ? rawMessage.content.voice_note : ( ( rawMessage.content['@type'] === "messageAudio" ) ? rawMessage.content.audio : "");
|
||||||
property string audioUrl;
|
property string audioUrl;
|
||||||
property int previewFileId;
|
property int previewFileId;
|
||||||
property int audioFileId;
|
property int audioFileId;
|
||||||
property bool onScreen: messageListItem.page.status === PageStatus.Active
|
property bool onScreen: messageListItem ? messageListItem.page.status === PageStatus.Active : true
|
||||||
property string audioType : "voiceNote";
|
property string audioType : "voiceNote";
|
||||||
|
|
||||||
width: parent.width
|
width: parent.width
|
||||||
|
|
|
@ -26,7 +26,8 @@ Item {
|
||||||
height: Theme.itemSizeLarge
|
height: Theme.itemSizeLarge
|
||||||
|
|
||||||
property ListItem messageListItem
|
property ListItem messageListItem
|
||||||
property var rawMessage: messageListItem.myMessage
|
property MessageOverlayFlickable overlayFlickable
|
||||||
|
property var rawMessage: messageListItem ? messageListItem.myMessage : overlayFlickable.overlayMessage
|
||||||
|
|
||||||
property var documentData: rawMessage.content.document
|
property var documentData: rawMessage.content.document
|
||||||
property bool openRequested: false;
|
property bool openRequested: false;
|
||||||
|
|
|
@ -24,7 +24,8 @@ Item {
|
||||||
id: imagePreviewItem
|
id: imagePreviewItem
|
||||||
|
|
||||||
property ListItem messageListItem
|
property ListItem messageListItem
|
||||||
property var rawMessage: messageListItem.myMessage
|
property MessageOverlayFlickable overlayFlickable
|
||||||
|
property var rawMessage: messageListItem ? messageListItem.myMessage : overlayFlickable.overlayMessage
|
||||||
property var photoData: rawMessage.content.photo;
|
property var photoData: rawMessage.content.photo;
|
||||||
property var pictureFileInformation;
|
property var pictureFileInformation;
|
||||||
|
|
||||||
|
|
|
@ -25,11 +25,12 @@ Item {
|
||||||
id: imagePreviewItem
|
id: imagePreviewItem
|
||||||
|
|
||||||
property ListItem messageListItem
|
property ListItem messageListItem
|
||||||
property var rawMessage: messageListItem.myMessage
|
property MessageOverlayFlickable overlayFlickable
|
||||||
|
property var rawMessage: messageListItem ? messageListItem.myMessage : overlayFlickable.overlayMessage
|
||||||
|
|
||||||
property var locationData : ( rawMessage.content['@type'] === "messageLocation" ) ? rawMessage.content.location : ( ( rawMessage.content['@type'] === "messageVenue" ) ? rawMessage.content.venue.location : "" )
|
property var locationData : ( rawMessage.content['@type'] === "messageLocation" ) ? rawMessage.content.location : ( ( rawMessage.content['@type'] === "messageVenue" ) ? rawMessage.content.venue.location : "" )
|
||||||
|
|
||||||
property string chatId: messageListItem.page.chatInformation.id
|
property string chatId: rawMessage.chat_id
|
||||||
property var pictureFileInformation;
|
property var pictureFileInformation;
|
||||||
width: parent.width
|
width: parent.width
|
||||||
height: width / 2
|
height: width / 2
|
||||||
|
|
|
@ -33,6 +33,8 @@ Flickable {
|
||||||
property bool showHeader: true
|
property bool showHeader: true
|
||||||
readonly property var userInformation: tdLibWrapper.getUserInformation(overlayMessage.sender_user_id);
|
readonly property var userInformation: tdLibWrapper.getUserInformation(overlayMessage.sender_user_id);
|
||||||
readonly property bool isOwnMessage: tdLibWrapper.getUserInformation().id === overlayMessage.sender_user_id;
|
readonly property bool isOwnMessage: tdLibWrapper.getUserInformation().id === overlayMessage.sender_user_id;
|
||||||
|
readonly property string extraContentComponentName: (typeof overlayMessage.content !== "undefined" && typeof chatView.contentComponentNames[overlayMessage.content['@type']] !== "undefined" )
|
||||||
|
? chatView.contentComponentNames[overlayMessage.content['@type']] : ""
|
||||||
signal requestClose;
|
signal requestClose;
|
||||||
|
|
||||||
function getOriginalAuthor(forwardInformation, fontSize) {
|
function getOriginalAuthor(forwardInformation, fontSize) {
|
||||||
|
@ -58,17 +60,17 @@ Flickable {
|
||||||
running: false
|
running: false
|
||||||
onTriggered: {
|
onTriggered: {
|
||||||
if (typeof overlayMessage.content !== "undefined") {
|
if (typeof overlayMessage.content !== "undefined") {
|
||||||
// if (messageListItem.extraContentComponentName !== "") {
|
if (messageOverlayFlickable.extraContentComponentName !== "") {
|
||||||
// extraContentLoader.setSource(
|
overlayExtraContentLoader.setSource(
|
||||||
// "../components/" +messageListItem.extraContentComponentName +".qml",
|
"../components/" + messageOverlayFlickable.extraContentComponentName + ".qml",
|
||||||
// {
|
{
|
||||||
// messageListItem: messageListItem
|
overlayFlickable: messageOverlayFlickable
|
||||||
// })
|
})
|
||||||
// } else {
|
} else {
|
||||||
if (typeof overlayMessage.content.web_page !== "undefined") {
|
if (typeof overlayMessage.content.web_page !== "undefined") {
|
||||||
overlayWebPagePreviewLoader.active = true;
|
overlayWebPagePreviewLoader.active = true;
|
||||||
}
|
}
|
||||||
// }
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -169,6 +171,40 @@ Flickable {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loader {
|
||||||
|
id: overlayExtraContentLoader
|
||||||
|
width: parent.width
|
||||||
|
asynchronous: true
|
||||||
|
}
|
||||||
|
|
||||||
|
Timer {
|
||||||
|
id: messageDateUpdater
|
||||||
|
interval: 60000
|
||||||
|
running: true
|
||||||
|
repeat: true
|
||||||
|
onTriggered: {
|
||||||
|
overlayMessageDateText.text = ( overlayMessageDateText.useElapsed ? Functions.getDateTimeElapsed(overlayMessage.date) : Functions.getDateTimeTranslated(overlayMessage.date) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Text {
|
||||||
|
width: parent.width
|
||||||
|
|
||||||
|
property bool useElapsed: true
|
||||||
|
|
||||||
|
id: overlayMessageDateText
|
||||||
|
font.pixelSize: Theme.fontSizeExtraSmall
|
||||||
|
color: Theme.secondaryColor
|
||||||
|
text: ( useElapsed ? Functions.getDateTimeElapsed(overlayMessage.date) : Functions.getDateTimeTranslated(overlayMessage.date) )
|
||||||
|
MouseArea {
|
||||||
|
anchors.fill: parent
|
||||||
|
onClicked: {
|
||||||
|
overlayMessageDateText.useElapsed = !overlayMessageDateText.useElapsed;
|
||||||
|
overlayMessageDateText.text = ( useElapsed ? Functions.getDateTimeElapsed(overlayMessage.date) : Functions.getDateTimeTranslated(overlayMessage.date) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Label {
|
Label {
|
||||||
id: separatorLabel
|
id: separatorLabel
|
||||||
width: parent.width
|
width: parent.width
|
||||||
|
|
|
@ -28,10 +28,11 @@ Item {
|
||||||
|
|
||||||
|
|
||||||
property ListItem messageListItem
|
property ListItem messageListItem
|
||||||
property var rawMessage: messageListItem.myMessage
|
property MessageOverlayFlickable overlayFlickable
|
||||||
property string chatId: messageListItem.page.chatInformation.id
|
property var rawMessage: messageListItem ? messageListItem.myMessage : overlayFlickable.overlayMessage
|
||||||
|
property string chatId: rawMessage.chat_id
|
||||||
|
|
||||||
property bool isOwnMessage: messageListItem.isOwnMessage
|
property bool isOwnMessage: messageListItem ? messageListItem.isOwnMessage : overlayFlickable.isOwnMessage
|
||||||
|
|
||||||
property string messageId: rawMessage.id
|
property string messageId: rawMessage.id
|
||||||
property bool canEdit: rawMessage.can_be_edited
|
property bool canEdit: rawMessage.can_be_edited
|
||||||
|
|
|
@ -21,12 +21,15 @@ import Sailfish.Silica 1.0
|
||||||
import WerkWolf.Fernschreiber 1.0
|
import WerkWolf.Fernschreiber 1.0
|
||||||
|
|
||||||
Item {
|
Item {
|
||||||
property ListItem messageListItem
|
|
||||||
|
|
||||||
readonly property var stickerData: messageListItem.myMessage.content.sticker;
|
property ListItem messageListItem
|
||||||
|
property MessageOverlayFlickable overlayFlickable
|
||||||
|
|
||||||
|
readonly property var stickerData: messageListItem ? messageListItem.myMessage.content.sticker : overlayFlickable.overlayMessage.content.sticker;
|
||||||
readonly property bool animated: stickerData.is_animated && appSettings.animateStickers
|
readonly property bool animated: stickerData.is_animated && appSettings.animateStickers
|
||||||
readonly property bool stickerVisible: staticStickerLoader.item ? staticStickerLoader.item.visible :
|
readonly property bool stickerVisible: staticStickerLoader.item ? staticStickerLoader.item.visible :
|
||||||
animatedStickerLoader.item ? animatedStickerLoader.item.visible : false
|
animatedStickerLoader.item ? animatedStickerLoader.item.visible : false
|
||||||
|
readonly property bool isOwnSticker : messageListItem ? messageListItem.isOwnMessage : overlayFlickable.isOwnMessage
|
||||||
property real aspectRatio: stickerData.width / stickerData.height
|
property real aspectRatio: stickerData.width / stickerData.height
|
||||||
|
|
||||||
implicitWidth: stickerData.width
|
implicitWidth: stickerData.width
|
||||||
|
@ -44,7 +47,7 @@ Item {
|
||||||
height: width * aspectRatio
|
height: width * aspectRatio
|
||||||
// (centered in image mode, text-like in sticker mode)
|
// (centered in image mode, text-like in sticker mode)
|
||||||
x: appSettings.showStickersAsImages ? (parent.width - width) / 2 :
|
x: appSettings.showStickersAsImages ? (parent.width - width) / 2 :
|
||||||
messageListItem.isOwnMessage ? (parent.width - width) : 0
|
isOwnSticker ? (parent.width - width) : 0
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
|
|
||||||
Loader {
|
Loader {
|
||||||
|
|
|
@ -25,19 +25,21 @@ Item {
|
||||||
id: videoMessageComponent
|
id: videoMessageComponent
|
||||||
|
|
||||||
property ListItem messageListItem
|
property ListItem messageListItem
|
||||||
property var rawMessage: messageListItem.myMessage
|
property MessageOverlayFlickable overlayFlickable
|
||||||
|
property var rawMessage: messageListItem ? messageListItem.myMessage : overlayFlickable.overlayMessage
|
||||||
|
|
||||||
property var videoData: ( rawMessage.content['@type'] === "messageVideo" ) ? rawMessage.content.video : ( ( rawMessage.content['@type'] === "messageAnimation" ) ? rawMessage.content.animation : rawMessage.content.video_note )
|
property var videoData: ( rawMessage.content['@type'] === "messageVideo" ) ? rawMessage.content.video : ( ( rawMessage.content['@type'] === "messageAnimation" ) ? rawMessage.content.animation : rawMessage.content.video_note )
|
||||||
property string videoUrl;
|
property string videoUrl;
|
||||||
property int previewFileId;
|
property int previewFileId;
|
||||||
property int videoFileId;
|
property int videoFileId;
|
||||||
|
property bool isVideoNote : false;
|
||||||
property bool fullscreen : false;
|
property bool fullscreen : false;
|
||||||
property bool onScreen: messageListItem.page.status === PageStatus.Active;
|
property bool onScreen: messageListItem ? messageListItem.page.status === PageStatus.Active : true;
|
||||||
property string videoType : "video";
|
property string videoType : "video";
|
||||||
property bool playRequested: false;
|
property bool playRequested: false;
|
||||||
|
|
||||||
width: parent.width
|
width: parent.width
|
||||||
height: ( rawMessage.content['@type'] === "messageVideoNote" ) ? width : Functions.getVideoHeight(width, videoData)
|
height: videoMessageComponent.isVideoNote ? width : Functions.getVideoHeight(width, videoData)
|
||||||
|
|
||||||
Timer {
|
Timer {
|
||||||
id: screensaverTimer
|
id: screensaverTimer
|
||||||
|
@ -78,11 +80,11 @@ Item {
|
||||||
|
|
||||||
function updateVideoThumbnail() {
|
function updateVideoThumbnail() {
|
||||||
if (videoData) {
|
if (videoData) {
|
||||||
if (rawMessage.content['@type'] === "messageVideoNote") {
|
if (typeof rawMessage !== "undefined") {
|
||||||
videoType = "video";
|
videoMessageComponent.isVideoNote = rawMessage.content['@type'] === "messageVideoNote";
|
||||||
} else {
|
|
||||||
videoType = videoData['@type'];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
videoMessageComponent.videoType = videoMessageComponent.isVideoNote ? "video" : videoData['@type'];
|
||||||
videoFileId = videoData[videoType].id;
|
videoFileId = videoData[videoType].id;
|
||||||
if (typeof videoData.thumbnail !== "undefined") {
|
if (typeof videoData.thumbnail !== "undefined") {
|
||||||
previewFileId = videoData.thumbnail.photo.id;
|
previewFileId = videoData.thumbnail.photo.id;
|
||||||
|
@ -264,7 +266,7 @@ Item {
|
||||||
id: videoComponentLoader
|
id: videoComponentLoader
|
||||||
active: false
|
active: false
|
||||||
width: parent.width
|
width: parent.width
|
||||||
height: ( rawMessage.content['@type'] === "messageVideoNote" ) ? width : Functions.getVideoHeight(parent.width, videoData)
|
height: videoMessageComponent.isVideoNote ? width : Functions.getVideoHeight(parent.width, videoData)
|
||||||
sourceComponent: videoComponent
|
sourceComponent: videoComponent
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue