Merge branch 'fix/6.1' into 'release/6.1'

Do not automatically select chat when added into the list

See merge request BC/public/linphone-desktop!1656
This commit is contained in:
Gaëlle Braud 2026-01-22 16:09:24 +00:00
commit 17a56e2e6c
6 changed files with 18 additions and 7 deletions

View file

@ -150,7 +150,7 @@ void ChatList::setSelf(QSharedPointer<ChatList> me) {
return;
}
auto chatCore = ChatCore::create(room);
mModelConnection->invokeToCore([this, chatCore] { addChatInList(chatCore); });
mModelConnection->invokeToCore([this, chatCore] { addChatInList(chatCore, false); });
};
mModelConnection->makeConnectToModel(&CoreModel::messageReceived,
[this, addChatToList](const std::shared_ptr<linphone::Core> &core,
@ -178,6 +178,11 @@ void ChatList::setSelf(QSharedPointer<ChatList> me) {
[this, addChatToList](const std::shared_ptr<linphone::Core> &core,
const std::shared_ptr<linphone::ChatRoom> &chatRoom, linphone::ChatRoom::State state) {
if (state == linphone::ChatRoom::State::Created) {
bool sendAddSignal = false;
if (chatRoom == CoreModel::getInstance()->mChatRoomBeingCreated) {
sendAddSignal = true;
}
CoreModel::getInstance()->mChatRoomBeingCreated = nullptr;
if (chatRoom->getConferenceInfo()) {
qWarning() << log().arg("Chatroom created during a conference, return");
return;
@ -191,7 +196,8 @@ void ChatList::setSelf(QSharedPointer<ChatList> me) {
return;
}
auto chatCore = ChatCore::create(chatRoom);
mModelConnection->invokeToCore([this, chatCore] { addChatInList(chatCore); });
mModelConnection->invokeToCore(
[this, chatCore, sendAddSignal] { addChatInList(chatCore, sendAddSignal); });
}
});
@ -212,7 +218,7 @@ int ChatList::findChatIndex(ChatGui *chatGui) {
return it == chatList.end() ? -1 : std::distance(chatList.begin(), it);
}
bool ChatList::addChatInList(QSharedPointer<ChatCore> chatCore) {
bool ChatList::addChatInList(QSharedPointer<ChatCore> chatCore, bool emitAddSignal) {
mustBeInMainThread(log().arg(Q_FUNC_INFO));
if (chatCore->getIdentifier().isEmpty()) {
qWarning() << "ChatRoom with invalid identifier cannot be added to the list, return";
@ -225,7 +231,7 @@ bool ChatList::addChatInList(QSharedPointer<ChatCore> chatCore) {
if (it == chatList.end()) {
connectItem(chatCore);
add(chatCore);
emit chatAdded(chatCore);
if (emitAddSignal) emit chatAdded(chatCore);
return true;
}
return false;

View file

@ -42,7 +42,7 @@ public:
void connectItem(QSharedPointer<ChatCore> chat);
int findChatIndex(ChatGui *chat);
bool addChatInList(QSharedPointer<ChatCore> chatCore);
bool addChatInList(QSharedPointer<ChatCore> chatCore, bool emitAddSignal);
virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
signals:

View file

@ -72,7 +72,7 @@ int ChatProxy::findChatIndex(ChatGui *chatGui) {
bool ChatProxy::addChatInList(ChatGui *chatGui) {
auto chatList = dynamic_cast<ChatList *>(sourceModel());
if (chatList && chatGui) {
return chatList->addChatInList(chatGui->mCore);
return chatList->addChatInList(chatGui->mCore, true);
}
return false;
}

View file

@ -79,6 +79,9 @@ public:
bool mEnd = false;
linphone::ConfiguringState mConfigStatus;
QString mConfigMessage;
// Used to get a chatroom created by user when trying to add
// one to the chat room list, so we can automatically select it
std::shared_ptr<linphone::ChatRoom> mChatRoomBeingCreated;
std::shared_ptr<linphone::Core> mCore;
std::shared_ptr<LoggerModel> mLogger;

View file

@ -757,6 +757,7 @@ std::shared_ptr<linphone::ChatRoom> ToolModel::createChatForAddress(std::shared_
return nullptr;
}
auto chatRoom = core->createChatRoom(params, participants);
CoreModel::getInstance()->mChatRoomBeingCreated = chatRoom;
return chatRoom;
}
@ -784,6 +785,7 @@ ToolModel::createGroupChatRoom(QString subject, std::list<std::shared_ptr<linpho
auto chatRoom = core->createChatRoom(params, participantsAddresses);
if (!chatRoom) lWarning() << ("[ToolModel] Failed to create group chat");
CoreModel::getInstance()->mChatRoomBeingCreated = chatRoom;
return chatRoom;
}

View file

@ -60,7 +60,7 @@ ListView {
}
}
onChatAdded: (chat) => {
// mainItem.chatToSelect = chat
mainItem.chatToSelect = chat
}
onRowsRemoved: {
var index = mainItem.currentIndex