mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
lobby id dialog - add vote neutral option
This commit is contained in:
parent
bc43cb8cf0
commit
cc3b8bde52
@ -88,7 +88,8 @@ ChatLobbyDialog::ChatLobbyDialog(const ChatLobbyId& lid, QWidget *parent, Qt::Wi
|
||||
|
||||
muteAct = new QAction(QIcon(), tr("Mute participant"), this);
|
||||
banAct = new QAction(QIcon(":/icons/png/thumbs-down.png"), tr("Ban this person (Sets negative opinion)"), this);
|
||||
voteAct = new QAction(QIcon(":/icons/png/thumbs-up.png"), tr("Give positive opinion"), this);
|
||||
voteNeutralAct = new QAction(QIcon(":/icons/png/thumbs-neutral.png"), tr("Give neutral opinion"), this);
|
||||
votePositiveAct = new QAction(QIcon(":/icons/png/thumbs-up.png"), tr("Give positive opinion"), this);
|
||||
distantChatAct = new QAction(QIcon(":/images/chat_24.png"), tr("Start private chat"), this);
|
||||
sendMessageAct = new QAction(QIcon(":/images/mail_new.png"), tr("Send Message"), this);
|
||||
|
||||
@ -107,8 +108,9 @@ ChatLobbyDialog::ChatLobbyDialog(const ChatLobbyId& lid, QWidget *parent, Qt::Wi
|
||||
connect(muteAct, SIGNAL(triggered()), this, SLOT(changePartipationState()));
|
||||
connect(distantChatAct, SIGNAL(triggered()), this, SLOT(distantChatParticipant()));
|
||||
connect(sendMessageAct, SIGNAL(triggered()), this, SLOT(sendMessage()));
|
||||
connect(banAct, SIGNAL(triggered()), this, SLOT(banParticipant()));
|
||||
connect(voteAct, SIGNAL(triggered()), this, SLOT(voteParticipant()));
|
||||
connect(votePositiveAct, SIGNAL(triggered()), this, SLOT(voteParticipant(1)));
|
||||
connect(voteNeutralAct, SIGNAL(triggered()), this, SLOT(voteParticipant(0)));
|
||||
connect(banAct, SIGNAL(triggered()), this, SLOT(voteParticipant(-1)));
|
||||
|
||||
connect(actionSortByName, SIGNAL(triggered()), this, SLOT(sortParcipants()));
|
||||
connect(actionSortByActivity, SIGNAL(triggered()), this, SLOT(sortParcipants()));
|
||||
@ -223,13 +225,15 @@ void ChatLobbyDialog::participantsTreeWidgetCustomPopupMenu(QPoint)
|
||||
contextMnu.addAction(actionSortByName);
|
||||
contextMnu.addSeparator();
|
||||
contextMnu.addAction(muteAct);
|
||||
contextMnu.addAction(voteAct);
|
||||
contextMnu.addAction(votePositiveAct);
|
||||
contextMnu.addAction(voteNeutralAct);
|
||||
contextMnu.addAction(banAct);
|
||||
|
||||
muteAct->setCheckable(true);
|
||||
muteAct->setEnabled(false);
|
||||
muteAct->setChecked(false);
|
||||
voteAct->setEnabled(false);
|
||||
votePositiveAct->setEnabled(false);
|
||||
voteNeutralAct->setEnabled(false);
|
||||
banAct->setEnabled(false);
|
||||
|
||||
if (selectedItems.size())
|
||||
@ -240,8 +244,9 @@ void ChatLobbyDialog::participantsTreeWidgetCustomPopupMenu(QPoint)
|
||||
if(selectedItems.count()>1 || (RsGxsId(selectedItems.at(0)->text(COLUMN_ID).toStdString())!=nickName))
|
||||
{
|
||||
muteAct->setEnabled(true);
|
||||
votePositiveAct->setEnabled(true);
|
||||
voteNeutralAct->setEnabled(true);
|
||||
banAct->setEnabled(true);
|
||||
voteAct->setEnabled(true);
|
||||
|
||||
QList<QTreeWidgetItem*>::iterator item;
|
||||
for (item = selectedItems.begin(); item != selectedItems.end(); ++item) {
|
||||
@ -263,7 +268,7 @@ void ChatLobbyDialog::participantsTreeWidgetCustomPopupMenu(QPoint)
|
||||
/**
|
||||
* @brief Called when the "ban" menu is selected. Sets a negative reputation on the selected user.
|
||||
*/
|
||||
void ChatLobbyDialog::banParticipant()
|
||||
void ChatLobbyDialog::voteParticipant(int vote)
|
||||
{
|
||||
QList<QTreeWidgetItem*> selectedItems = ui.participantsList->selectedItems();
|
||||
|
||||
@ -284,41 +289,14 @@ void ChatLobbyDialog::banParticipant()
|
||||
|
||||
if (gxs_id!=nickname)
|
||||
{
|
||||
std::cerr << "Giving negative opinion to GXS id " << nickname << std::endl;
|
||||
rsReputations->setOwnOpinion(nickname, RsReputations::OPINION_NEGATIVE);
|
||||
|
||||
dynamic_cast<GxsIdRSTreeWidgetItem*>(*item)->forceUpdate();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ChatLobbyDialog::voteParticipant()
|
||||
switch(vote)
|
||||
{
|
||||
QList<QTreeWidgetItem*> selectedItems = ui.participantsList->selectedItems();
|
||||
|
||||
if (selectedItems.isEmpty()) {
|
||||
return;
|
||||
case 1: rsReputations->setOwnOpinion(nickname, RsReputations::OPINION_POSITIVE);
|
||||
case -1: rsReputations->setOwnOpinion(nickname, RsReputations::OPINION_NEGATIVE);
|
||||
default: rsReputations->setOwnOpinion(nickname, RsReputations::OPINION_NEUTRAL);
|
||||
}
|
||||
|
||||
QList<QTreeWidgetItem*>::iterator item;
|
||||
for (item = selectedItems.begin(); item != selectedItems.end(); ++item) {
|
||||
|
||||
RsGxsId nickname;
|
||||
dynamic_cast<GxsIdRSTreeWidgetItem*>(*item)->getId(nickname) ;
|
||||
|
||||
RsGxsId gxs_id;
|
||||
rsMsgs->getIdentityForChatLobby(lobbyId, gxs_id);
|
||||
|
||||
// This test avoids to mute/ban your own identity
|
||||
|
||||
if (gxs_id!=nickname)
|
||||
{
|
||||
std::cerr << "Giving negative opinion to GXS id " << nickname << std::endl;
|
||||
rsReputations->setOwnOpinion(nickname, RsReputations::OPINION_POSITIVE);
|
||||
|
||||
std::cerr << "Giving " << vote << " opinion to GXS id " << nickname << std::endl;
|
||||
dynamic_cast<GxsIdRSTreeWidgetItem*>(*item)->forceUpdate();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -80,8 +80,7 @@ protected slots:
|
||||
void distantChatParticipant();
|
||||
void participantsTreeWidgetDoubleClicked(QTreeWidgetItem *item, int column);
|
||||
void sendMessage();
|
||||
void banParticipant();
|
||||
void voteParticipant();
|
||||
void voteParticipant(int vote);
|
||||
|
||||
private:
|
||||
void updateParticipantsList();
|
||||
@ -109,8 +108,9 @@ private:
|
||||
std::set<RsGxsId> mutedParticipants;
|
||||
|
||||
QAction *muteAct;
|
||||
QAction *votePositiveAct;
|
||||
QAction *voteNeutralAct;
|
||||
QAction *banAct;
|
||||
QAction *voteAct;
|
||||
QAction *distantChatAct;
|
||||
QAction *actionSortByName;
|
||||
QAction *actionSortByActivity;
|
||||
|
Loading…
Reference in New Issue
Block a user