Added reputation check for board posts

* Added reputation check for board posts
* Added show author feature for the menu
This commit is contained in:
defnax 2020-06-03 12:24:58 +02:00
parent 5f06651e54
commit 58a4eafcc2
3 changed files with 222 additions and 163 deletions

View File

@ -146,6 +146,8 @@ void PostedCardView::setup()
QAction *CopyLinkAction = new QAction(QIcon(""),tr("Copy RetroShare Link"), this);
connect(CopyLinkAction, SIGNAL(triggered()), this, SLOT(copyMessageLink()));
QAction *showInPeopleAct = new QAction(QIcon(), tr("Show author in people tab"), this);
connect(showInPeopleAct, SIGNAL(triggered()), this, SLOT(showAuthorInPeople()));
int S = QFontMetricsF(font()).height() ;
@ -157,6 +159,8 @@ void PostedCardView::setup()
QMenu *menu = new QMenu();
menu->addAction(CopyLinkAction);
menu->addSeparator();
menu->addAction(showInPeopleAct);
ui->shareButton->setMenu(menu);
ui->clearButton->hide();
@ -172,6 +176,22 @@ void PostedCardView::fill()
// return;
// }
RsReputationLevel overall_reputation = rsReputations->overallReputationLevel(mPost.mMeta.mAuthorId);
bool redacted = (overall_reputation == RsReputationLevel::LOCALLY_NEGATIVE);
if(redacted) {
ui->commentButton->setDisabled(true);
ui->voteUpButton->setDisabled(true);
ui->voteDownButton->setDisabled(true);
ui->picture_frame->hide();
ui->fromLabel->setId(mPost.mMeta.mAuthorId);
ui->titleLabel->setText(tr( "<p><font color=\"#ff0000\"><b>The author of this message (with ID %1) is banned.</b>").arg(QString::fromStdString(mPost.mMeta.mAuthorId.toStdString()))) ;
QDateTime qtime;
qtime.setTime_t(mPost.mMeta.mPublishTs);
QString timestamp = qtime.toString("hh:mm dd-MMM-yyyy");
ui->dateLabel->setText(timestamp);
} else {
QPixmap sqpixmap2 = QPixmap(":/images/thumb-default.png");
mInFill = true;
@ -255,7 +275,7 @@ void PostedCardView::fill()
{
ui->picture_frame->show();
}
}
//QString score = "Hot" + QString::number(post.mHotScore);
//score += " Top" + QString::number(post.mTopScore);

View File

@ -32,6 +32,8 @@
#include "gui/common/FilesDefs.h"
#include "util/qtthreadsutils.h"
#include "util/HandleRichText.h"
#include "gui/MainWindow.h"
#include "gui/Identity/IdDialog.h"
#include "PhotoView.h"
#include "ui_PostedItem.h"
@ -338,6 +340,24 @@ void BasePostedItem::viewPicture()
/* window will destroy itself! */
}
void BasePostedItem::showAuthorInPeople()
{
if(mPost.mMeta.mAuthorId.isNull())
{
std::cerr << "(EE) GxsForumThreadWidget::loadMsgData_showAuthorInPeople() ERROR Missing Message Data...";
std::cerr << std::endl;
}
/* window will destroy itself! */
IdDialog *idDialog = dynamic_cast<IdDialog*>(MainWindow::getPage(MainWindow::People));
if (!idDialog)
return ;
MainWindow::showWindow(MainWindow::People);
idDialog->navigate(RsGxsId(mPost.mMeta.mAuthorId));
}
//========================================================================================
// PostedItem //
//========================================================================================
@ -394,6 +414,8 @@ void PostedItem::setup()
QAction *CopyLinkAction = new QAction(QIcon(""),tr("Copy RetroShare Link"), this);
connect(CopyLinkAction, SIGNAL(triggered()), this, SLOT(copyMessageLink()));
QAction *showInPeopleAct = new QAction(QIcon(), tr("Show author in people tab"), this);
connect(showInPeopleAct, SIGNAL(triggered()), this, SLOT(showAuthorInPeople()));
int S = QFontMetricsF(font()).height() ;
@ -407,6 +429,8 @@ void PostedItem::setup()
QMenu *menu = new QMenu();
menu->addAction(CopyLinkAction);
menu->addSeparator();
menu->addAction(showInPeopleAct);
ui->shareButton->setMenu(menu);
ui->clearButton->hide();
@ -438,8 +462,6 @@ void PostedItem::makeUpVote()
emit vote(msgId, true);
}
void PostedItem::setComment(const RsGxsComment& cmt)
{
ui->newCommentLabel->show();
@ -459,6 +481,23 @@ void PostedItem::setCommentsSize(int comNb)
void PostedItem::fill()
{
RsReputationLevel overall_reputation = rsReputations->overallReputationLevel(mPost.mMeta.mAuthorId);
bool redacted = (overall_reputation == RsReputationLevel::LOCALLY_NEGATIVE);
if(redacted) {
ui->expandButton->setDisabled(true);
ui->commentButton->setDisabled(true);
ui->voteUpButton->setDisabled(true);
ui->voteDownButton->setDisabled(true);
ui->thumbnailLabel->setPixmap( QPixmap(":/images/thumb-default.png"));
ui->fromLabel->setId(mPost.mMeta.mAuthorId);
ui->titleLabel->setText(tr( "<p><font color=\"#ff0000\"><b>The author of this message (with ID %1) is banned.</b>").arg(QString::fromStdString(mPost.mMeta.mAuthorId.toStdString()))) ;
QDateTime qtime;
qtime.setTime_t(mPost.mMeta.mPublishTs);
QString timestamp = qtime.toString("hh:mm dd-MMM-yyyy");
ui->dateLabel->setText(timestamp);
} else {
RetroShareLink link = RetroShareLink::createGxsGroupLink(RetroShareLink::TYPE_POSTED, mGroupMeta.mGroupId, groupName());
ui->nameLabel->setText(link.toHtml());
@ -551,6 +590,7 @@ void PostedItem::fill()
ui->expandButton->setDisabled(true);
ui->thumbnailLabel->setPixmap(sqpixmap2);
}
}
//QString score = "Hot" + QString::number(post.mHotScore);
@ -701,5 +741,3 @@ void PostedItem::toggleNotes()
}
}

View File

@ -55,6 +55,7 @@ private slots:
void readAndClearItem();
void copyMessageLink();
void viewPicture();
void showAuthorInPeople();
signals:
void vote(const RsGxsGrpMsgIdPair& msgId, bool up);