fix admin rights modification #LINQT-2114

This commit is contained in:
Gaelle Braud 2025-11-07 15:40:38 +01:00
parent 74b2cf299b
commit afc03daa22
6 changed files with 46 additions and 44 deletions

View file

@ -362,12 +362,16 @@ void ChatCore::setSelf(QSharedPointer<ChatCore> me) {
auto participants = buildParticipants(chatRoom);
mChatModelConnection->invokeToCore([this, participants]() { setParticipants(participants); });
});
mChatModelConnection->makeConnectToModel(
&ChatModel::participantAdminStatusChanged, [this](const std::shared_ptr<linphone::ChatRoom> &chatRoom,
const std::shared_ptr<const linphone::EventLog> &eventLog) {
auto participants = buildParticipants(chatRoom);
mChatModelConnection->invokeToCore([this, participants]() { setParticipants(participants); });
});
mChatModelConnection->makeConnectToModel(&ChatModel::participantAdminStatusChanged,
[this](const std::shared_ptr<linphone::ChatRoom> &chatRoom,
const std::shared_ptr<const linphone::EventLog> &eventLog) {
auto participants = buildParticipants(chatRoom);
bool meAdmin = chatRoom->getMe()->isAdmin();
mChatModelConnection->invokeToCore([this, participants, meAdmin]() {
setParticipants(participants);
setMeAdmin(meAdmin);
});
});
mChatModelConnection->makeConnectToCore(&ChatCore::lRemoveParticipantAtIndex, [this](int index) {
mChatModelConnection->invokeToModel([this, index]() { mChatModel->removeParticipantAtIndex(index); });
});

View file

@ -3849,55 +3849,55 @@ Error</extracomment>
<context>
<name>GroupChatInfoParticipants</name>
<message>
<location filename="../../view/Page/Layout/Chat/GroupChatInfoParticipants.qml" line="95"/>
<location filename="../../view/Page/Layout/Chat/GroupChatInfoParticipants.qml" line="93"/>
<source>group_infos_participant_is_admin</source>
<translation>Admin</translation>
</message>
<message>
<location filename="../../view/Page/Layout/Chat/GroupChatInfoParticipants.qml" line="208"/>
<location filename="../../view/Page/Layout/Chat/GroupChatInfoParticipants.qml" line="206"/>
<source>group_infos_manage_participants_title</source>
<extracomment>&quot;Gérer des participants&quot;</extracomment>
<translation>Manage Participants</translation>
</message>
<message>
<location filename="../../view/Page/Layout/Chat/GroupChatInfoParticipants.qml" line="125"/>
<location filename="../../view/Page/Layout/Chat/GroupChatInfoParticipants.qml" line="123"/>
<source>menu_see_existing_contact</source>
<extracomment>&quot;Show contact&quot;</extracomment>
<translation>Kontakt anzeigen</translation>
</message>
<message>
<location filename="../../view/Page/Layout/Chat/GroupChatInfoParticipants.qml" line="127"/>
<location filename="../../view/Page/Layout/Chat/GroupChatInfoParticipants.qml" line="125"/>
<source>menu_add_address_to_contacts</source>
<extracomment>&quot;Add to contacts&quot;</extracomment>
<translation>Zu Kontakten hinzufügen</translation>
</message>
<message>
<location filename="../../view/Page/Layout/Chat/GroupChatInfoParticipants.qml" line="144"/>
<location filename="../../view/Page/Layout/Chat/GroupChatInfoParticipants.qml" line="142"/>
<source>group_infos_give_admin_rights</source>
<translation>Give admin rights</translation>
</message>
<message>
<location filename="../../view/Page/Layout/Chat/GroupChatInfoParticipants.qml" line="144"/>
<location filename="../../view/Page/Layout/Chat/GroupChatInfoParticipants.qml" line="142"/>
<source>group_infos_remove_admin_rights</source>
<translation>Remove admin rights</translation>
</message>
<message>
<location filename="../../view/Page/Layout/Chat/GroupChatInfoParticipants.qml" line="156"/>
<location filename="../../view/Page/Layout/Chat/GroupChatInfoParticipants.qml" line="154"/>
<source>group_infos_copy_sip_address</source>
<translation>Copy SIP Address</translation>
</message>
<message>
<location filename="../../view/Page/Layout/Chat/GroupChatInfoParticipants.qml" line="176"/>
<location filename="../../view/Page/Layout/Chat/GroupChatInfoParticipants.qml" line="174"/>
<source>group_infos_remove_participant</source>
<translation>Remove participant</translation>
</message>
<message>
<location filename="../../view/Page/Layout/Chat/GroupChatInfoParticipants.qml" line="183"/>
<location filename="../../view/Page/Layout/Chat/GroupChatInfoParticipants.qml" line="181"/>
<source>group_infos_remove_participants_toast_title</source>
<translation>Remove participant ?</translation>
</message>
<message>
<location filename="../../view/Page/Layout/Chat/GroupChatInfoParticipants.qml" line="184"/>
<location filename="../../view/Page/Layout/Chat/GroupChatInfoParticipants.qml" line="182"/>
<source>group_infos_remove_participants_toast_message</source>
<translation>Participant will be removed from chat room.</translation>
</message>

