mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
Added avatar image to ConfCertDialog (defnax).
Added new class AvatarDefs to get the avatar for a ssl id or gpg id. git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@4585 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
0591ef0432
commit
b35d32ef15
@ -303,6 +303,7 @@ HEADERS += rshare.h \
|
||||
gui/common/vmessagebox.h \
|
||||
gui/common/rwindow.h \
|
||||
gui/common/html.h \
|
||||
gui/common/AvatarDefs.h \
|
||||
gui/common/StatusDefs.h \
|
||||
gui/common/TagDefs.h \
|
||||
gui/common/GroupDefs.h \
|
||||
@ -523,6 +524,7 @@ SOURCES += main.cpp \
|
||||
gui/common/vmessagebox.cpp \
|
||||
gui/common/rwindow.cpp \
|
||||
gui/common/html.cpp \
|
||||
gui/common/AvatarDefs.cpp \
|
||||
gui/common/StatusDefs.cpp \
|
||||
gui/common/TagDefs.cpp \
|
||||
gui/common/GroupDefs.cpp \
|
||||
|
@ -60,6 +60,7 @@
|
||||
#include "feeds/AttachFileItem.h"
|
||||
#include "im_history/ImHistoryBrowser.h"
|
||||
#include "common/RSTreeWidgetItem.h"
|
||||
#include "gui/common/AvatarDefs.h"
|
||||
|
||||
#include "RetroShareLink.h"
|
||||
|
||||
@ -1795,26 +1796,11 @@ void FriendsDialog::viewprofile()
|
||||
|
||||
void FriendsDialog::updateAvatar()
|
||||
{
|
||||
unsigned char *data = NULL;
|
||||
int size = 0 ;
|
||||
|
||||
rsMsgs->getOwnAvatarData(data,size);
|
||||
|
||||
#ifdef FRIENDS_DEBUG
|
||||
std::cerr << "Image size = " << size << std::endl ;
|
||||
#endif
|
||||
|
||||
if(size == 0)
|
||||
std::cerr << "Got no image" << std::endl ;
|
||||
|
||||
// set the image
|
||||
QPixmap pix ;
|
||||
pix.loadFromData(data,size,"PNG") ;
|
||||
ui.avatartoolButton->setIcon(pix); // writes image into ba in PNG format
|
||||
QPixmap avatar;
|
||||
AvatarDefs::getOwnAvatar(avatar, "");
|
||||
ui.avatartoolButton->setIcon(avatar);
|
||||
|
||||
PopupChatDialog::updateAllAvatars();
|
||||
|
||||
delete[] data ;
|
||||
}
|
||||
|
||||
void FriendsDialog::getAvatar()
|
||||
|
@ -53,6 +53,7 @@
|
||||
#include "util/misc.h"
|
||||
#include "settings/rsharesettings.h"
|
||||
#include "common/RSTreeWidgetItem.h"
|
||||
#include "common/AvatarDefs.h"
|
||||
|
||||
#include "RetroShareLink.h"
|
||||
|
||||
@ -681,20 +682,10 @@ void MessengerWindow::insertPeers()
|
||||
|
||||
gpg_item -> setText(COLUMN_STATE, StatusDefs::name(it->status));
|
||||
|
||||
unsigned char *data = NULL;
|
||||
int size = 0 ;
|
||||
rsMsgs->getAvatarData(it->id ,data,size);
|
||||
|
||||
if(size != 0){
|
||||
QPixmap avatar ;
|
||||
avatar.loadFromData(data,size,"PNG") ;
|
||||
QPixmap avatar;
|
||||
AvatarDefs::getAvatarFromSslId(it->id, avatar, ":/images/no_avatar_70.png");
|
||||
QIcon avatar_icon(avatar);
|
||||
gpg_item-> setIcon(COLUMN_STATE, avatar_icon);
|
||||
delete[] data;
|
||||
|
||||
} else {
|
||||
gpg_item -> setIcon(COLUMN_STATE,(QIcon(":/images/no_avatar_70.png")));
|
||||
}
|
||||
gpg_item->setIcon(COLUMN_STATE, avatar_icon);
|
||||
|
||||
switch (it->status) {
|
||||
case RS_STATUS_INACTIVE:
|
||||
@ -1087,22 +1078,9 @@ void MessengerWindow::sendMessage()
|
||||
|
||||
void MessengerWindow::updateAvatar()
|
||||
{
|
||||
unsigned char *data = NULL;
|
||||
int size = 0 ;
|
||||
|
||||
rsMsgs->getOwnAvatarData(data,size);
|
||||
|
||||
std::cerr << "Image size = " << size << std::endl ;
|
||||
|
||||
if(size == 0)
|
||||
std::cerr << "Got no image" << std::endl ;
|
||||
|
||||
// set the image
|
||||
QPixmap pix ;
|
||||
pix.loadFromData(data,size,"PNG") ;
|
||||
ui.avatarButton->setIcon(pix); // writes image into ba in PNG format
|
||||
|
||||
delete[] data ;
|
||||
QPixmap avatar;
|
||||
AvatarDefs::getOwnAvatar(avatar);
|
||||
ui.avatarButton->setIcon(avatar);
|
||||
}
|
||||
|
||||
void MessengerWindow::getAvatar()
|
||||
|
@ -51,6 +51,7 @@
|
||||
#include "gui/notifyqt.h"
|
||||
#include "../RsAutoUpdatePage.h"
|
||||
#include "gui/common/StatusDefs.h"
|
||||
#include "gui/common/AvatarDefs.h"
|
||||
#include "gui/common/Emoticons.h"
|
||||
#include "gui/im_history/ImHistoryBrowser.h"
|
||||
|
||||
@ -163,7 +164,7 @@ PopupChatDialog::PopupChatDialog(const std::string &id, const QString &name, QWi
|
||||
colorChanged(mCurrentColor);
|
||||
fontChanged(mCurrentFont);
|
||||
|
||||
updateAvatar() ;
|
||||
updateOwnAvatar() ;
|
||||
updatePeerAvatar(id) ;
|
||||
|
||||
// load settings
|
||||
@ -415,7 +416,7 @@ void PopupChatDialog::chatFriend(const std::string &id)
|
||||
/*static*/ void PopupChatDialog::updateAllAvatars()
|
||||
{
|
||||
for(std::map<std::string, PopupChatDialog *>::const_iterator it(chatDialogs.begin());it!=chatDialogs.end();++it)
|
||||
it->second->updateAvatar() ;
|
||||
it->second->updateOwnAvatar() ;
|
||||
}
|
||||
|
||||
void PopupChatDialog::focusDialog()
|
||||
@ -846,59 +847,21 @@ void PopupChatDialog::on_actionDelete_Chat_History_triggered()
|
||||
|
||||
void PopupChatDialog::updatePeerAvatar(const std::string& peer_id)
|
||||
{
|
||||
#ifdef CHAT_DEBUG
|
||||
#ifdef CHAT_DEBUG
|
||||
std::cerr << "popupchatDialog::updatePeerAvatar() updating avatar for peer " << peer_id << std::endl ;
|
||||
std::cerr << "Requesting avatar image for peer " << peer_id << std::endl ;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
unsigned char *data = NULL;
|
||||
int size = 0 ;
|
||||
|
||||
rsMsgs->getAvatarData(peer_id,data,size);
|
||||
|
||||
#ifdef CHAT_DEBUG
|
||||
std::cerr << "Image size = " << size << std::endl;
|
||||
#endif
|
||||
|
||||
if(size == 0) {
|
||||
#ifdef CHAT_DEBUG
|
||||
std::cerr << "Got no image" << std::endl ;
|
||||
#endif
|
||||
ui.avatarlabel->setPixmap(QPixmap(":/images/no_avatar_background.png"));
|
||||
return ;
|
||||
}
|
||||
|
||||
// set the image
|
||||
QPixmap pix ;
|
||||
pix.loadFromData(data,size,"PNG") ;
|
||||
ui.avatarlabel->setPixmap(pix); // writes image into ba in JPG format
|
||||
|
||||
delete[] data ;
|
||||
QPixmap avatar;
|
||||
AvatarDefs::getAvatarFromSslId(peer_id, avatar);
|
||||
ui.avatarlabel->setPixmap(avatar);
|
||||
}
|
||||
|
||||
void PopupChatDialog::updateAvatar()
|
||||
void PopupChatDialog::updateOwnAvatar()
|
||||
{
|
||||
unsigned char *data = NULL;
|
||||
int size = 0 ;
|
||||
|
||||
rsMsgs->getOwnAvatarData(data,size);
|
||||
|
||||
#ifdef CHAT_DEBUG
|
||||
std::cerr << "Image size = " << size << std::endl ;
|
||||
#endif
|
||||
|
||||
if(size == 0) {
|
||||
#ifdef CHAT_DEBUG
|
||||
std::cerr << "Got no image" << std::endl ;
|
||||
#endif
|
||||
}
|
||||
|
||||
// set the image
|
||||
QPixmap pix ;
|
||||
pix.loadFromData(data,size,"PNG") ;
|
||||
ui.myavatarlabel->setPixmap(pix); // writes image into ba in PNGformat
|
||||
|
||||
delete[] data ;
|
||||
QPixmap avatar;
|
||||
AvatarDefs::getOwnAvatar(avatar);
|
||||
ui.myavatarlabel->setPixmap(avatar);
|
||||
}
|
||||
|
||||
void PopupChatDialog::addExtraFile()
|
||||
|
@ -81,7 +81,7 @@ protected:
|
||||
void insertChatMsgs();
|
||||
void addChatMsg(bool incoming, const std::string &id, const QString &name, const QDateTime &sendTime, const QDateTime &recvTime, const QString &message, enumChatType chatType, bool addToHistory);
|
||||
|
||||
void updateAvatar();
|
||||
void updateOwnAvatar();
|
||||
|
||||
private slots:
|
||||
void pasteLink() ;
|
||||
|
97
retroshare-gui/src/gui/common/AvatarDefs.cpp
Normal file
97
retroshare-gui/src/gui/common/AvatarDefs.cpp
Normal file
@ -0,0 +1,97 @@
|
||||
/****************************************************************
|
||||
* This file is distributed under the following license:
|
||||
*
|
||||
* Copyright (c) 2010, RetroShare Team
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
****************************************************************/
|
||||
|
||||
#include <QPixmap>
|
||||
|
||||
#include <retroshare/rsmsgs.h>
|
||||
#include <retroshare/rspeers.h>
|
||||
|
||||
#include "AvatarDefs.h"
|
||||
|
||||
void AvatarDefs::getOwnAvatar(QPixmap &avatar, const QString& defaultImage)
|
||||
{
|
||||
unsigned char *data = NULL;
|
||||
int size = 0;
|
||||
|
||||
/* get avatar */
|
||||
rsMsgs->getOwnAvatarData(data, size);
|
||||
|
||||
if (size == 0) {
|
||||
avatar = QPixmap(defaultImage);
|
||||
return;
|
||||
}
|
||||
|
||||
/* load image */
|
||||
avatar.loadFromData(data, size, "PNG") ;
|
||||
|
||||
delete[] data;
|
||||
}
|
||||
|
||||
void AvatarDefs::getAvatarFromSslId(const std::string& sslId, QPixmap &avatar, const QString& defaultImage)
|
||||
{
|
||||
unsigned char *data = NULL;
|
||||
int size = 0;
|
||||
|
||||
/* get avatar */
|
||||
rsMsgs->getAvatarData(sslId, data, size);
|
||||
if (size == 0) {
|
||||
avatar = QPixmap(defaultImage);
|
||||
return;
|
||||
}
|
||||
|
||||
/* load image */
|
||||
avatar.loadFromData(data, size, "PNG") ;
|
||||
|
||||
delete[] data;
|
||||
}
|
||||
|
||||
void AvatarDefs::getAvatarFromGpgId(const std::string& gpgId, QPixmap &avatar, const QString& defaultImage)
|
||||
{
|
||||
unsigned char *data = NULL;
|
||||
int size = 0;
|
||||
|
||||
if (gpgId == rsPeers->getGPGOwnId()) {
|
||||
/* Its me */
|
||||
rsMsgs->getOwnAvatarData(data,size);
|
||||
} else {
|
||||
/* get the first available avatar of one of the ssl ids */
|
||||
std::list<std::string> sslIds;
|
||||
if (rsPeers->getAssociatedSSLIds(gpgId, sslIds)) {
|
||||
std::list<std::string>::iterator sslId;
|
||||
for (sslId = sslIds.begin(); sslId != sslIds.end(); sslId++) {
|
||||
rsMsgs->getAvatarData(*sslId, data, size);
|
||||
if (size) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (size == 0) {
|
||||
avatar = QPixmap(defaultImage);
|
||||
return;
|
||||
}
|
||||
|
||||
/* load image */
|
||||
avatar.loadFromData(data, size, "PNG") ;
|
||||
|
||||
delete[] data;
|
||||
}
|
42
retroshare-gui/src/gui/common/AvatarDefs.h
Normal file
42
retroshare-gui/src/gui/common/AvatarDefs.h
Normal file
@ -0,0 +1,42 @@
|
||||
/****************************************************************
|
||||
* This file is distributed under the following license:
|
||||
*
|
||||
* Copyright (c) 2010, RetroShare Team
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
****************************************************************/
|
||||
|
||||
|
||||
#ifndef _AVATARDEFS_H
|
||||
#define _AVATARDEFS_H
|
||||
|
||||
#include <string>
|
||||
#include <QString>
|
||||
|
||||
#define AVATAR_DEFAULT_IMAGE ":/images/no_avatar_background.png"
|
||||
|
||||
class QPixmap;
|
||||
|
||||
class AvatarDefs
|
||||
{
|
||||
public:
|
||||
static void getOwnAvatar(QPixmap &avatar, const QString& defaultImage = AVATAR_DEFAULT_IMAGE);
|
||||
static void getAvatarFromSslId(const std::string& sslId, QPixmap &avatar, const QString& defaultImage = AVATAR_DEFAULT_IMAGE);
|
||||
static void getAvatarFromGpgId(const std::string& gpgId, QPixmap &avatar, const QString& defaultImage = AVATAR_DEFAULT_IMAGE);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -32,11 +32,14 @@
|
||||
|
||||
#include <retroshare/rspeers.h>
|
||||
#include <retroshare/rsdisc.h>
|
||||
#include <retroshare/rsmsgs.h>
|
||||
|
||||
#include "gui/help/browser/helpbrowser.h"
|
||||
#include "gui/common/PeerDefs.h"
|
||||
#include "gui/common/StatusDefs.h"
|
||||
#include "gui/RetroShareLink.h"
|
||||
#include "gui/notifyqt.h"
|
||||
#include "gui/common/AvatarDefs.h"
|
||||
|
||||
#ifndef MINIMAL_RSGUI
|
||||
#include "gui/MainWindow.h"
|
||||
@ -76,6 +79,10 @@ ConfCertDialog::ConfCertDialog(const std::string& id, QWidget *parent, Qt::WFlag
|
||||
connect(ui.signKeyButton, SIGNAL(clicked()), this, SLOT(signGPGKey()));
|
||||
connect(ui.trusthelpButton, SIGNAL(clicked()), this, SLOT(showHelpDialog()));
|
||||
|
||||
connect(NotifyQt::getInstance(), SIGNAL(peerHasNewAvatar(const QString&)), this, SLOT(updatePeersAvatar(const QString&)));
|
||||
|
||||
isOnlyGpg = false;
|
||||
|
||||
#ifndef MINIMAL_RSGUI
|
||||
MainWindow *w = MainWindow::getInstance();
|
||||
if (w) {
|
||||
@ -136,6 +143,8 @@ void ConfCertDialog::load()
|
||||
return;
|
||||
}
|
||||
|
||||
isOnlyGpg = detail.isOnlyGPGdetail;
|
||||
|
||||
ui.name->setText(QString::fromUtf8(detail.name.c_str()));
|
||||
ui.peerid->setText(QString::fromStdString(detail.id));
|
||||
|
||||
@ -326,6 +335,8 @@ void ConfCertDialog::load()
|
||||
font.setStyle(QFont::StyleNormal);
|
||||
ui.userCertificateText->setFont(font);
|
||||
ui.userCertificateText->setText(QString::fromUtf8(invite.c_str()));
|
||||
|
||||
updatePeersAvatar(QString::fromStdString(mId));
|
||||
}
|
||||
|
||||
|
||||
@ -439,3 +450,20 @@ void ConfCertDialog::showHelpDialog(const QString &topic)
|
||||
helpBrowser = new HelpBrowser(this);
|
||||
helpBrowser->showWindow(topic);
|
||||
}
|
||||
|
||||
void ConfCertDialog::updatePeersAvatar(const QString& peer_id)
|
||||
{
|
||||
if (isOnlyGpg) {
|
||||
QPixmap avatar;
|
||||
AvatarDefs::getAvatarFromGpgId(mId, avatar);
|
||||
ui.AvatarLabel->setPixmap(avatar);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (mId == peer_id.toStdString()) {
|
||||
QPixmap avatar;
|
||||
AvatarDefs::getAvatarFromSslId(mId, avatar);
|
||||
ui.AvatarLabel->setPixmap(avatar);
|
||||
}
|
||||
}
|
||||
|
@ -60,8 +60,11 @@ private slots:
|
||||
/** Called when a child window requests the given help <b>topic</b>. */
|
||||
void showHelpDialog(const QString &topic);
|
||||
|
||||
void updatePeersAvatar(const QString& peer_id);
|
||||
|
||||
private:
|
||||
std::string mId;
|
||||
bool isOnlyGpg;
|
||||
|
||||
/** Qt Designer generated object */
|
||||
Ui::ConfCertDialog ui;
|
||||
|
@ -6,8 +6,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>520</width>
|
||||
<height>639</height>
|
||||
<width>469</width>
|
||||
<height>528</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
@ -21,7 +21,7 @@
|
||||
<item row="0" column="0">
|
||||
<widget class="QTabWidget" name="stabWidget">
|
||||
<property name="currentIndex">
|
||||
<number>1</number>
|
||||
<number>0</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="tab">
|
||||
<attribute name="icon">
|
||||
@ -31,8 +31,21 @@
|
||||
<attribute name="title">
|
||||
<string>Details</string>
|
||||
</attribute>
|
||||
<layout class="QGridLayout">
|
||||
<layout class="QGridLayout" name="gridLayout_3">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="AvatarLabel">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>96</width>
|
||||
<height>96</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1" rowspan="2">
|
||||
<widget class="QGroupBox" name="groupBox_2">
|
||||
<property name="title">
|
||||
<string>Peer Info</string>
|
||||
@ -160,10 +173,36 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="8" column="0">
|
||||
<spacer name="verticalSpacer_5">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<spacer name="verticalSpacer_4">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>68</width>
|
||||
<height>126</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="2" column="0" colspan="2">
|
||||
<widget class="QGroupBox" name="groupBox">
|
||||
<property name="title">
|
||||
<string>Peer Address</string>
|
||||
@ -327,7 +366,7 @@
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<item row="3" column="0" colspan="2">
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
|
@ -27,6 +27,7 @@
|
||||
#include "../RsAutoUpdatePage.h"
|
||||
#include "gui/msgs/MessageComposer.h"
|
||||
#include "gui/chat/HandleRichText.h"
|
||||
#include "gui/common/AvatarDefs.h"
|
||||
#include "gui/settings/rsharesettings.h"
|
||||
|
||||
#include "gui/notifyqt.h"
|
||||
@ -228,24 +229,9 @@ void ChatMsgItem::updateAvatar(const QString &peer_id)
|
||||
return;
|
||||
}
|
||||
|
||||
unsigned char *data = NULL;
|
||||
int size = 0 ;
|
||||
|
||||
rsMsgs->getAvatarData(mPeerId,data,size);
|
||||
|
||||
if(size != 0)
|
||||
{
|
||||
// set the image
|
||||
QPixmap pix ;
|
||||
pix.loadFromData(data,size,"PNG") ;
|
||||
avatar_label->setPixmap(pix);
|
||||
delete[] data ;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
avatar_label->setPixmap(QPixmap(":/images/user/personal64.png"));
|
||||
}
|
||||
QPixmap avatar;
|
||||
AvatarDefs::getAvatarFromSslId(mPeerId, avatar, ":/images/user/personal64.png");
|
||||
avatar_label->setPixmap(avatar);
|
||||
}
|
||||
|
||||
void ChatMsgItem::togglequickmessage()
|
||||
|
@ -34,6 +34,7 @@
|
||||
|
||||
#include "gui/forums/CreateForumMsg.h"
|
||||
#include "gui/chat/HandleRichText.h"
|
||||
#include "gui/common/AvatarDefs.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
@ -429,46 +430,26 @@ void ForumMsgItem::updateAvatar(const QString &peer_id)
|
||||
void ForumMsgItem::showAvatar(const std::string &peer_id, bool next)
|
||||
{
|
||||
std::string gpgId = next ? mGpgIdNext : mGpgIdPrev;
|
||||
QLabel *avatar = next ? nextavatarlabel : avatarlabel;
|
||||
QLabel *avatarLabel = next ? nextavatarlabel : avatarlabel;
|
||||
|
||||
if (gpgId.empty()) {
|
||||
avatar->setPixmap(QPixmap(":/images/user/personal64.png"));
|
||||
avatarLabel->setPixmap(QPixmap(":/images/user/personal64.png"));
|
||||
return;
|
||||
}
|
||||
|
||||
unsigned char *data = NULL;
|
||||
int size = 0 ;
|
||||
QPixmap avatar;
|
||||
|
||||
if (gpgId == rsPeers->getGPGOwnId()) {
|
||||
/* Its me */
|
||||
rsMsgs->getOwnAvatarData(data,size);
|
||||
AvatarDefs::getOwnAvatar(avatar, ":/images/user/personal64.png");
|
||||
} else {
|
||||
if (peer_id.empty()) {
|
||||
/* Show the first available avatar of one of the ssl ids */
|
||||
std::list<std::string> sslIds;
|
||||
if (rsPeers->getAssociatedSSLIds(gpgId, sslIds) == false) {
|
||||
return;
|
||||
}
|
||||
|
||||
std::list<std::string>::iterator sslId;
|
||||
for (sslId = sslIds.begin(); sslId != sslIds.end(); sslId++) {
|
||||
rsMsgs->getAvatarData(*sslId,data,size);
|
||||
if (size) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
AvatarDefs::getAvatarFromGpgId(gpgId, avatar, ":/images/user/personal64.png");
|
||||
} else {
|
||||
rsMsgs->getAvatarData(peer_id,data,size);
|
||||
AvatarDefs::getAvatarFromSslId(peer_id, avatar, ":/images/user/personal64.png");
|
||||
}
|
||||
}
|
||||
|
||||
if(size != 0) {
|
||||
// set the image
|
||||
QPixmap pix ;
|
||||
pix.loadFromData(data,size,"PNG") ;
|
||||
avatar->setPixmap(pix);
|
||||
delete[] data ;
|
||||
} else {
|
||||
avatar->setPixmap(QPixmap(":/images/user/personal64.png"));
|
||||
}
|
||||
avatarLabel->setPixmap(avatar);
|
||||
}
|
||||
|
@ -27,6 +27,7 @@
|
||||
#include "SubFileItem.h"
|
||||
#include "gui/msgs/MessageComposer.h"
|
||||
#include "gui/chat/HandleRichText.h"
|
||||
#include "gui/common/AvatarDefs.h"
|
||||
#include "gui/notifyqt.h"
|
||||
|
||||
#include <retroshare/rsmsgs.h>
|
||||
@ -283,23 +284,8 @@ void MsgItem::updateAvatar(const QString &peer_id)
|
||||
return;
|
||||
}
|
||||
|
||||
unsigned char *data = NULL;
|
||||
int size = 0 ;
|
||||
|
||||
rsMsgs->getAvatarData(mPeerId,data,size);
|
||||
|
||||
if(size != 0)
|
||||
{
|
||||
// set the image
|
||||
QPixmap pix ;
|
||||
pix.loadFromData(data,size,"PNG") ;
|
||||
avatarlabel->setPixmap(pix);
|
||||
delete[] data ;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
avatarlabel->setPixmap(QPixmap(":/images/user/personal64.png"));
|
||||
}
|
||||
QPixmap avatar;
|
||||
AvatarDefs::getAvatarFromSslId(mPeerId, avatar, ":/images/user/personal64.png");
|
||||
avatarlabel->setPixmap(avatar);
|
||||
}
|
||||
|
||||
|
@ -27,6 +27,7 @@
|
||||
#include "../RsAutoUpdatePage.h"
|
||||
#include "gui/msgs/MessageComposer.h"
|
||||
#include "gui/common/StatusDefs.h"
|
||||
#include "gui/common/AvatarDefs.h"
|
||||
|
||||
#include "gui/notifyqt.h"
|
||||
|
||||
@ -315,23 +316,9 @@ void PeerItem::updateAvatar(const QString &peer_id)
|
||||
return;
|
||||
}
|
||||
|
||||
unsigned char *data = NULL;
|
||||
int size = 0 ;
|
||||
|
||||
rsMsgs->getAvatarData(mPeerId,data,size);
|
||||
|
||||
if(size != 0)
|
||||
{
|
||||
// set the image
|
||||
QPixmap pix ;
|
||||
pix.loadFromData(data,size,"PNG") ;
|
||||
avatar_label->setPixmap(pix);
|
||||
delete[] data ;
|
||||
}
|
||||
else
|
||||
{
|
||||
avatar_label->setPixmap(QPixmap(":/images/user/personal64.png"));
|
||||
}
|
||||
QPixmap avatar;
|
||||
AvatarDefs::getAvatarFromSslId(mPeerId, avatar, ":/images/user/personal64.png");
|
||||
avatar_label->setPixmap(avatar);
|
||||
}
|
||||
|
||||
void PeerItem::togglequickmessage()
|
||||
|
@ -29,6 +29,7 @@
|
||||
#include "gui/msgs/MessageComposer.h"
|
||||
#include "gui/common/StatusDefs.h"
|
||||
#include "gui/connect/ConfCertDialog.h"
|
||||
#include "gui/common/AvatarDefs.h"
|
||||
|
||||
#include "gui/notifyqt.h"
|
||||
|
||||
@ -385,23 +386,9 @@ void SecurityItem::updateAvatar(const QString &peer_id)
|
||||
return;
|
||||
}
|
||||
|
||||
unsigned char *data = NULL;
|
||||
int size = 0 ;
|
||||
|
||||
rsMsgs->getAvatarData(mSslId, data, size);
|
||||
|
||||
if(size != 0)
|
||||
{
|
||||
// set the image
|
||||
QPixmap pix ;
|
||||
pix.loadFromData(data,size,"PNG") ;
|
||||
avatar_label->setPixmap(pix);
|
||||
delete[] data ;
|
||||
}
|
||||
else
|
||||
{
|
||||
avatar_label->setPixmap(QPixmap(":/images/user/personal64.png"));
|
||||
}
|
||||
QPixmap avatar;
|
||||
AvatarDefs::getAvatarFromSslId(mSslId, avatar, ":/images/user/personal64.png");
|
||||
avatar_label->setPixmap(avatar);
|
||||
}
|
||||
|
||||
void SecurityItem::togglequickmessage()
|
||||
|
@ -456,15 +456,11 @@ void NotifyQt::UpdateGUI()
|
||||
|
||||
/* id the name */
|
||||
QString name;
|
||||
unsigned char *data = NULL;
|
||||
int size = 0 ;
|
||||
|
||||
if (type == RS_POPUP_DOWNLOAD) {
|
||||
/* id = file hash */
|
||||
} else {
|
||||
name = QString::fromUtf8(rsPeers->getPeerName(id).c_str());
|
||||
|
||||
rsMsgs->getAvatarData(id,data,size);
|
||||
}
|
||||
|
||||
switch(type)
|
||||
@ -478,18 +474,7 @@ void NotifyQt::UpdateGUI()
|
||||
case RS_POPUP_CONNECT:
|
||||
if (popupflags & RS_POPUP_CONNECT)
|
||||
{
|
||||
QPixmap avatar;
|
||||
if(size != 0)
|
||||
{
|
||||
// set the image
|
||||
avatar.loadFromData(data,size,"PNG");
|
||||
}
|
||||
else
|
||||
{
|
||||
avatar = QPixmap(":/images/user/personal64.png");
|
||||
}
|
||||
|
||||
toaster = new Toaster(new OnlineToaster(id, name, avatar));
|
||||
toaster = new Toaster(new OnlineToaster(id, name));
|
||||
}
|
||||
break;
|
||||
case RS_POPUP_DOWNLOAD:
|
||||
@ -500,10 +485,6 @@ void NotifyQt::UpdateGUI()
|
||||
break;
|
||||
}
|
||||
|
||||
if (data) {
|
||||
delete[] data;
|
||||
}
|
||||
|
||||
if (toaster) {
|
||||
/* init attributes */
|
||||
toaster->widget->setWindowFlags(Qt::ToolTip | Qt::WindowStaysOnTopHint);
|
||||
|
@ -23,8 +23,9 @@
|
||||
#include "gui/settings/rsharesettings.h"
|
||||
#include "gui/chat/PopupChatDialog.h"
|
||||
#include "util/WidgetBackgroundImage.h"
|
||||
#include "gui/common/AvatarDefs.h"
|
||||
|
||||
OnlineToaster::OnlineToaster(const std::string &peerId, const QString &name, const QPixmap &avatar) : QWidget(NULL)
|
||||
OnlineToaster::OnlineToaster(const std::string &peerId, const QString &name) : QWidget(NULL)
|
||||
{
|
||||
/* Invoke the Qt Designer generated object setup routine */
|
||||
ui.setupUi(this);
|
||||
@ -37,6 +38,9 @@ OnlineToaster::OnlineToaster(const std::string &peerId, const QString &name, con
|
||||
|
||||
/* set informations */
|
||||
ui.messageLabel->setText(name);
|
||||
|
||||
QPixmap avatar;
|
||||
AvatarDefs::getAvatarFromSslId(peerId, avatar, ":/images/user/personal64.png");
|
||||
ui.pixmaplabel->setPixmap(avatar);
|
||||
|
||||
WidgetBackgroundImage::setBackgroundImage(ui.windowFrame, ":images/toaster/backgroundtoaster.png", WidgetBackgroundImage::AdjustNone);
|
||||
|
@ -32,7 +32,7 @@ class OnlineToaster : public QWidget
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
OnlineToaster(const std::string &peerId, const QString &name, const QPixmap &avatar);
|
||||
OnlineToaster(const std::string &peerId, const QString &name);
|
||||
|
||||
private slots:
|
||||
void chatButtonSlot();
|
||||
|
@ -21,6 +21,7 @@
|
||||
|
||||
#include "gui/profile/ProfileView.h"
|
||||
#include "gui/profile/ProfileEdit.h"
|
||||
#include "gui/common/AvatarDefs.h"
|
||||
|
||||
#include <retroshare/rspeers.h>
|
||||
#include <retroshare/rsmsgs.h>
|
||||
@ -286,26 +287,9 @@ void ProfileView::filesClear()
|
||||
void ProfileView::loadAvatar()
|
||||
{
|
||||
|
||||
unsigned char *data = NULL;
|
||||
int size = 0 ;
|
||||
|
||||
rsMsgs->getAvatarData(pId,data,size);
|
||||
|
||||
|
||||
if(size != 0)
|
||||
{
|
||||
// set the image
|
||||
QPixmap pix ;
|
||||
pix.loadFromData(data,size,"PNG") ;
|
||||
ui.photoLabel->setPixmap(pix);
|
||||
delete[] data ;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
ui.photoLabel->setPixmap(QPixmap(":/images/user/personal64.png"));
|
||||
}
|
||||
|
||||
|
||||
QPixmap avatar;
|
||||
AvatarDefs::getAvatarFromSslId(pId, avatar, ":/images/user/personal64.png");
|
||||
ui.avatarlabel->setPixmap(avatar);
|
||||
ui.photoLabel->setPixmap(avatar);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user