Leave chatroom
This commit is contained in:
parent
f8276ac834
commit
9e04968b20
8 changed files with 93 additions and 2 deletions
|
|
@ -91,6 +91,7 @@ ChatCore::ChatCore(const std::shared_ptr<linphone::ChatRoom> &chatRoom) : QObjec
|
|||
mIdentifier = Utils::coreStringToAppString(chatRoom->getIdentifier());
|
||||
mChatRoomState = LinphoneEnums::fromLinphone(chatRoom->getState());
|
||||
mIsEncrypted = chatRoom->hasCapability((int)linphone::ChatRoom::Capabilities::Encrypted);
|
||||
mIsReadOnly = chatRoom->isReadOnly();
|
||||
connect(this, &ChatCore::messageListChanged, this, &ChatCore::lUpdateLastMessage);
|
||||
connect(this, &ChatCore::messagesInserted, this, &ChatCore::lUpdateLastMessage);
|
||||
connect(this, &ChatCore::messageRemoved, this, &ChatCore::lUpdateLastMessage);
|
||||
|
|
@ -107,6 +108,8 @@ void ChatCore::setSelf(QSharedPointer<ChatCore> me) {
|
|||
mChatModelConnection->makeConnectToCore(&ChatCore::lDeleteHistory, [this]() {
|
||||
mChatModelConnection->invokeToModel([this]() { mChatModel->deleteHistory(); });
|
||||
});
|
||||
mChatModelConnection->makeConnectToCore(
|
||||
&ChatCore::lLeave, [this]() { mChatModelConnection->invokeToModel([this]() { mChatModel->leave(); }); });
|
||||
mChatModelConnection->makeConnectToModel(&ChatModel::historyDeleted, [this]() {
|
||||
mChatModelConnection->invokeToCore([this]() {
|
||||
clearMessagesList();
|
||||
|
|
@ -138,7 +141,11 @@ void ChatCore::setSelf(QSharedPointer<ChatCore> me) {
|
|||
&ChatModel::stateChanged,
|
||||
[this](const std::shared_ptr<linphone::ChatRoom> &chatRoom, linphone::ChatRoom::State newState) {
|
||||
auto state = LinphoneEnums::fromLinphone(newState);
|
||||
mChatModelConnection->invokeToCore([this, state]() { setChatRoomState(state); });
|
||||
bool isReadOnly = chatRoom->isReadOnly();
|
||||
mChatModelConnection->invokeToCore([this, state, isReadOnly]() {
|
||||
setChatRoomState(state);
|
||||
setIsReadOnly(isReadOnly);
|
||||
});
|
||||
});
|
||||
|
||||
mChatModelConnection->makeConnectToModel(&ChatModel::chatMessageReceived,
|
||||
|
|
@ -296,6 +303,17 @@ void ChatCore::setChatRoomState(LinphoneEnums::ChatRoomState state) {
|
|||
}
|
||||
}
|
||||
|
||||
void ChatCore::setIsReadOnly(bool readOnly) {
|
||||
if (mIsReadOnly != readOnly) {
|
||||
mIsReadOnly = readOnly;
|
||||
emit readOnlyChanged();
|
||||
}
|
||||
}
|
||||
|
||||
bool ChatCore::getIsReadOnly() const {
|
||||
return mIsReadOnly;
|
||||
}
|
||||
|
||||
ChatMessageGui *ChatCore::getLastMessage() const {
|
||||
return mLastMessage ? new ChatMessageGui(mLastMessage) : nullptr;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -50,6 +50,7 @@ public:
|
|||
Q_PROPERTY(QString composingAddress READ getComposingAddress WRITE setComposingAddress NOTIFY composingUserChanged)
|
||||
Q_PROPERTY(bool isGroupChat READ isGroupChat CONSTANT)
|
||||
Q_PROPERTY(bool isEncrypted MEMBER mIsEncrypted)
|
||||
Q_PROPERTY(bool isReadOnly READ getIsReadOnly WRITE setIsReadOnly NOTIFY readOnlyChanged)
|
||||
|
||||
// Should be call from model Thread. Will be automatically in App thread after initialization
|
||||
static QSharedPointer<ChatCore> create(const std::shared_ptr<linphone::ChatRoom> &chatRoom);
|
||||
|
|
@ -75,6 +76,9 @@ public:
|
|||
LinphoneEnums::ChatRoomState getChatRoomState() const;
|
||||
void setChatRoomState(LinphoneEnums::ChatRoomState state);
|
||||
|
||||
bool getIsReadOnly() const;
|
||||
void setIsReadOnly(bool readOnly);
|
||||
|
||||
QSharedPointer<ChatMessageCore> getLastMessageCore() const;
|
||||
void setLastMessage(QSharedPointer<ChatMessageCore> lastMessage);
|
||||
|
||||
|
|
@ -115,6 +119,7 @@ signals:
|
|||
void deleted();
|
||||
void composingUserChanged();
|
||||
void chatRoomStateChanged();
|
||||
void readOnlyChanged();
|
||||
|
||||
void lDeleteMessage();
|
||||
void lDelete();
|
||||
|
|
@ -125,6 +130,7 @@ signals:
|
|||
void lUpdateLastUpdatedTime();
|
||||
void lSendTextMessage(QString message);
|
||||
void lCompose();
|
||||
void lLeave();
|
||||
|
||||
private:
|
||||
QString id;
|
||||
|
|
@ -139,6 +145,7 @@ private:
|
|||
QString mComposingAddress;
|
||||
bool mIsGroupChat = false;
|
||||
bool mIsEncrypted = false;
|
||||
bool mIsReadOnly = false;
|
||||
LinphoneEnums::ChatRoomState mChatRoomState;
|
||||
std::shared_ptr<ChatModel> mChatModel;
|
||||
QSharedPointer<ChatMessageCore> mLastMessage;
|
||||
|
|
|
|||
|
|
@ -4197,6 +4197,24 @@ To enable them in a commercial project, please contact us.</translation>
|
|||
<extracomment>All the messages will be removed from the chat room. Do you want to continue ?</extracomment>
|
||||
<translation>All the messages will be removed from the chat room. Do you want to continue ?</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../view/Page/Form/Chat/SelectedChatView.qml" line="292"/>
|
||||
<source>chat_view_detail_leave_room_toast_button</source>
|
||||
<extracomment>"Leave chat room"</extracomment>
|
||||
<translation>Leave chat room</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../view/Page/Form/Chat/SelectedChatView.qml" line="295"/>
|
||||
<source>chat_view_detail_leave_room_toast_title</source>
|
||||
<extracomment>Leave chat room ?</extracomment>
|
||||
<translation>Leave chat room ?</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../view/Page/Form/Chat/SelectedChatView.qml" line="297"/>
|
||||
<source>chat_view_detail_leave_room_toast_message</source>
|
||||
<extracomment>You will not be able to send or receive messages in this room anymore, leave ?</extracomment>
|
||||
<translation>You will not be able to send or receive messages in this room anymore, leave ?</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>SettingsPage</name>
|
||||
|
|
|
|||
|
|
@ -4212,6 +4212,24 @@ Pour les activer dans un projet commercial, merci de nous contacter.</translatio
|
|||
<extracomment>All the messages will be removed from the chat room. Do you want to continue ?</extracomment>
|
||||
<translation>Tous les messages seront supprimés. Souhaitez-vous continuer ?</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../view/Page/Form/Chat/SelectedChatView.qml" line="292"/>
|
||||
<source>chat_view_detail_leave_room_toast_button</source>
|
||||
<extracomment>"Leave chat room"</extracomment>
|
||||
<translation>Quitter la conversation</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../view/Page/Form/Chat/SelectedChatView.qml" line="295"/>
|
||||
<source>chat_view_detail_leave_room_toast_title</source>
|
||||
<extracomment>Leave chat room ?</extracomment>
|
||||
<translation>Quitter la conversation ?</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../view/Page/Form/Chat/SelectedChatView.qml" line="297"/>
|
||||
<source>chat_view_detail_leave_room_toast_message</source>
|
||||
<extracomment>You will not be able to send or receive messages in this room anymore, leave ?</extracomment>
|
||||
<translation>Vous ne recevrez ni pourrez envoyer des messages dans cette conversation, quitter ?</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>SettingsPage</name>
|
||||
|
|
|
|||
|
|
@ -109,6 +109,10 @@ void ChatModel::deleteHistory() {
|
|||
emit historyDeleted();
|
||||
}
|
||||
|
||||
void ChatModel::leave() {
|
||||
mMonitor->leave();
|
||||
}
|
||||
|
||||
void ChatModel::deleteChatRoom() {
|
||||
CoreModel::getInstance()->getCore()->deleteChatRoom(mMonitor);
|
||||
emit deleted();
|
||||
|
|
|
|||
|
|
@ -47,6 +47,7 @@ public:
|
|||
QString getIdentifier() const;
|
||||
void deleteHistory();
|
||||
void deleteChatRoom();
|
||||
void leave();
|
||||
std::shared_ptr<linphone::ChatMessage> createTextMessageFromText(QString text);
|
||||
void compose();
|
||||
linphone::ChatRoom::State getState() const;
|
||||
|
|
|
|||
|
|
@ -32,6 +32,8 @@ ColumnLayout {
|
|||
|
||||
property alias buttonContent: rightButton.data
|
||||
property alias detailContent: detailControl.data
|
||||
|
||||
property var hideChat: false
|
||||
|
||||
component LabelButton: ColumnLayout {
|
||||
id: labelButton
|
||||
|
|
@ -169,7 +171,7 @@ ColumnLayout {
|
|||
}
|
||||
}
|
||||
LabelButton {
|
||||
visible: !mainItem.isConference && !SettingsCpp.disableChatFeature
|
||||
visible: !mainItem.isConference && !SettingsCpp.disableChatFeature && !mainItem.hideChat
|
||||
width: Math.round(56 * DefaultStyle.dp)
|
||||
height: Math.round(56 * DefaultStyle.dp)
|
||||
button.icon.width: Math.round(24 * DefaultStyle.dp)
|
||||
|
|
|
|||
|
|
@ -104,6 +104,7 @@ RowLayout {
|
|||
},
|
||||
Control.Control {
|
||||
id: messageSender
|
||||
visible: !mainItem.chat.core.isReadOnly
|
||||
anchors.bottom: parent.bottom
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
|
|
@ -268,6 +269,7 @@ RowLayout {
|
|||
}
|
||||
contentItem: CallHistoryLayout {
|
||||
chatGui: mainItem.chat
|
||||
hideChat: mainItem.chat.core.isReadOnly
|
||||
detailContent: ColumnLayout {
|
||||
DetailLayout {
|
||||
//: Other actions
|
||||
|
|
@ -284,6 +286,27 @@ RowLayout {
|
|||
// }
|
||||
// style: ButtonStyle.noBackground
|
||||
// }
|
||||
IconLabelButton {
|
||||
Layout.fillWidth: true
|
||||
Layout.preferredHeight: Math.round(50 * DefaultStyle.dp)
|
||||
icon.source: AppIcons.signOut
|
||||
//: "Leave Chat Room"
|
||||
text: qsTr("chat_view_detail_leave_room_toast_button")
|
||||
visible: mainItem.chat.core.isGroupChat && !mainItem.chat.core.isReadOnly
|
||||
onClicked: {
|
||||
//: Leave Chat Room ?
|
||||
mainWindow.showConfirmationLambdaPopup(qsTr("chat_view_detail_leave_room_toast_title"),
|
||||
//: All the messages will be removed from the chat room. Do you want to continue ?
|
||||
qsTr("chat_view_detail_leave_room_toast_message"),
|
||||
"",
|
||||
function(confirmed) {
|
||||
if (confirmed) {
|
||||
mainItem.chat.core.lLeave()
|
||||
}
|
||||
})
|
||||
}
|
||||
style: ButtonStyle.noBackground
|
||||
}
|
||||
IconLabelButton {
|
||||
Layout.fillWidth: true
|
||||
Layout.preferredHeight: Math.round(50 * DefaultStyle.dp)
|
||||
|
|
|
|||
Loading…
Reference in a new issue