Use dedicated Files for message content
This commit is contained in:
parent
282ab1d2b9
commit
aa7a1f28ce
6 changed files with 84 additions and 58 deletions
|
@ -62,7 +62,6 @@ DISTFILES += qml/harbour-fernschreiber.qml \
|
||||||
qml/components/StickerPicker.qml \
|
qml/components/StickerPicker.qml \
|
||||||
qml/components/PhotoTextsListItem.qml \
|
qml/components/PhotoTextsListItem.qml \
|
||||||
qml/components/VoiceNoteOverlay.qml \
|
qml/components/VoiceNoteOverlay.qml \
|
||||||
qml/components/WebPagePreview.qml \
|
|
||||||
qml/components/chatInformationPage/ChatInformationEditArea.qml \
|
qml/components/chatInformationPage/ChatInformationEditArea.qml \
|
||||||
qml/components/chatInformationPage/ChatInformationPageContent.qml \
|
qml/components/chatInformationPage/ChatInformationPageContent.qml \
|
||||||
qml/components/chatInformationPage/ChatInformationProfilePicture.qml \
|
qml/components/chatInformationPage/ChatInformationProfilePicture.qml \
|
||||||
|
@ -89,6 +88,20 @@ DISTFILES += qml/harbour-fernschreiber.qml \
|
||||||
qml/components/inlineQueryResults/InlineQueryResultVenue.qml \
|
qml/components/inlineQueryResults/InlineQueryResultVenue.qml \
|
||||||
qml/components/inlineQueryResults/InlineQueryResultVideo.qml \
|
qml/components/inlineQueryResults/InlineQueryResultVideo.qml \
|
||||||
qml/components/inlineQueryResults/InlineQueryResultVoiceNote.qml \
|
qml/components/inlineQueryResults/InlineQueryResultVoiceNote.qml \
|
||||||
|
qml/components/messageContent/MessageAnimation.qml \
|
||||||
|
qml/components/messageContent/MessageAudio.qml \
|
||||||
|
qml/components/messageContent/MessageContentBase.qml \
|
||||||
|
qml/components/messageContent/MessageDocument.qml \
|
||||||
|
qml/components/messageContent/MessageGame.qml \
|
||||||
|
qml/components/messageContent/MessageLocation.qml \
|
||||||
|
qml/components/messageContent/MessagePhoto.qml \
|
||||||
|
qml/components/messageContent/MessagePoll.qml \
|
||||||
|
qml/components/messageContent/MessageSticker.qml \
|
||||||
|
qml/components/messageContent/MessageVenue.qml \
|
||||||
|
qml/components/messageContent/MessageVideoNote.qml \
|
||||||
|
qml/components/messageContent/MessageVideo.qml \
|
||||||
|
qml/components/messageContent/MessageVoiceNote.qml \
|
||||||
|
qml/components/messageContent/WebPagePreview.qml \
|
||||||
qml/js/debug.js \
|
qml/js/debug.js \
|
||||||
qml/js/functions.js \
|
qml/js/functions.js \
|
||||||
qml/pages/ChatInformationPage.qml \
|
qml/pages/ChatInformationPage.qml \
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
*/
|
*/
|
||||||
import QtQuick 2.6
|
import QtQuick 2.6
|
||||||
import Sailfish.Silica 1.0
|
import Sailfish.Silica 1.0
|
||||||
|
import "./messageContent"
|
||||||
import "../js/twemoji.js" as Emoji
|
import "../js/twemoji.js" as Emoji
|
||||||
import "../js/functions.js" as Functions
|
import "../js/functions.js" as Functions
|
||||||
import "../js/debug.js" as Debug
|
import "../js/debug.js" as Debug
|
||||||
|
@ -40,7 +41,7 @@ ListItem {
|
||||||
return existingMessage.id === messageId
|
return existingMessage.id === messageId
|
||||||
});
|
});
|
||||||
readonly property bool isOwnMessage: page.myUserId === myMessage.sender.user_id
|
readonly property bool isOwnMessage: page.myUserId === myMessage.sender.user_id
|
||||||
property string extraContentComponentName
|
property bool hasContentComponent
|
||||||
|
|
||||||
highlighted: (down || isSelected) && !menuOpen
|
highlighted: (down || isSelected) && !menuOpen
|
||||||
openMenuOnPressAndHold: !messageListItem.precalculatedValues.pageIsSelecting
|
openMenuOnPressAndHold: !messageListItem.precalculatedValues.pageIsSelecting
|
||||||
|
@ -199,17 +200,16 @@ ListItem {
|
||||||
repeat: false
|
repeat: false
|
||||||
running: false
|
running: false
|
||||||
onTriggered: {
|
onTriggered: {
|
||||||
if (typeof myMessage.content !== "undefined") {
|
if (messageListItem.hasContentComponent) {
|
||||||
if (messageListItem.extraContentComponentName !== "") {
|
var type = myMessage.content["@type"];
|
||||||
extraContentLoader.setSource(
|
extraContentLoader.setSource(
|
||||||
"../components/" +messageListItem.extraContentComponentName +".qml",
|
"../components/messageContent/" + type.charAt(0).toUpperCase() + type.substring(1) + ".qml",
|
||||||
{
|
{
|
||||||
messageListItem: messageListItem
|
messageListItem: messageListItem
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
if (typeof myMessage.content.web_page !== "undefined") { // only in messageText
|
if (typeof myMessage.content.web_page !== "undefined") { // only in messageText
|
||||||
webPagePreviewLoader.active = true;
|
webPagePreviewLoader.active = true;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -435,7 +435,7 @@ ListItem {
|
||||||
id: extraContentLoader
|
id: extraContentLoader
|
||||||
width: parent.width
|
width: parent.width
|
||||||
asynchronous: true
|
asynchronous: true
|
||||||
height: item ? item.height : (messageListItem.extraContentComponentName !== "" ? chatView.getContentComponentHeight(messageListItem.extraContentComponentName, myMessage.content, width) : 0)
|
height: item ? item.height : (messageListItem.hasContentComponent ? chatView.getContentComponentHeight(model.content_type, myMessage.content, width) : 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
Binding {
|
Binding {
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
*/
|
*/
|
||||||
import QtQuick 2.6
|
import QtQuick 2.6
|
||||||
import Sailfish.Silica 1.0
|
import Sailfish.Silica 1.0
|
||||||
|
import "./messageContent"
|
||||||
import "../js/functions.js" as Functions
|
import "../js/functions.js" as Functions
|
||||||
import "../js/twemoji.js" as Emoji
|
import "../js/twemoji.js" as Emoji
|
||||||
import "../js/debug.js" as Debug
|
import "../js/debug.js" as Debug
|
||||||
|
@ -34,8 +35,7 @@ Flickable {
|
||||||
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 bool isAnonymous: overlayMessage.sender["@type"] === "messageSenderChat"
|
readonly property bool isAnonymous: overlayMessage.sender["@type"] === "messageSenderChat"
|
||||||
readonly property string extraContentComponentName: (typeof overlayMessage.content !== "undefined" && typeof chatView.contentComponentNames[overlayMessage.content['@type']] !== "undefined" )
|
property bool hasContentComponent: overlayMessage.content && chatView.delegateMessagesContent.indexOf(overlayMessage.content['@type']) > -1
|
||||||
? chatView.contentComponentNames[overlayMessage.content['@type']] : ""
|
|
||||||
signal requestClose;
|
signal requestClose;
|
||||||
|
|
||||||
function getOriginalAuthor(forwardInformation, fontSize) {
|
function getOriginalAuthor(forwardInformation, fontSize) {
|
||||||
|
@ -61,18 +61,15 @@ Flickable {
|
||||||
repeat: false
|
repeat: false
|
||||||
running: false
|
running: false
|
||||||
onTriggered: {
|
onTriggered: {
|
||||||
if (typeof overlayMessage.content !== "undefined") {
|
if (messageOverlayFlickable.hasContentComponent) {
|
||||||
if (messageOverlayFlickable.extraContentComponentName !== "") {
|
var type = overlayMessage.content["@type"];
|
||||||
overlayExtraContentLoader.setSource(
|
overlayExtraContentLoader.setSource(
|
||||||
"../components/" + messageOverlayFlickable.extraContentComponentName + ".qml",
|
"../components/messageContent/" + type.charAt(0).toUpperCase() + type.substring(1) + ".qml",
|
||||||
{
|
{
|
||||||
overlayFlickable: messageOverlayFlickable
|
overlayFlickable: messageOverlayFlickable
|
||||||
})
|
})
|
||||||
} else {
|
} else if(overlayMessage.content && overlayMessage.content.web_page) {
|
||||||
if (typeof overlayMessage.content.web_page !== "undefined") {
|
overlayWebPagePreviewLoader.active = true;
|
||||||
overlayWebPagePreviewLoader.active = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,8 @@ import QtQuick 2.6
|
||||||
import QtGraphicalEffects 1.0
|
import QtGraphicalEffects 1.0
|
||||||
import Sailfish.Silica 1.0
|
import Sailfish.Silica 1.0
|
||||||
import WerkWolf.Fernschreiber 1.0
|
import WerkWolf.Fernschreiber 1.0
|
||||||
import "../js/functions.js" as Functions
|
import "../"
|
||||||
|
import "../../js/functions.js" as Functions
|
||||||
|
|
||||||
Column {
|
Column {
|
||||||
id: webPagePreviewColumn
|
id: webPagePreviewColumn
|
||||||
|
|
|
@ -1056,39 +1056,53 @@ Page {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
readonly property var contentComponentNames: ({
|
function getContentComponentHeight(contentType, content, parentWidth) {
|
||||||
messageSticker: "StickerPreview",
|
switch(contentType) {
|
||||||
messagePhoto: "ImagePreview",
|
case "messageAnimation":
|
||||||
messageVideo: "VideoPreview",
|
return Functions.getVideoHeight(parentWidth, content.video);
|
||||||
messageVideoNote: "VideoPreview",
|
case "messageAudio":
|
||||||
messageAnimation: "VideoPreview",
|
case "messageVoiceNote":
|
||||||
messageAudio: "AudioPreview",
|
return Theme.itemSizeLarge;
|
||||||
messageVoiceNote: "AudioPreview",
|
case "messageDocument":
|
||||||
messageDocument: "DocumentPreview",
|
|
||||||
messageLocation: "LocationPreview",
|
|
||||||
messageVenue: "LocationPreview",
|
|
||||||
messagePoll: "PollPreview",
|
|
||||||
messageGame: "GamePreview"
|
|
||||||
})
|
|
||||||
function getContentComponentHeight(componentName, content, parentWidth) {
|
|
||||||
switch(componentName) {
|
|
||||||
case "StickerPreview": return content.sticker.height;
|
|
||||||
case "ImagePreview":
|
|
||||||
case "LocationPreview":
|
|
||||||
return parentWidth * 0.66666666; // 2 / 3;
|
|
||||||
case "VideoPreview":
|
|
||||||
return ( content['@type'] === "messageVideoNote" ) ? parentWidth : ( Functions.getVideoHeight(parentWidth, ( content['@type'] === "messageVideo" ) ? content.video : content.animation) );
|
|
||||||
case "AudioPreview":
|
|
||||||
return parentWidth / 2;
|
|
||||||
case "DocumentPreview":
|
|
||||||
return Theme.itemSizeSmall;
|
return Theme.itemSizeSmall;
|
||||||
case "PollPreview":
|
case "messageGame":
|
||||||
return Theme.itemSizeSmall * (4 + content.poll.options);
|
|
||||||
case "GamePreview":
|
|
||||||
return parentWidth * 0.66666666 + Theme.itemSizeLarge; // 2 / 3;
|
return parentWidth * 0.66666666 + Theme.itemSizeLarge; // 2 / 3;
|
||||||
|
case "messageLocation":
|
||||||
|
case "messagePhoto":
|
||||||
|
case "messageVenue":
|
||||||
|
return parentWidth * 0.66666666; // 2 / 3;
|
||||||
|
case "messagePoll":
|
||||||
|
return Theme.itemSizeSmall * (4 + content.poll.options);
|
||||||
|
case "messageSticker":
|
||||||
|
return content.sticker.height;
|
||||||
|
case "messageVideo":
|
||||||
|
return Functions.getVideoHeight(parentWidth, content.video);
|
||||||
|
case "messageVideoNote":
|
||||||
|
return parentWidth
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
readonly property var delegateMessagesContent: [
|
||||||
|
"messageAnimation",
|
||||||
|
"messageAudio",
|
||||||
|
// "messageContact",
|
||||||
|
// "messageDice"
|
||||||
|
"messageDocument",
|
||||||
|
"messageGame",
|
||||||
|
// "messageInvoice",
|
||||||
|
"messageLocation",
|
||||||
|
// "messagePassportDataSent",
|
||||||
|
// "messagePaymentSuccessful",
|
||||||
|
"messagePhoto",
|
||||||
|
"messagePoll",
|
||||||
|
// "messageProximityAlertTriggered",
|
||||||
|
"messageSticker",
|
||||||
|
"messageVenue",
|
||||||
|
"messageVideo",
|
||||||
|
"messageVideoNote",
|
||||||
|
"messageVoiceNote"
|
||||||
|
]
|
||||||
|
|
||||||
readonly property var simpleDelegateMessages: ["messageBasicGroupChatCreate",
|
readonly property var simpleDelegateMessages: ["messageBasicGroupChatCreate",
|
||||||
"messageChatAddMembers",
|
"messageChatAddMembers",
|
||||||
"messageChatChangePhoto",
|
"messageChatChangePhoto",
|
||||||
|
@ -1098,6 +1112,7 @@ Page {
|
||||||
"messageChatJoinByLink",
|
"messageChatJoinByLink",
|
||||||
"messageChatSetTtl",
|
"messageChatSetTtl",
|
||||||
"messageChatUpgradeFrom",
|
"messageChatUpgradeFrom",
|
||||||
|
// "messageContactRegistered","messageExpiredPhoto", "messageExpiredVideo","messageWebsiteConnected"
|
||||||
"messageGameScore",
|
"messageGameScore",
|
||||||
"messageChatUpgradeTo",
|
"messageChatUpgradeTo",
|
||||||
"messageCustomServiceAction",
|
"messageCustomServiceAction",
|
||||||
|
@ -1115,7 +1130,7 @@ Page {
|
||||||
myMessage: model.display
|
myMessage: model.display
|
||||||
messageId: model.message_id
|
messageId: model.message_id
|
||||||
messageIndex: model.index
|
messageIndex: model.index
|
||||||
extraContentComponentName: chatView.contentComponentNames[model.content_type] || ""
|
hasContentComponent: !!myMessage.content && chatView.delegateMessagesContent.indexOf(model.content_type) > -1
|
||||||
canReplyToMessage: chatPage.canSendMessages
|
canReplyToMessage: chatPage.canSendMessages
|
||||||
onReplyToMessage: {
|
onReplyToMessage: {
|
||||||
newMessageInReplyToRow.inReplyToMessage = myMessage
|
newMessageInReplyToRow.inReplyToMessage = myMessage
|
||||||
|
|
Loading…
Reference in a new issue