View file

@ -3770,55 +3770,55 @@ Expiration : %1</translation>
<context>
<name>GroupChatInfoParticipants</name>
<message>
<location filename="../../view/Page/Layout/Chat/GroupChatInfoParticipants.qml" line="208"/>
<location filename="../../view/Page/Layout/Chat/GroupChatInfoParticipants.qml" line="206"/>
<source>group_infos_manage_participants_title</source>
<extracomment>&quot;Gérer des participants&quot;</extracomment>
<translation>Manage participants</translation>
</message>
<message>
<location filename="../../view/Page/Layout/Chat/GroupChatInfoParticipants.qml" line="95"/>
<location filename="../../view/Page/Layout/Chat/GroupChatInfoParticipants.qml" line="93"/>
<source>group_infos_participant_is_admin</source>
<translation>Admin</translation>
</message>
<message>
<location filename="../../view/Page/Layout/Chat/GroupChatInfoParticipants.qml" line="125"/>
<location filename="../../view/Page/Layout/Chat/GroupChatInfoParticipants.qml" line="123"/>
<source>menu_see_existing_contact</source>
<extracomment>&quot;Show contact&quot;</extracomment>
<translation>Show contact</translation>
</message>
<message>
<location filename="../../view/Page/Layout/Chat/GroupChatInfoParticipants.qml" line="127"/>
<location filename="../../view/Page/Layout/Chat/GroupChatInfoParticipants.qml" line="125"/>
<source>menu_add_address_to_contacts</source>
<extracomment>&quot;Add to contacts&quot;</extracomment>
<translation>Add to contacts</translation>
</message>
<message>
<location filename="../../view/Page/Layout/Chat/GroupChatInfoParticipants.qml" line="144"/>
<location filename="../../view/Page/Layout/Chat/GroupChatInfoParticipants.qml" line="142"/>
<source>group_infos_give_admin_rights</source>
<translation>Give admin rights</translation>
</message>
<message>
<location filename="../../view/Page/Layout/Chat/GroupChatInfoParticipants.qml" line="144"/>
<location filename="../../view/Page/Layout/Chat/GroupChatInfoParticipants.qml" line="142"/>
<source>group_infos_remove_admin_rights</source>
<translation>Remove admin rights</translation>
</message>
<message>
<location filename="../../view/Page/Layout/Chat/GroupChatInfoParticipants.qml" line="156"/>
<location filename="../../view/Page/Layout/Chat/GroupChatInfoParticipants.qml" line="154"/>
<source>group_infos_copy_sip_address</source>
<translation>Copy SIP Address</translation>
</message>
<message>
<location filename="../../view/Page/Layout/Chat/GroupChatInfoParticipants.qml" line="176"/>
<location filename="../../view/Page/Layout/Chat/GroupChatInfoParticipants.qml" line="174"/>
<source>group_infos_remove_participant</source>
<translation>Remove participant</translation>
</message>
<message>
<location filename="../../view/Page/Layout/Chat/GroupChatInfoParticipants.qml" line="183"/>
<location filename="../../view/Page/Layout/Chat/GroupChatInfoParticipants.qml" line="181"/>
<source>group_infos_remove_participants_toast_title</source>
<translation>Remove participant ?</translation>
</message>
<message>
<location filename="../../view/Page/Layout/Chat/GroupChatInfoParticipants.qml" line="184"/>
<location filename="../../view/Page/Layout/Chat/GroupChatInfoParticipants.qml" line="182"/>
<source>group_infos_remove_participants_toast_message</source>
<translation>Participant will be removed from chat room.</translation>
</message>

View file

