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); auto participants = buildParticipants(chatRoom);
mChatModelConnection->invokeToCore([this, participants]() { setParticipants(participants); }); mChatModelConnection->invokeToCore([this, participants]() { setParticipants(participants); });
}); });
mChatModelConnection->makeConnectToModel( mChatModelConnection->makeConnectToModel(&ChatModel::participantAdminStatusChanged,
&ChatModel::participantAdminStatusChanged, [this](const std::shared_ptr<linphone::ChatRoom> &chatRoom, [this](const std::shared_ptr<linphone::ChatRoom> &chatRoom,
const std::shared_ptr<const linphone::EventLog> &eventLog) { const std::shared_ptr<const linphone::EventLog> &eventLog) {
auto participants = buildParticipants(chatRoom); auto participants = buildParticipants(chatRoom);
mChatModelConnection->invokeToCore([this, participants]() { setParticipants(participants); }); bool meAdmin = chatRoom->getMe()->isAdmin();
}); mChatModelConnection->invokeToCore([this, participants, meAdmin]() {
setParticipants(participants);
setMeAdmin(meAdmin);
});
});
mChatModelConnection->makeConnectToCore(&ChatCore::lRemoveParticipantAtIndex, [this](int index) { mChatModelConnection->makeConnectToCore(&ChatCore::lRemoveParticipantAtIndex, [this](int index) {
mChatModelConnection->invokeToModel([this, index]() { mChatModel->removeParticipantAtIndex(index); }); mChatModelConnection->invokeToModel([this, index]() { mChatModel->removeParticipantAtIndex(index); });
}); });

View file

@ -3849,55 +3849,55 @@ Error</extracomment>
<context> <context>
<name>GroupChatInfoParticipants</name> <name>GroupChatInfoParticipants</name>
<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> <source>group_infos_participant_is_admin</source>
<translation>Admin</translation> <translation>Admin</translation>
</message> </message>
<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> <source>group_infos_manage_participants_title</source>
<extracomment>&quot;Gérer des participants&quot;</extracomment> <extracomment>&quot;Gérer des participants&quot;</extracomment>
<translation>Manage Participants</translation> <translation>Manage Participants</translation>
</message> </message>
<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> <source>menu_see_existing_contact</source>
<extracomment>&quot;Show contact&quot;</extracomment> <extracomment>&quot;Show contact&quot;</extracomment>
<translation>Kontakt anzeigen</translation> <translation>Kontakt anzeigen</translation>
</message> </message>
<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> <source>menu_add_address_to_contacts</source>
<extracomment>&quot;Add to contacts&quot;</extracomment> <extracomment>&quot;Add to contacts&quot;</extracomment>
<translation>Zu Kontakten hinzufügen</translation> <translation>Zu Kontakten hinzufügen</translation>
</message> </message>
<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> <source>group_infos_give_admin_rights</source>
<translation>Give admin rights</translation> <translation>Give admin rights</translation>
</message> </message>
<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> <source>group_infos_remove_admin_rights</source>
<translation>Remove admin rights</translation> <translation>Remove admin rights</translation>
</message> </message>
<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> <source>group_infos_copy_sip_address</source>
<translation>Copy SIP Address</translation> <translation>Copy SIP Address</translation>
</message> </message>
<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> <source>group_infos_remove_participant</source>
<translation>Remove participant</translation> <translation>Remove participant</translation>
</message> </message>
<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> <source>group_infos_remove_participants_toast_title</source>
<translation>Remove participant ?</translation> <translation>Remove participant ?</translation>
</message> </message>
<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> <source>group_infos_remove_participants_toast_message</source>
<translation>Participant will be removed from chat room.</translation> <translation>Participant will be removed from chat room.</translation>
</message> </message>

View file

