set some properties readonly

This commit is contained in:
John Gibbon 2020-11-08 20:37:17 +01:00
parent c3ccaa069d
commit 68e2dab715
2 changed files with 26 additions and 27 deletions

View file

@ -25,19 +25,19 @@ import QtQml.Models 2.3
ListItem {
id: messageListItem
contentHeight: messageBackground.height + Theme.paddingMedium
property var myMessage: display
property var userInformation: tdLibWrapper.getUserInformation(myMessage.sender_user_id)
readonly property var myMessage: display
readonly property var userInformation: tdLibWrapper.getUserInformation(myMessage.sender_user_id)
property QtObject precalculatedValues: ListView.view.precalculatedValues
property color textColor: isOwnMessage ? Theme.highlightColor : Theme.primaryColor
property int textAlign: isOwnMessage ? Text.AlignRight : Text.AlignLeft
property Page page: precalculatedValues.page
readonly property color textColor: isOwnMessage ? Theme.highlightColor : Theme.primaryColor
readonly property int textAlign: isOwnMessage ? Text.AlignRight : Text.AlignLeft
readonly property Page page: precalculatedValues.page
property bool isOwnMessage: page.myUserId === myMessage.sender_user_id
property string extraContentComponentName: typeof myMessage.content !== "undefined"
readonly property bool isOwnMessage: page.myUserId === myMessage.sender_user_id
readonly property string extraContentComponentName: typeof myMessage.content !== "undefined"
&& typeof chatView.contentComponentNames[myMessage.content['@type']] !== "undefined" ?
chatView.contentComponentNames[myMessage.content['@type']] : ""
property ObjectModel additionalContextItems: ObjectModel {}
readonly property ObjectModel additionalContextItems: ObjectModel {}
onPressAndHold: {
contextMenuLoader.active = true;

View file

@ -32,7 +32,7 @@ Page {
property bool loading: true;
property bool isInitialized: false;
property int myUserId: tdLibWrapper.getUserInformation().id;
readonly property int myUserId: tdLibWrapper.getUserInformation().id;
property var chatInformation;
property bool isPrivateChat: false;
property bool isBasicGroup: false;
@ -42,7 +42,7 @@ Page {
property var chatGroupInformation;
property int chatOnlineMemberCount: 0;
property var emojiProposals;
property bool userIsMember: (isPrivateChat && chatInformation["@type"]) || // should be optimized
readonly property bool userIsMember: (isPrivateChat && chatInformation["@type"]) || // should be optimized
(isBasicGroup || isSuperGroup) && (
(chatGroupInformation.status["@type"] === "chatMemberStatusMember")
|| (chatGroupInformation.status["@type"] === "chatMemberStatusAdministrator")
@ -82,11 +82,11 @@ Page {
chatPartnerInformation = tdLibWrapper.getUserInformation(chatInformation.type.user_id);
updateChatPartnerStatusText();
}
if (isBasicGroup) {
else if (isBasicGroup) {
chatGroupInformation = tdLibWrapper.getBasicGroup(chatInformation.type.basic_group_id);
updateGroupStatusText();
}
if (isSuperGroup) {
else if (isSuperGroup) {
chatGroupInformation = tdLibWrapper.getSuperGroup(chatInformation.type.supergroup_id);
isChannel = chatGroupInformation.is_channel;
updateGroupStatusText();
@ -232,7 +232,6 @@ Page {
}
break;
}
}
Connections {
@ -535,18 +534,18 @@ Page {
property bool inCooldown: false
property bool manuallyScrolledToBottom
property QtObject precalculatedValues: QtObject {
property alias page: chatPage
property bool showUserInfo: page.isBasicGroup || ( page.isSuperGroup && !page.isChannel)
property int profileThumbnailDimensions: showUserInfo ? Theme.itemSizeSmall : 0
property int pageMarginDouble: 2 * Theme.horizontalPageMargin
property int paddingMediumDouble: 2 * Theme.paddingMedium
property int entryWidth: chatView.width - pageMarginDouble
property int textItemWidth: entryWidth - profileThumbnailDimensions - Theme.paddingSmall
property int backgroundWidth: textItemWidth - pageMarginDouble
property int backgroundRadius: textItemWidth/50
property int textColumnWidth: backgroundWidth - Theme.horizontalPageMargin
property int messageInReplyToHeight: Theme.fontSizeExtraSmall * 2.571428571 + Theme.paddingSmall;
property int webPagePreviewHeight: ( (textColumnWidth * 2 / 3) + (6 * Theme.fontSizeExtraSmall) + ( 7 * Theme.paddingSmall) )
readonly property alias page: chatPage
readonly property bool showUserInfo: page.isBasicGroup || ( page.isSuperGroup && !page.isChannel)
readonly property int profileThumbnailDimensions: showUserInfo ? Theme.itemSizeSmall : 0
readonly property int pageMarginDouble: 2 * Theme.horizontalPageMargin
readonly property int paddingMediumDouble: 2 * Theme.paddingMedium
readonly property int entryWidth: chatView.width - pageMarginDouble
readonly property int textItemWidth: entryWidth - profileThumbnailDimensions - Theme.paddingSmall
readonly property int backgroundWidth: textItemWidth - pageMarginDouble
readonly property int backgroundRadius: textItemWidth/50
readonly property int textColumnWidth: backgroundWidth - Theme.horizontalPageMargin
readonly property int messageInReplyToHeight: Theme.fontSizeExtraSmall * 2.571428571 + Theme.paddingSmall;
readonly property int webPagePreviewHeight: ( (textColumnWidth * 2 / 3) + (6 * Theme.fontSizeExtraSmall) + ( 7 * Theme.paddingSmall) )
}
function handleScrollPositionChanged() {
@ -593,7 +592,7 @@ Page {
}
model: chatModel
property var contentComponentNames: ({
readonly property var contentComponentNames: ({
messageSticker: "StickerPreview",
messagePhoto: "ImagePreview",
messageVideo: "VideoPreview",
@ -622,7 +621,7 @@ Page {
}
}
property var simpleDelegateMessages: ["messageBasicGroupChatCreate", "messageChatAddMembers", "messageChatChangePhoto", "messageChatChangeTitle", "messageChatDeleteMember", "messageChatDeletePhoto", "messageChatJoinByLink", "messageChatSetTtl", "messageChatUpgradeFrom", "messageChatUpgradeTo", "messageCustomServiceAction", "messagePinMessage", "messageScreenshotTaken", "messageSupergroupChatCreate", "messageUnsupported"]
readonly property var simpleDelegateMessages: ["messageBasicGroupChatCreate", "messageChatAddMembers", "messageChatChangePhoto", "messageChatChangeTitle", "messageChatDeleteMember", "messageChatDeletePhoto", "messageChatJoinByLink", "messageChatSetTtl", "messageChatUpgradeFrom", "messageChatUpgradeTo", "messageCustomServiceAction", "messagePinMessage", "messageScreenshotTaken", "messageSupergroupChatCreate", "messageUnsupported"]
delegate: Loader {
width: chatView.width
Component {