From d9991cce791eddadc0c6af2861b618fbf8336e03 Mon Sep 17 00:00:00 2001 From: Sebastian Wolf Date: Sun, 14 Feb 2021 21:57:48 +0100 Subject: [PATCH 1/8] Try something for the too large context menu --- qml/components/MessageListViewItem.qml | 22 +- qml/pages/ChatPage.qml | 2211 ++++++++++--------- rpm/harbour-fernschreiber.spec | 2 +- rpm/harbour-fernschreiber.yaml | 2 +- translations/harbour-fernschreiber-de.ts | 12 + translations/harbour-fernschreiber-en.ts | 12 + translations/harbour-fernschreiber-es.ts | 12 + translations/harbour-fernschreiber-fi.ts | 12 + translations/harbour-fernschreiber-hu.ts | 12 + translations/harbour-fernschreiber-it.ts | 12 + translations/harbour-fernschreiber-pl.ts | 12 + translations/harbour-fernschreiber-ru.ts | 12 + translations/harbour-fernschreiber-sk.ts | 12 + translations/harbour-fernschreiber-sv.ts | 12 + translations/harbour-fernschreiber-zh_CN.ts | 12 + translations/harbour-fernschreiber.ts | 12 + 16 files changed, 1314 insertions(+), 1067 deletions(-) diff --git a/qml/components/MessageListViewItem.qml b/qml/components/MessageListViewItem.qml index 203bf09..a2c4341 100644 --- a/qml/components/MessageListViewItem.qml +++ b/qml/components/MessageListViewItem.qml @@ -78,6 +78,13 @@ ListItem { chatView.manuallyScrolledToBottom = false; } + Connections { + target: messageOptionsDrawer + onCloseRequested: { + messageListItem.highlighted = false; + } + } + Loader { id: contextMenuLoader active: false @@ -110,18 +117,21 @@ ListItem { onClicked: messageListItem.editMessage() text: qsTr("Edit Message") } - MenuItem { - onClicked: { - Clipboard.text = Functions.getMessageText(myMessage, true, userInformation.id, true); - } - text: qsTr("Copy Message to Clipboard") - } MenuItem { onClicked: { page.toggleMessageSelection(myMessage); } text: qsTr("Select Message") } + MenuItem { + onClicked: { + messageOptionsDrawer.myMessage = myMessage; + messageOptionsDrawer.userInformation = userInformation; + messageListItem.highlighted = true; + messageOptionsDrawer.open = true; + } + text: qsTr("More Options...") + } MenuItem { onClicked: { if (myMessage.is_pinned) { diff --git a/qml/pages/ChatPage.qml b/qml/pages/ChatPage.qml index 6922ab7..477d0e2 100644 --- a/qml/pages/ChatPage.qml +++ b/qml/pages/ChatPage.qml @@ -681,1081 +681,1213 @@ Page { } } - SilicaFlickable { - id: chatContainer + Drawer { + id: messageOptionsDrawer - onContentYChanged: { - // For some strange reason contentY sometimes is > 0 which doesn't make sense without a PushUpMenu (?) - // That leads to the problem that the whole flickable is moved slightly (or sometimes considerably) up - // which creates UX issues... As a workaround we are setting it to 0 in such cases. - // Better solutions are highly appreciated, contributions always welcome! ;) - if (contentY > 0) { - contentY = 0; - } - } + property var myMessage: ({}) + property var userInformation: ({}) + + signal closeRequested(); anchors.fill: parent - contentHeight: height - contentWidth: width + dock: chatPage.isPortrait ? Dock.Top : Dock.Right - PullDownMenu { - visible: chatInformation.id !== chatPage.myUserId && !stickerPickerLoader.active && !voiceNoteOverlayLoader.active && !messageOverlayLoader.active && !stickerSetOverlayLoader.active - MenuItem { - id: closeSecretChatMenuItem - visible: chatPage.isSecretChat && chatPage.secretChatDetails.state["@type"] !== "secretChatStateClosed" - onClicked: { - var secretChatId = chatPage.secretChatDetails.id; - Remorse.popupAction(chatPage, qsTr("Closing chat"), function() { tdLibWrapper.closeSecretChat(secretChatId) }); - } - text: qsTr("Close Chat") - } - - MenuItem { - id: joinLeaveChatMenuItem - visible: (chatPage.isSuperGroup || chatPage.isBasicGroup) && chatGroupInformation && chatGroupInformation.status["@type"] !== "chatMemberStatusBanned" - onClicked: { - if (chatPage.userIsMember) { - var chatId = chatInformation.id; - Remorse.popupAction(chatPage, qsTr("Leaving chat"), function() { - tdLibWrapper.leaveChat(chatId); - // this does not care about the response (ideally type "ok" without further reference) for now - pageStack.pop(pageStack.find( function(page){ return(page._depth === 0)} )); - }); - } else { - tdLibWrapper.joinChat(chatInformation.id); + background: SilicaListView { + anchors.fill: parent + model: ListModel { + id: myListModel + property var actions: { + "copyToClipboard": function() { Clipboard.text = Functions.getMessageText(messageOptionsDrawer.myMessage, true, messageOptionsDrawer.userInformation.id, true) }, + "pinMessage": function() { + if (messageOptionsDrawer.myMessage.is_pinned) { + Remorse.popupAction(page, qsTr("Message unpinned"), function() { tdLibWrapper.unpinMessage(chatPage.chatInformation.id, messageOptionsDrawer.myMessage.id); + pinnedMessageItem.requestCloseMessage(); } ); + } else { + tdLibWrapper.pinMessage(chatPage.chatInformation.id, messageOptionsDrawer.myMessage.id); + } } } - text: chatPage.userIsMember ? qsTr("Leave Chat") : qsTr("Join Chat") - } - - MenuItem { - id: muteChatMenuItem - visible: chatPage.userIsMember - onClicked: { - var newNotificationSettings = chatInformation.notification_settings; - if (newNotificationSettings.mute_for > 0) { - newNotificationSettings.mute_for = 0; - } else { - newNotificationSettings.mute_for = 6666666; - } - newNotificationSettings.use_default_mute_for = false; - tdLibWrapper.setChatNotificationSettings(chatInformation.id, newNotificationSettings); + property var conditions: { + "copyToClipboard": function() { return true; }, + "pinMessage": function() { return canPinMessages(); } } - text: chatInformation.notification_settings.mute_for > 0 ? qsTr("Unmute Chat") : qsTr("Mute Chat") - } - MenuItem { - id: searchInChatMenuItem - visible: !chatPage.isSecretChat && chatOverviewItem.visible - onClicked: { - // This automatically shows the search field as well - chatOverviewItem.visible = false; - searchInChatField.focus = true; + property var texts: { + "copyToClipboard": function() { return qsTr("Copy Message to Clipboard"); }, + "pinMessage": function() { return messageOptionsDrawer.myMessage.is_pinned ? qsTr("Unpin Message") : qsTr("Pin Message"); } } - text: qsTr("Search in Chat") - } - } - BackgroundItem { - id: headerMouseArea - height: headerRow.height - width: parent.width - onClicked: { - if (chatPage.isSelecting) { - chatPage.selectedMessages = []; - } else { - pageStack.navigateForward(); + ListElement { + elementActionName: "copyToClipboard" + } + + ListElement { + elementActionName: "pinMessage" } } - } - Column { - id: chatColumn - width: parent.width - height: parent.height - - Row { - id: headerRow - width: parent.width - (3 * Theme.horizontalPageMargin) - height: chatOverviewItem.height + ( chatPage.isPortrait ? (2 * Theme.paddingMedium) : (2 * Theme.paddingSmall) ) + header: Row { + width: parent.width - ( 4 * Theme.horizontalPageMargin) + height: messageOptionsLabel.height + Theme.paddingLarge + ( chatPage.isPortrait ? ( 2 * Theme.paddingSmall ) : 0 ) anchors.horizontalCenter: parent.horizontalCenter spacing: Theme.paddingMedium - - Item { - width: chatOverviewItem.height - height: chatOverviewItem.height - anchors.bottom: parent.bottom - anchors.bottomMargin: chatPage.isPortrait ? Theme.paddingMedium : Theme.paddingSmall - - ProfileThumbnail { - id: chatPictureThumbnail - replacementStringHint: chatNameText.text - width: parent.height - height: parent.height - - // Setting it directly may cause an stale state for the thumbnail in case the chat page - // was previously loaded with a picture and now it doesn't have one. Instead setting it - // when the ChatModel indicates a change. This also avoids flickering when the page is loaded... - Connections { - target: chatModel - onSmallPhotoChanged: { - chatPictureThumbnail.photoData = chatModel.smallPhoto; - } - } - } - - Rectangle { - id: chatSecretBackground - color: Theme.rgba(Theme.overlayBackgroundColor, Theme.opacityFaint) - width: chatPage.isPortrait ? Theme.fontSizeLarge : Theme.fontSizeMedium - height: width - anchors.left: parent.left - anchors.bottom: parent.bottom - radius: parent.width / 2 - visible: chatPage.isSecretChat - } - - Image { - source: "image://theme/icon-s-secure" - width: chatPage.isPortrait ? Theme.fontSizeSmall : Theme.fontSizeExtraSmall - height: width - anchors.centerIn: chatSecretBackground - visible: chatPage.isSecretChat - } - - } - - Item { - id: chatOverviewItem - opacity: visible ? 1 : 0 - Behavior on opacity { FadeAnimation {} } - width: parent.width - chatPictureThumbnail.width - Theme.paddingMedium - height: chatNameText.height + chatStatusText.height - anchors.bottom: parent.bottom - anchors.bottomMargin: chatPage.isPortrait ? Theme.paddingMedium : Theme.paddingSmall - Label { - id: chatNameText - width: Math.min(implicitWidth, parent.width) - anchors.right: parent.right - text: chatInformation.title !== "" ? Emoji.emojify(chatInformation.title, font.pixelSize) : qsTr("Unknown") - textFormat: Text.StyledText - font.pixelSize: chatPage.isPortrait ? Theme.fontSizeLarge : Theme.fontSizeMedium - font.family: Theme.fontFamilyHeading - color: Theme.highlightColor - truncationMode: TruncationMode.Fade - maximumLineCount: 1 - } - Label { - id: chatStatusText - width: Math.min(implicitWidth, parent.width) - anchors { - right: parent.right - bottom: parent.bottom - } - text: "" - textFormat: Text.StyledText - font.pixelSize: chatPage.isPortrait ? Theme.fontSizeExtraSmall : Theme.fontSizeTiny - font.family: Theme.fontFamilyHeading - color: headerMouseArea.pressed ? Theme.secondaryHighlightColor : Theme.secondaryColor - truncationMode: TruncationMode.Fade - maximumLineCount: 1 - } - } - - Item { - id: searchInChatItem - visible: !chatOverviewItem.visible - opacity: visible ? 1 : 0 - Behavior on opacity { FadeAnimation {} } - width: parent.width - chatPictureThumbnail.width - Theme.paddingMedium - height: searchInChatField.height - anchors.bottom: parent.bottom - anchors.bottomMargin: chatPage.isPortrait ? Theme.paddingSmall : 0 - - SearchField { - id: searchInChatField - visible: false - width: visible ? parent.width : 0 - placeholderText: qsTr("Search in chat...") - active: searchInChatItem.visible - canHide: text === "" - - onTextChanged: { - searchInChatTimer.restart(); - } - - onHideClicked: { - resetFocus(); - } - - EnterKey.iconSource: "image://theme/icon-m-enter-close" - EnterKey.onClicked: { - resetFocus(); - } - } - } - } - - PinnedMessageItem { - id: pinnedMessageItem - onRequestShowMessage: { - messageOverlayLoader.overlayMessage = pinnedMessageItem.pinnedMessage; - messageOverlayLoader.active = true; - } - onRequestCloseMessage: { - messageOverlayLoader.overlayMessage = undefined; - messageOverlayLoader.active = false; - } - } - - Item { - id: chatViewItem - width: parent.width - height: parent.height - headerRow.height - pinnedMessageItem.height - newMessageColumn.height - selectedMessagesActions.height - - property int previousHeight; - - Component.onCompleted: { - previousHeight = height; - } - - onHeightChanged: { - var deltaHeight = previousHeight - height; - chatView.contentY = chatView.contentY + deltaHeight; - previousHeight = height; - } - - Timer { - id: chatViewCooldownTimer - interval: 2000 - repeat: false - running: false - onTriggered: { - Debug.log("[ChatPage] Cooldown completed..."); - chatView.inCooldown = false; - - if (!chatPage.isInitialized) { - Debug.log("Page is initialized!"); - chatPage.isInitialized = true; - chatView.handleScrollPositionChanged(); - } - } - } - - Loader { - asynchronous: true - active: chatView.blurred - anchors.fill: chatView - sourceComponent: Component { - FastBlur { - source: chatView - radius: Theme.paddingLarge - } - } - } - - SilicaListView { - id: chatView - - visible: !blurred - property bool blurred: messageOverlayLoader.item || stickerPickerLoader.item || voiceNoteOverlayLoader.item || inlineQuery.hasOverlay || stickerSetOverlayLoader.item - - anchors.fill: parent - opacity: chatPage.loading ? 0 : 1 - Behavior on opacity { FadeAnimation {} } - clip: true - highlightMoveDuration: 0 - highlightResizeDuration: 0 - property int lastReadSentIndex: -1 - property bool inCooldown: false - property bool manuallyScrolledToBottom - property QtObject precalculatedValues: QtObject { - 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: page.isChannel ? textItemWidth : 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) ) - readonly property bool pageIsSelecting: chatPage.isSelecting - - } - - function handleScrollPositionChanged() { - Debug.log("Current position: ", chatView.contentY); - if (chatOverviewItem.visible && chatInformation.unread_count > 0) { - var bottomIndex = chatView.indexAt(chatView.contentX, ( chatView.contentY + chatView.height - Theme.horizontalPageMargin )); - if (bottomIndex > -1) { - viewMessageTimer.queueViewMessage(bottomIndex) - } - } else { - tdLibWrapper.readAllChatMentions(chatInformation.id); - } - manuallyScrolledToBottom = chatView.atYEnd - } - - function scrollToIndex(index) { - if(index > 0 && index < chatView.count) { - positionViewAtIndex(index, ListView.Contain) -// currentIndex = index; - if(index === chatView.count - 1) { - manuallyScrolledToBottom = true; - } - } - } - - onContentYChanged: { - if (!chatPage.loading && !chatView.inCooldown) { - if (chatView.indexAt(chatView.contentX, chatView.contentY) < 10) { - Debug.log("[ChatPage] Trying to get older history items..."); - chatView.inCooldown = true; - chatModel.triggerLoadMoreHistory(); - } else if (chatOverviewItem.visible && chatView.indexAt(chatView.contentX, chatView.contentY) > ( count - 10)) { - Debug.log("[ChatPage] Trying to get newer history items..."); - chatView.inCooldown = true; - chatModel.triggerLoadMoreFuture(); - } - } - } - - onMovementEnded: { - handleScrollPositionChanged(); - } - - onQuickScrollAnimatingChanged: { - if (!quickScrollAnimating) { - handleScrollPositionChanged(); - if(atYEnd) { // handle some false guesses from quick scroll - chatView.scrollToIndex(chatView.count - 2) - chatView.scrollToIndex(chatView.count - 1) - } - } - } - - model: chatModel - header: Component { - Loader { - active: !!chatPage.botInformation - && !!chatPage.botInformation.bot_info && chatPage.botInformation.bot_info.description.length > 0 - asynchronous: true - width: chatView.width - sourceComponent: Component { - Label { - id: botInfoLabel - topPadding: Theme.paddingLarge - bottomPadding: Theme.paddingLarge - leftPadding: Theme.horizontalPageMargin - rightPadding: Theme.horizontalPageMargin - text: Emoji.emojify(chatPage.botInformation.bot_info.description, font.pixelSize) - font.pixelSize: Theme.fontSizeSmall - color: Theme.highlightColor - wrapMode: Text.Wrap - textFormat: Text.StyledText - horizontalAlignment: Text.AlignHCenter - onLinkActivated: { - var chatCommand = Functions.handleLink(link); - if(chatCommand) { - tdLibWrapper.sendTextMessage(chatInformation.id, chatCommand); - } - } - linkColor: Theme.primaryColor - visible: (text !== "") - } - } - } - } - - function getContentComponentHeight(contentType, content, parentWidth) { - switch(contentType) { - case "messageAnimation": - return Functions.getVideoHeight(parentWidth, content.animation); - case "messageAudio": - case "messageVoiceNote": - case "messageDocument": - return Theme.itemSizeLarge; - case "messageGame": - return parentWidth * 0.66666666 + Theme.itemSizeLarge; // 2 / 3; - case "messageLocation": - case "messageVenue": - return parentWidth * 0.66666666; // 2 / 3; - case "messagePhoto": - var biggest = content.photo.sizes[content.photo.sizes.length - 1]; - var aspectRatio = biggest.width/biggest.height; - return Math.max(Theme.itemSizeExtraSmall, Math.min(parentWidth * 0.66666666, parentWidth / aspectRatio)); - 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", - "messageChatAddMembers", - "messageChatChangePhoto", - "messageChatChangeTitle", - "messageChatDeleteMember", - "messageChatDeletePhoto", - "messageChatJoinByLink", - "messageChatSetTtl", - "messageChatUpgradeFrom", - // "messageContactRegistered","messageExpiredPhoto", "messageExpiredVideo","messageWebsiteConnected" - "messageGameScore", - "messageChatUpgradeTo", - "messageCustomServiceAction", - "messagePinMessage", - "messageScreenshotTaken", - "messageSupergroupChatCreate", - "messageUnsupported"] - delegate: Loader { - width: chatView.width - Component { - id: messageListViewItemComponent - MessageListViewItem { - precalculatedValues: chatView.precalculatedValues - chatId: chatModel.chatId - myMessage: model.display - messageId: model.message_id - messageViewCount: model.view_count - messageIndex: model.index - hasContentComponent: !!myMessage.content && chatView.delegateMessagesContent.indexOf(model.content_type) > -1 - canReplyToMessage: chatPage.canSendMessages - onReplyToMessage: { - newMessageInReplyToRow.inReplyToMessage = myMessage - newMessageTextField.focus = true - } - onEditMessage: { - newMessageColumn.editMessageId = messageId - newMessageTextField.text = Functions.getMessageText(myMessage, false, chatPage.myUserId, true) - newMessageTextField.focus = true - } - } - } - Component { - id: messageListViewItemSimpleComponent - MessageListViewItemSimple {} - } - sourceComponent: chatView.simpleDelegateMessages.indexOf(model.content_type) > -1 ? messageListViewItemSimpleComponent : messageListViewItemComponent - } - VerticalScrollDecorator {} - - ViewPlaceholder { - id: chatViewPlaceholder - enabled: chatView.count === 0 - text: (chatPage.isSecretChat && !chatPage.isSecretChatReady) ? qsTr("This secret chat is not yet ready. Your chat partner needs to go online first.") : qsTr("This chat is empty.") - } - } - - Column { - width: parent.width - height: loadingLabel.height + loadingBusyIndicator.height + Theme.paddingMedium - spacing: Theme.paddingMedium + Label { + id: messageOptionsLabel + text: qsTr("Message Options") + color: Theme.highlightColor + font.pixelSize: Theme.fontSizeLarge + width: parent.width - closeMessageOptionsButton.width - Theme.paddingMedium anchors.verticalCenter: parent.verticalCenter + horizontalAlignment: Text.AlignRight - opacity: chatPage.loading ? 1 : 0 - Behavior on opacity { FadeAnimation {} } - visible: chatPage.loading - - InfoLabel { - id: loadingLabel - text: qsTr("Loading messages...") - } - - BusyIndicator { - id: loadingBusyIndicator - anchors.horizontalCenter: parent.horizontalCenter - running: chatPage.loading - size: BusyIndicatorSize.Large + } + IconButton { + id: closeMessageOptionsButton + icon.source: "image://theme/icon-m-clear" + anchors.verticalCenter: parent.verticalCenter + onClicked: { + messageOptionsDrawer.closeRequested(); + messageOptionsDrawer.open = false; } } + } - Item { - id: chatUnreadMessagesItem - width: Theme.fontSizeHuge - height: Theme.fontSizeHuge - anchors.right: parent.right - anchors.rightMargin: Theme.paddingMedium - anchors.bottom: parent.bottom - anchors.bottomMargin: Theme.paddingMedium - visible: !chatPage.loading && chatInformation.unread_count > 0 && chatOverviewItem.visible - Rectangle { - id: chatUnreadMessagesCountBackground - color: Theme.highlightBackgroundColor - anchors.fill: parent - radius: width / 2 - visible: chatUnreadMessagesItem.visible - } + delegate: ListItem { + width: parent.width + visible: myListModel.actions[conditions]() + onClicked: { + myListModel.actions[elementActionName](); + } + Label { + width: parent.width - ( 2 * Theme.horizontalPageMargin ) + text: myListModel.texts[elementActionName](); + anchors.verticalCenter: parent.verticalCenter + anchors.horizontalCenter: parent.horizontalCenter + horizontalAlignment: Text.AlignHCenter + } + } - Text { - id: chatUnreadMessagesCount - font.pixelSize: Theme.fontSizeMedium - font.bold: true - color: Theme.primaryColor - anchors.centerIn: chatUnreadMessagesCountBackground - visible: chatUnreadMessagesItem.visible - text: chatInformation.unread_count > 99 ? "99+" : chatInformation.unread_count + VerticalScrollDecorator {} + } + + SilicaFlickable { + id: chatContainer + + onContentYChanged: { + // For some strange reason contentY sometimes is > 0 which doesn't make sense without a PushUpMenu (?) + // That leads to the problem that the whole flickable is moved slightly (or sometimes considerably) up + // which creates UX issues... As a workaround we are setting it to 0 in such cases. + // Better solutions are highly appreciated, contributions always welcome! ;) + if (contentY > 0) { + contentY = 0; + } + } + + anchors.fill: parent + contentHeight: height + contentWidth: width + + PullDownMenu { + visible: chatInformation.id !== chatPage.myUserId && !stickerPickerLoader.active && !voiceNoteOverlayLoader.active && !messageOverlayLoader.active && !stickerSetOverlayLoader.active + MenuItem { + id: closeSecretChatMenuItem + visible: chatPage.isSecretChat && chatPage.secretChatDetails.state["@type"] !== "secretChatStateClosed" + onClicked: { + var secretChatId = chatPage.secretChatDetails.id; + Remorse.popupAction(chatPage, qsTr("Closing chat"), function() { tdLibWrapper.closeSecretChat(secretChatId) }); } - MouseArea { - anchors.fill: parent - onClicked: { - chatView.scrollToIndex(chatView.count - 1 - chatInformation.unread_count) + text: qsTr("Close Chat") + } + + MenuItem { + id: joinLeaveChatMenuItem + visible: (chatPage.isSuperGroup || chatPage.isBasicGroup) && chatGroupInformation && chatGroupInformation.status["@type"] !== "chatMemberStatusBanned" + onClicked: { + if (chatPage.userIsMember) { + var chatId = chatInformation.id; + Remorse.popupAction(chatPage, qsTr("Leaving chat"), function() { + tdLibWrapper.leaveChat(chatId); + // this does not care about the response (ideally type "ok" without further reference) for now + pageStack.pop(pageStack.find( function(page){ return(page._depth === 0)} )); + }); + } else { + tdLibWrapper.joinChat(chatInformation.id); } } + text: chatPage.userIsMember ? qsTr("Leave Chat") : qsTr("Join Chat") } - Loader { - id: stickerPickerLoader - active: false - asynchronous: true - width: parent.width - height: active ? parent.height : 0 - source: "../components/StickerPicker.qml" - } - - Connections { - target: stickerPickerLoader.item - onStickerPicked: { - Debug.log("Sticker picked: " + stickerId); - tdLibWrapper.sendStickerMessage(chatInformation.id, stickerId, newMessageColumn.replyToMessageId); - stickerPickerLoader.active = false; - attachmentOptionsFlickable.isNeeded = false; - newMessageInReplyToRow.inReplyToMessage = null; - newMessageColumn.editMessageId = "0"; - } - } - - Loader { - id: messageOverlayLoader - - property var overlayMessage; - - active: false - asynchronous: true - width: parent.width - height: active ? parent.height : 0 - sourceComponent: Component { - MessageOverlayFlickable { - overlayMessage: messageOverlayLoader.overlayMessage - showHeader: !chatPage.isChannel - onRequestClose: { - messageOverlayLoader.active = false; - } + MenuItem { + id: muteChatMenuItem + visible: chatPage.userIsMember + onClicked: { + var newNotificationSettings = chatInformation.notification_settings; + if (newNotificationSettings.mute_for > 0) { + newNotificationSettings.mute_for = 0; + } else { + newNotificationSettings.mute_for = 6666666; } + newNotificationSettings.use_default_mute_for = false; + tdLibWrapper.setChatNotificationSettings(chatInformation.id, newNotificationSettings); } + text: chatInformation.notification_settings.mute_for > 0 ? qsTr("Unmute Chat") : qsTr("Mute Chat") } - Loader { - id: voiceNoteOverlayLoader - active: false - asynchronous: true - width: parent.width - height: active ? parent.height : 0 - source: "../components/VoiceNoteOverlay.qml" - onActiveChanged: { - if (!active) { - fernschreiberUtils.stopRecordingVoiceNote(); - } + MenuItem { + id: searchInChatMenuItem + visible: !chatPage.isSecretChat && chatOverviewItem.visible + onClicked: { + // This automatically shows the search field as well + chatOverviewItem.visible = false; + searchInChatField.focus = true; } + text: qsTr("Search in Chat") } + } - Loader { - id: stickerSetOverlayLoader - - property string stickerSetId; - - active: false - asynchronous: true - width: parent.width - height: active ? parent.height : 0 - sourceComponent: Component { - StickerSetOverlay { - stickerSetId: stickerSetOverlayLoader.stickerSetId - onRequestClose: { - stickerSetOverlayLoader.active = false; - } - } + BackgroundItem { + id: headerMouseArea + height: headerRow.height + width: parent.width + onClicked: { + if (chatPage.isSelecting) { + chatPage.selectedMessages = []; + } else { + pageStack.navigateForward(); } - - onActiveChanged: { - if (active) { - attachmentOptionsFlickable.isNeeded = false; - } - } - } - - InlineQuery { - id: inlineQuery - textField: newMessageTextField - chatId: chatInformation.id } } Column { - id: newMessageColumn - spacing: Theme.paddingSmall - topPadding: Theme.paddingSmall + inlineQuery.buttonPadding - anchors.horizontalCenter: parent.horizontalCenter - visible: height > 0 - width: parent.width - ( 2 * Theme.horizontalPageMargin ) - height: isNeeded ? implicitHeight : 0 - Behavior on height { SmoothedAnimation { duration: 200 } } + id: chatColumn + width: parent.width + height: parent.height - readonly property bool isNeeded: !chatPage.isSelecting && chatPage.canSendMessages - property string replyToMessageId: "0"; - property string editMessageId: "0"; + Row { + id: headerRow + width: parent.width - (3 * Theme.horizontalPageMargin) + height: chatOverviewItem.height + ( chatPage.isPortrait ? (2 * Theme.paddingMedium) : (2 * Theme.paddingSmall) ) + anchors.horizontalCenter: parent.horizontalCenter + spacing: Theme.paddingMedium - InReplyToRow { - onInReplyToMessageChanged: { - if (inReplyToMessage) { - newMessageColumn.replyToMessageId = newMessageInReplyToRow.inReplyToMessage.id.toString() - newMessageInReplyToRow.visible = true; - } else { - newMessageInReplyToRow.visible = false; - newMessageColumn.replyToMessageId = "0"; + Item { + width: chatOverviewItem.height + height: chatOverviewItem.height + anchors.bottom: parent.bottom + anchors.bottomMargin: chatPage.isPortrait ? Theme.paddingMedium : Theme.paddingSmall + + ProfileThumbnail { + id: chatPictureThumbnail + replacementStringHint: chatNameText.text + width: parent.height + height: parent.height + + // Setting it directly may cause an stale state for the thumbnail in case the chat page + // was previously loaded with a picture and now it doesn't have one. Instead setting it + // when the ChatModel indicates a change. This also avoids flickering when the page is loaded... + Connections { + target: chatModel + onSmallPhotoChanged: { + chatPictureThumbnail.photoData = chatModel.smallPhoto; + } + } + } + + Rectangle { + id: chatSecretBackground + color: Theme.rgba(Theme.overlayBackgroundColor, Theme.opacityFaint) + width: chatPage.isPortrait ? Theme.fontSizeLarge : Theme.fontSizeMedium + height: width + anchors.left: parent.left + anchors.bottom: parent.bottom + radius: parent.width / 2 + visible: chatPage.isSecretChat + } + + Image { + source: "image://theme/icon-s-secure" + width: chatPage.isPortrait ? Theme.fontSizeSmall : Theme.fontSizeExtraSmall + height: width + anchors.centerIn: chatSecretBackground + visible: chatPage.isSecretChat + } + + } + + Item { + id: chatOverviewItem + opacity: visible ? 1 : 0 + Behavior on opacity { FadeAnimation {} } + width: parent.width - chatPictureThumbnail.width - Theme.paddingMedium + height: chatNameText.height + chatStatusText.height + anchors.bottom: parent.bottom + anchors.bottomMargin: chatPage.isPortrait ? Theme.paddingMedium : Theme.paddingSmall + Label { + id: chatNameText + width: Math.min(implicitWidth, parent.width) + anchors.right: parent.right + text: chatInformation.title !== "" ? Emoji.emojify(chatInformation.title, font.pixelSize) : qsTr("Unknown") + textFormat: Text.StyledText + font.pixelSize: chatPage.isPortrait ? Theme.fontSizeLarge : Theme.fontSizeMedium + font.family: Theme.fontFamilyHeading + color: Theme.highlightColor + truncationMode: TruncationMode.Fade + maximumLineCount: 1 + } + Label { + id: chatStatusText + width: Math.min(implicitWidth, parent.width) + anchors { + right: parent.right + bottom: parent.bottom + } + text: "" + textFormat: Text.StyledText + font.pixelSize: chatPage.isPortrait ? Theme.fontSizeExtraSmall : Theme.fontSizeTiny + font.family: Theme.fontFamilyHeading + color: headerMouseArea.pressed ? Theme.secondaryHighlightColor : Theme.secondaryColor + truncationMode: TruncationMode.Fade + maximumLineCount: 1 } } - editable: true + Item { + id: searchInChatItem + visible: !chatOverviewItem.visible + opacity: visible ? 1 : 0 + Behavior on opacity { FadeAnimation {} } + width: parent.width - chatPictureThumbnail.width - Theme.paddingMedium + height: searchInChatField.height + anchors.bottom: parent.bottom + anchors.bottomMargin: chatPage.isPortrait ? Theme.paddingSmall : 0 - onClearRequested: { - newMessageInReplyToRow.inReplyToMessage = null; + SearchField { + id: searchInChatField + visible: false + width: visible ? parent.width : 0 + placeholderText: qsTr("Search in chat...") + active: searchInChatItem.visible + canHide: text === "" + + onTextChanged: { + searchInChatTimer.restart(); + } + + onHideClicked: { + resetFocus(); + } + + EnterKey.iconSource: "image://theme/icon-m-enter-close" + EnterKey.onClicked: { + resetFocus(); + } + } } - - id: newMessageInReplyToRow - myUserId: chatPage.myUserId - visible: false } - Flickable { - id: attachmentOptionsFlickable + PinnedMessageItem { + id: pinnedMessageItem + onRequestShowMessage: { + messageOverlayLoader.overlayMessage = pinnedMessageItem.pinnedMessage; + messageOverlayLoader.active = true; + } + onRequestCloseMessage: { + messageOverlayLoader.overlayMessage = undefined; + messageOverlayLoader.active = false; + } + } - property bool isNeeded: false - width: chatPage.width - x: -Theme.horizontalPageMargin - height: isNeeded && !inlineQuery.userNameIsValid ? attachmentOptionsRow.height : 0 - Behavior on height { SmoothedAnimation { duration: 200 } } + Item { + id: chatViewItem + width: parent.width + height: parent.height - headerRow.height - pinnedMessageItem.height - newMessageColumn.height - selectedMessagesActions.height + + property int previousHeight; + + Component.onCompleted: { + previousHeight = height; + } + + onHeightChanged: { + var deltaHeight = previousHeight - height; + chatView.contentY = chatView.contentY + deltaHeight; + previousHeight = height; + } + + Timer { + id: chatViewCooldownTimer + interval: 2000 + repeat: false + running: false + onTriggered: { + Debug.log("[ChatPage] Cooldown completed..."); + chatView.inCooldown = false; + + if (!chatPage.isInitialized) { + Debug.log("Page is initialized!"); + chatPage.isInitialized = true; + chatView.handleScrollPositionChanged(); + } + } + } + + Loader { + asynchronous: true + active: chatView.blurred + anchors.fill: chatView + sourceComponent: Component { + FastBlur { + source: chatView + radius: Theme.paddingLarge + } + } + } + + SilicaListView { + id: chatView + + visible: !blurred + property bool blurred: messageOverlayLoader.item || stickerPickerLoader.item || voiceNoteOverlayLoader.item || inlineQuery.hasOverlay || stickerSetOverlayLoader.item + + anchors.fill: parent + opacity: chatPage.loading ? 0 : 1 + Behavior on opacity { FadeAnimation {} } + clip: true + highlightMoveDuration: 0 + highlightResizeDuration: 0 + property int lastReadSentIndex: -1 + property bool inCooldown: false + property bool manuallyScrolledToBottom + property QtObject precalculatedValues: QtObject { + 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: page.isChannel ? textItemWidth : 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) ) + readonly property bool pageIsSelecting: chatPage.isSelecting + + } + + function handleScrollPositionChanged() { + Debug.log("Current position: ", chatView.contentY); + if (chatOverviewItem.visible && chatInformation.unread_count > 0) { + var bottomIndex = chatView.indexAt(chatView.contentX, ( chatView.contentY + chatView.height - Theme.horizontalPageMargin )); + if (bottomIndex > -1) { + viewMessageTimer.queueViewMessage(bottomIndex) + } + } else { + tdLibWrapper.readAllChatMentions(chatInformation.id); + } + manuallyScrolledToBottom = chatView.atYEnd + } + + function scrollToIndex(index) { + if(index > 0 && index < chatView.count) { + positionViewAtIndex(index, ListView.Contain) + // currentIndex = index; + if(index === chatView.count - 1) { + manuallyScrolledToBottom = true; + } + } + } + + onContentYChanged: { + if (!chatPage.loading && !chatView.inCooldown) { + if (chatView.indexAt(chatView.contentX, chatView.contentY) < 10) { + Debug.log("[ChatPage] Trying to get older history items..."); + chatView.inCooldown = true; + chatModel.triggerLoadMoreHistory(); + } else if (chatOverviewItem.visible && chatView.indexAt(chatView.contentX, chatView.contentY) > ( count - 10)) { + Debug.log("[ChatPage] Trying to get newer history items..."); + chatView.inCooldown = true; + chatModel.triggerLoadMoreFuture(); + } + } + } + + onMovementEnded: { + handleScrollPositionChanged(); + } + + onQuickScrollAnimatingChanged: { + if (!quickScrollAnimating) { + handleScrollPositionChanged(); + if(atYEnd) { // handle some false guesses from quick scroll + chatView.scrollToIndex(chatView.count - 2) + chatView.scrollToIndex(chatView.count - 1) + } + } + } + + model: chatModel + header: Component { + Loader { + active: !!chatPage.botInformation + && !!chatPage.botInformation.bot_info && chatPage.botInformation.bot_info.description.length > 0 + asynchronous: true + width: chatView.width + sourceComponent: Component { + Label { + id: botInfoLabel + topPadding: Theme.paddingLarge + bottomPadding: Theme.paddingLarge + leftPadding: Theme.horizontalPageMargin + rightPadding: Theme.horizontalPageMargin + text: Emoji.emojify(chatPage.botInformation.bot_info.description, font.pixelSize) + font.pixelSize: Theme.fontSizeSmall + color: Theme.highlightColor + wrapMode: Text.Wrap + textFormat: Text.StyledText + horizontalAlignment: Text.AlignHCenter + onLinkActivated: { + var chatCommand = Functions.handleLink(link); + if(chatCommand) { + tdLibWrapper.sendTextMessage(chatInformation.id, chatCommand); + } + } + linkColor: Theme.primaryColor + visible: (text !== "") + } + } + } + } + + function getContentComponentHeight(contentType, content, parentWidth) { + switch(contentType) { + case "messageAnimation": + return Functions.getVideoHeight(parentWidth, content.animation); + case "messageAudio": + case "messageVoiceNote": + case "messageDocument": + return Theme.itemSizeLarge; + case "messageGame": + return parentWidth * 0.66666666 + Theme.itemSizeLarge; // 2 / 3; + case "messageLocation": + case "messageVenue": + return parentWidth * 0.66666666; // 2 / 3; + case "messagePhoto": + var biggest = content.photo.sizes[content.photo.sizes.length - 1]; + var aspectRatio = biggest.width/biggest.height; + return Math.max(Theme.itemSizeExtraSmall, Math.min(parentWidth * 0.66666666, parentWidth / aspectRatio)); + 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", + "messageChatAddMembers", + "messageChatChangePhoto", + "messageChatChangeTitle", + "messageChatDeleteMember", + "messageChatDeletePhoto", + "messageChatJoinByLink", + "messageChatSetTtl", + "messageChatUpgradeFrom", + // "messageContactRegistered","messageExpiredPhoto", "messageExpiredVideo","messageWebsiteConnected" + "messageGameScore", + "messageChatUpgradeTo", + "messageCustomServiceAction", + "messagePinMessage", + "messageScreenshotTaken", + "messageSupergroupChatCreate", + "messageUnsupported"] + delegate: Loader { + width: chatView.width + Component { + id: messageListViewItemComponent + MessageListViewItem { + precalculatedValues: chatView.precalculatedValues + chatId: chatModel.chatId + myMessage: model.display + messageId: model.message_id + messageViewCount: model.view_count + messageIndex: model.index + hasContentComponent: !!myMessage.content && chatView.delegateMessagesContent.indexOf(model.content_type) > -1 + canReplyToMessage: chatPage.canSendMessages + onReplyToMessage: { + newMessageInReplyToRow.inReplyToMessage = myMessage + newMessageTextField.focus = true + } + onEditMessage: { + newMessageColumn.editMessageId = messageId + newMessageTextField.text = Functions.getMessageText(myMessage, false, chatPage.myUserId, true) + newMessageTextField.focus = true + } + } + } + Component { + id: messageListViewItemSimpleComponent + MessageListViewItemSimple {} + } + sourceComponent: chatView.simpleDelegateMessages.indexOf(model.content_type) > -1 ? messageListViewItemSimpleComponent : messageListViewItemComponent + } + VerticalScrollDecorator {} + + ViewPlaceholder { + id: chatViewPlaceholder + enabled: chatView.count === 0 + text: (chatPage.isSecretChat && !chatPage.isSecretChatReady) ? qsTr("This secret chat is not yet ready. Your chat partner needs to go online first.") : qsTr("This chat is empty.") + } + } + + Column { + width: parent.width + height: loadingLabel.height + loadingBusyIndicator.height + Theme.paddingMedium + spacing: Theme.paddingMedium + anchors.verticalCenter: parent.verticalCenter + + opacity: chatPage.loading ? 1 : 0 + Behavior on opacity { FadeAnimation {} } + visible: chatPage.loading + + InfoLabel { + id: loadingLabel + text: qsTr("Loading messages...") + } + + BusyIndicator { + id: loadingBusyIndicator + anchors.horizontalCenter: parent.horizontalCenter + running: chatPage.loading + size: BusyIndicatorSize.Large + } + } + + Item { + id: chatUnreadMessagesItem + width: Theme.fontSizeHuge + height: Theme.fontSizeHuge + anchors.right: parent.right + anchors.rightMargin: Theme.paddingMedium + anchors.bottom: parent.bottom + anchors.bottomMargin: Theme.paddingMedium + visible: !chatPage.loading && chatInformation.unread_count > 0 && chatOverviewItem.visible + Rectangle { + id: chatUnreadMessagesCountBackground + color: Theme.highlightBackgroundColor + anchors.fill: parent + radius: width / 2 + visible: chatUnreadMessagesItem.visible + } + + Text { + id: chatUnreadMessagesCount + font.pixelSize: Theme.fontSizeMedium + font.bold: true + color: Theme.primaryColor + anchors.centerIn: chatUnreadMessagesCountBackground + visible: chatUnreadMessagesItem.visible + text: chatInformation.unread_count > 99 ? "99+" : chatInformation.unread_count + } + MouseArea { + anchors.fill: parent + onClicked: { + chatView.scrollToIndex(chatView.count - 1 - chatInformation.unread_count) + } + } + } + + Loader { + id: stickerPickerLoader + active: false + asynchronous: true + width: parent.width + height: active ? parent.height : 0 + source: "../components/StickerPicker.qml" + } + + Connections { + target: stickerPickerLoader.item + onStickerPicked: { + Debug.log("Sticker picked: " + stickerId); + tdLibWrapper.sendStickerMessage(chatInformation.id, stickerId, newMessageColumn.replyToMessageId); + stickerPickerLoader.active = false; + attachmentOptionsFlickable.isNeeded = false; + newMessageInReplyToRow.inReplyToMessage = null; + newMessageColumn.editMessageId = "0"; + } + } + + Loader { + id: messageOverlayLoader + + property var overlayMessage; + + active: false + asynchronous: true + width: parent.width + height: active ? parent.height : 0 + sourceComponent: Component { + MessageOverlayFlickable { + overlayMessage: messageOverlayLoader.overlayMessage + showHeader: !chatPage.isChannel + onRequestClose: { + messageOverlayLoader.active = false; + } + } + } + } + + Loader { + id: voiceNoteOverlayLoader + active: false + asynchronous: true + width: parent.width + height: active ? parent.height : 0 + source: "../components/VoiceNoteOverlay.qml" + onActiveChanged: { + if (!active) { + fernschreiberUtils.stopRecordingVoiceNote(); + } + } + } + + Loader { + id: stickerSetOverlayLoader + + property string stickerSetId; + + active: false + asynchronous: true + width: parent.width + height: active ? parent.height : 0 + sourceComponent: Component { + StickerSetOverlay { + stickerSetId: stickerSetOverlayLoader.stickerSetId + onRequestClose: { + stickerSetOverlayLoader.active = false; + } + } + } + + onActiveChanged: { + if (active) { + attachmentOptionsFlickable.isNeeded = false; + } + } + } + + InlineQuery { + id: inlineQuery + textField: newMessageTextField + chatId: chatInformation.id + } + } + + Column { + id: newMessageColumn + spacing: Theme.paddingSmall + topPadding: Theme.paddingSmall + inlineQuery.buttonPadding + anchors.horizontalCenter: parent.horizontalCenter visible: height > 0 - contentHeight: attachmentOptionsRow.height - contentWidth: Math.max(width, attachmentOptionsRow.width) - property bool fadeRight: (attachmentOptionsRow.width-contentX) > width - property bool fadeLeft: !fadeRight && contentX > 0 - layer.enabled: fadeRight || fadeLeft - layer.effect: OpacityRampEffectBase { - direction: attachmentOptionsFlickable.fadeRight ? OpacityRamp.LeftToRight : OpacityRamp.RightToLeft - source: attachmentOptionsFlickable - slope: 1 + 6 * (chatPage.width) / Screen.width - offset: 1 - 1 / slope + width: parent.width - ( 2 * Theme.horizontalPageMargin ) + height: isNeeded ? implicitHeight : 0 + Behavior on height { SmoothedAnimation { duration: 200 } } + + readonly property bool isNeeded: !chatPage.isSelecting && chatPage.canSendMessages + property string replyToMessageId: "0"; + property string editMessageId: "0"; + + InReplyToRow { + onInReplyToMessageChanged: { + if (inReplyToMessage) { + newMessageColumn.replyToMessageId = newMessageInReplyToRow.inReplyToMessage.id.toString() + newMessageInReplyToRow.visible = true; + } else { + newMessageInReplyToRow.visible = false; + newMessageColumn.replyToMessageId = "0"; + } + } + + editable: true + + onClearRequested: { + newMessageInReplyToRow.inReplyToMessage = null; + } + + id: newMessageInReplyToRow + myUserId: chatPage.myUserId + visible: false + } + + Flickable { + id: attachmentOptionsFlickable + + property bool isNeeded: false + width: chatPage.width + x: -Theme.horizontalPageMargin + height: isNeeded && !inlineQuery.userNameIsValid ? attachmentOptionsRow.height : 0 + Behavior on height { SmoothedAnimation { duration: 200 } } + visible: height > 0 + contentHeight: attachmentOptionsRow.height + contentWidth: Math.max(width, attachmentOptionsRow.width) + property bool fadeRight: (attachmentOptionsRow.width-contentX) > width + property bool fadeLeft: !fadeRight && contentX > 0 + layer.enabled: fadeRight || fadeLeft + layer.effect: OpacityRampEffectBase { + direction: attachmentOptionsFlickable.fadeRight ? OpacityRamp.LeftToRight : OpacityRamp.RightToLeft + source: attachmentOptionsFlickable + slope: 1 + 6 * (chatPage.width) / Screen.width + offset: 1 - 1 / slope + } + + + Row { + id: attachmentOptionsRow + + height: attachImageIconButton.height + + anchors.right: parent.right + layoutDirection: Qt.RightToLeft + spacing: Theme.paddingMedium + leftPadding: Theme.horizontalPageMargin + rightPadding: Theme.horizontalPageMargin + + IconButton { + id: attachImageIconButton + visible: chatPage.hasSendPrivilege("can_send_media_messages") + icon.source: "image://theme/icon-m-image" + onClicked: { + var picker = pageStack.push("Sailfish.Pickers.ImagePickerPage", { + allowedOrientations: chatPage.allowedOrientations + }) + picker.selectedContentPropertiesChanged.connect(function(){ + attachmentOptionsFlickable.isNeeded = false; + Debug.log("Selected document: ", picker.selectedContentProperties.filePath ); + attachmentPreviewRow.fileProperties = picker.selectedContentProperties; + attachmentPreviewRow.isPicture = true; + controlSendButton(); + }) + } + } + IconButton { + visible: chatPage.hasSendPrivilege("can_send_media_messages") + icon.source: "image://theme/icon-m-video" + onClicked: { + var picker = pageStack.push("Sailfish.Pickers.VideoPickerPage", { + allowedOrientations: chatPage.allowedOrientations + }) + picker.selectedContentPropertiesChanged.connect(function(){ + attachmentOptionsFlickable.isNeeded = false; + Debug.log("Selected video: ", picker.selectedContentProperties.filePath ); + attachmentPreviewRow.fileProperties = picker.selectedContentProperties; + attachmentPreviewRow.isVideo = true; + controlSendButton(); + }) + } + } + IconButton { + visible: chatPage.hasSendPrivilege("can_send_media_messages") + icon.source: "image://theme/icon-m-mic" + icon.sourceSize { + width: Theme.iconSizeMedium + height: Theme.iconSizeMedium + } + highlighted: down || voiceNoteOverlayLoader.active + onClicked: { + voiceNoteOverlayLoader.active = !voiceNoteOverlayLoader.active; + stickerPickerLoader.active = false; + } + } + IconButton { + visible: chatPage.hasSendPrivilege("can_send_media_messages") + icon.source: "image://theme/icon-m-document" + onClicked: { + var picker = pageStack.push("Sailfish.Pickers.FilePickerPage", { + allowedOrientations: chatPage.allowedOrientations + }) + picker.selectedContentPropertiesChanged.connect(function(){ + attachmentOptionsFlickable.isNeeded = false; + Debug.log("Selected document: ", picker.selectedContentProperties.filePath ); + attachmentPreviewRow.fileProperties = picker.selectedContentProperties; + attachmentPreviewRow.isDocument = true; + controlSendButton(); + }) + } + } + IconButton { + visible: chatPage.hasSendPrivilege("can_send_other_messages") + icon.source: "../../images/icon-m-sticker.svg" + icon.sourceSize { + width: Theme.iconSizeMedium + height: Theme.iconSizeMedium + } + highlighted: down || stickerPickerLoader.active + onClicked: { + stickerPickerLoader.active = !stickerPickerLoader.active; + voiceNoteOverlayLoader.active = false; + } + } + IconButton { + visible: !(chatPage.isPrivateChat || chatPage.isSecretChat) && chatPage.hasSendPrivilege("can_send_polls") + icon.source: "image://theme/icon-m-question" + onClicked: { + pageStack.push(Qt.resolvedUrl("../pages/PollCreationPage.qml"), { "chatId" : chatInformation.id, groupName: chatInformation.title}); + attachmentOptionsFlickable.isNeeded = false; + } + } + IconButton { + visible: fernschreiberUtils.supportsGeoLocation() && newMessageTextField.text === "" + icon.source: "image://theme/icon-m-location" + icon.sourceSize { + width: Theme.iconSizeMedium + height: Theme.iconSizeMedium + } + onClicked: { + fernschreiberUtils.startGeoLocationUpdates(); + attachmentOptionsFlickable.isNeeded = false; + attachmentPreviewRow.isLocation = true; + attachmentPreviewRow.attachmentDescription = qsTr("Location: Obtaining position..."); + controlSendButton(); + } + } + } + } Row { - id: attachmentOptionsRow - - height: attachImageIconButton.height - - anchors.right: parent.right - layoutDirection: Qt.RightToLeft + id: attachmentPreviewRow + visible: (!!locationData || !!fileProperties) && !inlineQuery.userNameIsValid spacing: Theme.paddingMedium - leftPadding: Theme.horizontalPageMargin - rightPadding: Theme.horizontalPageMargin + width: parent.width + layoutDirection: Qt.RightToLeft + anchors.right: parent.right + + property bool isPicture: false; + property bool isVideo: false; + property bool isDocument: false; + property bool isVoiceNote: false; + property bool isLocation: false; + property var locationData: null; + property var fileProperties: null; + property string attachmentDescription: ""; + + Connections { + target: fernschreiberUtils + onNewPositionInformation: { + attachmentPreviewRow.locationData = positionInformation; + if (attachmentPreviewRow.isLocation) { + attachmentPreviewRow.attachmentDescription = qsTr("Location (%1/%2)").arg(attachmentPreviewRow.locationData.latitude).arg(attachmentPreviewRow.locationData.longitude); + } + } + } IconButton { - id: attachImageIconButton - visible: chatPage.hasSendPrivilege("can_send_media_messages") - icon.source: "image://theme/icon-m-image" + id: removeAttachmentsIconButton + icon.source: "image://theme/icon-m-clear" onClicked: { - var picker = pageStack.push("Sailfish.Pickers.ImagePickerPage", { - allowedOrientations: chatPage.allowedOrientations - }) - picker.selectedContentPropertiesChanged.connect(function(){ - attachmentOptionsFlickable.isNeeded = false; - Debug.log("Selected document: ", picker.selectedContentProperties.filePath ); - attachmentPreviewRow.fileProperties = picker.selectedContentProperties; - attachmentPreviewRow.isPicture = true; - controlSendButton(); - }) - } - } - IconButton { - visible: chatPage.hasSendPrivilege("can_send_media_messages") - icon.source: "image://theme/icon-m-video" - onClicked: { - var picker = pageStack.push("Sailfish.Pickers.VideoPickerPage", { - allowedOrientations: chatPage.allowedOrientations - }) - picker.selectedContentPropertiesChanged.connect(function(){ - attachmentOptionsFlickable.isNeeded = false; - Debug.log("Selected video: ", picker.selectedContentProperties.filePath ); - attachmentPreviewRow.fileProperties = picker.selectedContentProperties; - attachmentPreviewRow.isVideo = true; - controlSendButton(); - }) - } - } - IconButton { - visible: chatPage.hasSendPrivilege("can_send_media_messages") - icon.source: "image://theme/icon-m-mic" - icon.sourceSize { - width: Theme.iconSizeMedium - height: Theme.iconSizeMedium - } - highlighted: down || voiceNoteOverlayLoader.active - onClicked: { - voiceNoteOverlayLoader.active = !voiceNoteOverlayLoader.active; - stickerPickerLoader.active = false; - } - } - IconButton { - visible: chatPage.hasSendPrivilege("can_send_media_messages") - icon.source: "image://theme/icon-m-document" - onClicked: { - var picker = pageStack.push("Sailfish.Pickers.FilePickerPage", { - allowedOrientations: chatPage.allowedOrientations - }) - picker.selectedContentPropertiesChanged.connect(function(){ - attachmentOptionsFlickable.isNeeded = false; - Debug.log("Selected document: ", picker.selectedContentProperties.filePath ); - attachmentPreviewRow.fileProperties = picker.selectedContentProperties; - attachmentPreviewRow.isDocument = true; - controlSendButton(); - }) - } - } - IconButton { - visible: chatPage.hasSendPrivilege("can_send_other_messages") - icon.source: "../../images/icon-m-sticker.svg" - icon.sourceSize { - width: Theme.iconSizeMedium - height: Theme.iconSizeMedium - } - highlighted: down || stickerPickerLoader.active - onClicked: { - stickerPickerLoader.active = !stickerPickerLoader.active; - voiceNoteOverlayLoader.active = false; - } - } - IconButton { - visible: !(chatPage.isPrivateChat || chatPage.isSecretChat) && chatPage.hasSendPrivilege("can_send_polls") - icon.source: "image://theme/icon-m-question" - onClicked: { - pageStack.push(Qt.resolvedUrl("../pages/PollCreationPage.qml"), { "chatId" : chatInformation.id, groupName: chatInformation.title}); - attachmentOptionsFlickable.isNeeded = false; - } - } - IconButton { - visible: fernschreiberUtils.supportsGeoLocation() && newMessageTextField.text === "" - icon.source: "image://theme/icon-m-location" - icon.sourceSize { - width: Theme.iconSizeMedium - height: Theme.iconSizeMedium - } - onClicked: { - fernschreiberUtils.startGeoLocationUpdates(); - attachmentOptionsFlickable.isNeeded = false; - attachmentPreviewRow.isLocation = true; - attachmentPreviewRow.attachmentDescription = qsTr("Location: Obtaining position..."); + clearAttachmentPreviewRow(); controlSendButton(); } } + + Thumbnail { + id: attachmentPreviewImage + width: Theme.itemSizeMedium + height: Theme.itemSizeMedium + sourceSize.width: width + sourceSize.height: height + + fillMode: Thumbnail.PreserveAspectCrop + mimeType: !!attachmentPreviewRow.fileProperties ? attachmentPreviewRow.fileProperties.mimeType || "" : "" + source: !!attachmentPreviewRow.fileProperties ? attachmentPreviewRow.fileProperties.url || "" : "" + visible: attachmentPreviewRow.isPicture || attachmentPreviewRow.isVideo + } + + Label { + id: attachmentPreviewText + font.pixelSize: Theme.fontSizeSmall + text: ( attachmentPreviewRow.isVoiceNote || attachmentPreviewRow.isLocation ) ? attachmentPreviewRow.attachmentDescription : ( !!attachmentPreviewRow.fileProperties ? attachmentPreviewRow.fileProperties.fileName || "" : "" ); + anchors.verticalCenter: parent.verticalCenter + + maximumLineCount: 1 + truncationMode: TruncationMode.Fade + color: Theme.secondaryColor + visible: attachmentPreviewRow.isDocument || attachmentPreviewRow.isVoiceNote || attachmentPreviewRow.isLocation + } } - } + Row { + id: uploadStatusRow + visible: false + spacing: Theme.paddingMedium + width: parent.width + anchors.right: parent.right + Text { + id: uploadingText + font.pixelSize: Theme.fontSizeSmall + text: qsTr("Uploading...") + anchors.verticalCenter: parent.verticalCenter + color: Theme.secondaryColor + visible: uploadStatusRow.visible + } - Row { - id: attachmentPreviewRow - visible: (!!locationData || !!fileProperties) && !inlineQuery.userNameIsValid - spacing: Theme.paddingMedium - width: parent.width - layoutDirection: Qt.RightToLeft - anchors.right: parent.right + ProgressBar { + id: uploadingProgressBar + minimumValue: 0 + maximumValue: 100 + value: 0 + visible: uploadStatusRow.visible + width: parent.width - uploadingText.width - Theme.paddingMedium + } - property bool isPicture: false; - property bool isVideo: false; - property bool isDocument: false; - property bool isVoiceNote: false; - property bool isLocation: false; - property var locationData: null; - property var fileProperties: null; - property string attachmentDescription: ""; + } - Connections { - target: fernschreiberUtils - onNewPositionInformation: { - attachmentPreviewRow.locationData = positionInformation; - if (attachmentPreviewRow.isLocation) { - attachmentPreviewRow.attachmentDescription = qsTr("Location (%1/%2)").arg(attachmentPreviewRow.locationData.latitude).arg(attachmentPreviewRow.locationData.longitude); + Column { + id: emojiColumn + width: parent.width + anchors.horizontalCenter: parent.horizontalCenter + visible: emojiProposals ? ( emojiProposals.length > 0 ? true : false ) : false + opacity: emojiProposals ? ( emojiProposals.length > 0 ? 1 : 0 ) : 0 + Behavior on opacity { NumberAnimation {} } + spacing: Theme.paddingMedium + + Flickable { + width: parent.width + height: emojiResultRow.height + Theme.paddingSmall + anchors.horizontalCenter: parent.horizontalCenter + contentWidth: emojiResultRow.width + clip: true + Row { + id: emojiResultRow + spacing: Theme.paddingMedium + Repeater { + model: emojiProposals + + Item { + height: singleEmojiRow.height + width: singleEmojiRow.width + + Row { + id: singleEmojiRow + spacing: Theme.paddingSmall + + Image { + id: emojiPicture + source: "../js/emoji/" + modelData.file_name + width: Theme.fontSizeLarge + height: Theme.fontSizeLarge + } + + } + + MouseArea { + anchors.fill: parent + onClicked: { + replaceMessageText(newMessageTextField.text, newMessageTextField.cursorPosition, modelData.emoji); + emojiProposals = null; + } + } + } + + } } } } - IconButton { - id: removeAttachmentsIconButton - icon.source: "image://theme/icon-m-clear" - onClicked: { - clearAttachmentPreviewRow(); - controlSendButton(); + Column { + id: atMentionColumn + width: parent.width + anchors.horizontalCenter: parent.horizontalCenter + visible: opacity > 0 + opacity: knownUsersRepeater.count > 0 ? 1 : 0 + Behavior on opacity { NumberAnimation {} } + height: knownUsersRepeater.count > 0 ? childrenRect.height : 0 + Behavior on height { SmoothedAnimation { duration: 200 } } + spacing: Theme.paddingMedium + + Flickable { + width: parent.width + height: atMentionResultRow.height + Theme.paddingSmall + anchors.horizontalCenter: parent.horizontalCenter + contentWidth: atMentionResultRow.width + clip: true + Row { + id: atMentionResultRow + spacing: Theme.paddingMedium + Repeater { + id: knownUsersRepeater + + Item { + id: knownUserItem + height: singleAtMentionRow.height + width: singleAtMentionRow.width + + property string atMentionText: "@" + (user_name ? user_name : user_id + "(" + title + ")"); + + Row { + id: singleAtMentionRow + spacing: Theme.paddingSmall + + Item { + width: Theme.fontSizeHuge + height: Theme.fontSizeHuge + anchors.verticalCenter: parent.verticalCenter + ProfileThumbnail { + id: atMentionThumbnail + replacementStringHint: title + width: parent.width + height: parent.width + photoData: photo_small + } + } + + Column { + Text { + text: Emoji.emojify(title, Theme.fontSizeExtraSmall) + textFormat: Text.StyledText + color: Theme.primaryColor + font.pixelSize: Theme.fontSizeExtraSmall + font.bold: true + } + Text { + id: userHandleText + text: user_handle + textFormat: Text.StyledText + color: Theme.primaryColor + font.pixelSize: Theme.fontSizeExtraSmall + } + } + } + + MouseArea { + anchors.fill: parent + onClicked: { + replaceMessageText(newMessageTextField.text, newMessageTextField.cursorPosition, knownUserItem.atMentionText); + knownUsersRepeater.model = undefined; + } + } + } + + } + } } } - Thumbnail { - id: attachmentPreviewImage - width: Theme.itemSizeMedium - height: Theme.itemSizeMedium - sourceSize.width: width - sourceSize.height: height - - fillMode: Thumbnail.PreserveAspectCrop - mimeType: !!attachmentPreviewRow.fileProperties ? attachmentPreviewRow.fileProperties.mimeType || "" : "" - source: !!attachmentPreviewRow.fileProperties ? attachmentPreviewRow.fileProperties.url || "" : "" - visible: attachmentPreviewRow.isPicture || attachmentPreviewRow.isVideo - } - - Label { - id: attachmentPreviewText - font.pixelSize: Theme.fontSizeSmall - text: ( attachmentPreviewRow.isVoiceNote || attachmentPreviewRow.isLocation ) ? attachmentPreviewRow.attachmentDescription : ( !!attachmentPreviewRow.fileProperties ? attachmentPreviewRow.fileProperties.fileName || "" : "" ); - anchors.verticalCenter: parent.verticalCenter - - maximumLineCount: 1 - truncationMode: TruncationMode.Fade - color: Theme.secondaryColor - visible: attachmentPreviewRow.isDocument || attachmentPreviewRow.isVoiceNote || attachmentPreviewRow.isLocation - } - } - - Row { - id: uploadStatusRow - visible: false - spacing: Theme.paddingMedium - width: parent.width - anchors.right: parent.right - - Text { - id: uploadingText - font.pixelSize: Theme.fontSizeSmall - text: qsTr("Uploading...") - anchors.verticalCenter: parent.verticalCenter - color: Theme.secondaryColor - visible: uploadStatusRow.visible - } - - ProgressBar { - id: uploadingProgressBar - minimumValue: 0 - maximumValue: 100 - value: 0 - visible: uploadStatusRow.visible - width: parent.width - uploadingText.width - Theme.paddingMedium - } - - } - - Column { - id: emojiColumn - width: parent.width - anchors.horizontalCenter: parent.horizontalCenter - visible: emojiProposals ? ( emojiProposals.length > 0 ? true : false ) : false - opacity: emojiProposals ? ( emojiProposals.length > 0 ? 1 : 0 ) : 0 - Behavior on opacity { NumberAnimation {} } - spacing: Theme.paddingMedium - - Flickable { + Row { + width: parent.width + spacing: Theme.paddingSmall + visible: newMessageColumn.editMessageId !== "0" + + Text { + width: parent.width - Theme.paddingSmall - removeEditMessageIconButton.width + + anchors.verticalCenter: parent.verticalCenter + + id: editMessageText + font.pixelSize: Theme.fontSizeSmall + font.bold: true + text: qsTr("Edit Message") + color: Theme.secondaryColor + } + + IconButton { + id: removeEditMessageIconButton + icon.source: "image://theme/icon-m-clear" + onClicked: { + newMessageColumn.editMessageId = "0"; + newMessageTextField.text = ""; + } + } + } + + Row { + id: newMessageRow width: parent.width - height: emojiResultRow.height + Theme.paddingSmall anchors.horizontalCenter: parent.horizontalCenter - contentWidth: emojiResultRow.width - clip: true - Row { - id: emojiResultRow - spacing: Theme.paddingMedium - Repeater { - model: emojiProposals - Item { - height: singleEmojiRow.height - width: singleEmojiRow.width - - Row { - id: singleEmojiRow - spacing: Theme.paddingSmall - - Image { - id: emojiPicture - source: "../js/emoji/" + modelData.file_name - width: Theme.fontSizeLarge - height: Theme.fontSizeLarge - } - - } - - MouseArea { - anchors.fill: parent - onClicked: { - replaceMessageText(newMessageTextField.text, newMessageTextField.cursorPosition, modelData.emoji); - emojiProposals = null; - } + TextArea { + id: newMessageTextField + width: parent.width - (attachmentIconButton.visible ? attachmentIconButton.width : 0) - (newMessageSendButton.visible ? newMessageSendButton.width : 0) - (cancelInlineQueryButton.visible ? cancelInlineQueryButton.width : 0) + height: Math.min(chatContainer.height / 3, implicitHeight) + anchors.verticalCenter: parent.verticalCenter + font.pixelSize: Theme.fontSizeSmall + placeholderText: qsTr("Your message") + labelVisible: false + textLeftMargin: 0 + textTopMargin: 0 + enabled: !attachmentPreviewRow.isLocation + EnterKey.onClicked: { + if (appSettings.sendByEnter) { + sendMessage(); + newMessageTextField.text = ""; + if(!appSettings.focusTextAreaAfterSend) { + newMessageTextField.focus = false; } } + } + EnterKey.enabled: !inlineQuery.userNameIsValid && (!appSettings.sendByEnter || text.length) + EnterKey.iconSource: appSettings.sendByEnter ? "image://theme/icon-m-chat" : "image://theme/icon-m-enter" + + onTextChanged: { + controlSendButton(); + textReplacementTimer.restart(); } } - } - } - Column { - id: atMentionColumn - width: parent.width - anchors.horizontalCenter: parent.horizontalCenter - visible: opacity > 0 - opacity: knownUsersRepeater.count > 0 ? 1 : 0 - Behavior on opacity { NumberAnimation {} } - height: knownUsersRepeater.count > 0 ? childrenRect.height : 0 - Behavior on height { SmoothedAnimation { duration: 200 } } - spacing: Theme.paddingMedium - - Flickable { - width: parent.width - height: atMentionResultRow.height + Theme.paddingSmall - anchors.horizontalCenter: parent.horizontalCenter - contentWidth: atMentionResultRow.width - clip: true - Row { - id: atMentionResultRow - spacing: Theme.paddingMedium - Repeater { - id: knownUsersRepeater - - Item { - id: knownUserItem - height: singleAtMentionRow.height - width: singleAtMentionRow.width - - property string atMentionText: "@" + (user_name ? user_name : user_id + "(" + title + ")"); - - Row { - id: singleAtMentionRow - spacing: Theme.paddingSmall - - Item { - width: Theme.fontSizeHuge - height: Theme.fontSizeHuge - anchors.verticalCenter: parent.verticalCenter - ProfileThumbnail { - id: atMentionThumbnail - replacementStringHint: title - width: parent.width - height: parent.width - photoData: photo_small - } - } - - Column { - Text { - text: Emoji.emojify(title, Theme.fontSizeExtraSmall) - textFormat: Text.StyledText - color: Theme.primaryColor - font.pixelSize: Theme.fontSizeExtraSmall - font.bold: true - } - Text { - id: userHandleText - text: user_handle - textFormat: Text.StyledText - color: Theme.primaryColor - font.pixelSize: Theme.fontSizeExtraSmall - } - } - } - - MouseArea { - anchors.fill: parent - onClicked: { - replaceMessageText(newMessageTextField.text, newMessageTextField.cursorPosition, knownUserItem.atMentionText); - knownUsersRepeater.model = undefined; - } - } + IconButton { + id: attachmentIconButton + icon.source: "image://theme/icon-m-attach?" + (attachmentOptionsFlickable.isNeeded ? Theme.highlightColor : Theme.primaryColor) + anchors.bottom: parent.bottom + anchors.bottomMargin: Theme.paddingSmall + enabled: !attachmentPreviewRow.visible && !stickerSetOverlayLoader.item + visible: !inlineQuery.userNameIsValid + onClicked: { + if (attachmentOptionsFlickable.isNeeded) { + attachmentOptionsFlickable.isNeeded = false; + stickerPickerLoader.active = false; + voiceNoteOverlayLoader.active = false; + } else { + attachmentOptionsFlickable.isNeeded = true; } - } } - } - } - Row { - width: parent.width - spacing: Theme.paddingSmall - visible: newMessageColumn.editMessageId !== "0" - - Text { - width: parent.width - Theme.paddingSmall - removeEditMessageIconButton.width - - anchors.verticalCenter: parent.verticalCenter - - id: editMessageText - font.pixelSize: Theme.fontSizeSmall - font.bold: true - text: qsTr("Edit Message") - color: Theme.secondaryColor - } - - IconButton { - id: removeEditMessageIconButton - icon.source: "image://theme/icon-m-clear" - onClicked: { - newMessageColumn.editMessageId = "0"; - newMessageTextField.text = ""; - } - } - } - - Row { - id: newMessageRow - width: parent.width - anchors.horizontalCenter: parent.horizontalCenter - - TextArea { - id: newMessageTextField - width: parent.width - (attachmentIconButton.visible ? attachmentIconButton.width : 0) - (newMessageSendButton.visible ? newMessageSendButton.width : 0) - (cancelInlineQueryButton.visible ? cancelInlineQueryButton.width : 0) - height: Math.min(chatContainer.height / 3, implicitHeight) - anchors.verticalCenter: parent.verticalCenter - font.pixelSize: Theme.fontSizeSmall - placeholderText: qsTr("Your message") - labelVisible: false - textLeftMargin: 0 - textTopMargin: 0 - enabled: !attachmentPreviewRow.isLocation - EnterKey.onClicked: { - if (appSettings.sendByEnter) { + IconButton { + id: newMessageSendButton + icon.source: "image://theme/icon-m-chat" + anchors.bottom: parent.bottom + anchors.bottomMargin: Theme.paddingSmall + visible: !inlineQuery.userNameIsValid && (!appSettings.sendByEnter || attachmentPreviewRow.visible) + enabled: false + onClicked: { sendMessage(); newMessageTextField.text = ""; if(!appSettings.focusTextAreaAfterSend) { @@ -1764,89 +1896,50 @@ Page { } } - EnterKey.enabled: !inlineQuery.userNameIsValid && (!appSettings.sendByEnter || text.length) - EnterKey.iconSource: appSettings.sendByEnter ? "image://theme/icon-m-chat" : "image://theme/icon-m-enter" + Item { + width: cancelInlineQueryButton.width + height: cancelInlineQueryButton.height + visible: inlineQuery.userNameIsValid + anchors.bottom: parent.bottom + anchors.bottomMargin: Theme.paddingSmall - onTextChanged: { - controlSendButton(); - textReplacementTimer.restart(); - } - } - - IconButton { - id: attachmentIconButton - icon.source: "image://theme/icon-m-attach?" + (attachmentOptionsFlickable.isNeeded ? Theme.highlightColor : Theme.primaryColor) - anchors.bottom: parent.bottom - anchors.bottomMargin: Theme.paddingSmall - enabled: !attachmentPreviewRow.visible && !stickerSetOverlayLoader.item - visible: !inlineQuery.userNameIsValid - onClicked: { - if (attachmentOptionsFlickable.isNeeded) { - attachmentOptionsFlickable.isNeeded = false; - stickerPickerLoader.active = false; - voiceNoteOverlayLoader.active = false; - } else { - attachmentOptionsFlickable.isNeeded = true; - } - } - } - - IconButton { - id: newMessageSendButton - icon.source: "image://theme/icon-m-chat" - anchors.bottom: parent.bottom - anchors.bottomMargin: Theme.paddingSmall - visible: !inlineQuery.userNameIsValid && (!appSettings.sendByEnter || attachmentPreviewRow.visible) - enabled: false - onClicked: { - sendMessage(); - newMessageTextField.text = ""; - if(!appSettings.focusTextAreaAfterSend) { - newMessageTextField.focus = false; - } - } - } - - Item { - width: cancelInlineQueryButton.width - height: cancelInlineQueryButton.height - visible: inlineQuery.userNameIsValid - anchors.bottom: parent.bottom - anchors.bottomMargin: Theme.paddingSmall - - IconButton { - id: cancelInlineQueryButton - icon.source: "image://theme/icon-m-cancel" - visible: parent.visible - opacity: inlineQuery.isLoading ? 0.2 : 1 - Behavior on opacity { FadeAnimation {} } - onClicked: { - if(inlineQuery.query !== "") { - newMessageTextField.text = "@" + inlineQuery.userName + " " - newMessageTextField.cursorPosition = newMessageTextField.text.length - lostFocusTimer.start(); - } else { + IconButton { + id: cancelInlineQueryButton + icon.source: "image://theme/icon-m-cancel" + visible: parent.visible + opacity: inlineQuery.isLoading ? 0.2 : 1 + Behavior on opacity { FadeAnimation {} } + onClicked: { + if(inlineQuery.query !== "") { + newMessageTextField.text = "@" + inlineQuery.userName + " " + newMessageTextField.cursorPosition = newMessageTextField.text.length + lostFocusTimer.start(); + } else { + newMessageTextField.text = "" + } + } + onPressAndHold: { newMessageTextField.text = "" } } - onPressAndHold: { - newMessageTextField.text = "" + + BusyIndicator { + size: BusyIndicatorSize.Small + anchors.centerIn: parent + running: inlineQuery.isLoading } } - BusyIndicator { - size: BusyIndicatorSize.Small - anchors.centerIn: parent - running: inlineQuery.isLoading - } + } - - } } } + + } + Loader { id: selectedMessagesActions asynchronous: true diff --git a/rpm/harbour-fernschreiber.spec b/rpm/harbour-fernschreiber.spec index 8b97fa8..999885f 100644 --- a/rpm/harbour-fernschreiber.spec +++ b/rpm/harbour-fernschreiber.spec @@ -12,7 +12,7 @@ Name: harbour-fernschreiber Summary: Fernschreiber is a Telegram client for Sailfish OS Version: 0.7.1 -Release: 2 +Release: 3 Group: Qt/Qt License: LICENSE URL: http://werkwolf.eu/ diff --git a/rpm/harbour-fernschreiber.yaml b/rpm/harbour-fernschreiber.yaml index b8168df..b1a564d 100644 --- a/rpm/harbour-fernschreiber.yaml +++ b/rpm/harbour-fernschreiber.yaml @@ -1,7 +1,7 @@ Name: harbour-fernschreiber Summary: Fernschreiber is a Telegram client for Sailfish OS Version: 0.7.1 -Release: 2 +Release: 3 # The contents of the Group field should be one of the groups listed here: # https://github.com/mer-tools/spectacle/blob/master/data/GROUPS Group: Qt/Qt diff --git a/translations/harbour-fernschreiber-de.ts b/translations/harbour-fernschreiber-de.ts index 1e7fac7..f15679a 100644 --- a/translations/harbour-fernschreiber-de.ts +++ b/translations/harbour-fernschreiber-de.ts @@ -435,6 +435,14 @@ Location (%1/%2) Standort (%1/%2) + + Copy Message to Clipboard + Nachricht in die Zwischenablage kopieren + + + Message Options + + ChatSelectionPage @@ -991,6 +999,10 @@ Unpin Message Nachricht losheften + + More Options... + + MessageListViewItemSimple diff --git a/translations/harbour-fernschreiber-en.ts b/translations/harbour-fernschreiber-en.ts index cbd94b1..4785223 100644 --- a/translations/harbour-fernschreiber-en.ts +++ b/translations/harbour-fernschreiber-en.ts @@ -435,6 +435,14 @@ Location (%1/%2) Location (%1/%2) + + Copy Message to Clipboard + Copy Message to Clipboard + + + Message Options + + ChatSelectionPage @@ -993,6 +1001,10 @@ messages Unpin Message Unpin Message + + More Options... + + MessageListViewItemSimple diff --git a/translations/harbour-fernschreiber-es.ts b/translations/harbour-fernschreiber-es.ts index 3e216ce..aa9b741 100644 --- a/translations/harbour-fernschreiber-es.ts +++ b/translations/harbour-fernschreiber-es.ts @@ -435,6 +435,14 @@ Location (%1/%2) Ubicación (%1/%2) + + Copy Message to Clipboard + Copiar + + + Message Options + + ChatSelectionPage @@ -991,6 +999,10 @@ Unpin Message Desanclar mensaje + + More Options... + + MessageListViewItemSimple diff --git a/translations/harbour-fernschreiber-fi.ts b/translations/harbour-fernschreiber-fi.ts index 2dbffc2..093bc77 100644 --- a/translations/harbour-fernschreiber-fi.ts +++ b/translations/harbour-fernschreiber-fi.ts @@ -435,6 +435,14 @@ Location (%1/%2) Sijainti (%1/%2) + + Copy Message to Clipboard + Kopioi viesti leikepöydälle + + + Message Options + + ChatSelectionPage @@ -992,6 +1000,10 @@ Unpin Message Poista viestin kiinnitys + + More Options... + + MessageListViewItemSimple diff --git a/translations/harbour-fernschreiber-hu.ts b/translations/harbour-fernschreiber-hu.ts index de21a42..31173e4 100644 --- a/translations/harbour-fernschreiber-hu.ts +++ b/translations/harbour-fernschreiber-hu.ts @@ -425,6 +425,14 @@ Location (%1/%2) + + Copy Message to Clipboard + + + + Message Options + + ChatSelectionPage @@ -977,6 +985,10 @@ Unpin Message + + More Options... + + MessageListViewItemSimple diff --git a/translations/harbour-fernschreiber-it.ts b/translations/harbour-fernschreiber-it.ts index 63eec71..366d1a7 100644 --- a/translations/harbour-fernschreiber-it.ts +++ b/translations/harbour-fernschreiber-it.ts @@ -435,6 +435,14 @@ Location (%1/%2) Posizione(%1/%2) + + Copy Message to Clipboard + Copia messaggio nella clipboard + + + Message Options + + ChatSelectionPage @@ -991,6 +999,10 @@ Unpin Message Togli messaggio in evidenza + + More Options... + + MessageListViewItemSimple diff --git a/translations/harbour-fernschreiber-pl.ts b/translations/harbour-fernschreiber-pl.ts index dfc6fdf..f0acce1 100644 --- a/translations/harbour-fernschreiber-pl.ts +++ b/translations/harbour-fernschreiber-pl.ts @@ -445,6 +445,14 @@ Location (%1/%2) Lokalizacja (%1/%2) + + Copy Message to Clipboard + Skopiuj wiadomość do schowka + + + Message Options + + ChatSelectionPage @@ -1005,6 +1013,10 @@ Unpin Message Odepnij wiadomość + + More Options... + + MessageListViewItemSimple diff --git a/translations/harbour-fernschreiber-ru.ts b/translations/harbour-fernschreiber-ru.ts index f054407..84182ef 100644 --- a/translations/harbour-fernschreiber-ru.ts +++ b/translations/harbour-fernschreiber-ru.ts @@ -445,6 +445,14 @@ Location (%1/%2) Местоположение (%1/%2) + + Copy Message to Clipboard + Скопировать в буфер обмена + + + Message Options + + ChatSelectionPage @@ -1008,6 +1016,10 @@ Unpin Message Открепить сообщение + + More Options... + + MessageListViewItemSimple diff --git a/translations/harbour-fernschreiber-sk.ts b/translations/harbour-fernschreiber-sk.ts index 5bbc498..56cf8f9 100644 --- a/translations/harbour-fernschreiber-sk.ts +++ b/translations/harbour-fernschreiber-sk.ts @@ -445,6 +445,14 @@ Location (%1/%2) Poloha (%1/%2) + + Copy Message to Clipboard + Kopírovať správu do schránky + + + Message Options + + ChatSelectionPage @@ -1005,6 +1013,10 @@ Unpin Message Odopnúť správu + + More Options... + + MessageListViewItemSimple diff --git a/translations/harbour-fernschreiber-sv.ts b/translations/harbour-fernschreiber-sv.ts index fb90049..910c4b9 100644 --- a/translations/harbour-fernschreiber-sv.ts +++ b/translations/harbour-fernschreiber-sv.ts @@ -435,6 +435,14 @@ Location (%1/%2) Plats (%1/%2) + + Copy Message to Clipboard + Kopiera meddelandet till urklipp + + + Message Options + + ChatSelectionPage @@ -991,6 +999,10 @@ Unpin Message Lösgör meddelandet + + More Options... + + MessageListViewItemSimple diff --git a/translations/harbour-fernschreiber-zh_CN.ts b/translations/harbour-fernschreiber-zh_CN.ts index cc64d84..127afe2 100644 --- a/translations/harbour-fernschreiber-zh_CN.ts +++ b/translations/harbour-fernschreiber-zh_CN.ts @@ -425,6 +425,14 @@ Location (%1/%2) 位置 (%1/%2) + + Copy Message to Clipboard + 复制消息到剪切板 + + + Message Options + + ChatSelectionPage @@ -978,6 +986,10 @@ Unpin Message 取消置顶 + + More Options... + + MessageListViewItemSimple diff --git a/translations/harbour-fernschreiber.ts b/translations/harbour-fernschreiber.ts index a3c7cdd..7160831 100644 --- a/translations/harbour-fernschreiber.ts +++ b/translations/harbour-fernschreiber.ts @@ -435,6 +435,14 @@ Location (%1/%2) + + Copy Message to Clipboard + Copy Message to Clipboard + + + Message Options + + ChatSelectionPage @@ -991,6 +999,10 @@ Unpin Message + + More Options... + + MessageListViewItemSimple From 0a8f507f6fcac9cd602d09dba810687e7582c393 Mon Sep 17 00:00:00 2001 From: Sebastian Wolf Date: Mon, 15 Feb 2021 21:20:38 +0100 Subject: [PATCH 2/8] Message option drawer: This crazy idea really seems to work... --- qml/components/MessageListViewItem.qml | 33 +---- qml/pages/ChatPage.qml | 148 +++++++++++++------- translations/harbour-fernschreiber-de.ts | 52 ++++--- translations/harbour-fernschreiber-en.ts | 52 ++++--- translations/harbour-fernschreiber-es.ts | 46 +++--- translations/harbour-fernschreiber-fi.ts | 46 +++--- translations/harbour-fernschreiber-hu.ts | 46 +++--- translations/harbour-fernschreiber-it.ts | 46 +++--- translations/harbour-fernschreiber-pl.ts | 46 +++--- translations/harbour-fernschreiber-ru.ts | 46 +++--- translations/harbour-fernschreiber-sk.ts | 46 +++--- translations/harbour-fernschreiber-sv.ts | 46 +++--- translations/harbour-fernschreiber-zh_CN.ts | 46 +++--- translations/harbour-fernschreiber.ts | 46 +++--- 14 files changed, 355 insertions(+), 390 deletions(-) diff --git a/qml/components/MessageListViewItem.qml b/qml/components/MessageListViewItem.qml index a2c4341..61c7cb4 100644 --- a/qml/components/MessageListViewItem.qml +++ b/qml/components/MessageListViewItem.qml @@ -97,16 +97,6 @@ ListItem { } sourceComponent: Component { ContextMenu { - Repeater { - model: (extraContentLoader.item && ("extraContextMenuItems" in extraContentLoader.item)) ? - extraContentLoader.item.extraContextMenuItems : 0 - delegate: MenuItem { - visible: modelData.visible - text: modelData.name - onClicked: modelData.action() - } - } - MenuItem { visible: messageListItem.canReplyToMessage onClicked: messageListItem.replyToMessage() @@ -127,32 +117,13 @@ ListItem { onClicked: { messageOptionsDrawer.myMessage = myMessage; messageOptionsDrawer.userInformation = userInformation; + messageOptionsDrawer.sourceItem = messageListItem + messageOptionsDrawer.additionalItemsModel = (extraContentLoader.item && ("extraContextMenuItems" in extraContentLoader.item)) ? extraContentLoader.item.extraContextMenuItems : 0; messageListItem.highlighted = true; messageOptionsDrawer.open = true; } text: qsTr("More Options...") } - MenuItem { - onClicked: { - if (myMessage.is_pinned) { - Remorse.popupAction(page, qsTr("Message unpinned"), function() { tdLibWrapper.unpinMessage(page.chatInformation.id, messageId); - pinnedMessageItem.requestCloseMessage(); } ); - } else { - tdLibWrapper.pinMessage(page.chatInformation.id, messageId); - } - } - text: myMessage.is_pinned ? qsTr("Unpin Message") : qsTr("Pin Message") - visible: canPinMessages() - } - MenuItem { - onClicked: { - var chatId = page.chatInformation.id; - var messageId = messageListItem.messageId; - Remorse.itemAction(messageListItem, qsTr("Message deleted"), function() { tdLibWrapper.deleteMessages(chatId, [ messageId]); }) - } - text: qsTr("Delete Message") - visible: myMessage.can_be_deleted_for_all_users || (myMessage.can_be_deleted_only_for_self && myMessage.chat_id === page.myUserId) - } } } } diff --git a/qml/pages/ChatPage.qml b/qml/pages/ChatPage.qml index 477d0e2..a91f5dd 100644 --- a/qml/pages/ChatPage.qml +++ b/qml/pages/ChatPage.qml @@ -686,54 +686,31 @@ Page { property var myMessage: ({}) property var userInformation: ({}) + property var additionalItemsModel: 0 + property var sourceItem signal closeRequested(); + function closeDrawer() { + messageOptionsDrawer.closeRequested(); + messageOptionsDrawer.open = false; + } + anchors.fill: parent - dock: chatPage.isPortrait ? Dock.Top : Dock.Right + dock: chatPage.isPortrait ? Dock.Bottom : Dock.Right + backgroundSize: dock == Dock.Left || dock == Dock.Right ? width / 2 : height / 3 - background: SilicaListView { + background: Column { anchors.fill: parent - model: ListModel { - id: myListModel - property var actions: { - "copyToClipboard": function() { Clipboard.text = Functions.getMessageText(messageOptionsDrawer.myMessage, true, messageOptionsDrawer.userInformation.id, true) }, - "pinMessage": function() { - if (messageOptionsDrawer.myMessage.is_pinned) { - Remorse.popupAction(page, qsTr("Message unpinned"), function() { tdLibWrapper.unpinMessage(chatPage.chatInformation.id, messageOptionsDrawer.myMessage.id); - pinnedMessageItem.requestCloseMessage(); } ); - } else { - tdLibWrapper.pinMessage(chatPage.chatInformation.id, messageOptionsDrawer.myMessage.id); - } - } - } - property var conditions: { - "copyToClipboard": function() { return true; }, - "pinMessage": function() { return canPinMessages(); } - } - - property var texts: { - "copyToClipboard": function() { return qsTr("Copy Message to Clipboard"); }, - "pinMessage": function() { return messageOptionsDrawer.myMessage.is_pinned ? qsTr("Unpin Message") : qsTr("Pin Message"); } - } - - ListElement { - elementActionName: "copyToClipboard" - } - - ListElement { - elementActionName: "pinMessage" - } - } - - header: Row { - width: parent.width - ( 4 * Theme.horizontalPageMargin) + Row { + id: drawerHeaderRow + width: parent.width - ( 2 * Theme.horizontalPageMargin) height: messageOptionsLabel.height + Theme.paddingLarge + ( chatPage.isPortrait ? ( 2 * Theme.paddingSmall ) : 0 ) anchors.horizontalCenter: parent.horizontalCenter spacing: Theme.paddingMedium Label { id: messageOptionsLabel - text: qsTr("Message Options") + text: qsTr("Additional Options") color: Theme.highlightColor font.pixelSize: Theme.fontSizeLarge width: parent.width - closeMessageOptionsButton.width - Theme.paddingMedium @@ -746,28 +723,93 @@ Page { icon.source: "image://theme/icon-m-clear" anchors.verticalCenter: parent.verticalCenter onClicked: { - messageOptionsDrawer.closeRequested(); - messageOptionsDrawer.open = false; + messageOptionsDrawer.closeDrawer(); } } } - delegate: ListItem { + Flickable { + id: drawerFlickable width: parent.width - visible: myListModel.actions[conditions]() - onClicked: { - myListModel.actions[elementActionName](); - } - Label { - width: parent.width - ( 2 * Theme.horizontalPageMargin ) - text: myListModel.texts[elementActionName](); - anchors.verticalCenter: parent.verticalCenter - anchors.horizontalCenter: parent.horizontalCenter - horizontalAlignment: Text.AlignHCenter - } - } + height: parent.height - drawerHeaderRow.height + contentHeight: drawerContentColumn.height + clip: true + Column { + id: drawerContentColumn + width: parent.width + Repeater { + model: messageOptionsDrawer.additionalItemsModel + delegate: BackgroundItem { + width: parent.width + visible: modelData.visible + onClicked: { + modelData.action(); + messageOptionsDrawer.closeDrawer(); + } + Label { + width: parent.width - ( 2 * Theme.horizontalPageMargin ) + text: modelData.name + anchors.verticalCenter: parent.verticalCenter + anchors.horizontalCenter: parent.horizontalCenter + horizontalAlignment: Text.AlignHCenter + } + } + } + BackgroundItem { + width: parent.width + onClicked: { + Clipboard.text = Functions.getMessageText(messageOptionsDrawer.myMessage, true, messageOptionsDrawer.userInformation.id, true); + messageOptionsDrawer.closeDrawer(); + } + Label { + width: parent.width - ( 2 * Theme.horizontalPageMargin ) + text: qsTr("Copy Message to Clipboard") + anchors.verticalCenter: parent.verticalCenter + anchors.horizontalCenter: parent.horizontalCenter + horizontalAlignment: Text.AlignHCenter + } + } + BackgroundItem { + width: parent.width + visible: canPinMessages() + onClicked: { + if (messageOptionsDrawer.myMessage.is_pinned) { + Remorse.popupAction(page, qsTr("Message unpinned"), function() { tdLibWrapper.unpinMessage(chatPage.chatInformation.id, messageOptionsDrawer.myMessage.id); + pinnedMessageItem.requestCloseMessage(); } ); + } else { + tdLibWrapper.pinMessage(chatPage.chatInformation.id, messageOptionsDrawer.myMessage.id); + } + messageOptionsDrawer.closeDrawer(); + } + Label { + width: parent.width - ( 2 * Theme.horizontalPageMargin ) + text: messageOptionsDrawer.myMessage.is_pinned ? qsTr("Unpin Message") : qsTr("Pin Message") + anchors.verticalCenter: parent.verticalCenter + anchors.horizontalCenter: parent.horizontalCenter + horizontalAlignment: Text.AlignHCenter + } + } + BackgroundItem { + width: parent.width + visible: messageOptionsDrawer.myMessage.can_be_deleted_for_all_users || (messageOptionsDrawer.myMessage.can_be_deleted_only_for_self && messageOptionsDrawer.myMessage.chat_id === chatPage.myUserId) + onClicked: { + var chatId = page.chatInformation.id; + var messageId = messageOptionsDrawer.myMessage.id; + Remorse.itemAction(messageOptionsDrawer.sourceItem, qsTr("Message deleted"), function() { tdLibWrapper.deleteMessages(chatId, [ messageId ]); }); + messageOptionsDrawer.closeDrawer(); + } + Label { + width: parent.width - ( 2 * Theme.horizontalPageMargin ) + text: qsTr("Delete Message") + anchors.verticalCenter: parent.verticalCenter + anchors.horizontalCenter: parent.horizontalCenter + horizontalAlignment: Text.AlignHCenter + } + } - VerticalScrollDecorator {} + } + VerticalScrollDecorator {} + } } SilicaFlickable { diff --git a/translations/harbour-fernschreiber-de.ts b/translations/harbour-fernschreiber-de.ts index f15679a..61604bc 100644 --- a/translations/harbour-fernschreiber-de.ts +++ b/translations/harbour-fernschreiber-de.ts @@ -437,11 +437,31 @@ Copy Message to Clipboard - Nachricht in die Zwischenablage kopieren + Nachricht in die Zwischenablage kopieren - Message Options - + Message unpinned + Nachricht losgeheftet + + + Unpin Message + Nachricht losheften + + + Pin Message + Nachricht anheften + + + Additional Options + Zusätzliche Optionen + + + Message deleted + Nachricht gelöscht + + + Delete Message + Nachricht löschen @@ -963,18 +983,6 @@ Edit Message Nachricht bearbeiten - - Copy Message to Clipboard - Nachricht in die Zwischenablage kopieren - - - Message deleted - Nachricht gelöscht - - - Delete Message - Nachricht löschen - You Sie @@ -987,21 +995,9 @@ Select Message Nachricht auswählen - - Pin Message - Nachricht anheften - - - Message unpinned - Nachricht losgeheftet - - - Unpin Message - Nachricht losheften - More Options... - + Mehr Optionen... diff --git a/translations/harbour-fernschreiber-en.ts b/translations/harbour-fernschreiber-en.ts index 4785223..5c1938c 100644 --- a/translations/harbour-fernschreiber-en.ts +++ b/translations/harbour-fernschreiber-en.ts @@ -437,11 +437,31 @@ Copy Message to Clipboard - Copy Message to Clipboard + Copy Message to Clipboard - Message Options - + Message unpinned + Message unpinned + + + Unpin Message + Unpin Message + + + Pin Message + Pin Message + + + Additional Options + Additional Options + + + Message deleted + Message deleted + + + Delete Message + Delete Message @@ -965,18 +985,6 @@ messages Edit Message Edit Message - - Copy Message to Clipboard - Copy Message to Clipboard - - - Message deleted - Message deleted - - - Delete Message - Delete Message - You You @@ -989,21 +997,9 @@ messages Select Message Select Message - - Pin Message - Pin Message - - - Message unpinned - Message unpinned - - - Unpin Message - Unpin Message - More Options... - + More Options... diff --git a/translations/harbour-fernschreiber-es.ts b/translations/harbour-fernschreiber-es.ts index aa9b741..fd979a2 100644 --- a/translations/harbour-fernschreiber-es.ts +++ b/translations/harbour-fernschreiber-es.ts @@ -440,9 +440,29 @@ Copiar - Message Options + Message unpinned + Mensaje desanclado + + + Unpin Message + Desanclar mensaje + + + Pin Message + Anclar mensaje + + + Additional Options + + Message deleted + Mensaje borrado + + + Delete Message + Borrar + ChatSelectionPage @@ -963,18 +983,6 @@ Edit Message Editar - - Copy Message to Clipboard - Copiar - - - Message deleted - Mensaje borrado - - - Delete Message - Borrar - You Usted @@ -987,18 +995,6 @@ Select Message Seleccionar - - Pin Message - Anclar mensaje - - - Message unpinned - Mensaje desanclado - - - Unpin Message - Desanclar mensaje - More Options... diff --git a/translations/harbour-fernschreiber-fi.ts b/translations/harbour-fernschreiber-fi.ts index 093bc77..a9a4acd 100644 --- a/translations/harbour-fernschreiber-fi.ts +++ b/translations/harbour-fernschreiber-fi.ts @@ -440,9 +440,29 @@ Kopioi viesti leikepöydälle - Message Options + Message unpinned + Viestin kiinnitys poistettu + + + Unpin Message + Poista viestin kiinnitys + + + Pin Message + Kiinnitä viesti + + + Additional Options + + Message deleted + Viesti poistettu + + + Delete Message + Poista viesti + ChatSelectionPage @@ -964,18 +984,6 @@ Edit Message Muokkaa viestiä - - Copy Message to Clipboard - Kopioi viesti leikepöydälle - - - Message deleted - Viesti poistettu - - - Delete Message - Poista viesti - You Sinä @@ -988,18 +996,6 @@ Select Message Valitse viesti - - Pin Message - Kiinnitä viesti - - - Message unpinned - Viestin kiinnitys poistettu - - - Unpin Message - Poista viestin kiinnitys - More Options... diff --git a/translations/harbour-fernschreiber-hu.ts b/translations/harbour-fernschreiber-hu.ts index 31173e4..4617ee6 100644 --- a/translations/harbour-fernschreiber-hu.ts +++ b/translations/harbour-fernschreiber-hu.ts @@ -430,9 +430,29 @@ - Message Options + Message unpinned + + Unpin Message + + + + Pin Message + + + + Additional Options + + + + Message deleted + + + + Delete Message + Üzenet törlése + ChatSelectionPage @@ -949,18 +969,6 @@ Edit Message Üzenet szerkesztése - - Copy Message to Clipboard - - - - Message deleted - - - - Delete Message - Üzenet törlése - You Te @@ -973,18 +981,6 @@ Select Message - - Pin Message - - - - Message unpinned - - - - Unpin Message - - More Options... diff --git a/translations/harbour-fernschreiber-it.ts b/translations/harbour-fernschreiber-it.ts index 366d1a7..23b9379 100644 --- a/translations/harbour-fernschreiber-it.ts +++ b/translations/harbour-fernschreiber-it.ts @@ -440,9 +440,29 @@ Copia messaggio nella clipboard - Message Options + Message unpinned + Messaggio non più in evidenza + + + Unpin Message + Togli messaggio in evidenza + + + Pin Message + Metti messaggio in evidenza + + + Additional Options + + Message deleted + Messaggio cancellato + + + Delete Message + Cancella messaggio + ChatSelectionPage @@ -963,18 +983,6 @@ Edit Message Modifica messaggio - - Copy Message to Clipboard - Copia messaggio nella clipboard - - - Message deleted - Messaggio cancellato - - - Delete Message - Cancella messaggio - You Tu @@ -987,18 +995,6 @@ Select Message Seleziona messaggio - - Pin Message - Metti messaggio in evidenza - - - Message unpinned - Messaggio non più in evidenza - - - Unpin Message - Togli messaggio in evidenza - More Options... diff --git a/translations/harbour-fernschreiber-pl.ts b/translations/harbour-fernschreiber-pl.ts index f0acce1..4869f04 100644 --- a/translations/harbour-fernschreiber-pl.ts +++ b/translations/harbour-fernschreiber-pl.ts @@ -450,9 +450,29 @@ Skopiuj wiadomość do schowka - Message Options + Message unpinned + Wiadomość opięta + + + Unpin Message + Odepnij wiadomość + + + Pin Message + Przypnij wiadomość + + + Additional Options + + Message deleted + Wiadomość usunięta + + + Delete Message + Usuń wiadomość + ChatSelectionPage @@ -977,18 +997,6 @@ Edit Message Edytuj widomość - - Copy Message to Clipboard - Skopiuj wiadomość do schowka - - - Message deleted - Wiadomość usunięta - - - Delete Message - Usuń wiadomość - You Ty @@ -1001,18 +1009,6 @@ Select Message Wybierz wiadomość - - Pin Message - Przypnij wiadomość - - - Message unpinned - Wiadomość odpięta - - - Unpin Message - Odepnij wiadomość - More Options... diff --git a/translations/harbour-fernschreiber-ru.ts b/translations/harbour-fernschreiber-ru.ts index 84182ef..0c0b046 100644 --- a/translations/harbour-fernschreiber-ru.ts +++ b/translations/harbour-fernschreiber-ru.ts @@ -450,9 +450,29 @@ Скопировать в буфер обмена - Message Options + Message unpinned + Сообщение откреплено + + + Unpin Message + Открепить сообщение + + + Pin Message + Закрепить сообщение + + + Additional Options + + Message deleted + Сообщение удалено + + + Delete Message + Удалить + ChatSelectionPage @@ -980,18 +1000,6 @@ Edit Message Редактировать - - Copy Message to Clipboard - Скопировать в буфер обмена - - - Message deleted - Сообщение удалено - - - Delete Message - Удалить - You Вы @@ -1004,18 +1012,6 @@ Select Message Выбрать сообщение - - Pin Message - Закрепить сообщение - - - Message unpinned - Сообщение откреплено - - - Unpin Message - Открепить сообщение - More Options... diff --git a/translations/harbour-fernschreiber-sk.ts b/translations/harbour-fernschreiber-sk.ts index 56cf8f9..ce27ea6 100644 --- a/translations/harbour-fernschreiber-sk.ts +++ b/translations/harbour-fernschreiber-sk.ts @@ -450,9 +450,29 @@ Kopírovať správu do schránky - Message Options + Message unpinned + Správa bola odopnutá + + + Unpin Message + Odopnúť správu + + + Pin Message + Pripnúť správu + + + Additional Options + + Message deleted + Správa bola odstránená + + + Delete Message + Odstrániť správu + ChatSelectionPage @@ -977,18 +997,6 @@ Edit Message Upraviť správu - - Copy Message to Clipboard - Kopírovať správu do schránky - - - Message deleted - Správa bola odstránená - - - Delete Message - Odstrániť správu - You Ja @@ -1001,18 +1009,6 @@ Select Message Vybrať správu - - Pin Message - Pripnúť správu - - - Message unpinned - Správa bola odopnutá - - - Unpin Message - Odopnúť správu - More Options... diff --git a/translations/harbour-fernschreiber-sv.ts b/translations/harbour-fernschreiber-sv.ts index 910c4b9..16911ce 100644 --- a/translations/harbour-fernschreiber-sv.ts +++ b/translations/harbour-fernschreiber-sv.ts @@ -440,9 +440,29 @@ Kopiera meddelandet till urklipp - Message Options + Message unpinned + Meddelandet lösgjort + + + Unpin Message + Lösgör meddelandet + + + Pin Message + Fäst meddelandet + + + Additional Options + + Message deleted + Mededelande borttaget + + + Delete Message + Ta bort meddelandet + ChatSelectionPage @@ -963,18 +983,6 @@ Edit Message Redigera meddelandet - - Copy Message to Clipboard - Kopiera meddelandet till urklipp - - - Message deleted - Mededelande borttaget - - - Delete Message - Ta bort meddelandet - You Du @@ -987,18 +995,6 @@ Select Message Markera meddelanden - - Pin Message - Fäst meddelandet - - - Message unpinned - Meddelandet lösgjort - - - Unpin Message - Lösgör meddelandet - More Options... diff --git a/translations/harbour-fernschreiber-zh_CN.ts b/translations/harbour-fernschreiber-zh_CN.ts index 127afe2..eac8e4e 100644 --- a/translations/harbour-fernschreiber-zh_CN.ts +++ b/translations/harbour-fernschreiber-zh_CN.ts @@ -430,9 +430,29 @@ 复制消息到剪切板 - Message Options + Message unpinned + 已取消置顶消息 + + + Unpin Message + 取消置顶 + + + Pin Message + 置顶消息 + + + Additional Options + + Message deleted + 已删除消息 + + + Delete Message + 删除消息 + ChatSelectionPage @@ -950,18 +970,6 @@ Edit Message 编辑消息 - - Copy Message to Clipboard - 复制消息到剪切板 - - - Message deleted - 已删除消息 - - - Delete Message - 删除消息 - You @@ -974,18 +982,6 @@ Select Message 选择消息 - - Pin Message - 置顶消息 - - - Message unpinned - 已取消消息置顶 - - - Unpin Message - 取消置顶 - More Options... diff --git a/translations/harbour-fernschreiber.ts b/translations/harbour-fernschreiber.ts index 7160831..985cbc1 100644 --- a/translations/harbour-fernschreiber.ts +++ b/translations/harbour-fernschreiber.ts @@ -440,9 +440,29 @@ Copy Message to Clipboard - Message Options + Message unpinned + + Unpin Message + + + + Pin Message + + + + Additional Options + + + + Message deleted + Message deleted + + + Delete Message + Delete Message + ChatSelectionPage @@ -963,18 +983,6 @@ Edit Message Edit Message - - Copy Message to Clipboard - Copy Message to Clipboard - - - Message deleted - Message deleted - - - Delete Message - Delete Message - You You @@ -987,18 +995,6 @@ Select Message Select Message - - Pin Message - - - - Message unpinned - - - - Unpin Message - - More Options... From 532b35e9f3ad13aebb3c9adf3208f920071a324b Mon Sep 17 00:00:00 2001 From: Sebastian Wolf Date: Mon, 15 Feb 2021 21:57:44 +0100 Subject: [PATCH 3/8] Adjust changed localization files --- rpm/harbour-fernschreiber.spec | 2 +- rpm/harbour-fernschreiber.yaml | 2 +- translations/harbour-fernschreiber-es.ts | 32 +++++++-------------- translations/harbour-fernschreiber-fi.ts | 12 ++++---- translations/harbour-fernschreiber-it.ts | 12 ++++---- translations/harbour-fernschreiber-pl.ts | 12 ++++---- translations/harbour-fernschreiber-ru.ts | 10 +++---- translations/harbour-fernschreiber-sk.ts | 12 ++++---- translations/harbour-fernschreiber-sv.ts | 12 ++++---- translations/harbour-fernschreiber-zh_CN.ts | 12 ++++---- 10 files changed, 53 insertions(+), 65 deletions(-) diff --git a/rpm/harbour-fernschreiber.spec b/rpm/harbour-fernschreiber.spec index 999885f..0d7c696 100644 --- a/rpm/harbour-fernschreiber.spec +++ b/rpm/harbour-fernschreiber.spec @@ -12,7 +12,7 @@ Name: harbour-fernschreiber Summary: Fernschreiber is a Telegram client for Sailfish OS Version: 0.7.1 -Release: 3 +Release: 4 Group: Qt/Qt License: LICENSE URL: http://werkwolf.eu/ diff --git a/rpm/harbour-fernschreiber.yaml b/rpm/harbour-fernschreiber.yaml index b1a564d..478fe32 100644 --- a/rpm/harbour-fernschreiber.yaml +++ b/rpm/harbour-fernschreiber.yaml @@ -1,7 +1,7 @@ Name: harbour-fernschreiber Summary: Fernschreiber is a Telegram client for Sailfish OS Version: 0.7.1 -Release: 3 +Release: 4 # The contents of the Group field should be one of the groups listed here: # https://github.com/mer-tools/spectacle/blob/master/data/GROUPS Group: Qt/Qt diff --git a/translations/harbour-fernschreiber-es.ts b/translations/harbour-fernschreiber-es.ts index ec4d531..cf69565 100644 --- a/translations/harbour-fernschreiber-es.ts +++ b/translations/harbour-fernschreiber-es.ts @@ -437,19 +437,19 @@ Copy Message to Clipboard - Copiar + Copiar Message unpinned - Mensaje desanclado + Mensaje desanclado Unpin Message - Desanclar mensaje + Desanclar mensaje Pin Message - Anclar mensaje + Anclar mensaje Additional Options @@ -457,11 +457,11 @@ Message deleted - Mensaje borrado + Mensaje borrado Delete Message - Borrar + Borrar @@ -999,18 +999,6 @@ More Options... - - Pin Message - Anclar mensaje - - - Message unpinned - Mensaje desanclado - - - Unpin Message - Desanclar mensaje - MessageListViewItemSimple @@ -2164,18 +2152,18 @@ scored %Ln points myself - - + punto %Ln anotado + puntos %Ln anotados sent a game myself - + envió un juego sent a game - + envió un juego diff --git a/translations/harbour-fernschreiber-fi.ts b/translations/harbour-fernschreiber-fi.ts index a9a4acd..023cab4 100644 --- a/translations/harbour-fernschreiber-fi.ts +++ b/translations/harbour-fernschreiber-fi.ts @@ -437,19 +437,19 @@ Copy Message to Clipboard - Kopioi viesti leikepöydälle + Kopioi viesti leikepöydälle Message unpinned - Viestin kiinnitys poistettu + Viestin kiinnitys poistettu Unpin Message - Poista viestin kiinnitys + Poista viestin kiinnitys Pin Message - Kiinnitä viesti + Kiinnitä viesti Additional Options @@ -457,11 +457,11 @@ Message deleted - Viesti poistettu + Viesti poistettu Delete Message - Poista viesti + Poista viesti diff --git a/translations/harbour-fernschreiber-it.ts b/translations/harbour-fernschreiber-it.ts index cb62027..f9cf1c6 100644 --- a/translations/harbour-fernschreiber-it.ts +++ b/translations/harbour-fernschreiber-it.ts @@ -437,19 +437,19 @@ Copy Message to Clipboard - Copia messaggio nella clipboard + Copia messaggio nella clipboard Message unpinned - Messaggio non più in evidenza + Messaggio non più in evidenza Unpin Message - Togli messaggio in evidenza + Togli messaggio in evidenza Pin Message - Metti messaggio in evidenza + Metti messaggio in evidenza Additional Options @@ -457,11 +457,11 @@ Message deleted - Messaggio cancellato + Messaggio cancellato Delete Message - Cancella messaggio + Cancella messaggio diff --git a/translations/harbour-fernschreiber-pl.ts b/translations/harbour-fernschreiber-pl.ts index 4869f04..d27feec 100644 --- a/translations/harbour-fernschreiber-pl.ts +++ b/translations/harbour-fernschreiber-pl.ts @@ -447,19 +447,19 @@ Copy Message to Clipboard - Skopiuj wiadomość do schowka + Skopiuj wiadomość do schowka Message unpinned - Wiadomość opięta + Wiadomość opięta Unpin Message - Odepnij wiadomość + Odepnij wiadomość Pin Message - Przypnij wiadomość + Przypnij wiadomość Additional Options @@ -467,11 +467,11 @@ Message deleted - Wiadomość usunięta + Wiadomość usunięta Delete Message - Usuń wiadomość + Usuń wiadomość diff --git a/translations/harbour-fernschreiber-ru.ts b/translations/harbour-fernschreiber-ru.ts index 2bac172..53459c1 100644 --- a/translations/harbour-fernschreiber-ru.ts +++ b/translations/harbour-fernschreiber-ru.ts @@ -447,19 +447,19 @@ Copy Message to Clipboard - Скопировать в буфер обмена + Скопировать в буфер обмена Message unpinned - Сообщение откреплено + Сообщение откреплено Unpin Message - Открепить сообщение + Открепить сообщение Pin Message - Закрепить сообщение + Закрепить сообщение Additional Options @@ -467,7 +467,7 @@ Message deleted - Сообщение удалено + Сообщение удалено Delete Message diff --git a/translations/harbour-fernschreiber-sk.ts b/translations/harbour-fernschreiber-sk.ts index ce27ea6..56e89c6 100644 --- a/translations/harbour-fernschreiber-sk.ts +++ b/translations/harbour-fernschreiber-sk.ts @@ -447,19 +447,19 @@ Copy Message to Clipboard - Kopírovať správu do schránky + Kopírovať správu do schránky Message unpinned - Správa bola odopnutá + Správa bola odopnutá Unpin Message - Odopnúť správu + Odopnúť správu Pin Message - Pripnúť správu + Pripnúť správu Additional Options @@ -467,11 +467,11 @@ Message deleted - Správa bola odstránená + Správa bola odstránená Delete Message - Odstrániť správu + Odstrániť správu diff --git a/translations/harbour-fernschreiber-sv.ts b/translations/harbour-fernschreiber-sv.ts index 16911ce..fc87885 100644 --- a/translations/harbour-fernschreiber-sv.ts +++ b/translations/harbour-fernschreiber-sv.ts @@ -437,19 +437,19 @@ Copy Message to Clipboard - Kopiera meddelandet till urklipp + Kopiera meddelandet till urklipp Message unpinned - Meddelandet lösgjort + Meddelandet lösgjort Unpin Message - Lösgör meddelandet + Lösgör meddelandet Pin Message - Fäst meddelandet + Fäst meddelandet Additional Options @@ -457,11 +457,11 @@ Message deleted - Mededelande borttaget + Mededelande borttaget Delete Message - Ta bort meddelandet + Ta bort meddelandet diff --git a/translations/harbour-fernschreiber-zh_CN.ts b/translations/harbour-fernschreiber-zh_CN.ts index eac8e4e..1c782c7 100644 --- a/translations/harbour-fernschreiber-zh_CN.ts +++ b/translations/harbour-fernschreiber-zh_CN.ts @@ -427,19 +427,19 @@ Copy Message to Clipboard - 复制消息到剪切板 + 复制消息到剪切板 Message unpinned - 已取消置顶消息 + 已取消置顶消息 Unpin Message - 取消置顶 + 取消置顶 Pin Message - 置顶消息 + 置顶消息 Additional Options @@ -447,11 +447,11 @@ Message deleted - 已删除消息 + 已删除消息 Delete Message - 删除消息 + 删除消息 From 01cdb18b46e4e53cdc147c7503c117a881f3f3f4 Mon Sep 17 00:00:00 2001 From: Sebastian Wolf Date: Tue, 16 Feb 2021 18:47:12 +0100 Subject: [PATCH 4/8] Reference chatPage correctly in new delete action Co-authored-by: jgibbon <99138+jgibbon@users.noreply.github.com> --- qml/pages/ChatPage.qml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qml/pages/ChatPage.qml b/qml/pages/ChatPage.qml index a91f5dd..7a2c18f 100644 --- a/qml/pages/ChatPage.qml +++ b/qml/pages/ChatPage.qml @@ -793,7 +793,7 @@ Page { width: parent.width visible: messageOptionsDrawer.myMessage.can_be_deleted_for_all_users || (messageOptionsDrawer.myMessage.can_be_deleted_only_for_self && messageOptionsDrawer.myMessage.chat_id === chatPage.myUserId) onClicked: { - var chatId = page.chatInformation.id; + var chatId = chatPage.chatInformation.id; var messageId = messageOptionsDrawer.myMessage.id; Remorse.itemAction(messageOptionsDrawer.sourceItem, qsTr("Message deleted"), function() { tdLibWrapper.deleteMessages(chatId, [ messageId ]); }); messageOptionsDrawer.closeDrawer(); From 9688c09002be685eb2a127acf6975a2d9ddda05c Mon Sep 17 00:00:00 2001 From: Sebastian Wolf Date: Tue, 16 Feb 2021 18:51:50 +0100 Subject: [PATCH 5/8] Define dock height/width more transparently --- qml/pages/ChatPage.qml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qml/pages/ChatPage.qml b/qml/pages/ChatPage.qml index a91f5dd..e73effc 100644 --- a/qml/pages/ChatPage.qml +++ b/qml/pages/ChatPage.qml @@ -698,7 +698,7 @@ Page { anchors.fill: parent dock: chatPage.isPortrait ? Dock.Bottom : Dock.Right - backgroundSize: dock == Dock.Left || dock == Dock.Right ? width / 2 : height / 3 + backgroundSize: chatPage.isPortrait ? height / 3 : width / 2 background: Column { anchors.fill: parent From e2e78713df2b2e735f0bd6a97f848830f1e61e2c Mon Sep 17 00:00:00 2001 From: Sebastian Wolf Date: Tue, 16 Feb 2021 20:54:48 +0100 Subject: [PATCH 6/8] Drawer: Replace Flickable/Column with SilicaListView --- qml/pages/ChatPage.qml | 144 ++++++++++++++++++----------------------- 1 file changed, 62 insertions(+), 82 deletions(-) diff --git a/qml/pages/ChatPage.qml b/qml/pages/ChatPage.qml index 210ae62..00b8e2a 100644 --- a/qml/pages/ChatPage.qml +++ b/qml/pages/ChatPage.qml @@ -689,6 +689,48 @@ Page { property var additionalItemsModel: 0 property var sourceItem + property list messageOptionsModel: [ + NamedAction { + visible: true + name: qsTr("Copy Message to Clipboard") + action: function () { Clipboard.text = Functions.getMessageText(messageOptionsDrawer.myMessage, true, messageOptionsDrawer.userInformation.id, true); } + }, + NamedAction { + visible: canPinMessages() + name: messageOptionsDrawer.myMessage.is_pinned ? qsTr("Unpin Message") : qsTr("Pin Message") + action: function () { + if (messageOptionsDrawer.myMessage.is_pinned) { + Remorse.popupAction(page, qsTr("Message unpinned"), function() { tdLibWrapper.unpinMessage(chatPage.chatInformation.id, messageOptionsDrawer.myMessage.id); + pinnedMessageItem.requestCloseMessage(); } ); + } else { + tdLibWrapper.pinMessage(chatPage.chatInformation.id, messageOptionsDrawer.myMessage.id); + } + } + }, + NamedAction { + visible: messageOptionsDrawer.myMessage.can_be_deleted_for_all_users || (messageOptionsDrawer.myMessage.can_be_deleted_only_for_self && messageOptionsDrawer.myMessage.chat_id === chatPage.myUserId) + name: qsTr("Delete Message") + action: function () { + var chatId = chatPage.chatInformation.id; + var messageId = messageOptionsDrawer.myMessage.id; + Remorse.itemAction(messageOptionsDrawer.sourceItem, qsTr("Message deleted"), function() { tdLibWrapper.deleteMessages(chatId, [ messageId ]); }); + } + } + ] + + onOpenChanged: { + if (open) { + var jointModel = []; + for (var j = 0; j < additionalItemsModel.length; j++) { + jointModel.push(additionalItemsModel[j]); + } + for (var i = 0; i < messageOptionsModel.length; i++) { + jointModel.push(messageOptionsModel[i]); + } + drawerListView.model = jointModel; + } + } + signal closeRequested(); function closeDrawer() { @@ -700,9 +742,15 @@ Page { dock: chatPage.isPortrait ? Dock.Bottom : Dock.Right backgroundSize: chatPage.isPortrait ? height / 3 : width / 2 - background: Column { + background: SilicaListView { + id: drawerListView + anchors.fill: parent - Row { + clip: true + + VerticalScrollDecorator {} + + header: Row { id: drawerHeaderRow width: parent.width - ( 2 * Theme.horizontalPageMargin) height: messageOptionsLabel.height + Theme.paddingLarge + ( chatPage.isPortrait ? ( 2 * Theme.paddingSmall ) : 0 ) @@ -728,87 +776,19 @@ Page { } } - Flickable { - id: drawerFlickable - width: parent.width - height: parent.height - drawerHeaderRow.height - contentHeight: drawerContentColumn.height - clip: true - Column { - id: drawerContentColumn - width: parent.width - Repeater { - model: messageOptionsDrawer.additionalItemsModel - delegate: BackgroundItem { - width: parent.width - visible: modelData.visible - onClicked: { - modelData.action(); - messageOptionsDrawer.closeDrawer(); - } - Label { - width: parent.width - ( 2 * Theme.horizontalPageMargin ) - text: modelData.name - anchors.verticalCenter: parent.verticalCenter - anchors.horizontalCenter: parent.horizontalCenter - horizontalAlignment: Text.AlignHCenter - } - } - } - BackgroundItem { - width: parent.width - onClicked: { - Clipboard.text = Functions.getMessageText(messageOptionsDrawer.myMessage, true, messageOptionsDrawer.userInformation.id, true); - messageOptionsDrawer.closeDrawer(); - } - Label { - width: parent.width - ( 2 * Theme.horizontalPageMargin ) - text: qsTr("Copy Message to Clipboard") - anchors.verticalCenter: parent.verticalCenter - anchors.horizontalCenter: parent.horizontalCenter - horizontalAlignment: Text.AlignHCenter - } - } - BackgroundItem { - width: parent.width - visible: canPinMessages() - onClicked: { - if (messageOptionsDrawer.myMessage.is_pinned) { - Remorse.popupAction(page, qsTr("Message unpinned"), function() { tdLibWrapper.unpinMessage(chatPage.chatInformation.id, messageOptionsDrawer.myMessage.id); - pinnedMessageItem.requestCloseMessage(); } ); - } else { - tdLibWrapper.pinMessage(chatPage.chatInformation.id, messageOptionsDrawer.myMessage.id); - } - messageOptionsDrawer.closeDrawer(); - } - Label { - width: parent.width - ( 2 * Theme.horizontalPageMargin ) - text: messageOptionsDrawer.myMessage.is_pinned ? qsTr("Unpin Message") : qsTr("Pin Message") - anchors.verticalCenter: parent.verticalCenter - anchors.horizontalCenter: parent.horizontalCenter - horizontalAlignment: Text.AlignHCenter - } - } - BackgroundItem { - width: parent.width - visible: messageOptionsDrawer.myMessage.can_be_deleted_for_all_users || (messageOptionsDrawer.myMessage.can_be_deleted_only_for_self && messageOptionsDrawer.myMessage.chat_id === chatPage.myUserId) - onClicked: { - var chatId = chatPage.chatInformation.id; - var messageId = messageOptionsDrawer.myMessage.id; - Remorse.itemAction(messageOptionsDrawer.sourceItem, qsTr("Message deleted"), function() { tdLibWrapper.deleteMessages(chatId, [ messageId ]); }); - messageOptionsDrawer.closeDrawer(); - } - Label { - width: parent.width - ( 2 * Theme.horizontalPageMargin ) - text: qsTr("Delete Message") - anchors.verticalCenter: parent.verticalCenter - anchors.horizontalCenter: parent.horizontalCenter - horizontalAlignment: Text.AlignHCenter - } - } - + delegate: ListItem { + Label { + width: parent.width - ( 2 * Theme.horizontalPageMargin ) + text: modelData.name + anchors.verticalCenter: parent.verticalCenter + anchors.horizontalCenter: parent.horizontalCenter + horizontalAlignment: Text.AlignHCenter } - VerticalScrollDecorator {} + onClicked: { + modelData.action(); + messageOptionsDrawer.closeDrawer(); + } + hidden: !modelData.visible } } From 7ae58badd9a2e009db5aafbaa23aa251873147ee Mon Sep 17 00:00:00 2001 From: Sebastian Wolf Date: Tue, 16 Feb 2021 21:36:29 +0100 Subject: [PATCH 7/8] Fix highlighted behavior after options drawer was opened --- qml/components/MessageListViewItem.qml | 7 ++++--- rpm/harbour-fernschreiber.spec | 2 +- rpm/harbour-fernschreiber.yaml | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/qml/components/MessageListViewItem.qml b/qml/components/MessageListViewItem.qml index 61c7cb4..5a8ea23 100644 --- a/qml/components/MessageListViewItem.qml +++ b/qml/components/MessageListViewItem.qml @@ -43,8 +43,9 @@ ListItem { }); readonly property bool isOwnMessage: page.myUserId === myMessage.sender.user_id property bool hasContentComponent + property bool additionalOptionsOpened - highlighted: (down || isSelected) && !menuOpen + highlighted: (down || isSelected || additionalOptionsOpened) && !menuOpen openMenuOnPressAndHold: !messageListItem.precalculatedValues.pageIsSelecting signal replyToMessage() @@ -81,7 +82,7 @@ ListItem { Connections { target: messageOptionsDrawer onCloseRequested: { - messageListItem.highlighted = false; + messageListItem.additionalOptionsOpened = false; } } @@ -119,7 +120,7 @@ ListItem { messageOptionsDrawer.userInformation = userInformation; messageOptionsDrawer.sourceItem = messageListItem messageOptionsDrawer.additionalItemsModel = (extraContentLoader.item && ("extraContextMenuItems" in extraContentLoader.item)) ? extraContentLoader.item.extraContextMenuItems : 0; - messageListItem.highlighted = true; + messageListItem.additionalOptionsOpened = true; messageOptionsDrawer.open = true; } text: qsTr("More Options...") diff --git a/rpm/harbour-fernschreiber.spec b/rpm/harbour-fernschreiber.spec index 0d7c696..97dd7bf 100644 --- a/rpm/harbour-fernschreiber.spec +++ b/rpm/harbour-fernschreiber.spec @@ -12,7 +12,7 @@ Name: harbour-fernschreiber Summary: Fernschreiber is a Telegram client for Sailfish OS Version: 0.7.1 -Release: 4 +Release: 5 Group: Qt/Qt License: LICENSE URL: http://werkwolf.eu/ diff --git a/rpm/harbour-fernschreiber.yaml b/rpm/harbour-fernschreiber.yaml index 478fe32..5994827 100644 --- a/rpm/harbour-fernschreiber.yaml +++ b/rpm/harbour-fernschreiber.yaml @@ -1,7 +1,7 @@ Name: harbour-fernschreiber Summary: Fernschreiber is a Telegram client for Sailfish OS Version: 0.7.1 -Release: 4 +Release: 5 # The contents of the Group field should be one of the groups listed here: # https://github.com/mer-tools/spectacle/blob/master/data/GROUPS Group: Qt/Qt From 1a409407c9fc1fec8106ad347f2288b8e6d29081 Mon Sep 17 00:00:00 2001 From: Sebastian Wolf Date: Wed, 17 Feb 2021 23:48:08 +0100 Subject: [PATCH 8/8] Add 'Forward Message' to options drawer, fix SFOS 4.0.1 bug --- qml/pages/ChatPage.qml | 30 ++++++++++++++------- qml/pages/ChatSelectionPage.qml | 10 ++++++- translations/harbour-fernschreiber-de.ts | 4 +++ translations/harbour-fernschreiber-en.ts | 4 +++ translations/harbour-fernschreiber-es.ts | 4 +++ translations/harbour-fernschreiber-fi.ts | 4 +++ translations/harbour-fernschreiber-hu.ts | 4 +++ translations/harbour-fernschreiber-it.ts | 4 +++ translations/harbour-fernschreiber-pl.ts | 4 +++ translations/harbour-fernschreiber-ru.ts | 4 +++ translations/harbour-fernschreiber-sk.ts | 4 +++ translations/harbour-fernschreiber-sv.ts | 4 +++ translations/harbour-fernschreiber-zh_CN.ts | 4 +++ translations/harbour-fernschreiber.ts | 4 +++ 14 files changed, 78 insertions(+), 10 deletions(-) diff --git a/qml/pages/ChatPage.qml b/qml/pages/ChatPage.qml index bfeb4be..ca6867b 100644 --- a/qml/pages/ChatPage.qml +++ b/qml/pages/ChatPage.qml @@ -335,6 +335,18 @@ Page { } + function startForwardingMessages(messages) { + var ids = Functions.getMessagesArrayIds(messages); + var neededPermissions = Functions.getMessagesNeededForwardPermissions(messages); + var chatId = chatInformation.id; + pageStack.push(Qt.resolvedUrl("../pages/ChatSelectionPage.qml"), { + myUserId: chatPage.myUserId, + headerDescription: qsTr("Forward %Ln messages", "dialog header", ids.length), + payload: {fromChatId: chatId, messageIds:ids, neededPermissions: neededPermissions}, + state: "forwardMessages" + }); + } + function forwardMessages(fromChatId, messageIds) { forwardMessagesTimer.fromChatId = fromChatId; forwardMessagesTimer.messageIds = messageIds; @@ -697,6 +709,14 @@ Page { name: qsTr("Copy Message to Clipboard") action: function () { Clipboard.text = Functions.getMessageText(messageOptionsDrawer.myMessage, true, messageOptionsDrawer.userInformation.id, true); } }, + NamedAction { + visible: messageOptionsDrawer.myMessage.can_be_forwarded + name: qsTr("Forward Message") + action: function () { + var messagesToForward = [ messageOptionsDrawer.myMessage ]; + startForwardingMessages(messagesToForward); + } + }, NamedAction { visible: canPinMessages() name: messageOptionsDrawer.myMessage.is_pinned ? qsTr("Unpin Message") : qsTr("Pin Message") @@ -2029,15 +2049,7 @@ Page { icon.sourceSize: Qt.size(Theme.iconSizeMedium, Theme.iconSizeMedium) icon.source: "image://theme/icon-m-forward" onClicked: { - var ids = Functions.getMessagesArrayIds(chatPage.selectedMessages) - var neededPermissions = Functions.getMessagesNeededForwardPermissions(chatPage.selectedMessages) - var chatId = chatInformation.id - pageStack.push(Qt.resolvedUrl("../pages/ChatSelectionPage.qml"), { - myUserId: chatPage.myUserId, - headerDescription: qsTr("Forward %Ln messages", "dialog header", ids.length), - payload: {fromChatId: chatId, messageIds:ids, neededPermissions: neededPermissions}, - state: "forwardMessages" - }) + startForwardingMessages(chatPage.selectedMessages); } } diff --git a/qml/pages/ChatSelectionPage.qml b/qml/pages/ChatSelectionPage.qml index 1e6262a..c3027dd 100644 --- a/qml/pages/ChatSelectionPage.qml +++ b/qml/pages/ChatSelectionPage.qml @@ -28,10 +28,18 @@ Dialog { allowedOrientations: Orientation.All canAccept: false acceptDestinationAction: PageStackAction.Replace - acceptDestinationReplaceTarget: pageStack.find( function(page){ return(page._depth === 0)} ) + acceptDestinationReplaceTarget: pageStack.find( function(page){ + // This crazy workaround is presented to you by a bug introduced with SFOS 4.0.1 + // See https://forum.sailfishos.org/t/4-0-1-45-pagestack-find-not-working-properly-anymore-in-a-dialog/4723 for details. + chatSelectionPage.currentDepth = chatSelectionPage.currentDepth - 1; + return(chatSelectionPage.currentDepth === 0); + } ) property int myUserId: tdLibWrapper.getUserInformation().id property alias headerTitle: pageHeader.title property alias headerDescription: pageHeader.description + + property var currentDepth: pageStack.depth + /* payload dependent on chatSelectionPage.state - forwardMessages: {fromChatId, messageIds, neededPermissions} diff --git a/translations/harbour-fernschreiber-de.ts b/translations/harbour-fernschreiber-de.ts index 61604bc..39beb6b 100644 --- a/translations/harbour-fernschreiber-de.ts +++ b/translations/harbour-fernschreiber-de.ts @@ -463,6 +463,10 @@ Delete Message Nachricht löschen + + Forward Message + Nachricht weiterleiten + ChatSelectionPage diff --git a/translations/harbour-fernschreiber-en.ts b/translations/harbour-fernschreiber-en.ts index 5c1938c..25436de 100644 --- a/translations/harbour-fernschreiber-en.ts +++ b/translations/harbour-fernschreiber-en.ts @@ -463,6 +463,10 @@ Delete Message Delete Message + + Forward Message + Forward Message + ChatSelectionPage diff --git a/translations/harbour-fernschreiber-es.ts b/translations/harbour-fernschreiber-es.ts index cf69565..41416d8 100644 --- a/translations/harbour-fernschreiber-es.ts +++ b/translations/harbour-fernschreiber-es.ts @@ -463,6 +463,10 @@ Delete Message Borrar + + Forward Message + + ChatSelectionPage diff --git a/translations/harbour-fernschreiber-fi.ts b/translations/harbour-fernschreiber-fi.ts index 023cab4..22d88c6 100644 --- a/translations/harbour-fernschreiber-fi.ts +++ b/translations/harbour-fernschreiber-fi.ts @@ -463,6 +463,10 @@ Delete Message Poista viesti + + Forward Message + + ChatSelectionPage diff --git a/translations/harbour-fernschreiber-hu.ts b/translations/harbour-fernschreiber-hu.ts index 4617ee6..07c781e 100644 --- a/translations/harbour-fernschreiber-hu.ts +++ b/translations/harbour-fernschreiber-hu.ts @@ -453,6 +453,10 @@ Delete Message Üzenet törlése + + Forward Message + + ChatSelectionPage diff --git a/translations/harbour-fernschreiber-it.ts b/translations/harbour-fernschreiber-it.ts index f9cf1c6..15176ad 100644 --- a/translations/harbour-fernschreiber-it.ts +++ b/translations/harbour-fernschreiber-it.ts @@ -463,6 +463,10 @@ Delete Message Cancella messaggio + + Forward Message + + ChatSelectionPage diff --git a/translations/harbour-fernschreiber-pl.ts b/translations/harbour-fernschreiber-pl.ts index d27feec..6124a01 100644 --- a/translations/harbour-fernschreiber-pl.ts +++ b/translations/harbour-fernschreiber-pl.ts @@ -473,6 +473,10 @@ Delete Message Usuń wiadomość + + Forward Message + + ChatSelectionPage diff --git a/translations/harbour-fernschreiber-ru.ts b/translations/harbour-fernschreiber-ru.ts index 0e3885d..35c3a3d 100644 --- a/translations/harbour-fernschreiber-ru.ts +++ b/translations/harbour-fernschreiber-ru.ts @@ -473,6 +473,10 @@ Delete Message Удалить + + Forward Message + + ChatSelectionPage diff --git a/translations/harbour-fernschreiber-sk.ts b/translations/harbour-fernschreiber-sk.ts index 56e89c6..cfd935f 100644 --- a/translations/harbour-fernschreiber-sk.ts +++ b/translations/harbour-fernschreiber-sk.ts @@ -473,6 +473,10 @@ Delete Message Odstrániť správu + + Forward Message + + ChatSelectionPage diff --git a/translations/harbour-fernschreiber-sv.ts b/translations/harbour-fernschreiber-sv.ts index fc87885..3976b92 100644 --- a/translations/harbour-fernschreiber-sv.ts +++ b/translations/harbour-fernschreiber-sv.ts @@ -463,6 +463,10 @@ Delete Message Ta bort meddelandet + + Forward Message + + ChatSelectionPage diff --git a/translations/harbour-fernschreiber-zh_CN.ts b/translations/harbour-fernschreiber-zh_CN.ts index 1c782c7..6d8f06e 100644 --- a/translations/harbour-fernschreiber-zh_CN.ts +++ b/translations/harbour-fernschreiber-zh_CN.ts @@ -453,6 +453,10 @@ Delete Message 删除消息 + + Forward Message + + ChatSelectionPage diff --git a/translations/harbour-fernschreiber.ts b/translations/harbour-fernschreiber.ts index 985cbc1..178e268 100644 --- a/translations/harbour-fernschreiber.ts +++ b/translations/harbour-fernschreiber.ts @@ -463,6 +463,10 @@ Delete Message Delete Message + + Forward Message + + ChatSelectionPage