@ -3770,55 +3770,55 @@ Expiration : %1</translation>
<context> <context>
<name>GroupChatInfoParticipants</name> <name>GroupChatInfoParticipants</name>
<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> <source>group_infos_manage_participants_title</source>
<extracomment>&quot;Gérer des participants&quot;</extracomment> <extracomment>&quot;Gérer des participants&quot;</extracomment>
<translation>Manage participants</translation> <translation>Manage participants</translation>
</message> </message>
<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> <source>group_infos_participant_is_admin</source>
<translation>Admin</translation> <translation>Admin</translation>
</message> </message>
<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> <source>menu_see_existing_contact</source>
<extracomment>&quot;Show contact&quot;</extracomment> <extracomment>&quot;Show contact&quot;</extracomment>
<translation>Show contact</translation> <translation>Show contact</translation>
</message> </message>
<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> <source>menu_add_address_to_contacts</source>
<extracomment>&quot;Add to contacts&quot;</extracomment> <extracomment>&quot;Add to contacts&quot;</extracomment>
<translation>Add to contacts</translation> <translation>Add to contacts</translation>
</message> </message>
<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> <source>group_infos_give_admin_rights</source>
<translation>Give admin rights</translation> <translation>Give admin rights</translation>
</message> </message>
<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> <source>group_infos_remove_admin_rights</source>
<translation>Remove admin rights</translation> <translation>Remove admin rights</translation>
</message> </message>
<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> <source>group_infos_copy_sip_address</source>
<translation>Copy SIP Address</translation> <translation>Copy SIP Address</translation>
</message> </message>
<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> <source>group_infos_remove_participant</source>
<translation>Remove participant</translation> <translation>Remove participant</translation>
</message> </message>
<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> <source>group_infos_remove_participants_toast_title</source>
<translation>Remove participant ?</translation> <translation>Remove participant ?</translation>
</message> </message>
<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> <source>group_infos_remove_participants_toast_message</source>
<translation>Participant will be removed from chat room.</translation> <translation>Participant will be removed from chat room.</translation>
</message> </message>

View file

@ -3770,55 +3770,55 @@ Expiration : %1</translation>
<context> <context>
<name>GroupChatInfoParticipants</name> <name>GroupChatInfoParticipants</name>
<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> <source>group_infos_manage_participants_title</source>
<extracomment>&quot;Gérer des participants&quot;</extracomment> <extracomment>&quot;Gérer des participants&quot;</extracomment>
<translation>Gérer les participants</translation> <translation>Gérer les participants</translation>
</message> </message>
<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> <source>group_infos_participant_is_admin</source>
<translation>Admin</translation> <translation>Admin</translation>
</message> </message>
<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> <source>menu_see_existing_contact</source>
<extracomment>&quot;Show contact&quot;</extracomment> <extracomment>&quot;Show contact&quot;</extracomment>
<translation>Voir le contact</translation> <translation>Voir le contact</translation>
</message> </message>
<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> <source>menu_add_address_to_contacts</source>
<extracomment>&quot;Add to contacts&quot;</extracomment> <extracomment>&quot;Add to contacts&quot;</extracomment>
<translation>Ajouter aux contacts</translation> <translation>Ajouter aux contacts</translation>
</message> </message>
<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> <source>group_infos_give_admin_rights</source>
<translation>Donner les droits admins</translation> <translation>Donner les droits admins</translation>
</message> </message>
<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> <source>group_infos_remove_admin_rights</source>
<translation>Retirer les droits admins</translation> <translation>Retirer les droits admins</translation>
</message> </message>
<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> <source>group_infos_copy_sip_address</source>
<translation>Copier ladresse SIP</translation> <translation>Copier ladresse SIP</translation>
</message> </message>
<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> <source>group_infos_remove_participant</source>
<translation>Retirer le participant</translation> <translation>Retirer le participant</translation>
</message> </message>
<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> <source>group_infos_remove_participants_toast_title</source>
<translation>Retirer le participant ?</translation> <translation>Retirer le participant ?</translation>
</message> </message>
<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> <source>group_infos_remove_participants_toast_message</source>
<translation>La participant sere retiré de la conversation</translation> <translation>La participant sere retiré de la conversation</translation>
</message> </message>

View file

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

View file

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