mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
added ban menu entry to chat lobby participant list
This commit is contained in:
parent
49605a33dc
commit
0282c2aeb3
@ -85,6 +85,7 @@ ChatLobbyDialog::ChatLobbyDialog(const ChatLobbyId& lid, QWidget *parent, Qt::Wi
|
|||||||
ui.participantsList->setColumnHidden(COLUMN_ID,true);
|
ui.participantsList->setColumnHidden(COLUMN_ID,true);
|
||||||
|
|
||||||
muteAct = new QAction(QIcon(), tr("Mute participant"), this);
|
muteAct = new QAction(QIcon(), tr("Mute participant"), this);
|
||||||
|
banAct = new QAction(QIcon(":/icons/yellow_biohazard64.png"), tr("Ban this person (Sets negative opinion)"), this);
|
||||||
distantChatAct = new QAction(QIcon(":/images/chat_24.png"), tr("Start private chat"), 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);
|
sendMessageAct = new QAction(QIcon(":/images/mail_new.png"), tr("Send Message"), this);
|
||||||
|
|
||||||
@ -103,6 +104,7 @@ ChatLobbyDialog::ChatLobbyDialog(const ChatLobbyId& lid, QWidget *parent, Qt::Wi
|
|||||||
connect(muteAct, SIGNAL(triggered()), this, SLOT(changePartipationState()));
|
connect(muteAct, SIGNAL(triggered()), this, SLOT(changePartipationState()));
|
||||||
connect(distantChatAct, SIGNAL(triggered()), this, SLOT(distantChatParticipant()));
|
connect(distantChatAct, SIGNAL(triggered()), this, SLOT(distantChatParticipant()));
|
||||||
connect(sendMessageAct, SIGNAL(triggered()), this, SLOT(sendMessage()));
|
connect(sendMessageAct, SIGNAL(triggered()), this, SLOT(sendMessage()));
|
||||||
|
connect(banAct, SIGNAL(triggered()), this, SLOT(banParticipant()));
|
||||||
|
|
||||||
connect(actionSortByName, SIGNAL(triggered()), this, SLOT(sortParcipants()));
|
connect(actionSortByName, SIGNAL(triggered()), this, SLOT(sortParcipants()));
|
||||||
connect(actionSortByActivity, SIGNAL(triggered()), this, SLOT(sortParcipants()));
|
connect(actionSortByActivity, SIGNAL(triggered()), this, SLOT(sortParcipants()));
|
||||||
@ -201,15 +203,16 @@ void ChatLobbyDialog::participantsTreeWidgetCustomPopupMenu(QPoint)
|
|||||||
contextMnu.addAction(distantChatAct);
|
contextMnu.addAction(distantChatAct);
|
||||||
contextMnu.addAction(sendMessageAct);
|
contextMnu.addAction(sendMessageAct);
|
||||||
contextMnu.addSeparator();
|
contextMnu.addSeparator();
|
||||||
contextMnu.addAction(muteAct);
|
|
||||||
contextMnu.addSeparator();
|
|
||||||
contextMnu.addAction(actionSortByActivity);
|
contextMnu.addAction(actionSortByActivity);
|
||||||
contextMnu.addAction(actionSortByName);
|
contextMnu.addAction(actionSortByName);
|
||||||
|
contextMnu.addSeparator();
|
||||||
|
contextMnu.addAction(muteAct);
|
||||||
|
contextMnu.addAction(banAct);
|
||||||
|
|
||||||
muteAct->setCheckable(true);
|
muteAct->setCheckable(true);
|
||||||
muteAct->setEnabled(false);
|
muteAct->setEnabled(false);
|
||||||
muteAct->setChecked(false);
|
muteAct->setChecked(false);
|
||||||
|
banAct->setEnabled(false);
|
||||||
|
|
||||||
if (selectedItems.size())
|
if (selectedItems.size())
|
||||||
{
|
{
|
||||||
@ -219,6 +222,7 @@ void ChatLobbyDialog::participantsTreeWidgetCustomPopupMenu(QPoint)
|
|||||||
if(selectedItems.count()>1 || (RsGxsId(selectedItems.at(0)->text(COLUMN_ID).toStdString())!=nickName))
|
if(selectedItems.count()>1 || (RsGxsId(selectedItems.at(0)->text(COLUMN_ID).toStdString())!=nickName))
|
||||||
{
|
{
|
||||||
muteAct->setEnabled(true);
|
muteAct->setEnabled(true);
|
||||||
|
banAct->setEnabled(true);
|
||||||
|
|
||||||
QList<QTreeWidgetItem*>::iterator item;
|
QList<QTreeWidgetItem*>::iterator item;
|
||||||
for (item = selectedItems.begin(); item != selectedItems.end(); ++item) {
|
for (item = selectedItems.begin(); item != selectedItems.end(); ++item) {
|
||||||
@ -237,6 +241,40 @@ void ChatLobbyDialog::participantsTreeWidgetCustomPopupMenu(QPoint)
|
|||||||
contextMnu.exec(QCursor::pos());
|
contextMnu.exec(QCursor::pos());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Called when the "ban" menu is selected. Sets a negative reputation on the selected user.
|
||||||
|
*/
|
||||||
|
void ChatLobbyDialog::banParticipant()
|
||||||
|
{
|
||||||
|
QList<QTreeWidgetItem*> selectedItems = ui.participantsList->selectedItems();
|
||||||
|
|
||||||
|
if (selectedItems.isEmpty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
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_NEGATIVE);
|
||||||
|
|
||||||
|
dynamic_cast<GxsIdRSTreeWidgetItem*>(*item)->forceUpdate();
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void ChatLobbyDialog::init()
|
void ChatLobbyDialog::init()
|
||||||
{
|
{
|
||||||
ChatLobbyInfo linfo ;
|
ChatLobbyInfo linfo ;
|
||||||
@ -502,6 +540,8 @@ void ChatLobbyDialog::updateParticipantsList()
|
|||||||
|
|
||||||
if (RsGxsId(participant.toStdString()) == gxs_id) widgetitem->setIcon(COLUMN_ICON, QIcon(":/icons/bullet_yellow_128.png"));
|
if (RsGxsId(participant.toStdString()) == gxs_id) widgetitem->setIcon(COLUMN_ICON, QIcon(":/icons/bullet_yellow_128.png"));
|
||||||
|
|
||||||
|
widgetitem->updateBannedState();
|
||||||
|
|
||||||
QTime qtLastAct=QTime(0,0,0).addSecs(now-tLastAct);
|
QTime qtLastAct=QTime(0,0,0).addSecs(now-tLastAct);
|
||||||
widgetitem->setToolTip(COLUMN_ICON,tr("Right click to mute/unmute participants<br/>Double click to address this person<br/>")
|
widgetitem->setToolTip(COLUMN_ICON,tr("Right click to mute/unmute participants<br/>Double click to address this person<br/>")
|
||||||
+tr("This participant is not active since:")
|
+tr("This participant is not active since:")
|
||||||
|
@ -79,6 +79,7 @@ protected slots:
|
|||||||
void distantChatParticipant();
|
void distantChatParticipant();
|
||||||
void participantsTreeWidgetDoubleClicked(QTreeWidgetItem *item, int column);
|
void participantsTreeWidgetDoubleClicked(QTreeWidgetItem *item, int column);
|
||||||
void sendMessage();
|
void sendMessage();
|
||||||
|
void banParticipant();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void updateParticipantsList();
|
void updateParticipantsList();
|
||||||
@ -104,6 +105,7 @@ private:
|
|||||||
std::set<RsGxsId> mutedParticipants;
|
std::set<RsGxsId> mutedParticipants;
|
||||||
|
|
||||||
QAction *muteAct;
|
QAction *muteAct;
|
||||||
|
QAction *banAct;
|
||||||
QAction *distantChatAct;
|
QAction *distantChatAct;
|
||||||
QAction *actionSortByName;
|
QAction *actionSortByName;
|
||||||
QAction *actionSortByActivity;
|
QAction *actionSortByActivity;
|
||||||
|
@ -46,6 +46,7 @@ void GxsIdRSTreeWidgetItem::init()
|
|||||||
{
|
{
|
||||||
mIdFound = false;
|
mIdFound = false;
|
||||||
mRetryWhenFailed = false;
|
mRetryWhenFailed = false;
|
||||||
|
mBannedState = false ;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void fillGxsIdRSTreeWidgetItemCallback(GxsIdDetailsType type, const RsIdentityDetails &details, QObject *object, const QVariant &/*data*/)
|
static void fillGxsIdRSTreeWidgetItemCallback(GxsIdDetailsType type, const RsIdentityDetails &details, QObject *object, const QVariant &/*data*/)
|
||||||
@ -114,6 +115,20 @@ void GxsIdRSTreeWidgetItem::setId(const RsGxsId &id, int column, bool retryWhenF
|
|||||||
startProcess();
|
startProcess();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GxsIdRSTreeWidgetItem::updateBannedState()
|
||||||
|
{
|
||||||
|
if(mBannedState != rsReputations->isIdentityBanned(mId))
|
||||||
|
forceUpdate() ;
|
||||||
|
}
|
||||||
|
|
||||||
|
void GxsIdRSTreeWidgetItem::forceUpdate()
|
||||||
|
{
|
||||||
|
mIdFound = false;
|
||||||
|
mBannedState = rsReputations->isIdentityBanned(mId) ;
|
||||||
|
|
||||||
|
startProcess();
|
||||||
|
}
|
||||||
|
|
||||||
void GxsIdRSTreeWidgetItem::startProcess()
|
void GxsIdRSTreeWidgetItem::startProcess()
|
||||||
{
|
{
|
||||||
if (mRetryWhenFailed) {
|
if (mRetryWhenFailed) {
|
||||||
|
@ -52,6 +52,10 @@ public:
|
|||||||
|
|
||||||
void setAvatar(const RsGxsImage &avatar);
|
void setAvatar(const RsGxsImage &avatar);
|
||||||
virtual QVariant data(int column, int role) const;
|
virtual QVariant data(int column, int role) const;
|
||||||
|
void forceUpdate();
|
||||||
|
|
||||||
|
void setBannedState(bool b) { mBannedState = b; } // does not actually change the state, but used instead by callbacks to leave a trace
|
||||||
|
void updateBannedState() ; // checks reputation, and update is needed
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void startProcess();
|
void startProcess();
|
||||||
@ -62,6 +66,7 @@ private:
|
|||||||
RsGxsId mId;
|
RsGxsId mId;
|
||||||
int mColumn;
|
int mColumn;
|
||||||
bool mIdFound;
|
bool mIdFound;
|
||||||
|
bool mBannedState ;
|
||||||
bool mRetryWhenFailed;
|
bool mRetryWhenFailed;
|
||||||
uint32_t mIconTypeMask;
|
uint32_t mIconTypeMask;
|
||||||
RsGxsImage mAvatar;
|
RsGxsImage mAvatar;
|
||||||
|
Loading…
Reference in New Issue
Block a user