From ce9b2bf3b9797eb6409422c65c3be8af304ea50a Mon Sep 17 00:00:00 2001 From: Julien Wadel Date: Thu, 19 Aug 2021 19:16:55 +0200 Subject: [PATCH] Add menu button in chat and remove trashcan Add ephemeral messages to files Fix call from encrypted chat room --- .../assets/images/chat_menu_hovered.svg | 111 ++++++++++++ .../assets/images/chat_menu_normal.svg | 111 ++++++++++++ .../assets/images/chat_menu_pressed.svg | 111 ++++++++++++ linphone-app/resources.qrc | 3 + .../ui/modules/Linphone/Chat/ChatMenu.qml | 9 +- .../ui/modules/Linphone/Chat/Event.qml | 162 ++++++++++-------- .../ui/modules/Linphone/Chat/FileMessage.qml | 56 ++++-- .../modules/Linphone/Chat/IncomingMessage.qml | 9 - .../ui/modules/Linphone/Chat/Message.qml | 19 +- .../modules/Linphone/Chat/OutgoingMessage.qml | 9 - .../ui/modules/Linphone/Contact/Contact.qml | 2 +- .../ui/views/App/Main/Conversation.qml | 4 +- 12 files changed, 493 insertions(+), 113 deletions(-) create mode 100644 linphone-app/assets/images/chat_menu_hovered.svg create mode 100644 linphone-app/assets/images/chat_menu_normal.svg create mode 100644 linphone-app/assets/images/chat_menu_pressed.svg diff --git a/linphone-app/assets/images/chat_menu_hovered.svg b/linphone-app/assets/images/chat_menu_hovered.svg new file mode 100644 index 000000000..57fcc7150 --- /dev/null +++ b/linphone-app/assets/images/chat_menu_hovered.svg @@ -0,0 +1,111 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/linphone-app/assets/images/chat_menu_normal.svg b/linphone-app/assets/images/chat_menu_normal.svg new file mode 100644 index 000000000..57fcc7150 --- /dev/null +++ b/linphone-app/assets/images/chat_menu_normal.svg @@ -0,0 +1,111 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/linphone-app/assets/images/chat_menu_pressed.svg b/linphone-app/assets/images/chat_menu_pressed.svg new file mode 100644 index 000000000..17e46f152 --- /dev/null +++ b/linphone-app/assets/images/chat_menu_pressed.svg @@ -0,0 +1,111 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/linphone-app/resources.qrc b/linphone-app/resources.qrc index f96bda4cc..89b3517dd 100644 --- a/linphone-app/resources.qrc +++ b/linphone-app/resources.qrc @@ -66,6 +66,9 @@ assets/images/chat_delivered.svg assets/images/chat_error.svg assets/images/chat_hovered.svg + assets/images/chat_menu_hovered.svg + assets/images/chat_menu_normal.svg + assets/images/chat_menu_pressed.svg assets/images/chat_is_composing_0.svg assets/images/chat_is_composing_1.svg assets/images/chat_is_composing_2.svg diff --git a/linphone-app/ui/modules/Linphone/Chat/ChatMenu.qml b/linphone-app/ui/modules/Linphone/Chat/ChatMenu.qml index 21aa56d96..895ca0010 100644 --- a/linphone-app/ui/modules/Linphone/Chat/ChatMenu.qml +++ b/linphone-app/ui/modules/Linphone/Chat/ChatMenu.qml @@ -23,8 +23,12 @@ Item { property string content property int deliveryCount : 0 - signal deliveryStatusClecked() + signal deliveryStatusClicked() signal removeEntryRequested() + + function open(){ + messageMenu.open() + } Menu { @@ -61,7 +65,7 @@ Item { iconLayoutDirection: Qt.RightToLeft menuItemStyle : MenuItemStyle.aux visible: container.deliveryCount > 0 - onTriggered: container.deliveryStatusClecked() + onTriggered: container.deliveryStatusClicked() } MenuItem { //: 'Delete' : Item menu to delete a message @@ -83,6 +87,7 @@ Item { // width: rectangle.width acceptedButtons: Qt.RightButton + propagateComposedEvents:true cursorShape: parent.hoveredLink ? Qt.PointingHandCursor : Qt.IBeamCursor diff --git a/linphone-app/ui/modules/Linphone/Chat/Event.qml b/linphone-app/ui/modules/Linphone/Chat/Event.qml index ac5733f57..739502e56 100644 --- a/linphone-app/ui/modules/Linphone/Chat/Event.qml +++ b/linphone-app/ui/modules/Linphone/Chat/Event.qml @@ -8,80 +8,90 @@ import Utils 1.0 // ============================================================================= Row { - property string _type: { - var status = $chatEntry.state - - if (status === ChatRoomModel.CallStatusSuccess) { - if (!$chatEntry.isStart) { - return 'ended_call' - } - return $chatEntry.isOutgoing ? 'outgoing_call' : 'incoming_call' - } - if (status === ChatRoomModel.CallStatusDeclined) { - return $chatEntry.isOutgoing ? 'declined_outgoing_call' : 'declined_incoming_call' - } - if (status === ChatRoomModel.CallStatusMissed) { - return $chatEntry.isOutgoing ? 'missed_outgoing_call' : 'missed_incoming_call' - } - if (status === ChatRoomModel.CallStatusAborted) { - return $chatEntry.isOutgoing ? 'outgoing_call' : 'incoming_call' - } - if (status === ChatRoomModel.CallStatusEarlyAborted) { - return $chatEntry.isOutgoing ? 'missed_outgoing_call' : 'missed_incoming_call' - } - if (status === ChatRoomModel.CallStatusAcceptedElsewhere) { - return $chatEntry.isOutgoing ? 'outgoing_call' : 'incoming_call' - } - if (status === ChatRoomModel.CallStatusDeclinedElsewhere) { - return $chatEntry.isOutgoing ? 'declined_outgoing_call' : 'declined_incoming_call' - } - - return 'unknown_call_event' - } - - height: ChatStyle.entry.lineHeight - spacing: ChatStyle.entry.message.extraContent.spacing - - Icon { - height: parent.height - icon: _type - iconSize: ChatStyle.entry.event.iconSize - width: ChatStyle.entry.metaWidth - } - - Text { - Component { - // Never created. - // Private data for `lupdate`. - Item { - property var i18n: [ - QT_TR_NOOP('declinedIncomingCall'), - QT_TR_NOOP('declinedOutgoingCall'), - QT_TR_NOOP('endedCall'), - QT_TR_NOOP('incomingCall'), - QT_TR_NOOP('missedIncomingCall'), - QT_TR_NOOP('missedOutgoingCall'), - QT_TR_NOOP('outgoingCall') - ] - } - } - - color: ChatStyle.entry.event.text.color - font { - bold: true - pointSize: ChatStyle.entry.event.text.pointSize - } - height: parent.height - text: qsTr(Utils.snakeToCamel(_type)) - verticalAlignment: Text.AlignVCenter - } - - ActionButton { - height: ChatStyle.entry.lineHeight - icon: 'delete' - iconSize: ChatStyle.entry.deleteIconSize - visible: isHoverEntry() - - onClicked: removeEntry() - } + property string _type: { + var status = $chatEntry.state + + if (status === ChatRoomModel.CallStatusSuccess) { + if (!$chatEntry.isStart) { + return 'ended_call' + } + return $chatEntry.isOutgoing ? 'outgoing_call' : 'incoming_call' + } + if (status === ChatRoomModel.CallStatusDeclined) { + return $chatEntry.isOutgoing ? 'declined_outgoing_call' : 'declined_incoming_call' + } + if (status === ChatRoomModel.CallStatusMissed) { + return $chatEntry.isOutgoing ? 'missed_outgoing_call' : 'missed_incoming_call' + } + if (status === ChatRoomModel.CallStatusAborted) { + return $chatEntry.isOutgoing ? 'outgoing_call' : 'incoming_call' + } + if (status === ChatRoomModel.CallStatusEarlyAborted) { + return $chatEntry.isOutgoing ? 'missed_outgoing_call' : 'missed_incoming_call' + } + if (status === ChatRoomModel.CallStatusAcceptedElsewhere) { + return $chatEntry.isOutgoing ? 'outgoing_call' : 'incoming_call' + } + if (status === ChatRoomModel.CallStatusDeclinedElsewhere) { + return $chatEntry.isOutgoing ? 'declined_outgoing_call' : 'declined_incoming_call' + } + + return 'unknown_call_event' + } + + height: ChatStyle.entry.lineHeight + spacing: ChatStyle.entry.message.extraContent.spacing + + Icon { + height: parent.height + icon: _type + iconSize: ChatStyle.entry.event.iconSize + width: ChatStyle.entry.metaWidth + } + + Text { + id:textArea + Component { + // Never created. + // Private data for `lupdate`. + Item { + property var i18n: [ + QT_TR_NOOP('declinedIncomingCall'), + QT_TR_NOOP('declinedOutgoingCall'), + QT_TR_NOOP('endedCall'), + QT_TR_NOOP('incomingCall'), + QT_TR_NOOP('missedIncomingCall'), + QT_TR_NOOP('missedOutgoingCall'), + QT_TR_NOOP('outgoingCall') + ] + } + } + + color: ChatStyle.entry.event.text.color + font { + bold: true + pointSize: ChatStyle.entry.event.text.pointSize + } + height: parent.height + text: qsTr(Utils.snakeToCamel(_type)) + verticalAlignment: Text.AlignVCenter + ChatMenu{ + id:chatMenu + height: parent.height + width: textArea.width + + deliveryCount: 0 + onRemoveEntryRequested: removeEntry() + } + } + + ActionButton { + height: ChatStyle.entry.lineHeight + + icon: 'chat_menu' + iconSize: ChatStyle.entry.deleteIconSize + visible: isHoverEntry() + + onClicked: chatMenu.open() + } } diff --git a/linphone-app/ui/modules/Linphone/Chat/FileMessage.qml b/linphone-app/ui/modules/Linphone/Chat/FileMessage.qml index deaaa2195..fe7d5f527 100644 --- a/linphone-app/ui/modules/Linphone/Chat/FileMessage.qml +++ b/linphone-app/ui/modules/Linphone/Chat/FileMessage.qml @@ -8,6 +8,7 @@ import LinphoneUtils 1.0 import LinphoneEnums 1.0 import Linphone.Styles 1.0 import Utils 1.0 +import Units 1.0 // ============================================================================= @@ -253,6 +254,7 @@ Row { } Icon { + id:downloadButton anchors { bottom: parent.bottom bottomMargin: ChatStyle.entry.message.file.margins @@ -262,7 +264,7 @@ Row { icon: 'download' iconSize: ChatStyle.entry.message.file.iconSize - visible: (rectangle.contentModel?!isOutgoing&& !rectangle.contentModel.wasDownloaded : false) + visible: (rectangle.contentModel?!isOutgoing && !rectangle.contentModel.wasDownloaded : false) } MouseArea { @@ -273,7 +275,7 @@ Row { } anchors.fill: parent - visible: ((rectangle.isUploaded || rectangle.isRead) && !isOutgoing) || isOutgoing + visible: downloadButton.visible || ((rectangle.isUploaded || rectangle.isRead) && !isOutgoing) || isOutgoing onClicked: { if (Utils.pointIsInItem(this, thumbnailProvider, mouse)) { @@ -294,9 +296,34 @@ Row { width: rectangle.width deliveryCount: deliveryLayout.model.count - onDeliveryStatusClecked: deliveryLayout.visible = !deliveryLayout.visible + onDeliveryStatusClicked: deliveryLayout.visible = !deliveryLayout.visible onRemoveEntryRequested: removeEntry() } + + Row{ + id:ephemeralTimerRow + anchors.right:downloadButton.visible?downloadButton.left:parent.right + anchors.bottom:parent.bottom + anchors.bottomMargin: 5 + anchors.rightMargin : 5 + visible:$chatEntry.isEphemeral + spacing:5 + Text{ + text: $chatEntry.ephemeralExpireTime > 0 ? Utils.formatElapsedTime($chatEntry.ephemeralExpireTime) : Utils.formatElapsedTime($chatEntry.ephemeralLifetime) + color:"#FF5E00" + font.pointSize: Units.dp * 8 + Timer{ + running:parent.visible + interval: 1000 + repeat:true + onTriggered: if($chatEntry.getEphemeralExpireTime() > 0 ) parent.text = Utils.formatElapsedTime($chatEntry.getEphemeralExpireTime())// Use the function + } + } + Icon{ + icon:'timer' + iconSize: 15 + } + } } ChatDeliveries{ @@ -308,6 +335,20 @@ Row { chatMessageModel: $chatEntry } + + ActionButton { + height: ChatStyle.entry.lineHeight + anchors.left:rectangle.right + anchors.leftMargin: -10 + anchors.top:rectangle.top + anchors.topMargin: 5 + + icon: 'chat_menu' + iconSize: ChatStyle.entry.deleteIconSize + visible: isHoverEntry() + + onClicked: chatMenu.open() + } } // ------------------------------------------------------------------------- @@ -363,15 +404,6 @@ Row { : icon ) : undefined } - - ActionButton { - height: ChatStyle.entry.lineHeight - icon: 'delete' - iconSize: ChatStyle.entry.deleteIconSize - visible: isHoverEntry() - - onClicked: removeEntry() - } } } diff --git a/linphone-app/ui/modules/Linphone/Chat/IncomingMessage.qml b/linphone-app/ui/modules/Linphone/Chat/IncomingMessage.qml index 055d658aa..8e41a305e 100644 --- a/linphone-app/ui/modules/Linphone/Chat/IncomingMessage.qml +++ b/linphone-app/ui/modules/Linphone/Chat/IncomingMessage.qml @@ -60,14 +60,5 @@ RowLayout { backgroundColor: ChatStyle.entry.message.incoming.backgroundColor color: ChatStyle.entry.message.incoming.text.color pointSize: ChatStyle.entry.message.incoming.text.pointSize - - ActionButton { - height: ChatStyle.entry.lineHeight - icon: 'delete' - iconSize: ChatStyle.entry.deleteIconSize - visible: isHoverEntry() - - onClicked: removeEntry() - } } } diff --git a/linphone-app/ui/modules/Linphone/Chat/Message.qml b/linphone-app/ui/modules/Linphone/Chat/Message.qml index 53c21437b..722e0b99c 100644 --- a/linphone-app/ui/modules/Linphone/Chat/Message.qml +++ b/linphone-app/ui/modules/Linphone/Chat/Message.qml @@ -70,7 +70,7 @@ Item { icon:'timer' iconSize: 15 } - } + } } @@ -112,13 +112,14 @@ Item { } ChatMenu{ + id:chatMenu height: parent.height width: rectangle.width lastTextSelected: message.lastTextSelected content: $chatEntry.content deliveryCount: deliveryLayout.model.count - onDeliveryStatusClecked: deliveryLayout.visible = !deliveryLayout.visible + onDeliveryStatusClicked: deliveryLayout.visible = !deliveryLayout.visible onRemoveEntryRequested: removeEntry() } } @@ -144,4 +145,18 @@ Item { chatMessageModel: $chatEntry } + + ActionButton { + height: ChatStyle.entry.lineHeight + anchors.left:rectangle.right + anchors.leftMargin: -10 + anchors.top:rectangle.top + anchors.topMargin: 5 + + icon: 'chat_menu' + iconSize: ChatStyle.entry.deleteIconSize + visible: isHoverEntry() + + onClicked: chatMenu.open() + } } diff --git a/linphone-app/ui/modules/Linphone/Chat/OutgoingMessage.qml b/linphone-app/ui/modules/Linphone/Chat/OutgoingMessage.qml index e1788fd05..fd05897f2 100644 --- a/linphone-app/ui/modules/Linphone/Chat/OutgoingMessage.qml +++ b/linphone-app/ui/modules/Linphone/Chat/OutgoingMessage.qml @@ -88,15 +88,6 @@ Item { ? indicator : iconComponent } - - ActionButton { - height: ChatStyle.entry.lineHeight - icon: 'delete' - iconSize: ChatStyle.entry.deleteIconSize - visible: isHoverEntry() - - onClicked: removeEntry() - } } } } diff --git a/linphone-app/ui/modules/Linphone/Contact/Contact.qml b/linphone-app/ui/modules/Linphone/Contact/Contact.qml index b3fb01893..cb67b1ceb 100644 --- a/linphone-app/ui/modules/Linphone/Contact/Contact.qml +++ b/linphone-app/ui/modules/Linphone/Contact/Contact.qml @@ -106,7 +106,7 @@ Rectangle { && (entry.isOneToOne == undefined || entry.isOneToOne) && (entry.haveEncryption == undefined || !entry.haveEncryption) ? entry.sipAddress || entry.fullPeerAddress || entry.peerAddress || '' : '') - participants: entry && item.showContactAddress && sipAddress == '' && entry.isOneToOne ? entry.participants.addressesToString : '' + participants: entry && item.showContactAddress && sipAddress == '' && entry.isOneToOne && entry.participants ? entry.participants.addressesToString : '' username: avatar.username } diff --git a/linphone-app/ui/views/App/Main/Conversation.qml b/linphone-app/ui/views/App/Main/Conversation.qml index 92bc00eb4..824337288 100644 --- a/linphone-app/ui/views/App/Main/Conversation.qml +++ b/linphone-app/ui/views/App/Main/Conversation.qml @@ -223,14 +223,14 @@ ColumnLayout { icon: 'video_call' visible: SettingsModel.videoSupported && SettingsModel.outgoingCallsEnabled && SettingsModel.showStartVideoCallButton && !conversation.haveMoreThanOneParticipants - onClicked: CallsListModel.launchVideoCall(conversation.peerAddress) + onClicked: CallsListModel.launchVideoCall(chatRoomModel.participants.addressesToString) } ActionButton { icon: 'call' visible: SettingsModel.outgoingCallsEnabled && !conversation.haveMoreThanOneParticipants - onClicked: CallsListModel.launchAudioCall(conversation.peerAddress) + onClicked: CallsListModel.launchAudioCall(chatRoomModel.participants.addressesToString) } ActionButton { icon: 'chat'