Open chat in right panel on state Created (fix #LINQT-2500)

This commit is contained in:
Gaelle Braud 2026-04-09 15:30:06 +02:00
parent 238774ddf9
commit 63831f9542
6 changed files with 50 additions and 22 deletions

View file

@ -249,6 +249,25 @@ void ChatCore::setSelf(const QSharedPointer<ChatCore> &me) {
emit lUpdateLastUpdatedTime();
});
});
mChatModelConnection->makeConnectToModel(
&ChatModel::chatMessageSent, [this](const std::shared_ptr<linphone::ChatRoom> &chatRoom,
const std::shared_ptr<const linphone::EventLog> &eventLog) {
if (!mChatModel) {
lWarning() << log().arg("Chat model is null !");
return;
} else if (!mChatModelConnection) {
lWarning() << log().arg("Connection between Core and Model is null !");
return;
}
if (mChatModel->getMonitor() != chatRoom) return;
lInfo() << log().arg("Chat message sent in chatroom") << this << mChatModel->getTitle();
QList<QSharedPointer<EventLogCore>> list;
if (eventLog) {
emit CoreModel::getInstance()->messageSent(CoreModel::getInstance()->getCore(), chatRoom, eventLog);
} else {
lWarning() << log().arg("message sent : event log is null");
}
});
mChatModelConnection->makeConnectToCore(&ChatCore::lMarkAsRead, [this]() {
auto lastActiveWindow = Utils::getLastActiveWindow();

View file

@ -154,10 +154,8 @@ void ChatList::setSelf(QSharedPointer<ChatList> me) {
[this](std::shared_ptr<linphone::Core> core, std::shared_ptr<linphone::Account> account) { lUpdate(); });
auto addChatToList = [this](const std::shared_ptr<linphone::Core> &core,
const std::shared_ptr<linphone::ChatRoom> &room,
const std::shared_ptr<linphone::ChatMessage> &message, bool sendAddSignal = false) {
const std::shared_ptr<linphone::ChatRoom> &room, bool sendAddSignal = false) {
mustBeInLinphoneThread(log().arg(Q_FUNC_INFO));
// if (!message) return;
if (room->getAccount() != core->getDefaultAccount()) {
qInfo() << log().arg("Chat room to add does not refer to current account, return");
return;
@ -181,27 +179,28 @@ void ChatList::setSelf(QSharedPointer<ChatList> me) {
auto chatCore = ChatCore::create(room);
mModelConnection->invokeToCore([this, chatCore, sendAddSignal] { addChatInList(chatCore, sendAddSignal); });
};
mModelConnection->makeConnectToModel(&CoreModel::messageReceived,
[this, addChatToList](const std::shared_ptr<linphone::Core> &core,
const std::shared_ptr<linphone::ChatRoom> &room,
const std::shared_ptr<linphone::ChatMessage> &message) {
addChatToList(core, room, message);
});
mModelConnection->makeConnectToModel(
&CoreModel::messagesReceived,
&CoreModel::messageReceived,
[this, addChatToList](const std::shared_ptr<linphone::Core> &core,
const std::shared_ptr<linphone::ChatRoom> &room,
const std::list<std::shared_ptr<linphone::ChatMessage>> &messages) {
addChatToList(core, room, messages.front());
const std::shared_ptr<linphone::ChatMessage> &message) { addChatToList(core, room); });
mModelConnection->makeConnectToModel(
&CoreModel::messagesReceived,
[this, addChatToList](
const std::shared_ptr<linphone::Core> &core, const std::shared_ptr<linphone::ChatRoom> &room,
const std::list<std::shared_ptr<linphone::ChatMessage>> &messages) { addChatToList(core, room); });
mModelConnection->makeConnectToModel(
&CoreModel::messageSent, [this, addChatToList](const std::shared_ptr<linphone::Core> &core,
const std::shared_ptr<linphone::ChatRoom> &room,
const std::shared_ptr<const linphone::EventLog> &eventLog) {
addChatToList(core, room, true);
});
mModelConnection->makeConnectToModel(
&CoreModel::newMessageReaction,
[this, addChatToList](const std::shared_ptr<linphone::Core> &core,
const std::shared_ptr<linphone::ChatRoom> &room,
const std::shared_ptr<linphone::ChatMessage> &message,
const std::shared_ptr<const linphone::ChatMessageReaction> &reaction) {
addChatToList(core, room, message);
});
[this, addChatToList](
const std::shared_ptr<linphone::Core> &core, const std::shared_ptr<linphone::ChatRoom> &room,
const std::shared_ptr<linphone::ChatMessage> &message,
const std::shared_ptr<const linphone::ChatMessageReaction> &reaction) { addChatToList(core, room); });
mModelConnection->makeConnectToModel(&CoreModel::chatRoomStateChanged,
[this, addChatToList](const std::shared_ptr<linphone::Core> &core,
const std::shared_ptr<linphone::ChatRoom> &chatRoom,
@ -211,8 +210,7 @@ void ChatList::setSelf(QSharedPointer<ChatList> me) {
if (chatRoom == CoreModel::getInstance()->mChatRoomBeingCreated) {
sendAddSignal = true;
}
CoreModel::getInstance()->mChatRoomBeingCreated = nullptr;
addChatToList(core, chatRoom, nullptr, sendAddSignal);
addChatToList(core, chatRoom, sendAddSignal);
}
});
@ -247,7 +245,10 @@ bool ChatList::addChatInList(QSharedPointer<ChatCore> chatCore, bool emitAddSign
connectItem(chatCore);
lInfo() << "Add ChatRoom" << chatCore->getTitle();
add(chatCore);
if (emitAddSignal) emit chatAdded(chatCore);
if (emitAddSignal) {
CoreModel::getInstance()->mChatRoomBeingCreated = nullptr;
emit chatAdded(chatCore);
}
return true;
}
return false;

View file

@ -175,7 +175,7 @@ bool Notifier::createNotification(Notifier::NotificationType type, QVariantMap d
// to have the Window on Top and fullscreen independant
window->setFlags((showAsTool ? Qt::Tool : Qt::WindowStaysOnTopHint) |
Qt::FramelessWindowHint);
#ifdef Q_OS_LINUX || Q_OS_WIN
#if defined(Q_OS_LINUX) || defined(Q_OS_WIN)
window->setFlag(Qt::WindowDoesNotAcceptFocus);
#endif
// for (auto it = data.begin(); it != data.end(); ++it)

View file

@ -275,6 +275,9 @@ signals:
void messageReceived(const std::shared_ptr<linphone::Core> &core,
const std::shared_ptr<linphone::ChatRoom> &room,
const std::shared_ptr<linphone::ChatMessage> &message);
void messageSent(const std::shared_ptr<linphone::Core> &core,
const std::shared_ptr<linphone::ChatRoom> &room,
const std::shared_ptr<const linphone::EventLog> &message);
void messagesReceived(const std::shared_ptr<linphone::Core> &core,
const std::shared_ptr<linphone::ChatRoom> &room,
const std::list<std::shared_ptr<linphone::ChatMessage>> &messages);

View file

@ -99,6 +99,8 @@ ListView {
if (index === -1 && force === true && chatGui) {
if (chatProxy.addChatInList(chatGui)) {
var index = chatProxy.findChatIndex(chatGui)
} else {
console.log("could not add chat in list !")
}
}
mainItem.currentIndex = index

View file

@ -44,6 +44,9 @@ 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) {
console.log("chat room state Created, open chat in right panel")
mainItem.selectedChatGui = remoteChat
}
}
}