mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-01-14 08:59:50 -05:00
added proper icons and names for banned users
This commit is contained in:
parent
68ca57ce75
commit
f750818402
@ -42,6 +42,8 @@
|
|||||||
#define TYPE_UNKNOWN_ID 3
|
#define TYPE_UNKNOWN_ID 3
|
||||||
#define TYPE_CREATE_ID 4
|
#define TYPE_CREATE_ID 4
|
||||||
|
|
||||||
|
#define BANNED_ICON ":/icons/yellow_biohazard64.png"
|
||||||
|
|
||||||
#define IDCHOOSER_REFRESH 1
|
#define IDCHOOSER_REFRESH 1
|
||||||
|
|
||||||
//#define IDCHOOSER_DEBUG
|
//#define IDCHOOSER_DEBUG
|
||||||
@ -148,6 +150,10 @@ static void loadPrivateIdsCallback(GxsIdDetailsType type, const RsIdentityDetail
|
|||||||
case GXS_ID_DETAILS_TYPE_DONE:
|
case GXS_ID_DETAILS_TYPE_DONE:
|
||||||
GxsIdDetails::getIcons(details, icons);
|
GxsIdDetails::getIcons(details, icons);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case GXS_ID_DETAILS_TYPE_BANNED:
|
||||||
|
icons.push_back(QIcon(BANNED_ICON)) ;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
chooser->setItemData(index, QString("%1_%2").arg((type == GXS_ID_DETAILS_TYPE_DONE) ? TYPE_FOUND_ID : TYPE_UNKNOWN_ID).arg(text), ROLE_SORT);
|
chooser->setItemData(index, QString("%1_%2").arg((type == GXS_ID_DETAILS_TYPE_DONE) ? TYPE_FOUND_ID : TYPE_UNKNOWN_ID).arg(text), ROLE_SORT);
|
||||||
|
@ -29,6 +29,7 @@
|
|||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include "GxsIdDetails.h"
|
#include "GxsIdDetails.h"
|
||||||
#include "retroshare-gui/RsAutoUpdatePage.h"
|
#include "retroshare-gui/RsAutoUpdatePage.h"
|
||||||
|
#include "retroshare/rsreputations.h"
|
||||||
|
|
||||||
#include <retroshare/rspeers.h>
|
#include <retroshare/rspeers.h>
|
||||||
|
|
||||||
@ -40,6 +41,7 @@
|
|||||||
#define IMAGE_PGPKNOWN ":/images/contact.png"
|
#define IMAGE_PGPKNOWN ":/images/contact.png"
|
||||||
#define IMAGE_PGPUNKNOWN ":/images/tags/pgp-unknown.png"
|
#define IMAGE_PGPUNKNOWN ":/images/tags/pgp-unknown.png"
|
||||||
#define IMAGE_ANON ":/images/tags/anon.png"
|
#define IMAGE_ANON ":/images/tags/anon.png"
|
||||||
|
#define IMAGE_BANNED ":/icons/yellow_biohazard64.png"
|
||||||
|
|
||||||
#define IMAGE_DEV_AMBASSADOR ":/images/tags/dev-ambassador.png"
|
#define IMAGE_DEV_AMBASSADOR ":/images/tags/dev-ambassador.png"
|
||||||
#define IMAGE_DEV_CONTRIBUTOR ":/images/tags/vote_down.png"
|
#define IMAGE_DEV_CONTRIBUTOR ":/images/tags/vote_down.png"
|
||||||
@ -821,6 +823,9 @@ QString GxsIdDetails::getNameForType(GxsIdDetailsType type, const RsIdentityDeta
|
|||||||
case GXS_ID_DETAILS_TYPE_DONE:
|
case GXS_ID_DETAILS_TYPE_DONE:
|
||||||
return getName(details);
|
return getName(details);
|
||||||
|
|
||||||
|
case GXS_ID_DETAILS_TYPE_BANNED:
|
||||||
|
return tr("[Banned]") ;
|
||||||
|
|
||||||
case GXS_ID_DETAILS_TYPE_FAILED:
|
case GXS_ID_DETAILS_TYPE_FAILED:
|
||||||
return getFailedText(details.mId);
|
return getFailedText(details.mId);
|
||||||
}
|
}
|
||||||
@ -873,7 +878,10 @@ bool GxsIdDetails::MakeIdDesc(const RsGxsId &id, bool doIcons, QString &str, QLi
|
|||||||
|
|
||||||
QString GxsIdDetails::getName(const RsIdentityDetails &details)
|
QString GxsIdDetails::getName(const RsIdentityDetails &details)
|
||||||
{
|
{
|
||||||
QString name = QString::fromUtf8(details.mNickname.c_str()).left(RSID_MAXIMUM_NICKNAME_SIZE);
|
if(!rsReputations->isIdentityOk(details.mId))
|
||||||
|
return tr("[Banned]") ;
|
||||||
|
|
||||||
|
QString name = QString::fromUtf8(details.mNickname.c_str()).left(RSID_MAXIMUM_NICKNAME_SIZE);
|
||||||
|
|
||||||
std::list<RsRecognTag>::const_iterator it;
|
std::list<RsRecognTag>::const_iterator it;
|
||||||
for (it = details.mRecognTags.begin(); it != details.mRecognTags.end(); ++it)
|
for (it = details.mRecognTags.begin(); it != details.mRecognTags.end(); ++it)
|
||||||
@ -887,9 +895,18 @@ QString GxsIdDetails::getName(const RsIdentityDetails &details)
|
|||||||
QString GxsIdDetails::getComment(const RsIdentityDetails &details)
|
QString GxsIdDetails::getComment(const RsIdentityDetails &details)
|
||||||
{
|
{
|
||||||
QString comment;
|
QString comment;
|
||||||
|
QString nickname ;
|
||||||
|
|
||||||
QString nickname = details.mNickname.empty()?tr("[Unknown]"):QString::fromUtf8(details.mNickname.c_str()).left(RSID_MAXIMUM_NICKNAME_SIZE) ;
|
bool banned = !rsReputations->isIdentityOk(details.mId) ;
|
||||||
|
|
||||||
|
if(details.mNickname.empty())
|
||||||
|
nickname = tr("[Unknown]") ;
|
||||||
|
else if(banned)
|
||||||
|
nickname = tr("[Banned]") ;
|
||||||
|
else
|
||||||
|
nickname = QString::fromUtf8(details.mNickname.c_str()).left(RSID_MAXIMUM_NICKNAME_SIZE) ;
|
||||||
|
|
||||||
|
|
||||||
comment = QString("%1:%2<br/>%3:%4").arg(QApplication::translate("GxsIdDetails", "Identity name"),
|
comment = QString("%1:%2<br/>%3:%4").arg(QApplication::translate("GxsIdDetails", "Identity name"),
|
||||||
nickname,
|
nickname,
|
||||||
QApplication::translate("GxsIdDetails", "Identity Id"),
|
QApplication::translate("GxsIdDetails", "Identity Id"),
|
||||||
@ -903,7 +920,8 @@ QString nickname = details.mNickname.empty()?tr("[Unknown]"):QString::fromUtf8(d
|
|||||||
{
|
{
|
||||||
/* look up real name */
|
/* look up real name */
|
||||||
std::string authorName = rsPeers->getGPGName(details.mPgpId);
|
std::string authorName = rsPeers->getGPGName(details.mPgpId);
|
||||||
comment += QString("%1 [%2]").arg(QString::fromUtf8(authorName.c_str()), QString::fromStdString(details.mPgpId.toStdString()));
|
|
||||||
|
comment += QString("%1 [%2]").arg(QString::fromUtf8(authorName.c_str()), QString::fromStdString(details.mPgpId.toStdString()));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
comment += QApplication::translate("GxsIdDetails", "unknown Key");
|
comment += QApplication::translate("GxsIdDetails", "unknown Key");
|
||||||
@ -918,6 +936,13 @@ void GxsIdDetails::getIcons(const RsIdentityDetails &details, QList<QIcon> &icon
|
|||||||
{
|
{
|
||||||
QPixmap pix ;
|
QPixmap pix ;
|
||||||
|
|
||||||
|
if(!rsReputations->isIdentityOk(details.mId))
|
||||||
|
{
|
||||||
|
icons.clear() ;
|
||||||
|
icons.push_back(QIcon(IMAGE_BANNED)) ;
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
|
||||||
if(icon_types & ICON_TYPE_AVATAR)
|
if(icon_types & ICON_TYPE_AVATAR)
|
||||||
{
|
{
|
||||||
if(details.mAvatar.mSize == 0 || !pix.loadFromData(details.mAvatar.mData, details.mAvatar.mSize, "PNG"))
|
if(details.mAvatar.mSize == 0 || !pix.loadFromData(details.mAvatar.mData, details.mAvatar.mSize, "PNG"))
|
||||||
|
@ -39,7 +39,8 @@ enum GxsIdDetailsType
|
|||||||
GXS_ID_DETAILS_TYPE_EMPTY,
|
GXS_ID_DETAILS_TYPE_EMPTY,
|
||||||
GXS_ID_DETAILS_TYPE_LOADING,
|
GXS_ID_DETAILS_TYPE_LOADING,
|
||||||
GXS_ID_DETAILS_TYPE_DONE,
|
GXS_ID_DETAILS_TYPE_DONE,
|
||||||
GXS_ID_DETAILS_TYPE_FAILED
|
GXS_ID_DETAILS_TYPE_FAILED,
|
||||||
|
GXS_ID_DETAILS_TYPE_BANNED
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef void (*GxsIdDetailsCallbackFunction)(GxsIdDetailsType type, const RsIdentityDetails &details, QObject *object, const QVariant &data);
|
typedef void (*GxsIdDetailsCallbackFunction)(GxsIdDetailsType type, const RsIdentityDetails &details, QObject *object, const QVariant &data);
|
||||||
|
@ -25,6 +25,9 @@
|
|||||||
#include "GxsIdTreeWidgetItem.h"
|
#include "GxsIdTreeWidgetItem.h"
|
||||||
#include "GxsIdDetails.h"
|
#include "GxsIdDetails.h"
|
||||||
#include "util/HandleRichText.h"
|
#include "util/HandleRichText.h"
|
||||||
|
#include "retroshare/rsreputations.h"
|
||||||
|
|
||||||
|
#define BANNED_IMAGE ":/icons/yellow_biohazard64.png"
|
||||||
|
|
||||||
/** Constructor */
|
/** Constructor */
|
||||||
GxsIdRSTreeWidgetItem::GxsIdRSTreeWidgetItem(const RSTreeWidgetItemCompareRole *compareRole, uint32_t icon_mask,QTreeWidget *parent)
|
GxsIdRSTreeWidgetItem::GxsIdRSTreeWidgetItem(const RSTreeWidgetItemCompareRole *compareRole, uint32_t icon_mask,QTreeWidget *parent)
|
||||||
@ -71,6 +74,10 @@ static void fillGxsIdRSTreeWidgetItemCallback(GxsIdDetailsType type, const RsIde
|
|||||||
GxsIdDetails::getIcons(details, icons, item->iconTypeMask());
|
GxsIdDetails::getIcons(details, icons, item->iconTypeMask());
|
||||||
item->processResult(true);
|
item->processResult(true);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case GXS_ID_DETAILS_TYPE_BANNED:
|
||||||
|
icons.push_back(QIcon(":/icons/yellow_biohazard64.png")) ;
|
||||||
|
break ;
|
||||||
}
|
}
|
||||||
|
|
||||||
int column = item->idColumn();
|
int column = item->idColumn();
|
||||||
@ -139,28 +146,28 @@ void GxsIdRSTreeWidgetItem::setAvatar(const RsGxsImage &avatar)
|
|||||||
|
|
||||||
QVariant GxsIdRSTreeWidgetItem::data(int column, int role) const
|
QVariant GxsIdRSTreeWidgetItem::data(int column, int role) const
|
||||||
{
|
{
|
||||||
if (column == idColumn()) {
|
if (column == idColumn())
|
||||||
switch (role) {
|
{
|
||||||
case Qt::ToolTipRole:
|
if (role == Qt::ToolTipRole)
|
||||||
{
|
{
|
||||||
QString t = RSTreeWidgetItem::data(column, role).toString();
|
QString t = RSTreeWidgetItem::data(column, role).toString();
|
||||||
|
QImage pix;
|
||||||
|
|
||||||
QImage pix;
|
if(!rsReputations->isIdentityOk(mId))
|
||||||
if (mAvatar.mSize == 0 || !pix.loadFromData(mAvatar.mData, mAvatar.mSize, "PNG")) {
|
pix = QImage(BANNED_IMAGE) ;
|
||||||
pix = GxsIdDetails::makeDefaultIcon(mId);
|
else if (mAvatar.mSize == 0 || !pix.loadFromData(mAvatar.mData, mAvatar.mSize, "PNG"))
|
||||||
}
|
pix = GxsIdDetails::makeDefaultIcon(mId);
|
||||||
|
|
||||||
int S = QFontMetricsF(font(column)).height();
|
int S = QFontMetricsF(font(column)).height();
|
||||||
|
|
||||||
QString embeddedImage;
|
QString embeddedImage;
|
||||||
if (RsHtml::makeEmbeddedImage(pix.scaled(QSize(4*S,4*S), Qt::KeepAspectRatio, Qt::SmoothTransformation), embeddedImage, 8*S * 8*S)) {
|
if (RsHtml::makeEmbeddedImage(pix.scaled(QSize(4*S,4*S), Qt::KeepAspectRatio, Qt::SmoothTransformation), embeddedImage, 8*S * 8*S)) {
|
||||||
t = "<table><tr><td>" + embeddedImage + "</td><td>" + t + "</td></table>";
|
t = "<table><tr><td>" + embeddedImage + "</td><td>" + t + "</td></table>";
|
||||||
}
|
}
|
||||||
|
|
||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return RSTreeWidgetItem::data(column, role);
|
return RSTreeWidgetItem::data(column, role);
|
||||||
}
|
}
|
||||||
|
@ -83,7 +83,6 @@
|
|||||||
#define ROLE_THREAD_READCHILDREN Qt::UserRole + 4
|
#define ROLE_THREAD_READCHILDREN Qt::UserRole + 4
|
||||||
#define ROLE_THREAD_UNREADCHILDREN Qt::UserRole + 5
|
#define ROLE_THREAD_UNREADCHILDREN Qt::UserRole + 5
|
||||||
#define ROLE_THREAD_SORT Qt::UserRole + 6
|
#define ROLE_THREAD_SORT Qt::UserRole + 6
|
||||||
#define ROLE_THREAD_REDACTED Qt::UserRole + 7
|
|
||||||
|
|
||||||
#define ROLE_THREAD_COUNT 4
|
#define ROLE_THREAD_COUNT 4
|
||||||
|
|
||||||
@ -980,7 +979,6 @@ QTreeWidgetItem *GxsForumThreadWidget::convertMsgToThreadWidget(const RsGxsForum
|
|||||||
#endif
|
#endif
|
||||||
item->setData(COLUMN_THREAD_DATA, ROLE_THREAD_STATUS, msg.mMeta.mMsgStatus);
|
item->setData(COLUMN_THREAD_DATA, ROLE_THREAD_STATUS, msg.mMeta.mMsgStatus);
|
||||||
item->setData(COLUMN_THREAD_DATA, ROLE_THREAD_MISSING, false);
|
item->setData(COLUMN_THREAD_DATA, ROLE_THREAD_MISSING, false);
|
||||||
item->setData(COLUMN_THREAD_DATA, ROLE_THREAD_REDACTED, redacted);
|
|
||||||
|
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
@ -1357,9 +1355,9 @@ void GxsForumThreadWidget::insertMessageData(const RsGxsForumMsg &msg)
|
|||||||
if(redacted)
|
if(redacted)
|
||||||
{
|
{
|
||||||
QString extraTxt = tr("<p><font color=\"#ff0000\"><b>The author of this message (with ID %1) is banned.</b>").arg(QString::fromStdString(msg.mMeta.mAuthorId.toStdString())) ;
|
QString extraTxt = tr("<p><font color=\"#ff0000\"><b>The author of this message (with ID %1) is banned.</b>").arg(QString::fromStdString(msg.mMeta.mAuthorId.toStdString())) ;
|
||||||
extraTxt += "<UL><li></b><font color=\"#ff0000\">Messages from this author are not forwarded. </font></b></li>" ;
|
extraTxt += "<UL><li><b><font color=\"#ff0000\">Messages from this author are not forwarded. </font></b></li>" ;
|
||||||
extraTxt += "<UL><li></b><font color=\"#ff0000\">Messages from this author are replaced by this text. </font></b></li>" ;
|
extraTxt += "<li><b><font color=\"#ff0000\">Messages from this author are replaced by this text. </font></b></li></ul>" ;
|
||||||
ui->postText->setHtml(extraTxt);
|
ui->postText->setHtml(extraTxt);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -1721,6 +1719,8 @@ void GxsForumThreadWidget::flagpersonasbad()
|
|||||||
QTreeWidgetItem *item = ui->threadTreeWidget->currentItem();
|
QTreeWidgetItem *item = ui->threadTreeWidget->currentItem();
|
||||||
|
|
||||||
std::cerr << "Author string: \"" << item->data(COLUMN_THREAD_DATA, ROLE_THREAD_AUTHOR).toString().toStdString()<< std::endl;
|
std::cerr << "Author string: \"" << item->data(COLUMN_THREAD_DATA, ROLE_THREAD_AUTHOR).toString().toStdString()<< std::endl;
|
||||||
|
std::cerr << "Messagestring: \"" << item->data(COLUMN_THREAD_DATA, ROLE_THREAD_MSGID).toString().toStdString()<< std::endl;
|
||||||
|
std::cerr << "Messagestring: \"" << item->data(COLUMN_THREAD_DATA, ROLE_THREAD_STATUS).toString().toStdString()<< std::endl;
|
||||||
RsGxsId gxsId(item->data(COLUMN_THREAD_DATA, ROLE_THREAD_AUTHOR).toString().toStdString());
|
RsGxsId gxsId(item->data(COLUMN_THREAD_DATA, ROLE_THREAD_AUTHOR).toString().toStdString());
|
||||||
|
|
||||||
// Get Message ... then complete replyMessageData().
|
// Get Message ... then complete replyMessageData().
|
||||||
|
Loading…
Reference in New Issue
Block a user