diff --git a/retroshare-gui/src/RetroShare.pro b/retroshare-gui/src/RetroShare.pro index c83142ebc..542045420 100644 --- a/retroshare-gui/src/RetroShare.pro +++ b/retroshare-gui/src/RetroShare.pro @@ -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 \ diff --git a/retroshare-gui/src/gui/FriendsDialog.cpp b/retroshare-gui/src/gui/FriendsDialog.cpp index 97bda40eb..e27ba38b3 100644 --- a/retroshare-gui/src/gui/FriendsDialog.cpp +++ b/retroshare-gui/src/gui/FriendsDialog.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() diff --git a/retroshare-gui/src/gui/MessengerWindow.cpp b/retroshare-gui/src/gui/MessengerWindow.cpp index 3dbd39c56..612db2068 100644 --- a/retroshare-gui/src/gui/MessengerWindow.cpp +++ b/retroshare-gui/src/gui/MessengerWindow.cpp @@ -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") ; - 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"))); - } + QPixmap avatar; + AvatarDefs::getAvatarFromSslId(it->id, avatar, ":/images/no_avatar_70.png"); + QIcon avatar_icon(avatar); + 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() diff --git a/retroshare-gui/src/gui/chat/PopupChatDialog.cpp b/retroshare-gui/src/gui/chat/PopupChatDialog.cpp index d23941e47..cff6a5337 100644 --- a/retroshare-gui/src/gui/chat/PopupChatDialog.cpp +++ b/retroshare-gui/src/gui/chat/PopupChatDialog.cpp @@ -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::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 - std::cerr << "popupchatDialog::updatePeerAvatar() updating avatar for peer " << peer_id << std::endl ; - std::cerr << "Requesting avatar image for peer " << peer_id << std::endl ; - #endif +#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 - 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() diff --git a/retroshare-gui/src/gui/chat/PopupChatDialog.h b/retroshare-gui/src/gui/chat/PopupChatDialog.h index 0a323ddc0..b1dca12ef 100644 --- a/retroshare-gui/src/gui/chat/PopupChatDialog.h +++ b/retroshare-gui/src/gui/chat/PopupChatDialog.h @@ -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() ; diff --git a/retroshare-gui/src/gui/common/AvatarDefs.cpp b/retroshare-gui/src/gui/common/AvatarDefs.cpp new file mode 100644 index 000000000..ed582f60e --- /dev/null +++ b/retroshare-gui/src/gui/common/AvatarDefs.cpp @@ -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 + +#include +#include + +#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 sslIds; + if (rsPeers->getAssociatedSSLIds(gpgId, sslIds)) { + std::list::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; +} diff --git a/retroshare-gui/src/gui/common/AvatarDefs.h b/retroshare-gui/src/gui/common/AvatarDefs.h new file mode 100644 index 000000000..c79a3a797 --- /dev/null +++ b/retroshare-gui/src/gui/common/AvatarDefs.h @@ -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 +#include + +#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 + diff --git a/retroshare-gui/src/gui/connect/ConfCertDialog.cpp b/retroshare-gui/src/gui/connect/ConfCertDialog.cpp index f9f2245aa..a94c00a04 100644 --- a/retroshare-gui/src/gui/connect/ConfCertDialog.cpp +++ b/retroshare-gui/src/gui/connect/ConfCertDialog.cpp @@ -32,11 +32,14 @@ #include #include +#include #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); + } +} diff --git a/retroshare-gui/src/gui/connect/ConfCertDialog.h b/retroshare-gui/src/gui/connect/ConfCertDialog.h index 5900a7b8d..0ab9ae18a 100644 --- a/retroshare-gui/src/gui/connect/ConfCertDialog.h +++ b/retroshare-gui/src/gui/connect/ConfCertDialog.h @@ -60,8 +60,11 @@ private slots: /** Called when a child window requests the given help topic. */ void showHelpDialog(const QString &topic); + void updatePeersAvatar(const QString& peer_id); + private: std::string mId; + bool isOnlyGpg; /** Qt Designer generated object */ Ui::ConfCertDialog ui; diff --git a/retroshare-gui/src/gui/connect/ConfCertDialog.ui b/retroshare-gui/src/gui/connect/ConfCertDialog.ui index 31b9f8e4e..10ec06709 100644 --- a/retroshare-gui/src/gui/connect/ConfCertDialog.ui +++ b/retroshare-gui/src/gui/connect/ConfCertDialog.ui @@ -6,8 +6,8 @@ 0 0 - 520 - 639 + 469 + 528 @@ -21,7 +21,7 @@ - 1 + 0 @@ -31,8 +31,21 @@ Details - + + + + + 96 + 96 + + + + + + + + Peer Info @@ -160,10 +173,36 @@ + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + Qt::Vertical + + + + 68 + 126 + + + + + Peer Address @@ -327,7 +366,7 @@ - + Qt::Vertical diff --git a/retroshare-gui/src/gui/feeds/ChatMsgItem.cpp b/retroshare-gui/src/gui/feeds/ChatMsgItem.cpp index dcfa91e10..a36b6c8ac 100644 --- a/retroshare-gui/src/gui/feeds/ChatMsgItem.cpp +++ b/retroshare-gui/src/gui/feeds/ChatMsgItem.cpp @@ -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,25 +229,10 @@ 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() { diff --git a/retroshare-gui/src/gui/feeds/ForumMsgItem.cpp b/retroshare-gui/src/gui/feeds/ForumMsgItem.cpp index cc4461993..5b0d60cc9 100644 --- a/retroshare-gui/src/gui/feeds/ForumMsgItem.cpp +++ b/retroshare-gui/src/gui/feeds/ForumMsgItem.cpp @@ -34,6 +34,7 @@ #include "gui/forums/CreateForumMsg.h" #include "gui/chat/HandleRichText.h" +#include "gui/common/AvatarDefs.h" #include @@ -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 sslIds; - if (rsPeers->getAssociatedSSLIds(gpgId, sslIds) == false) { - return; - } - - std::list::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); } diff --git a/retroshare-gui/src/gui/feeds/MsgItem.cpp b/retroshare-gui/src/gui/feeds/MsgItem.cpp index 221e223c7..9eff852cc 100644 --- a/retroshare-gui/src/gui/feeds/MsgItem.cpp +++ b/retroshare-gui/src/gui/feeds/MsgItem.cpp @@ -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 @@ -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); +} diff --git a/retroshare-gui/src/gui/feeds/PeerItem.cpp b/retroshare-gui/src/gui/feeds/PeerItem.cpp index 6fee61eca..2b69ee7f6 100644 --- a/retroshare-gui/src/gui/feeds/PeerItem.cpp +++ b/retroshare-gui/src/gui/feeds/PeerItem.cpp @@ -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,24 +316,10 @@ 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() { diff --git a/retroshare-gui/src/gui/feeds/SecurityItem.cpp b/retroshare-gui/src/gui/feeds/SecurityItem.cpp index 91ed195bc..144608eba 100644 --- a/retroshare-gui/src/gui/feeds/SecurityItem.cpp +++ b/retroshare-gui/src/gui/feeds/SecurityItem.cpp @@ -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() diff --git a/retroshare-gui/src/gui/notifyqt.cpp b/retroshare-gui/src/gui/notifyqt.cpp index c18c6b090..3d12d74a4 100644 --- a/retroshare-gui/src/gui/notifyqt.cpp +++ b/retroshare-gui/src/gui/notifyqt.cpp @@ -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); diff --git a/retroshare-gui/src/gui/toaster/OnlineToaster.cpp b/retroshare-gui/src/gui/toaster/OnlineToaster.cpp index 7ece1dc65..75a45838c 100644 --- a/retroshare-gui/src/gui/toaster/OnlineToaster.cpp +++ b/retroshare-gui/src/gui/toaster/OnlineToaster.cpp @@ -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); diff --git a/retroshare-gui/src/gui/toaster/OnlineToaster.h b/retroshare-gui/src/gui/toaster/OnlineToaster.h index 1a4515a7a..c2bf9fbba 100644 --- a/retroshare-gui/src/gui/toaster/OnlineToaster.h +++ b/retroshare-gui/src/gui/toaster/OnlineToaster.h @@ -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(); diff --git a/retroshare-gui/src/gui/unfinished/profile/ProfileView.cpp b/retroshare-gui/src/gui/unfinished/profile/ProfileView.cpp index 48c6a6239..50e0da535 100644 --- a/retroshare-gui/src/gui/unfinished/profile/ProfileView.cpp +++ b/retroshare-gui/src/gui/unfinished/profile/ProfileView.cpp @@ -21,6 +21,7 @@ #include "gui/profile/ProfileView.h" #include "gui/profile/ProfileEdit.h" +#include "gui/common/AvatarDefs.h" #include #include @@ -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); }