@@ -999,67 +999,11 @@ void CreateCircleDialog::IdListCustomPopupMenu( QPoint )
999999 contextMnu.exec (QCursor::pos ());
10001000}
10011001
1002- void CreateCircleDialog::MembershipListCustomPopupMenu ( QPoint )
1003- {
1004- QMenu contextMnu ( this );
1005-
1006- QTreeWidgetItem *item = ui.treeWidget_membership ->currentItem ();
1007-
1008- RsGxsId current_gxs_id (item->text (RSCIRCLEID_COL_KEYID).toStdString ());
1009- RsIdentityDetails idd;
1010- bool is_my_own_id = rsIdentity->getIdDetails (current_gxs_id, idd);
1011-
1012- if (item && !mReadOnly && item->text (RSCIRCLEID_COL_STATUS) == tr (" Invited" ))
1013- contextMnu.addAction (QIcon (" :/images/delete.png" ), tr (" Remove Member" ), this , SLOT (removeMember ()));
1014-
1015- if (is_my_own_id && item->text (RSCIRCLEID_COL_STATUS) == tr (" Invited" )) {
1016- contextMnu.addAction (tr (" Accept Invite" ), this , SLOT (acceptInvite ()));
1017- contextMnu.addAction (tr (" Reject Invite" ), this , SLOT (rejectInvite ()));
1018- contextMnu.addSeparator ();
1019- }
1020-
1021- if (is_my_own_id && item->text (RSCIRCLEID_COL_STATUS) == tr (" Subscription pending" )) {
1022- QAction *actionCancel = new QAction (tr (" Cancel request" ), this );
1023- connect (actionCancel, &QAction::triggered, this , &CreateCircleDialog::rejectInvite);
1024- contextMnu.addAction (actionCancel);
1025- contextMnu.addSeparator ();
1026- }
1027-
1028- if (am_I_circle_admin)
1029- {
1030- RsGxsCircleDetails details;
1031- if (rsGxsCircles->getCircleDetails (RsGxsCircleId (mCircleGroup .mMeta .mGroupId ), details))
1032- {
1033- auto it = details.mSubscriptionFlags .find (current_gxs_id);
1034- if (it != details.mSubscriptionFlags .end ())
1035- {
1036- contextMnu.addSeparator ();
1037-
1038- if (it->second & GXS_EXTERNAL_CIRCLE_FLAGS_IN_ADMIN_LIST)
1039- {
1040- QAction *action = new QAction (tr (" Revoke this member" ), this );
1041- connect (action, &QAction::triggered, this , &CreateCircleDialog::revokeCircleMembership);
1042- contextMnu.addAction (action);
1043- }
1044- else
1045- {
1046- QAction *action = new QAction (tr (" Grant membership" ), this );
1047- connect (action, &QAction::triggered, this , &CreateCircleDialog::grantCircleMembership);
1048- contextMnu.addAction (action);
1049-
1050- QAction *actionReject = new QAction (tr (" Reject request" ), this );
1051- connect (actionReject, &QAction::triggered, this , &CreateCircleDialog::revokeCircleMembership);
1052- contextMnu.addAction (actionReject);
1053- }
1054- }
1055- }
1056- }
1057-
1058- contextMnu.exec (QCursor::pos ());
1059- }
1060-
10611002void CreateCircleDialog::updateMembership ()
10621003{
1004+ am_I_invited = false ;
1005+ am_I_pending = false ;
1006+
10631007 RsGxsCircleDetails details;
10641008 if (!rsGxsCircles->getCircleDetails (RsGxsCircleId (mCircleGroup .mMeta .mGroupId ), details)) {
10651009 return ;
@@ -1080,7 +1024,7 @@ void CreateCircleDialog::updateMembership()
10801024 }
10811025 }
10821026
1083- // Use the flags defined in rsgxscircles.h
1027+ // Map flags using correct bitmasks
10841028 bool invited = (flags & GXS_EXTERNAL_CIRCLE_FLAGS_IN_ADMIN_LIST);
10851029 bool subscrb = (flags & GXS_EXTERNAL_CIRCLE_FLAGS_SUBSCRIBED);
10861030
@@ -1100,11 +1044,15 @@ void CreateCircleDialog::updateMembership()
11001044 }
11011045 continue ;
11021046 }
1103-
11041047
11051048 // Check if this ID is one of your own
1106- RsIdentityDetails idd;
1107- bool is_own_id = rsIdentity->getIdDetails (memberId, idd);
1049+ bool is_own_id = rsIdentity->isOwnId (memberId);
1050+
1051+ // Update global flags for the Context Menu
1052+ if (is_own_id) {
1053+ if (invited && !subscrb) am_I_invited = true ;
1054+ if (!invited && subscrb) am_I_pending = true ;
1055+ }
11081056
11091057 RsGxsId ownId;
11101058 if (ui.idChooser ->getChosenId (ownId) == GxsIdChooser::KnowId) {
@@ -1119,12 +1067,12 @@ void CreateCircleDialog::updateMemberStatus(QTreeWidgetItem* subitem, bool invit
11191067{
11201068 QString statusText;
11211069 QString tooltip = tr (" Status: " );
1122- bool am_I_pending = false ;
11231070
11241071 if (invited && !subscrb) {
11251072 // Case: Admin invited them, but they haven't accepted yet
11261073 statusText = tr (" Invited" );
11271074 tooltip += tr (" Invited by admin" );
1075+ if (is_own_id) am_I_invited = true ;
11281076 subitem->setIcon (RSCIRCLEID_COL_STATUS, FilesDefs::getIconFromQtResourcePath (IMAGE_INVITED)) ;
11291077 } else if (!invited && subscrb) {
11301078 // Case: User requested to join, but Admin hasn't approved yet
@@ -1156,6 +1104,60 @@ void CreateCircleDialog::updateMemberStatus(QTreeWidgetItem* subitem, bool invit
11561104 ui.members_groupBox ->setTitle ( tr (" Invited Members" ) + " (" + QString::number (ui.treeWidget_membership ->topLevelItemCount ()) + " )" );
11571105}
11581106
1107+ void CreateCircleDialog::MembershipListCustomPopupMenu ( QPoint )
1108+ {
1109+ QMenu contextMnu ( this );
1110+
1111+ QTreeWidgetItem *item = ui.treeWidget_membership ->currentItem ();
1112+
1113+ RsGxsId current_gxs_id (item->text (RSCIRCLEID_COL_KEYID).toStdString ());
1114+
1115+ if (item && !mReadOnly && item->text (RSCIRCLEID_COL_STATUS) == tr (" Invited" ))
1116+ contextMnu.addAction (QIcon (" :/images/delete.png" ), tr (" Remove Member" ), this , SLOT (removeMember ()));
1117+
1118+ if (am_I_invited) {
1119+ contextMnu.addAction (tr (" Accept Invite" ), this , SLOT (acceptInvite ()));
1120+ contextMnu.addSeparator ();
1121+ }
1122+
1123+ if (am_I_pending) {
1124+ contextMnu.addAction (tr (" Reject request" ), this , SLOT (rejectInvite ()));
1125+ contextMnu.addSeparator ();
1126+ }
1127+
1128+ if (am_I_circle_admin)
1129+ {
1130+ RsGxsCircleDetails details;
1131+ if (rsGxsCircles->getCircleDetails (RsGxsCircleId (mCircleGroup .mMeta .mGroupId ), details))
1132+ {
1133+ auto it = details.mSubscriptionFlags .find (current_gxs_id);
1134+ if (it != details.mSubscriptionFlags .end ())
1135+ {
1136+ contextMnu.addSeparator ();
1137+
1138+ if (it->second & GXS_EXTERNAL_CIRCLE_FLAGS_IN_ADMIN_LIST)
1139+ {
1140+ QAction *action = new QAction (tr (" Revoke this member" ), this );
1141+ connect (action, &QAction::triggered, this , &CreateCircleDialog::revokeCircleMembership);
1142+ contextMnu.addAction (action);
1143+ }
1144+ else
1145+ {
1146+ QAction *action = new QAction (tr (" Grant membership" ), this );
1147+ connect (action, &QAction::triggered, this , &CreateCircleDialog::grantCircleMembership);
1148+ contextMnu.addAction (action);
1149+
1150+ // QAction *actionReject = new QAction(tr("Reject request"), this);
1151+ // connect(actionReject, &QAction::triggered, this, &CreateCircleDialog::revokeCircleMembership);
1152+ // contextMnu.addAction(actionReject);
1153+ }
1154+ }
1155+ }
1156+ }
1157+
1158+ contextMnu.exec (QCursor::pos ());
1159+ }
1160+
11591161void CreateCircleDialog::acceptInvite ()
11601162{
11611163 QTreeWidgetItem *item = ui.treeWidget_membership ->currentItem ();
0 commit comments