chatlobby id context menu - fix display conditions

This commit is contained in:
RetroPooh 2017-01-12 16:26:06 +03:00
parent 36dbdee409
commit 10ba3a6364

View File

@ -222,7 +222,7 @@ void ChatLobbyDialog::participantsTreeWidgetCustomPopupMenu(QPoint)
QMenu contextMnu(this); QMenu contextMnu(this);
contextMnu.addAction(distantChatAct); contextMnu.addAction(distantChatAct);
contextMnu.addAction(sendMessageAct); contextMnu.addAction(sendMessageAct);
contextMnu.addSeparator(); contextMnu.addSeparator();
contextMnu.addAction(actionSortByActivity); contextMnu.addAction(actionSortByActivity);
contextMnu.addAction(actionSortByName); contextMnu.addAction(actionSortByName);
@ -233,40 +233,33 @@ void ChatLobbyDialog::participantsTreeWidgetCustomPopupMenu(QPoint)
contextMnu.addAction(banAct); contextMnu.addAction(banAct);
contextMnu.addAction(showinpeopleAct); contextMnu.addAction(showinpeopleAct);
distantChatAct->setEnabled(false);
sendMessageAct->setEnabled(false);
muteAct->setCheckable(true); muteAct->setCheckable(true);
muteAct->setEnabled(false); muteAct->setEnabled(false);
muteAct->setChecked(false); muteAct->setChecked(false);
votePositiveAct->setEnabled(false); votePositiveAct->setEnabled(false);
voteNeutralAct->setEnabled(false); voteNeutralAct->setEnabled(false);
banAct->setEnabled(false); banAct->setEnabled(false);
showinpeopleAct->setEnabled(true); if(selectedItems.count()==1)
if (selectedItems.size())
{ {
sendMessageAct->setEnabled(true);
showinpeopleAct->setEnabled(true);
RsGxsId nickName; RsGxsId nickName;
rsMsgs->getIdentityForChatLobby(lobbyId, nickName); rsMsgs->getIdentityForChatLobby(lobbyId, nickName);
if(RsGxsId(selectedItems.at(0)->text(COLUMN_ID).toStdString())!=nickName)
if(selectedItems.count()>1 || (RsGxsId(selectedItems.at(0)->text(COLUMN_ID).toStdString())!=nickName)) {
{ distantChatAct->setEnabled(true);
muteAct->setEnabled(true); RsGxsId gxsid ;
votePositiveAct->setEnabled(true); dynamic_cast<GxsIdRSTreeWidgetItem*>(*selectedItems.begin())->getId(gxsid);
voteNeutralAct->setEnabled(true); votePositiveAct->setEnabled(rsIdentity->overallReputationLevel(gxsid) != RsReputations::REPUTATION_LOCALLY_POSITIVE);
banAct->setEnabled(true); voteNeutralAct->setEnabled((rsIdentity->overallReputationLevel(gxsid) == RsReputations::REPUTATION_LOCALLY_POSITIVE) || (rsIdentity->overallReputationLevel(gxsid) == RsReputations::REPUTATION_LOCALLY_NEGATIVE) );
banAct->setEnabled(rsIdentity->overallReputationLevel(gxsid) != RsReputations::REPUTATION_LOCALLY_NEGATIVE);
QList<QTreeWidgetItem*>::iterator item; muteAct->setEnabled(true);
for (item = selectedItems.begin(); item != selectedItems.end(); ++item) { if(isParticipantMuted(gxsid))
muteAct->setChecked(true);
RsGxsId gxsid ; }
if ( dynamic_cast<GxsIdRSTreeWidgetItem*>(*item)->getId(gxsid) && isParticipantMuted(gxsid))
{
muteAct->setChecked(true);
break;
}
}
}
distantChatAct->setEnabled(selectedItems.count()==1 && RsGxsId(selectedItems.front()->text(COLUMN_ID).toStdString())!=nickName) ;
} }
contextMnu.exec(QCursor::pos()); contextMnu.exec(QCursor::pos());
} }