From cc3b8bde52f87e42d2aaaad97f9ea82242c937f3 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 9 Jan 2017 16:05:23 +0300 Subject: [PATCH] lobby id dialog - add vote neutral option --- .../src/gui/chat/ChatLobbyDialog.cpp | 66 +++++++------------ retroshare-gui/src/gui/chat/ChatLobbyDialog.h | 6 +- 2 files changed, 25 insertions(+), 47 deletions(-) diff --git a/retroshare-gui/src/gui/chat/ChatLobbyDialog.cpp b/retroshare-gui/src/gui/chat/ChatLobbyDialog.cpp index db2263964..79fb6820a 100644 --- a/retroshare-gui/src/gui/chat/ChatLobbyDialog.cpp +++ b/retroshare-gui/src/gui/chat/ChatLobbyDialog.cpp @@ -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,9 +108,10 @@ 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); - banAct->setEnabled(true); - voteAct->setEnabled(true); + votePositiveAct->setEnabled(true); + voteNeutralAct->setEnabled(true); + banAct->setEnabled(true); QList::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 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(*item)->forceUpdate(); - - } - } -} - -void ChatLobbyDialog::voteParticipant() -{ - QList selectedItems = ui.participantsList->selectedItems(); - - if (selectedItems.isEmpty()) { - return; - } - - QList::iterator item; - for (item = selectedItems.begin(); item != selectedItems.end(); ++item) { - - RsGxsId nickname; - dynamic_cast(*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); - - dynamic_cast(*item)->forceUpdate(); - + switch(vote) + { + case 1: rsReputations->setOwnOpinion(nickname, RsReputations::OPINION_POSITIVE); + case -1: rsReputations->setOwnOpinion(nickname, RsReputations::OPINION_NEGATIVE); + default: rsReputations->setOwnOpinion(nickname, RsReputations::OPINION_NEUTRAL); + } + std::cerr << "Giving " << vote << " opinion to GXS id " << nickname << std::endl; + dynamic_cast(*item)->forceUpdate(); } } } diff --git a/retroshare-gui/src/gui/chat/ChatLobbyDialog.h b/retroshare-gui/src/gui/chat/ChatLobbyDialog.h index cab44d989..de5a5055f 100644 --- a/retroshare-gui/src/gui/chat/ChatLobbyDialog.h +++ b/retroshare-gui/src/gui/chat/ChatLobbyDialog.h @@ -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 mutedParticipants; QAction *muteAct; + QAction *votePositiveAct; + QAction *voteNeutralAct; QAction *banAct; - QAction *voteAct; QAction *distantChatAct; QAction *actionSortByName; QAction *actionSortByActivity;