@ -3770,55 +3770,55 @@ Expiration : %1</translation>
<context>
<name>GroupChatInfoParticipants</name>
<message>
<location filename="../../view/Page/Layout/Chat/GroupChatInfoParticipants.qml" line="208"/>
<location filename="../../view/Page/Layout/Chat/GroupChatInfoParticipants.qml" line="206"/>
<source>group_infos_manage_participants_title</source>
<extracomment>&quot;Gérer des participants&quot;</extracomment>
<translation>Gérer les participants</translation>
</message>
<message>
<location filename="../../view/Page/Layout/Chat/GroupChatInfoParticipants.qml" line="95"/>
<location filename="../../view/Page/Layout/Chat/GroupChatInfoParticipants.qml" line="93"/>
<source>group_infos_participant_is_admin</source>
<translation>Admin</translation>
</message>
<message>
<location filename="../../view/Page/Layout/Chat/GroupChatInfoParticipants.qml" line="125"/>
<location filename="../../view/Page/Layout/Chat/GroupChatInfoParticipants.qml" line="123"/>
<source>menu_see_existing_contact</source>
<extracomment>&quot;Show contact&quot;</extracomment>
<translation>Voir le contact</translation>
</message>
<message>
<location filename="../../view/Page/Layout/Chat/GroupChatInfoParticipants.qml" line="127"/>
<location filename="../../view/Page/Layout/Chat/GroupChatInfoParticipants.qml" line="125"/>
<source>menu_add_address_to_contacts</source>
<extracomment>&quot;Add to contacts&quot;</extracomment>
<translation>Ajouter aux contacts</translation>
</message>
<message>
<location filename="../../view/Page/Layout/Chat/GroupChatInfoParticipants.qml" line="144"/>
<location filename="../../view/Page/Layout/Chat/GroupChatInfoParticipants.qml" line="142"/>
<source>group_infos_give_admin_rights</source>
<translation>Donner les droits admins</translation>
</message>
<message>
<location filename="../../view/Page/Layout/Chat/GroupChatInfoParticipants.qml" line="144"/>
<location filename="../../view/Page/Layout/Chat/GroupChatInfoParticipants.qml" line="142"/>
<source>group_infos_remove_admin_rights</source>
<translation>Retirer les droits admins</translation>
</message>
<message>
<location filename="../../view/Page/Layout/Chat/GroupChatInfoParticipants.qml" line="156"/>
<location filename="../../view/Page/Layout/Chat/GroupChatInfoParticipants.qml" line="154"/>
<source>group_infos_copy_sip_address</source>
<translation>Copier ladresse SIP</translation>
</message>
<message>
<location filename="../../view/Page/Layout/Chat/GroupChatInfoParticipants.qml" line="176"/>
<location filename="../../view/Page/Layout/Chat/GroupChatInfoParticipants.qml" line="174"/>
<source>group_infos_remove_participant</source>
<translation>Retirer le participant</translation>
</message>
<message>
<location filename="../../view/Page/Layout/Chat/GroupChatInfoParticipants.qml" line="183"/>
<location filename="../../view/Page/Layout/Chat/GroupChatInfoParticipants.qml" line="181"/>
<source>group_infos_remove_participants_toast_title</source>
<translation>Retirer le participant ?</translation>
</message>
<message>
<location filename="../../view/Page/Layout/Chat/GroupChatInfoParticipants.qml" line="184"/>
<location filename="../../view/Page/Layout/Chat/GroupChatInfoParticipants.qml" line="182"/>
<source>group_infos_remove_participants_toast_message</source>
<translation>La participant sere retiré de la conversation</translation>
</message>

View file

@ -52,7 +52,7 @@ Control.Button {
property real keyboardFocusedBorderWidth: Utils.getSizeWithScreenRatio(3)
// Image properties
property var contentImageColor: style?.image? style.image.normal : DefaultStyle.main2_600
property var hoveredImageColor: style?.image? style.image.pressed : Qt.darker(contentImageColor, 1.05)
property var hoveredImageColor: style?.image? style.image.hovered : Qt.darker(contentImageColor, 1.05)
property var checkedImageColor: style?.image? style.image.checked : Qt.darker(contentImageColor, 1.1)
property var pressedImageColor: style?.image? style.image.pressed : Qt.darker(contentImageColor, 1.1)
icon.source: style?.iconSource || ""

View file

@ -18,9 +18,7 @@ ColumnLayout {
property var chatCore
signal manageParticipantsRequested()
function isGroupEditable() {
return chatCore && chatCore.meAdmin && !chatCore.isReadOnly
}
property bool isGroupEditable: chatCore && chatCore.meAdmin && !chatCore.isReadOnly
RowLayout {
Text {
@ -139,7 +137,7 @@ ColumnLayout {
}
}
IconLabelButton {
visible: mainItem.isGroupEditable()
visible: mainItem.isGroupEditable
Layout.fillWidth: true
text: participantCore.isAdmin ? qsTr("group_infos_remove_admin_rights") : qsTr("group_infos_give_admin_rights")
icon.source: AppIcons.profile
@ -163,7 +161,7 @@ ColumnLayout {
}
}
Rectangle {
visible: mainItem.isGroupEditable()
visible: mainItem.isGroupEditable
color: DefaultStyle.main2_200
Layout.fillWidth: true
height: Utils.getSizeWithScreenRatio(1)
@ -171,7 +169,7 @@ ColumnLayout {
Layout.leftMargin: Utils.getSizeWithScreenRatio(17)
}
IconLabelButton {
visible: mainItem.isGroupEditable()
visible: mainItem.isGroupEditable
Layout.fillWidth: true
text: qsTr("group_infos_remove_participant")
icon.source: AppIcons.trashCan
@ -199,7 +197,7 @@ ColumnLayout {
MediumButton {
id: manageParticipants
visible: mainItem.isGroupEditable()
visible: mainItem.isGroupEditable
height: Utils.getSizeWithScreenRatio(40)
icon.source: AppIcons.plusCircle
icon.width: Utils.getSizeWithScreenRatio(16)