mirror of
https://gitlab.linphone.org/BC/public/linphone-desktop.git
synced 2026-04-18 04:38:29 +00:00
Open chat in right panel on state Created (fix #LINQT-2500)
This commit is contained in:
parent
c8088a8608
commit
f3e524713d
5 changed files with 49 additions and 21 deletions
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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 (!core->getDefaultAccount()) return;
|
||||
if (room->getAccount() != core->getDefaultAccount()) {
|
||||
qInfo() << log().arg("Chat room to add does not refer to current account, return");
|
||||
|
|
@ -182,27 +180,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,
|
||||
|
|
@ -212,8 +211,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);
|
||||
}
|
||||
});
|
||||
|
||||
|
|
@ -248,7 +246,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;
|
||||
|
|
|
|||
|
|
@ -274,6 +274,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);
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -52,6 +52,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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue