From 36fbf44d422e64d10b5f2dcb776c8f839d8ac85f Mon Sep 17 00:00:00 2001 From: Gaelle Braud Date: Thu, 18 Dec 2025 10:35:01 +0100 Subject: [PATCH] fix new chat selection --- Linphone/core/chat/ChatList.cpp | 2 +- Linphone/core/chat/ChatList.hpp | 2 +- Linphone/core/chat/ChatProxy.cpp | 7 ++- Linphone/core/chat/ChatProxy.hpp | 3 ++ .../core/participant/ParticipantInfoProxy.cpp | 2 +- Linphone/data/languages/de.ts | 44 +++++++++---------- Linphone/data/languages/en.ts | 44 +++++++++---------- Linphone/data/languages/fr.ts | 44 +++++++++---------- .../Control/Display/Chat/ChatListView.qml | 10 ++++- Linphone/view/Page/Main/Chat/ChatPage.qml | 10 +++-- 10 files changed, 93 insertions(+), 75 deletions(-) diff --git a/Linphone/core/chat/ChatList.cpp b/Linphone/core/chat/ChatList.cpp index 36179c3fd..7f73dbb66 100644 --- a/Linphone/core/chat/ChatList.cpp +++ b/Linphone/core/chat/ChatList.cpp @@ -218,7 +218,7 @@ bool ChatList::addChatInList(QSharedPointer chatCore) { if (it == chatList.end()) { connectItem(chatCore); add(chatCore); - emit chatAdded(); + emit chatAdded(chatCore); return true; } return false; diff --git a/Linphone/core/chat/ChatList.hpp b/Linphone/core/chat/ChatList.hpp index 0ec7ab87a..8f67bbe02 100644 --- a/Linphone/core/chat/ChatList.hpp +++ b/Linphone/core/chat/ChatList.hpp @@ -48,7 +48,7 @@ public: signals: void lUpdate(); void filterChanged(QString filter); - void chatAdded(); + void chatAdded(QSharedPointer chatCore); void chatUpdated(); private: diff --git a/Linphone/core/chat/ChatProxy.cpp b/Linphone/core/chat/ChatProxy.cpp index fd30a71a6..6f4eed9da 100644 --- a/Linphone/core/chat/ChatProxy.cpp +++ b/Linphone/core/chat/ChatProxy.cpp @@ -45,7 +45,12 @@ void ChatProxy::setSourceModel(QAbstractItemModel *model) { if (newChatList) { connect(this, &ChatProxy::filterTextChanged, newChatList, [this, newChatList] { emit newChatList->filterChanged(getFilterText()); }); - connect(newChatList, &ChatList::chatAdded, this, [this] { invalidate(); }); + connect(newChatList, &ChatList::chatAdded, this, [this](QSharedPointer chatCore) { + if (chatCore) { + invalidate(); + emit chatAdded(new ChatGui(chatCore)); + } + }); connect(newChatList, &ChatList::dataChanged, this, [this] { invalidate(); }); } QSortFilterProxyModel::setSourceModel(newChatList); diff --git a/Linphone/core/chat/ChatProxy.hpp b/Linphone/core/chat/ChatProxy.hpp index 63164f076..7a11debd0 100644 --- a/Linphone/core/chat/ChatProxy.hpp +++ b/Linphone/core/chat/ChatProxy.hpp @@ -43,6 +43,9 @@ public: Q_INVOKABLE int findChatIndex(ChatGui *chatGui); Q_INVOKABLE bool addChatInList(ChatGui *chatGui); +signals: + void chatAdded(ChatGui *chat); + protected: QSharedPointer mList; DECLARE_ABSTRACT_OBJECT diff --git a/Linphone/core/participant/ParticipantInfoProxy.cpp b/Linphone/core/participant/ParticipantInfoProxy.cpp index 94c55e3d1..0acdf6ebd 100644 --- a/Linphone/core/participant/ParticipantInfoProxy.cpp +++ b/Linphone/core/participant/ParticipantInfoProxy.cpp @@ -44,7 +44,7 @@ ChatGui *ParticipantInfoProxy::getChat() const { } void ParticipantInfoProxy::setChat(ChatGui *chat) { - lDebug() << "[ParticipantInfoProxy] set current chat " << chat; + lDebug() << "[ParticipantInfoProxy] set current chat " << chat << (chat ? chat->mCore->getTitle() : "NULL"); if (mChat != chat) { mChat = chat; mParticipants->setChatCore(chat ? chat->mCore : nullptr); diff --git a/Linphone/data/languages/de.ts b/Linphone/data/languages/de.ts index 8bc8bda74..2e20452ec 100644 --- a/Linphone/data/languages/de.ts +++ b/Linphone/data/languages/de.ts @@ -2132,65 +2132,65 @@ ChatListView - + chat_message_is_writing_info %1 is writing… %1 schreibt… - + chat_message_draft_sending_text Entwurf: %1 - + chat_room_delete "Delete" Löschen - + chat_room_mute Stummschalten - + chat_room_unmute "Mute" Stummschaltung aufheben - + chat_room_mark_as_read "Mark as read" Als gelesen markieren - + chat_room_leave "leave" Verlassen - + chat_list_leave_chat_popup_title leave the conversation ? Chat verlassen? - + chat_list_leave_chat_popup_message You will not be able to send or receive messages in this conversation anymore. Do You want to continue ? „Sie können in diesem Chat keine Nachrichten mehr senden oder empfangen. Möchten Sie fortfahren? - + chat_list_delete_chat_popup_title Delete the conversation ? Chat löschen? - + chat_list_delete_chat_popup_message This conversation and all its messages will be deleted. Do You want to continue ? Dieser Chat und alle seine Nachrichten werden gelöscht. Möchten Sie fortfahren? @@ -2606,32 +2606,32 @@ Stellen Sie sicher, dass Sie keine sensiblen Informationen teilen! Keine Chats in der Historie - + chat_action_start_new_chat "New chat" Neuer Chat - + chat_start_group_chat_title "Nouveau groupe" Neuer Gruppenchat - + chat_action_start_group_chat "Créer" Erstellen - - - + + + information_popup_error_title Fehler - + information_popup_chat_creation_failed_message "La création a échoué" Erstellen fehlgeschlagen @@ -2642,25 +2642,25 @@ Stellen Sie sicher, dass Sie keine sensiblen Informationen teilen! Der Codec konnte nicht installiert werden. - + group_chat_error_must_have_name "Un nom doit être donné au groupe Für den Gruppenchat muss ein Name festgelegt werden - + group_chat_error_no_participant "Please select at least one participant - + group_call_error_not_connected "Vous n'etes pas connecté" Sie sind nicht verbunden - + chat_creation_in_progress Creation de la conversation en cours … Chat-Erstellung ausstehend… diff --git a/Linphone/data/languages/en.ts b/Linphone/data/languages/en.ts index 4d17ea4ce..02fb06521 100644 --- a/Linphone/data/languages/en.ts +++ b/Linphone/data/languages/en.ts @@ -2095,65 +2095,65 @@ ChatListView - + chat_message_is_writing_info %1 is writing… %1 is writing… - + chat_message_draft_sending_text Draft : %1 - + chat_room_delete "Delete" Delete - + chat_room_mute Mute - + chat_room_unmute "Mute" Unmute - + chat_room_mark_as_read "Mark as read" Mark as read - + chat_room_leave "leave" Leave - + chat_list_leave_chat_popup_title leave the conversation ? Leave the conversation ? - + chat_list_leave_chat_popup_message You will not be able to send or receive messages in this conversation anymore. Do You want to continue ? You will not be able to send or receive messages in this conversation anymore. Do You want to continue ? - + chat_list_delete_chat_popup_title Delete the conversation ? Delete the conversation ? - + chat_list_delete_chat_popup_message This conversation and all its messages will be deleted. Do You want to continue ? This conversation and all its messages will be deleted. Do You want to continue ? @@ -2564,56 +2564,56 @@ Only your correspondent can decrypt them. No conversation in history - + chat_action_start_new_chat "New chat" New conversation - + chat_start_group_chat_title "Nouveau groupe" New group - + chat_action_start_group_chat "Créer" Create - - - + + + information_popup_error_title Error - + information_popup_chat_creation_failed_message "La création a échoué" Creation failed - + group_chat_error_must_have_name "Un nom doit être donné au groupe A name must be set for the group - + group_chat_error_no_participant "Please select at least one participant Please select at least one participant - + group_call_error_not_connected "Vous n'etes pas connecté" You are not connected - + chat_creation_in_progress Creation de la conversation en cours … Chat creation pending… diff --git a/Linphone/data/languages/fr.ts b/Linphone/data/languages/fr.ts index 7c04a1ab5..03856b854 100644 --- a/Linphone/data/languages/fr.ts +++ b/Linphone/data/languages/fr.ts @@ -2090,65 +2090,65 @@ ChatListView - + chat_message_is_writing_info %1 is writing… %1 est en train d'écrire… - + chat_message_draft_sending_text Brouillon : %1 - + chat_room_delete "Delete" Supprimer - + chat_room_mute Mettre en sourdine - + chat_room_unmute "Mute" Enlever la sourdine - + chat_room_mark_as_read "Mark as read" Marquer comme lu - + chat_room_leave "leave" Quitter la conversation - + chat_list_leave_chat_popup_title leave the conversation ? Quitter la conversation ? - + chat_list_leave_chat_popup_message You will not be able to send or receive messages in this conversation anymore. Do You want to continue ? Vous ne pourrez plus envoyer ou recevoir de messages dans cette conversation. Souhaitez-vous continuer ? - + chat_list_delete_chat_popup_title Delete the conversation ? Supprimer la conversation ? - + chat_list_delete_chat_popup_message This conversation and all its messages will be deleted. Do You want to continue ? La conversation et tous ses messages seront supprimés. Souhaitez-vous continuer ? @@ -2559,56 +2559,56 @@ en bout. Seul votre correspondant peut les déchiffrer. Aucune conversation dans votre historique - + chat_action_start_new_chat "New chat" Nouvelle conversation - + chat_start_group_chat_title "Nouveau groupe" Nouveau groupe - + chat_action_start_group_chat "Créer" Créer - - - + + + information_popup_error_title Erreur - + information_popup_chat_creation_failed_message "La création a échoué" La création a échoué - + group_chat_error_must_have_name "Un nom doit être donné au groupe Un nom doit être donné au groupe - + group_chat_error_no_participant "Please select at least one participant Veuillez sélectionner au moins un participant - + group_call_error_not_connected "Vous n'etes pas connecté" Vous n'êtes pas connecté - + chat_creation_in_progress Creation de la conversation en cours … Création de la conversation en cours… diff --git a/Linphone/view/Control/Display/Chat/ChatListView.qml b/Linphone/view/Control/Display/Chat/ChatListView.qml index 7dc26c867..c54f965da 100644 --- a/Linphone/view/Control/Display/Chat/ChatListView.qml +++ b/Linphone/view/Control/Display/Chat/ChatListView.qml @@ -45,7 +45,6 @@ ListView { } onModelAboutToBeReset: { loading = true - } onModelReset: { loading = false @@ -56,8 +55,13 @@ ListView { else if (mainItem.chatToSelect) { selectChat(mainItem.chatToSelect) mainItem.chatToSelect = null + } else { + selectChat(mainItem.currentChatGui) } } + onChatAdded: (chat) => { + mainItem.chatToSelect = chat + } onRowsRemoved: { var index = mainItem.currentIndex mainItem.currentIndex = -1 @@ -83,7 +87,9 @@ ListView { function selectChat(chatGui, force) { var index = chatProxy.findChatIndex(chatGui) - // force adding chat to list if not in list for now + // force adding chat to list if it already exists + // but has not been added to the list yet because + // it is empty and hide_empty_chatrooms is set if (index === -1 && force === true && chatGui) { if (chatProxy.addChatInList(chatGui)) { var index = chatProxy.findChatIndex(chatGui) diff --git a/Linphone/view/Page/Main/Chat/ChatPage.qml b/Linphone/view/Page/Main/Chat/ChatPage.qml index 44a143cba..560b7526c 100644 --- a/Linphone/view/Page/Main/Chat/ChatPage.qml +++ b/Linphone/view/Page/Main/Chat/ChatPage.qml @@ -28,7 +28,7 @@ AbstractMainPage { property var selectedChatGui: null property string remoteAddress onRemoteAddressChanged: console.log("ChatPage : remote address changed :", remoteAddress) - property var remoteChatObj: UtilsCpp.getChatForAddress(remoteAddress) + property var remoteChatObj: remoteAddress.length > 0 ? UtilsCpp.getChatForAddress(remoteAddress) : null property var remoteChat: remoteChatObj ? remoteChatObj.value : null signal openChatRequested(ChatGui chat) @@ -46,8 +46,6 @@ AbstractMainPage { UtilsCpp.showInformationPopup(qsTr("info_popup_error_title"), //: Chat room creation failed ! qsTr("info_popup_chatroom_creation_failed"), false) - } else if (remoteChat.core.state === LinphoneEnums.ChatRoomState.Created) { - openChatRequested(remoteChat) } } } @@ -78,6 +76,7 @@ AbstractMainPage { rightPanelStackView.visible: false//listStackView.currentItem && listStackView.currentItem.objectName === "chatListItem" && selectedChatGui !== null onNoItemButtonPressed: goToNewChat() + signal newChatItemOpen() showDefaultItem: listStackView.currentItem && listStackView.currentItem.objectName == "chatListItem" @@ -88,6 +87,7 @@ AbstractMainPage { if (listStackView.currentItem && listStackView.currentItem.objectName != "newChatItem") listStackView.push(newChatItem) + newChatItemOpen() } Dialog { @@ -226,6 +226,10 @@ AbstractMainPage { function onOpenChatRequested(chat) { chatListView.chatToSelect = chat } + function onNewChatItemOpen() { + // reset index to clear right panel when opening new conversation + chatListView.currentIndex = -1 + } } } }