mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
added avatar to GxsId tooltip (see in forums). Removed thread data race due to multiple threads accessing the static data member image_cache, causing avatars to not show up randomly. I do not have a clean solution yet on how to restore this cache
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@7911 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
52901c1ddb
commit
5ae5d4f0a1
@ -207,13 +207,13 @@ bool GxsIdDetails::process(const RsGxsId &id, GxsIdDetailsCallbackFunction callb
|
||||
}
|
||||
|
||||
details.mId = id;
|
||||
callback(GXS_ID_DETAILS_TYPE_LOADING, details, object, data);
|
||||
|
||||
/* Add id to the pending list */
|
||||
if (!mInstance) {
|
||||
mInstance = new GxsIdDetails;
|
||||
mInstance->moveToThread(qApp->thread());
|
||||
}
|
||||
callback(GXS_ID_DETAILS_TYPE_LOADING, details, object, data);
|
||||
|
||||
CallbackData pendingData;
|
||||
pendingData.mId = id;
|
||||
@ -338,9 +338,9 @@ static bool findTagIcon(int tag_class, int /*tag_type*/, QIcon &icon)
|
||||
* Bring the source code from this adaptation:
|
||||
* http://francisshanahan.com/identicon5/test.html
|
||||
*/
|
||||
QImage GxsIdDetails::makeDefaultIcon(const RsGxsId& id)
|
||||
QImage GxsIdDetails::makeDefaultIconLocal_locked(const RsGxsId& id)
|
||||
{
|
||||
static std::map<RsGxsId,QImage> image_cache ;
|
||||
QMutexLocker lock(&mMutex2);
|
||||
|
||||
std::map<RsGxsId,QImage>::const_iterator it = image_cache.find(id) ;
|
||||
|
||||
@ -351,6 +351,13 @@ QImage GxsIdDetails::makeDefaultIcon(const RsGxsId& id)
|
||||
|
||||
return image_cache[id] ;
|
||||
}
|
||||
QImage GxsIdDetails::makeDefaultIcon(const RsGxsId& id)
|
||||
{
|
||||
// if(mInstance != NULL)
|
||||
// return mInstance->makeDefaultIconLocal_locked(id) ;
|
||||
// else
|
||||
return drawIdentIcon(QString::fromStdString(id.toStdString()),64*3, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief GxsIdDetails::getSprite
|
||||
@ -846,26 +853,26 @@ QString GxsIdDetails::getComment(const RsIdentityDetails &details)
|
||||
{
|
||||
QString comment;
|
||||
|
||||
comment = QString("%1: %2\n%3: %4").arg(QApplication::translate("GxsIdDetails", "Identity name"),
|
||||
comment = QString("%1:%2<br/>%3:%4").arg(QApplication::translate("GxsIdDetails", "Identity name"),
|
||||
QString::fromUtf8(details.mNickname.c_str()),
|
||||
QApplication::translate("GxsIdDetails", "Identity Id"),
|
||||
QApplication::translate("GxsIdDetails", "Identity Id"),
|
||||
QString::fromStdString(details.mId.toStdString()));
|
||||
|
||||
if (details.mPgpLinked)
|
||||
{
|
||||
comment += QString("\n%1: %2 ").arg(QApplication::translate("GxsIdDetails", "Authentication"), QApplication::translate("GxsIdDetails", "signed by"));
|
||||
comment += QString("<br/>%1:%2 ").arg(QApplication::translate("GxsIdDetails", "Authentication"), QApplication::translate("GxsIdDetails", "Signed by"));
|
||||
|
||||
if (details.mPgpKnown)
|
||||
{
|
||||
/* look up real name */
|
||||
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
|
||||
comment += QApplication::translate("GxsIdDetails", "unknown Key");
|
||||
}
|
||||
else
|
||||
comment += QString("\n%1: %2").arg(QApplication::translate("GxsIdDetails", "Authentication"), QApplication::translate("GxsIdDetails", "anonymous"));
|
||||
comment += QString("<br/>%1: %2").arg(QApplication::translate("GxsIdDetails", "Authentication"), QApplication::translate("GxsIdDetails", "anonymous"));
|
||||
|
||||
return comment;
|
||||
}
|
||||
|
@ -80,6 +80,7 @@ signals:
|
||||
|
||||
protected:
|
||||
void connectObject_locked(QObject *object, bool doConnect);
|
||||
QImage makeDefaultIconLocal_locked(const RsGxsId& id);
|
||||
|
||||
/* Timer */
|
||||
virtual void timerEvent(QTimerEvent *event);
|
||||
@ -123,9 +124,11 @@ protected:
|
||||
/* Pending data */
|
||||
QList<CallbackData> mPendingData;
|
||||
int mCheckTimerId;
|
||||
std::map<RsGxsId,QImage> image_cache ;
|
||||
|
||||
/* Thread safe */
|
||||
QMutex mMutex;
|
||||
QMutex mMutex2;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -23,6 +23,7 @@
|
||||
|
||||
#include "GxsIdTreeWidgetItem.h"
|
||||
#include "GxsIdDetails.h"
|
||||
#include "util/HandleRichText.h"
|
||||
|
||||
/** Constructor */
|
||||
GxsIdRSTreeWidgetItem::GxsIdRSTreeWidgetItem(const RSTreeWidgetItemCompareRole *compareRole, QTreeWidget *parent)
|
||||
@ -69,7 +70,6 @@ static void fillGxsIdRSTreeWidgetItemCallback(GxsIdDetailsType type, const RsIde
|
||||
int column = item->idColumn();
|
||||
|
||||
item->setText(column, GxsIdDetails::getNameForType(type, details));
|
||||
item->setToolTip(column, toolTip);
|
||||
item->setData(column, Qt::UserRole, QString::fromStdString(details.mId.toStdString()));
|
||||
|
||||
QIcon combinedIcon;
|
||||
@ -77,6 +77,18 @@ static void fillGxsIdRSTreeWidgetItemCallback(GxsIdDetailsType type, const RsIde
|
||||
GxsIdDetails::GenerateCombinedIcon(combinedIcon, icons);
|
||||
}
|
||||
item->setIcon(column, combinedIcon);
|
||||
|
||||
QImage pix ;
|
||||
|
||||
if(details.mAvatar.mSize == 0 || !pix.loadFromData(details.mAvatar.mData, details.mAvatar.mSize, "PNG"))
|
||||
pix = GxsIdDetails::makeDefaultIcon(details.mId);
|
||||
|
||||
QString embeddedImage ;
|
||||
|
||||
if(RsHtml::makeEmbeddedImage(pix.scaled(QSize(64,64),Qt::KeepAspectRatio,Qt::SmoothTransformation),embeddedImage,128*128))
|
||||
toolTip = "<table><tr><td>"+embeddedImage+"</td><td>" +toolTip+ "</td></table>" ;
|
||||
|
||||
item->setToolTip(column, toolTip);
|
||||
}
|
||||
|
||||
void GxsIdRSTreeWidgetItem::setId(const RsGxsId &id, int column)
|
||||
|
Loading…
Reference in New Issue
Block a user