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;
}else if(status == RS_STATUS_INACTIVE){ case RS_STATUS_INACTIVE:
statusString = "Inactive"; statusString = "Inactive";
break;
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,7 +766,11 @@ void MessengerWindow::insertPeers()
} }
} }
if (bestPeerState) { if (bestPeerState == 0) {
// show as online
bestPeerState = PEER_STATE_ONLINE;
}
QFont font; QFont font;
font.setBold(true); font.setBold(true);
@ -846,12 +846,6 @@ void MessengerWindow::insertPeers()
/* show the name with custom state string */ /* show the name with custom state string */
gpg_item->setText(COLUMN_NAME, QString::fromStdString(detail.name) + "\n" + customStateString->second); gpg_item->setText(COLUMN_NAME, QString::fromStdString(detail.name) + "\n" + customStateString->second);
} }
} else {
/* show only the name */
gpgIcon = QIcon(IMAGE_ONLINE);
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,7 +766,11 @@ void PeersDialog::insertPeers()
} }
} }
if (bestPeerState) { if (bestPeerState == 0) {
// show as online
bestPeerState = PEER_STATE_ONLINE;
}
QFont font; QFont font;
font.setBold(true); font.setBold(true);
@ -815,10 +819,6 @@ void PeersDialog::insertPeers()
} }
break; break;
} }
} else {
gpgIcon = QIcon(IMAGE_ONLINE);
bestPeerState = PEER_STATE_ONLINE; // show as online
}
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));
} else if (gpg_online) { } else if (gpg_online) {