Show the connected gpg item with no state information in PeersDialog and MessengerWindow as online.

Added state string "Offline" to p3Status::getStatusString.

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@3470 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
thunder2 2010-09-11 20:25:08 +00:00
parent c854b9feb1
commit 3759f8de6f
4 changed files with 153 additions and 153 deletions

View File

@ -59,23 +59,23 @@ bool p3Status::sendStatus(std::string id, uint32_t status){
void p3Status::getStatusString(uint32_t status, std::string& statusString){ void p3Status::getStatusString(uint32_t status, std::string& statusString){
if (status == RS_STATUS_AWAY){ switch (status) {
case RS_STATUS_OFFLINE:
statusString = "Offline";
break;
case RS_STATUS_AWAY:
statusString = "Away"; statusString = "Away";
break;
}else if (status == RS_STATUS_BUSY){ case RS_STATUS_BUSY:
statusString = "Busy"; statusString = "Busy";
break;
}else if (status == RS_STATUS_ONLINE){ case RS_STATUS_ONLINE:
statusString = "Online";
statusString = "Online"; break;
case RS_STATUS_INACTIVE:
}else if(status == RS_STATUS_INACTIVE){ statusString = "Inactive";
break;
statusString = "Inactive"; default:
statusString.erase();
} }
return;
} }

View File

@ -997,24 +997,29 @@ void MainWindow::initializeStatusObject(QObject *pObject, bool bConnect)
m_apStatusObjects.insert(m_apStatusObjects.end(), pObject); m_apStatusObjects.insert(m_apStatusObjects.end(), pObject);
std::string statusString;
QMenu *pMenu = dynamic_cast<QMenu*>(pObject); QMenu *pMenu = dynamic_cast<QMenu*>(pObject);
if (pMenu) { if (pMenu) {
/* initialize menu */ /* initialize menu */
QActionGroup *pGroup = new QActionGroup(pMenu); QActionGroup *pGroup = new QActionGroup(pMenu);
QAction *pAction = new QAction(QIcon(":/images/im-user.png"), tr("Online"), pMenu); rsStatus->getStatusString(RS_STATUS_ONLINE, statusString);
QAction *pAction = new QAction(QIcon(":/images/im-user.png"), tr(statusString.c_str()), pMenu);
pAction->setData(RS_STATUS_ONLINE); pAction->setData(RS_STATUS_ONLINE);
pAction->setCheckable(true); pAction->setCheckable(true);
pMenu->addAction(pAction); pMenu->addAction(pAction);
pGroup->addAction(pAction); pGroup->addAction(pAction);
pAction = new QAction(QIcon(":/images/im-user-busy.png"), tr("Busy"), pMenu); rsStatus->getStatusString(RS_STATUS_BUSY, statusString);
pAction = new QAction(QIcon(":/images/im-user-busy.png"), tr(statusString.c_str()), pMenu);
pAction->setData(RS_STATUS_BUSY); pAction->setData(RS_STATUS_BUSY);
pAction->setCheckable(true); pAction->setCheckable(true);
pMenu->addAction(pAction); pMenu->addAction(pAction);
pGroup->addAction(pAction); pGroup->addAction(pAction);
pAction = new QAction(QIcon(":/images/im-user-away.png"), tr("Away"), pMenu); rsStatus->getStatusString(RS_STATUS_AWAY, statusString);
pAction = new QAction(QIcon(":/images/im-user-away.png"), tr(statusString.c_str()), pMenu);
pAction->setData(RS_STATUS_AWAY); pAction->setData(RS_STATUS_AWAY);
pAction->setCheckable(true); pAction->setCheckable(true);
pMenu->addAction(pAction); pMenu->addAction(pAction);
@ -1027,9 +1032,12 @@ void MainWindow::initializeStatusObject(QObject *pObject, bool bConnect)
/* initialize combobox */ /* initialize combobox */
QComboBox *pComboBox = dynamic_cast<QComboBox*>(pObject); QComboBox *pComboBox = dynamic_cast<QComboBox*>(pObject);
if (pComboBox) { if (pComboBox) {
pComboBox->addItem(QIcon(":/images/im-user.png"), tr("Online"), RS_STATUS_ONLINE); rsStatus->getStatusString(RS_STATUS_ONLINE, statusString);
pComboBox->addItem(QIcon(":/images/im-user-busy.png"), tr("Busy"), RS_STATUS_BUSY); pComboBox->addItem(QIcon(":/images/im-user.png"), tr(statusString.c_str()), RS_STATUS_ONLINE);
pComboBox->addItem(QIcon(":/images/im-user-away.png"), tr("Away"), RS_STATUS_AWAY); rsStatus->getStatusString(RS_STATUS_BUSY, statusString);
pComboBox->addItem(QIcon(":/images/im-user-busy.png"), tr(statusString.c_str()), RS_STATUS_BUSY);
rsStatus->getStatusString(RS_STATUS_AWAY, statusString);
pComboBox->addItem(QIcon(":/images/im-user-away.png"), tr(statusString.c_str()), RS_STATUS_AWAY);
if (bConnect) { if (bConnect) {
connect(pComboBox, SIGNAL(activated(int)), this, SLOT(statusChangedComboBox(int))); connect(pComboBox, SIGNAL(activated(int)), this, SLOT(statusChangedComboBox(int)));

View File

@ -503,10 +503,6 @@ void MessengerWindow::insertPeers()
//add the gpg friends //add the gpg friends
for(it = gpgFriends.begin(); it != gpgFriends.end(); it++) { for(it = gpgFriends.begin(); it != gpgFriends.end(); it++) {
// if (*it == sOwnId) {
// continue;
// }
/* make a widget per friend */ /* make a widget per friend */
QTreeWidgetItem *gpg_item = NULL; QTreeWidgetItem *gpg_item = NULL;
QTreeWidgetItem *gpg_item_loop = NULL; QTreeWidgetItem *gpg_item_loop = NULL;
@ -770,87 +766,85 @@ void MessengerWindow::insertPeers()
} }
} }
if (bestPeerState) { if (bestPeerState == 0) {
QFont font; // show as online
font.setBold(true); bestPeerState = PEER_STATE_ONLINE;
}
QString stateString; QFont font;
font.setBold(true);
switch (bestPeerState) { QString stateString;
case PEER_STATE_INACTIVE:
gpgIcon = QIcon(IMAGE_INACTIVE);
gpg_item -> setToolTip(COLUMN_NAME, tr("Peer Idle"));
stateString = tr("Idle");
for(i = 0; i < COLUMN_COUNT; i++) { switch (bestPeerState) {
gpg_item -> setTextColor(i,(Qt::gray)); case PEER_STATE_INACTIVE:
gpg_item -> setFont(i,font); gpgIcon = QIcon(IMAGE_INACTIVE);
} gpg_item -> setToolTip(COLUMN_NAME, tr("Peer Idle"));
break; stateString = tr("Idle");
case PEER_STATE_ONLINE: for(i = 0; i < COLUMN_COUNT; i++) {
gpgIcon = QIcon(IMAGE_ONLINE); gpg_item -> setTextColor(i,(Qt::gray));
gpg_item -> setToolTip(COLUMN_NAME, tr("Peer Online")); gpg_item -> setFont(i,font);
stateString = tr("Online");
for(i = 0; i < COLUMN_COUNT; i++) {
gpg_item -> setTextColor(i,(Qt::darkBlue));
gpg_item -> setFont(i,font);
}
break;
case PEER_STATE_AWAY:
gpgIcon = QIcon(IMAGE_AWAY);
gpg_item -> setToolTip(COLUMN_NAME, tr("Peer Away"));
stateString = tr("Away");
for(i = 0; i < COLUMN_COUNT; i++) {
gpg_item -> setTextColor(i,(Qt::gray));
gpg_item -> setFont(i,font);
}
break;
case PEER_STATE_BUSY:
gpgIcon = QIcon(IMAGE_BUSY);
gpg_item -> setToolTip(COLUMN_NAME, tr("Peer Busy"));
stateString = tr("Busy");
for(i = 0; i < COLUMN_COUNT; i++) {
gpg_item -> setTextColor(i,(Qt::gray));
gpg_item -> setFont(i,font);
}
break;
} }
gpg_item->setText(COLUMN_NAME, QString::fromStdString(detail.name)); break;
std::map<std::string, QString>::iterator customStateString = sslCustomStateStrings.find(bestSslId); case PEER_STATE_ONLINE:
if (customStateString == sslCustomStateStrings.end()) { gpgIcon = QIcon(IMAGE_ONLINE);
// std::map<std::string, std::string>::iterator location = sslLocations.find(bestSslId); gpg_item -> setToolTip(COLUMN_NAME, tr("Peer Online"));
// if (location == sslLocations.end()) { stateString = tr("Online");
// /* show only the name */
// gpg_item->setText(COLUMN_NAME, QString::fromStdString(detail.name));
// } else {
// /* show the name with location */
// gpg_item->setText(COLUMN_NAME, QString::fromStdString(detail.name) + "\n" + QString::fromStdString(location->second));
// }
/* use state string for location */ for(i = 0; i < COLUMN_COUNT; i++) {
if (stateString.isEmpty()) { gpg_item -> setTextColor(i,(Qt::darkBlue));
/* show only the name */ gpg_item -> setFont(i,font);
gpg_item->setText(COLUMN_NAME, QString::fromStdString(detail.name)); }
} else { break;
/* show the name with location */
gpg_item->setText(COLUMN_NAME, QString::fromStdString(detail.name) + "\n" + stateString); case PEER_STATE_AWAY:
} gpgIcon = QIcon(IMAGE_AWAY);
gpg_item -> setToolTip(COLUMN_NAME, tr("Peer Away"));
stateString = tr("Away");
for(i = 0; i < COLUMN_COUNT; i++) {
gpg_item -> setTextColor(i,(Qt::gray));
gpg_item -> setFont(i,font);
}
break;
case PEER_STATE_BUSY:
gpgIcon = QIcon(IMAGE_BUSY);
gpg_item -> setToolTip(COLUMN_NAME, tr("Peer Busy"));
stateString = tr("Busy");
for(i = 0; i < COLUMN_COUNT; i++) {
gpg_item -> setTextColor(i,(Qt::gray));
gpg_item -> setFont(i,font);
}
break;
}
gpg_item->setText(COLUMN_NAME, QString::fromStdString(detail.name));
std::map<std::string, QString>::iterator customStateString = sslCustomStateStrings.find(bestSslId);
if (customStateString == sslCustomStateStrings.end()) {
// std::map<std::string, std::string>::iterator location = sslLocations.find(bestSslId);
// if (location == sslLocations.end()) {
// /* show only the name */
// gpg_item->setText(COLUMN_NAME, QString::fromStdString(detail.name));
// } else {
// /* show the name with location */
// gpg_item->setText(COLUMN_NAME, QString::fromStdString(detail.name) + "\n" + QString::fromStdString(location->second));
// }
/* use state string for location */
if (stateString.isEmpty()) {
/* show only the name */
gpg_item->setText(COLUMN_NAME, QString::fromStdString(detail.name));
} else { } else {
/* show the name with custom state string */ /* show the name with location */
gpg_item->setText(COLUMN_NAME, QString::fromStdString(detail.name) + "\n" + customStateString->second); gpg_item->setText(COLUMN_NAME, QString::fromStdString(detail.name) + "\n" + stateString);
} }
} else { } else {
/* show only the name */ /* show the name with custom state string */
gpgIcon = QIcon(IMAGE_ONLINE); gpg_item->setText(COLUMN_NAME, QString::fromStdString(detail.name) + "\n" + customStateString->second);
gpg_item->setText(COLUMN_NAME, QString::fromStdString(detail.name));
bestPeerState = PEER_STATE_ONLINE; // show as online
} }
gpg_item->setData(COLUMN_NAME, ROLE_SORT, BuildStateSortString(sortState, gpg_item->text(COLUMN_NAME), bestPeerState)); gpg_item->setData(COLUMN_NAME, ROLE_SORT, BuildStateSortString(sortState, gpg_item->text(COLUMN_NAME), bestPeerState));
@ -1213,31 +1207,29 @@ void MessengerWindow::updateOwnStatus(const QString &peer_id, int status)
if (peer_id.toStdString() == rsPeers->getOwnId()) if (peer_id.toStdString() == rsPeers->getOwnId())
{ {
// my status has changed // my status has changed
std::string statusString;
rsStatus->getStatusString(status, statusString);
ui.statusButton->setText(m_nickName + " (" + tr(statusString.c_str()) + ")");
switch (status) { switch (status) {
case RS_STATUS_OFFLINE: case RS_STATUS_OFFLINE:
ui.avatarButton->setStyleSheet("QToolButton#avatarButton{border-image:url(:/images/mystatus_bg_offline.png); }"); ui.avatarButton->setStyleSheet("QToolButton#avatarButton{border-image:url(:/images/mystatus_bg_offline.png); }");
ui.statusButton->setText(m_nickName + tr(" ") + tr("(Offline)"));
break; break;
case RS_STATUS_INACTIVE: case RS_STATUS_INACTIVE:
ui.avatarButton->setStyleSheet("QToolButton#avatarButton{border-image:url(:/images/mystatus_bg_idle.png); }"); ui.avatarButton->setStyleSheet("QToolButton#avatarButton{border-image:url(:/images/mystatus_bg_idle.png); }");
ui.statusButton->setText(m_nickName + tr(" ") + tr("(Idle)"));
break; break;
case RS_STATUS_ONLINE: case RS_STATUS_ONLINE:
ui.avatarButton->setStyleSheet("QToolButton#avatarButton{border-image:url(:/images/mystatus_bg_online.png); }"); ui.avatarButton->setStyleSheet("QToolButton#avatarButton{border-image:url(:/images/mystatus_bg_online.png); }");
ui.statusButton->setText(m_nickName + tr(" ") + tr("(Online)"));
break; break;
case RS_STATUS_AWAY: case RS_STATUS_AWAY:
ui.avatarButton->setStyleSheet("QToolButton#avatarButton{border-image:url(:/images/mystatus_bg_idle.png); }"); ui.avatarButton->setStyleSheet("QToolButton#avatarButton{border-image:url(:/images/mystatus_bg_idle.png); }");
ui.statusButton->setText(m_nickName + tr(" ") + tr("(Away)"));
break; break;
case RS_STATUS_BUSY: case RS_STATUS_BUSY:
ui.avatarButton->setStyleSheet("QToolButton#avatarButton{border-image:url(:/images/mystatus_bg_busy.png); }"); ui.avatarButton->setStyleSheet("QToolButton#avatarButton{border-image:url(:/images/mystatus_bg_busy.png); }");
ui.statusButton->setText(m_nickName + tr(" ") + tr("(Busy)"));
break; break;
} }

View File

@ -766,58 +766,58 @@ void PeersDialog::insertPeers()
} }
} }
if (bestPeerState) { if (bestPeerState == 0) {
QFont font; // show as online
font.setBold(true); bestPeerState = PEER_STATE_ONLINE;
}
switch (bestPeerState) { QFont font;
case PEER_STATE_INACTIVE: font.setBold(true);
gpgIcon = QIcon(IMAGE_INACTIVE);
gpg_item -> setToolTip(COLUMN_NAME, tr("Peer Idle"));
gpg_item -> setText(COLUMN_STATE, tr("Idle"));
for(i = 0; i < COLUMN_COUNT; i++) { switch (bestPeerState) {
gpg_item -> setTextColor(i,(Qt::gray)); case PEER_STATE_INACTIVE:
gpg_item -> setFont(i,font); gpgIcon = QIcon(IMAGE_INACTIVE);
} gpg_item -> setToolTip(COLUMN_NAME, tr("Peer Idle"));
break; gpg_item -> setText(COLUMN_STATE, tr("Idle"));
case PEER_STATE_ONLINE: for(i = 0; i < COLUMN_COUNT; i++) {
gpgIcon = QIcon(IMAGE_ONLINE); gpg_item -> setTextColor(i,(Qt::gray));
gpg_item -> setToolTip(COLUMN_NAME, tr("Peer Online")); gpg_item -> setFont(i,font);
gpg_item -> setText(COLUMN_STATE, tr("Online"));
for(i = 0; i < COLUMN_COUNT; i++) {
gpg_item -> setTextColor(i,(Qt::darkBlue));
gpg_item -> setFont(i,font);
}
break;
case PEER_STATE_AWAY:
gpgIcon = QIcon(IMAGE_AWAY);
gpg_item -> setToolTip(COLUMN_NAME, tr("Peer Away"));
gpg_item -> setText(COLUMN_STATE, tr("Away"));
for(i = 0; i < COLUMN_COUNT; i++) {
gpg_item -> setTextColor(i,(Qt::gray));
gpg_item -> setFont(i,font);
}
break;
case PEER_STATE_BUSY:
gpgIcon = QIcon(IMAGE_BUSY);
gpg_item -> setToolTip(COLUMN_NAME, tr("Peer Busy"));
gpg_item -> setText(COLUMN_STATE, tr("Busy"));
for(i = 0; i < COLUMN_COUNT; i++) {
gpg_item -> setTextColor(i,(Qt::gray));
gpg_item -> setFont(i,font);
}
break;
} }
} else { break;
case PEER_STATE_ONLINE:
gpgIcon = QIcon(IMAGE_ONLINE); gpgIcon = QIcon(IMAGE_ONLINE);
bestPeerState = PEER_STATE_ONLINE; // show as online gpg_item -> setToolTip(COLUMN_NAME, tr("Peer Online"));
gpg_item -> setText(COLUMN_STATE, tr("Online"));
for(i = 0; i < COLUMN_COUNT; i++) {
gpg_item -> setTextColor(i,(Qt::darkBlue));
gpg_item -> setFont(i,font);
}
break;
case PEER_STATE_AWAY:
gpgIcon = QIcon(IMAGE_AWAY);
gpg_item -> setToolTip(COLUMN_NAME, tr("Peer Away"));
gpg_item -> setText(COLUMN_STATE, tr("Away"));
for(i = 0; i < COLUMN_COUNT; i++) {
gpg_item -> setTextColor(i,(Qt::gray));
gpg_item -> setFont(i,font);
}
break;
case PEER_STATE_BUSY:
gpgIcon = QIcon(IMAGE_BUSY);
gpg_item -> setToolTip(COLUMN_NAME, tr("Peer Busy"));
gpg_item -> setText(COLUMN_STATE, tr("Busy"));
for(i = 0; i < COLUMN_COUNT; i++) {
gpg_item -> setTextColor(i,(Qt::gray));
gpg_item -> setFont(i,font);
}
break;
} }
gpg_item -> setData(COLUMN_STATE, ROLE_SORT, BuildStateSortString(true, gpg_item->text(COLUMN_NAME), PEER_STATE_INACTIVE)); gpg_item -> setData(COLUMN_STATE, ROLE_SORT, BuildStateSortString(true, gpg_item->text(COLUMN_NAME), PEER_STATE_INACTIVE));