Skip to content
Snippets Groups Projects
Commit c52d288c authored by Sébastien Blin's avatar Sébastien Blin
Browse files

messagesadapter: add kick member

GitLab: #340
Change-Id: I4cfdc6392c8b6de573f8d4471b7b5501f393379b
parent 76896e79
No related branches found
No related tags found
No related merge requests found
...@@ -109,6 +109,7 @@ ...@@ -109,6 +109,7 @@
<file>src/mainview/components/SidePanelTabBar.qml</file> <file>src/mainview/components/SidePanelTabBar.qml</file>
<file>src/mainview/components/WelcomePageQrDialog.qml</file> <file>src/mainview/components/WelcomePageQrDialog.qml</file>
<file>src/mainview/components/ConversationSmartListContextMenu.qml</file> <file>src/mainview/components/ConversationSmartListContextMenu.qml</file>
<file>src/mainview/components/SwarmParticipantContextMenu.qml</file>
<file>src/mainview/components/CallViewContextMenu.qml</file> <file>src/mainview/components/CallViewContextMenu.qml</file>
<file>src/mainview/components/UserProfile.qml</file> <file>src/mainview/components/UserProfile.qml</file>
<file>src/mainview/components/SwarmDetailsPanel.qml</file> <file>src/mainview/components/SwarmDetailsPanel.qml</file>
......
...@@ -623,4 +623,9 @@ Item { ...@@ -623,4 +623,9 @@ Item {
// NewSwarmPage // NewSwarmPage
property string createTheSwarm: qsTr("Create the swarm") property string createTheSwarm: qsTr("Create the swarm")
property string goToConversation: qsTr("Go to conversation")
property string promoteAdministrator: qsTr("Promote to administrator")
property string kickMember: qsTr("Kick member")
property string administrator: qsTr("Administrator")
property string invited: qsTr("Invited")
} }
...@@ -48,6 +48,8 @@ Rectangle { ...@@ -48,6 +48,8 @@ Rectangle {
Layout.alignment: Qt.AlignCenter Layout.alignment: Qt.AlignCenter
Layout.preferredWidth: JamiTheme.avatarSizeInCall Layout.preferredWidth: JamiTheme.avatarSizeInCall
Layout.preferredHeight: JamiTheme.avatarSizeInCall Layout.preferredHeight: JamiTheme.avatarSizeInCall
Layout.topMargin: JamiTheme.swarmDetailsPageTopMargin
Layout.bottomMargin: JamiTheme.preferredMarginSize
imageId: LRCInstance.selectedConvUid imageId: LRCInstance.selectedConvUid
...@@ -164,50 +166,97 @@ Rectangle { ...@@ -164,50 +166,97 @@ Rectangle {
spacing: JamiTheme.preferredMarginSize spacing: JamiTheme.preferredMarginSize
anchors.topMargin: JamiTheme.preferredMarginSize anchors.topMargin: JamiTheme.preferredMarginSize
model: CurrentConversation.uris SwarmParticipantContextMenu {
delegate: RowLayout { id: contextMenu
spacing: 10
Avatar { function openMenuAt(x, y, participantUri) {
width: JamiTheme.smartListAvatarSize contextMenu.x = x
height: JamiTheme.smartListAvatarSize contextMenu.y = y
z: -index contextMenu.conversationId = CurrentConversation.id
contextMenu.participantUri = participantUri
imageId: CurrentAccount.uri == modelData ? CurrentAccount.id : modelData openMenu()
showPresenceIndicator: UtilsAdapter.getContactPresence(CurrentAccount.id, modelData)
mode: CurrentAccount.uri == modelData ? Avatar.Mode.Account : Avatar.Mode.Contact
} }
}
ElidedTextLabel { model: CurrentConversation.uris
id: bestName delegate: Item {
Layout.preferredWidth: JamiTheme.preferredFieldWidth
Layout.preferredHeight: JamiTheme.preferredFieldHeight
eText: UtilsAdapter.getContactBestName(CurrentAccount.id, modelData)
maxWidth: JamiTheme.preferredFieldWidth
font.pointSize: JamiTheme.participantFontSize width: members.width
color: JamiTheme.primaryForegroundColor height: JamiTheme.smartListItemHeight
font.kerning: true
verticalAlignment: Text.AlignVCenter MouseArea {
anchors.fill: parent
acceptedButtons: Qt.RightButton
onClicked: function (mouse) {
contextMenu.openMenuAt(x + mouse.x, y + mouse.y, modelData)
}
} }
ElidedTextLabel { RowLayout {
id: role spacing: 10
Layout.preferredHeight: JamiTheme.preferredFieldHeight Avatar {
width: JamiTheme.smartListAvatarSize
eText: UtilsAdapter.getParticipantRole(CurrentAccount.id, CurrentConversation.id, modelData) height: JamiTheme.smartListAvatarSize
maxWidth: JamiTheme.preferredFieldWidth Layout.leftMargin: JamiTheme.preferredMarginSize
z: -index
font.pointSize: JamiTheme.participantFontSize opacity: {
color: JamiTheme.textColorHovered var role = UtilsAdapter.getParticipantRole(CurrentAccount.id, CurrentConversation.id, modelData)
font.kerning: true return role === Member.Role.INVITED ? 0.5 : 1
}
horizontalAlignment: Text.AlignRight
verticalAlignment: Text.AlignVCenter imageId: CurrentAccount.uri == modelData ? CurrentAccount.id : modelData
showPresenceIndicator: UtilsAdapter.getContactPresence(CurrentAccount.id, modelData)
mode: CurrentAccount.uri == modelData ? Avatar.Mode.Account : Avatar.Mode.Contact
}
ElidedTextLabel {
id: bestName
Layout.preferredWidth: JamiTheme.preferredFieldWidth
Layout.preferredHeight: JamiTheme.preferredFieldHeight
eText: UtilsAdapter.getContactBestName(CurrentAccount.id, modelData)
maxWidth: JamiTheme.preferredFieldWidth
font.pointSize: JamiTheme.participantFontSize
color: JamiTheme.primaryForegroundColor
opacity: {
var role = UtilsAdapter.getParticipantRole(CurrentAccount.id, CurrentConversation.id, modelData)
return role === Member.Role.INVITED ? 0.5 : 1
}
font.kerning: true
verticalAlignment: Text.AlignVCenter
}
ElidedTextLabel {
id: role
Layout.preferredHeight: JamiTheme.preferredFieldHeight
eText: {
var role = UtilsAdapter.getParticipantRole(CurrentAccount.id, CurrentConversation.id, modelData)
if (role === Member.Role.ADMIN)
return JamiStrings.administrator
if (role === Member.Role.INVITED)
return JamiStrings.invited
return ""
}
maxWidth: JamiTheme.preferredFieldWidth
font.pointSize: JamiTheme.participantFontSize
color: JamiTheme.textColorHovered
opacity: {
var role = UtilsAdapter.getParticipantRole(CurrentAccount.id, CurrentConversation.id, modelData)
return role === Member.Role.INVITED ? 0.5 : 1
}
font.kerning: true
horizontalAlignment: Text.AlignRight
verticalAlignment: Text.AlignVCenter
}
} }
} }
} }
......
/*
* Copyright (C) 2021 by Savoir-faire Linux
* Author: Sébastien Blin <sebastien.blin@savoirfairelinux.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
import QtQuick
import net.jami.Models 1.1
import net.jami.Adapters 1.1
import net.jami.Constants 1.1
import "../../commoncomponents"
import "../../commoncomponents/contextmenu"
ContextMenuAutoLoader {
id: root
property var conversationId: ""
property var participantUri: ""
// TODO get authorization
property list<GeneralMenuItem> menuItems: [
GeneralMenuItem {
id: startVideoCallItem
itemName: JamiStrings.startVideoCall
onClicked: {
}
},
GeneralMenuItem {
id: startAudioCall
itemName: JamiStrings.startAudioCall
onClicked: {
}
},
GeneralMenuItem {
id: goToConversation
itemName: JamiStrings.goToConversation
onClicked: {
}
},
GeneralMenuItem {
id: promoteAdministrator
itemName: JamiStrings.promoteAdministrator
},
GeneralMenuItem {
id: blockContact
itemName: JamiStrings.blockContact
iconSource: JamiResources.block_black_24dp_svg
},
GeneralMenuItem {
id: kickMember
itemName: JamiStrings.kickMember
// TODO can trigger (enough permission for self and member accepted)
onClicked: {
MessagesAdapter.removeConversationMember(conversationId, participantUri)
}
}
]
Component.onCompleted: menuItemsToLoad = menuItems
}
...@@ -384,6 +384,13 @@ MessagesAdapter::removeConversation(const QString& convUid) ...@@ -384,6 +384,13 @@ MessagesAdapter::removeConversation(const QString& convUid)
accInfo.conversationModel->removeConversation(convUid); accInfo.conversationModel->removeConversation(convUid);
} }
void
MessagesAdapter::removeConversationMember(const QString& convUid, const QString& memberUri)
{
auto& accInfo = lrcInstance_->getCurrentAccountInfo();
accInfo.conversationModel->removeConversationMember(convUid, memberUri);
}
void void
MessagesAdapter::removeContact(const QString& convUid, bool banContact) MessagesAdapter::removeContact(const QString& convUid, bool banContact)
{ {
......
...@@ -85,6 +85,7 @@ protected: ...@@ -85,6 +85,7 @@ protected:
Q_INVOKABLE void connectConversationModel(); Q_INVOKABLE void connectConversationModel();
Q_INVOKABLE void sendConversationRequest(); Q_INVOKABLE void sendConversationRequest();
Q_INVOKABLE void removeConversation(const QString& convUid); Q_INVOKABLE void removeConversation(const QString& convUid);
Q_INVOKABLE void removeConversationMember(const QString& convUid, const QString& participantUri);
Q_INVOKABLE void removeContact(const QString& convUid, bool banContact = false); Q_INVOKABLE void removeContact(const QString& convUid, bool banContact = false);
Q_INVOKABLE void clearConversationHistory(const QString& accountId, const QString& convUid); Q_INVOKABLE void clearConversationHistory(const QString& accountId, const QString& convUid);
Q_INVOKABLE void acceptInvitation(const QString& convId = {}); Q_INVOKABLE void acceptInvitation(const QString& convId = {});
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment