From 3056ec087521e7a3fb09b46d163c67e17f125ca5 Mon Sep 17 00:00:00 2001 From: defnax Date: Sat, 5 Jun 2010 22:42:32 +0000 Subject: [PATCH] Added to display Friends rsstatus on PeersDialog, icon and color change when Friend is Idle, Away or Busy git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@3075 b45a01b8-16f6-495d-af2f-9b41ad6348cc --- retroshare-gui/src/gui/MessengerWindow.cpp | 112 +++++++++++++-------- retroshare-gui/src/gui/PeersDialog.cpp | 82 ++++++++++++++- retroshare-gui/src/gui/images.qrc | 2 + 3 files changed, 148 insertions(+), 48 deletions(-) diff --git a/retroshare-gui/src/gui/MessengerWindow.cpp b/retroshare-gui/src/gui/MessengerWindow.cpp index a9456ce2a..60237b6bf 100644 --- a/retroshare-gui/src/gui/MessengerWindow.cpp +++ b/retroshare-gui/src/gui/MessengerWindow.cpp @@ -343,6 +343,8 @@ void MessengerWindow::insertPeers() gpg_item->setData(0, Qt::UserRole, true); gpg_item -> setTextAlignment(0, Qt::AlignLeft | Qt::AlignVCenter ); + + gpg_item -> setSizeHint(0, QSize( 27,27 ) ); /* not displayed, used to find back the item */ gpg_item -> setText(3, QString::fromStdString(detail.id)); @@ -468,65 +470,87 @@ void MessengerWindow::insertPeers() for(; it != statusInfo.end() ; it++){ - std::list::iterator cont_it = sslContacts.begin(); + std::list::iterator cont_it = sslContacts.begin(); - // don't forget the kids - for(; cont_it != sslContacts.end(); cont_it++){ + // don't forget the kids + for(; cont_it != sslContacts.end(); cont_it++){ - if((it->id == *cont_it) && (rsPeers->isOnline(*cont_it))){ + if((it->id == *cont_it) && (rsPeers->isOnline(*cont_it))){ std::string status; rsStatus->getStatusString(it->status, status); gpg_item -> setText(1, QString::fromStdString(status)); + + QFont font; + font.setBold(true); - unsigned char *data = NULL; - int size = 0 ; - rsMsgs->getAvatarData(it->id ,data,size); + unsigned char *data = NULL; + int size = 0 ; + rsMsgs->getAvatarData(it->id ,data,size); - if(size != 0){ + if(size != 0){ - QPixmap avatar ; - avatar.loadFromData(data,size,"PNG") ; - QIcon avatar_icon(avatar); - QSize av_icon_size(100, 100); - gpg_item-> setIcon(1, avatar_icon); - delete[] data; + QPixmap avatar ; + avatar.loadFromData(data,size,"PNG") ; + QIcon avatar_icon(avatar); + QSize av_icon_size(100, 100); + gpg_item-> setIcon(1, avatar_icon); + delete[] data; - }else - { - gpg_item -> setIcon(1,(QIcon(":/images/no_avatar_70.png"))); - } - if(it->status == RS_STATUS_INACTIVE){ - gpg_item -> setIcon(0,(QIcon(IMAGE_INACTIVE))); - gpg_item -> setToolTip(0, tr("Peer Idle")); - } - else - if(it->status == RS_STATUS_ONLINE){ - gpg_item -> setIcon(0,(QIcon(IMAGE_ONLINE))); - gpg_item -> setToolTip(0, tr("Peer Online")); - } - else - if(it->status == RS_STATUS_AWAY){ - gpg_item -> setIcon(0,(QIcon(IMAGE_AWAY))); - gpg_item -> setToolTip(0, tr("Peer Away")); - } - else - if(it->status == RS_STATUS_BUSY){ - gpg_item -> setIcon(0,(QIcon(IMAGE_BUSY))); - gpg_item -> setToolTip(0, tr("Peer Busy")); - } - } + }else + { + gpg_item -> setIcon(1,(QIcon(":/images/no_avatar_70.png"))); + } + if(it->status == RS_STATUS_INACTIVE) + { + gpg_item -> setIcon(0,(QIcon(IMAGE_INACTIVE))); + gpg_item -> setToolTip(0, tr("Peer Idle")); + + for(i = 0; i < 3; i++) { + gpg_item -> setTextColor(i,(Qt::gray)); + gpg_item -> setFont(i,font); + } + } + else + if(it->status == RS_STATUS_ONLINE) + { + gpg_item -> setIcon(0,(QIcon(IMAGE_ONLINE))); + gpg_item -> setToolTip(0, tr("Peer Online")); + + for(i = 0; i < 3; i++) { + gpg_item -> setTextColor(i,(Qt::darkBlue)); + gpg_item -> setFont(i,font); } + } + else + if(it->status == RS_STATUS_AWAY) + { + gpg_item -> setIcon(0,(QIcon(IMAGE_AWAY))); + gpg_item -> setToolTip(0, tr("Peer Away")); + + for(i = 0; i < 3; i++) { + gpg_item -> setTextColor(i,(Qt::gray)); + gpg_item -> setFont(i,font); + } + } + else + if(it->status == RS_STATUS_BUSY) + { + gpg_item -> setIcon(0,(QIcon(IMAGE_BUSY))); + gpg_item -> setToolTip(0, tr("Peer Busy")); + + for(i = 0; i < 3; i++) { + gpg_item -> setTextColor(i,(Qt::gray)); + gpg_item -> setFont(i,font); + } + } + + } + } } - QFont font; - font.setBold(true); - for(i = 0; i < 3; i++) { - gpg_item -> setTextColor(i,(Qt::darkBlue)); - gpg_item -> setFont(i,font); - } } else if (gpg_online) { gpg_item->setHidden(ui.actionHide_Offline_Friends->isChecked()); gpg_item -> setIcon(0,(QIcon(IMAGE_AVAIBLE))); diff --git a/retroshare-gui/src/gui/PeersDialog.cpp b/retroshare-gui/src/gui/PeersDialog.cpp index 8ed229b9b..23d12e6f4 100644 --- a/retroshare-gui/src/gui/PeersDialog.cpp +++ b/retroshare-gui/src/gui/PeersDialog.cpp @@ -62,6 +62,9 @@ #define IMAGE_CONNECT ":/images/connect_friend.png" /* Images for Status icons */ #define IMAGE_ONLINE ":/images/user/identity24.png" +#define IMAGE_AWAY ":/images/user/identity24away.png" +#define IMAGE_BUSY ":/images/user/identity24busy.png" +#define IMAGE_INACTIVE ":/images/user/identity24away.png" #define IMAGE_OFFLINE ":/images/user/identityoffline24.png" #define IMAGE_OFFLINE2 ":/images/user/identitylightgrey24.png" #define IMAGE_AVAIBLE ":/images/user/identityavaiblecyan24.png" @@ -361,7 +364,10 @@ void PeersDialog::insertPeers() std::cerr << "PeersDialog::insertPeers() called." << std::endl; #endif std::list gpgFriends; - std::list::iterator it; + std::list::iterator it; + + std::list statusInfo; + rsStatus->getStatus(statusInfo); if (!rsPeers) { /* not ready yet! */ @@ -557,12 +563,80 @@ void PeersDialog::insertPeers() gpg_item->setHidden(false); gpg_item -> setIcon(0,(QIcon(IMAGE_ONLINE))); gpg_item -> setText(1, tr("Online")); - QFont font; - font.setBold(true); - for(i = 0; i < 3; i++) { + + std::list::iterator it = statusInfo.begin(); + + for(; it != statusInfo.end() ; it++){ + + std::list::iterator cont_it = sslContacts.begin(); + + // don't forget the kids + for(; cont_it != sslContacts.end(); cont_it++){ + + + if((it->id == *cont_it) && (rsPeers->isOnline(*cont_it))){ + + std::string status; + rsStatus->getStatusString(it->status, status); + gpg_item -> setText(2, QString::fromStdString(status)); + + QFont font; + font.setBold(true); + + + if(it->status == RS_STATUS_INACTIVE) + { + gpg_item -> setIcon(0,(QIcon(IMAGE_INACTIVE))); + gpg_item -> setToolTip(0, tr("Peer Idle")); + gpg_item -> setText(1, tr("Idle")); + + for(i = 0; i < 3; i++) { + gpg_item -> setTextColor(i,(Qt::gray)); + gpg_item -> setFont(i,font); + } + } + else + if(it->status == RS_STATUS_ONLINE) + { + gpg_item -> setIcon(0,(QIcon(IMAGE_ONLINE))); + gpg_item -> setToolTip(0, tr("Peer Online")); + gpg_item -> setText(1, tr("Online")); + + for(i = 0; i < 3; i++) { gpg_item -> setTextColor(i,(Qt::darkBlue)); gpg_item -> setFont(i,font); + } + } + else + if(it->status == RS_STATUS_AWAY) + { + gpg_item -> setIcon(0,(QIcon(IMAGE_AWAY))); + gpg_item -> setToolTip(0, tr("Peer Away")); + gpg_item -> setText(1, tr("Away")); + + for(i = 0; i < 3; i++) { + gpg_item -> setTextColor(i,(Qt::gray)); + gpg_item -> setFont(i,font); + } + } + else + if(it->status == RS_STATUS_BUSY) + { + gpg_item -> setIcon(0,(QIcon(IMAGE_BUSY))); + gpg_item -> setToolTip(0, tr("Peer Busy")); + gpg_item -> setText(1, tr("Busy")); + + for(i = 0; i < 3; i++) { + gpg_item -> setTextColor(i,(Qt::gray)); + gpg_item -> setFont(i,font); + } + } + } + } } + + + } else if (gpg_online) { gpg_item->setHidden(ui.hide_unconnected->isChecked()); gpg_item -> setIcon(0,(QIcon(IMAGE_AVAIBLE))); diff --git a/retroshare-gui/src/gui/images.qrc b/retroshare-gui/src/gui/images.qrc index 3cf078304..0448447e0 100644 --- a/retroshare-gui/src/gui/images.qrc +++ b/retroshare-gui/src/gui/images.qrc @@ -401,6 +401,8 @@ images/user/identity16.png images/user/identity24.png images/user/identityoffline24.png + images/user/identity24away.png + images/user/identity24busy.png images/user/identitylightgrey24.png images/user/identityavaiblecyan24.png images/user/identityunreachable24.png