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
This commit is contained in:
defnax 2010-06-05 22:42:32 +00:00
parent 619a2d7491
commit 3056ec0875
3 changed files with 148 additions and 48 deletions

View File

@ -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<std::string>::iterator cont_it = sslContacts.begin();
std::list<std::string>::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)));

View File

@ -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<std::string> gpgFriends;
std::list<std::string>::iterator it;
std::list<std::string>::iterator it;
std::list<StatusInfo> 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<StatusInfo>::iterator it = statusInfo.begin();
for(; it != statusInfo.end() ; it++){
std::list<std::string>::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)));

View File

@ -401,6 +401,8 @@
<file>images/user/identity16.png</file>
<file>images/user/identity24.png</file>
<file>images/user/identityoffline24.png</file>
<file>images/user/identity24away.png</file>
<file>images/user/identity24busy.png</file>
<file>images/user/identitylightgrey24.png</file>
<file>images/user/identityavaiblecyan24.png</file>
<file>images/user/identityunreachable24.png</file>