mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
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:
parent
c854b9feb1
commit
3759f8de6f
@ -59,23 +59,23 @@ bool p3Status::sendStatus(std::string id, uint32_t status){
|
||||
|
||||
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";
|
||||
|
||||
}else if (status == RS_STATUS_BUSY){
|
||||
|
||||
break;
|
||||
case RS_STATUS_BUSY:
|
||||
statusString = "Busy";
|
||||
|
||||
}else if (status == RS_STATUS_ONLINE){
|
||||
|
||||
statusString = "Online";
|
||||
|
||||
}else if(status == RS_STATUS_INACTIVE){
|
||||
|
||||
statusString = "Inactive";
|
||||
|
||||
}
|
||||
|
||||
return;
|
||||
break;
|
||||
case RS_STATUS_ONLINE:
|
||||
statusString = "Online";
|
||||
break;
|
||||
case RS_STATUS_INACTIVE:
|
||||
statusString = "Inactive";
|
||||
break;
|
||||
default:
|
||||
statusString.erase();
|
||||
}
|
||||
}
|
||||
|
@ -997,24 +997,29 @@ void MainWindow::initializeStatusObject(QObject *pObject, bool bConnect)
|
||||
|
||||
m_apStatusObjects.insert(m_apStatusObjects.end(), pObject);
|
||||
|
||||
std::string statusString;
|
||||
|
||||
QMenu *pMenu = dynamic_cast<QMenu*>(pObject);
|
||||
if (pMenu) {
|
||||
/* initialize menu */
|
||||
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->setCheckable(true);
|
||||
pMenu->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->setCheckable(true);
|
||||
pMenu->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->setCheckable(true);
|
||||
pMenu->addAction(pAction);
|
||||
@ -1027,9 +1032,12 @@ void MainWindow::initializeStatusObject(QObject *pObject, bool bConnect)
|
||||
/* initialize combobox */
|
||||
QComboBox *pComboBox = dynamic_cast<QComboBox*>(pObject);
|
||||
if (pComboBox) {
|
||||
pComboBox->addItem(QIcon(":/images/im-user.png"), tr("Online"), RS_STATUS_ONLINE);
|
||||
pComboBox->addItem(QIcon(":/images/im-user-busy.png"), tr("Busy"), RS_STATUS_BUSY);
|
||||
pComboBox->addItem(QIcon(":/images/im-user-away.png"), tr("Away"), RS_STATUS_AWAY);
|
||||
rsStatus->getStatusString(RS_STATUS_ONLINE, statusString);
|
||||
pComboBox->addItem(QIcon(":/images/im-user.png"), tr(statusString.c_str()), RS_STATUS_ONLINE);
|
||||
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) {
|
||||
connect(pComboBox, SIGNAL(activated(int)), this, SLOT(statusChangedComboBox(int)));
|
||||
|
@ -503,10 +503,6 @@ void MessengerWindow::insertPeers()
|
||||
|
||||
//add the gpg friends
|
||||
for(it = gpgFriends.begin(); it != gpgFriends.end(); it++) {
|
||||
// if (*it == sOwnId) {
|
||||
// continue;
|
||||
// }
|
||||
|
||||
/* make a widget per friend */
|
||||
QTreeWidgetItem *gpg_item = NULL;
|
||||
QTreeWidgetItem *gpg_item_loop = NULL;
|
||||
@ -770,87 +766,85 @@ void MessengerWindow::insertPeers()
|
||||
}
|
||||
}
|
||||
|
||||
if (bestPeerState) {
|
||||
QFont font;
|
||||
font.setBold(true);
|
||||
if (bestPeerState == 0) {
|
||||
// show as online
|
||||
bestPeerState = PEER_STATE_ONLINE;
|
||||
}
|
||||
|
||||
QString stateString;
|
||||
QFont font;
|
||||
font.setBold(true);
|
||||
|
||||
switch (bestPeerState) {
|
||||
case PEER_STATE_INACTIVE:
|
||||
gpgIcon = QIcon(IMAGE_INACTIVE);
|
||||
gpg_item -> setToolTip(COLUMN_NAME, tr("Peer Idle"));
|
||||
stateString = tr("Idle");
|
||||
QString stateString;
|
||||
|
||||
for(i = 0; i < COLUMN_COUNT; i++) {
|
||||
gpg_item -> setTextColor(i,(Qt::gray));
|
||||
gpg_item -> setFont(i,font);
|
||||
}
|
||||
break;
|
||||
switch (bestPeerState) {
|
||||
case PEER_STATE_INACTIVE:
|
||||
gpgIcon = QIcon(IMAGE_INACTIVE);
|
||||
gpg_item -> setToolTip(COLUMN_NAME, tr("Peer Idle"));
|
||||
stateString = tr("Idle");
|
||||
|
||||
case PEER_STATE_ONLINE:
|
||||
gpgIcon = QIcon(IMAGE_ONLINE);
|
||||
gpg_item -> setToolTip(COLUMN_NAME, tr("Peer Online"));
|
||||
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;
|
||||
for(i = 0; i < COLUMN_COUNT; i++) {
|
||||
gpg_item -> setTextColor(i,(Qt::gray));
|
||||
gpg_item -> setFont(i,font);
|
||||
}
|
||||
gpg_item->setText(COLUMN_NAME, QString::fromStdString(detail.name));
|
||||
break;
|
||||
|
||||
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));
|
||||
// }
|
||||
case PEER_STATE_ONLINE:
|
||||
gpgIcon = QIcon(IMAGE_ONLINE);
|
||||
gpg_item -> setToolTip(COLUMN_NAME, tr("Peer Online"));
|
||||
stateString = tr("Online");
|
||||
|
||||
/* use state string for location */
|
||||
if (stateString.isEmpty()) {
|
||||
/* 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" + stateString);
|
||||
}
|
||||
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));
|
||||
|
||||
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 {
|
||||
/* show the name with custom state string */
|
||||
gpg_item->setText(COLUMN_NAME, QString::fromStdString(detail.name) + "\n" + customStateString->second);
|
||||
/* show the name with location */
|
||||
gpg_item->setText(COLUMN_NAME, QString::fromStdString(detail.name) + "\n" + stateString);
|
||||
}
|
||||
} 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
|
||||
/* show the name with custom state string */
|
||||
gpg_item->setText(COLUMN_NAME, QString::fromStdString(detail.name) + "\n" + customStateString->second);
|
||||
}
|
||||
|
||||
gpg_item->setData(COLUMN_NAME, ROLE_SORT, BuildStateSortString(sortState, gpg_item->text(COLUMN_NAME), bestPeerState));
|
||||
@ -1211,36 +1205,34 @@ void MessengerWindow::updateOwnStatus(const QString &peer_id, int status)
|
||||
{
|
||||
// add self nick + own status
|
||||
if (peer_id.toStdString() == rsPeers->getOwnId())
|
||||
{
|
||||
{
|
||||
// my status has changed
|
||||
|
||||
std::string statusString;
|
||||
rsStatus->getStatusString(status, statusString);
|
||||
ui.statusButton->setText(m_nickName + " (" + tr(statusString.c_str()) + ")");
|
||||
|
||||
switch (status) {
|
||||
case RS_STATUS_OFFLINE:
|
||||
ui.avatarButton->setStyleSheet("QToolButton#avatarButton{border-image:url(:/images/mystatus_bg_offline.png); }");
|
||||
ui.statusButton->setText(m_nickName + tr(" ") + tr("(Offline)"));
|
||||
break;
|
||||
|
||||
case RS_STATUS_INACTIVE:
|
||||
ui.avatarButton->setStyleSheet("QToolButton#avatarButton{border-image:url(:/images/mystatus_bg_idle.png); }");
|
||||
ui.statusButton->setText(m_nickName + tr(" ") + tr("(Idle)"));
|
||||
break;
|
||||
|
||||
case RS_STATUS_ONLINE:
|
||||
ui.avatarButton->setStyleSheet("QToolButton#avatarButton{border-image:url(:/images/mystatus_bg_online.png); }");
|
||||
ui.statusButton->setText(m_nickName + tr(" ") + tr("(Online)"));
|
||||
break;
|
||||
|
||||
case RS_STATUS_AWAY:
|
||||
ui.avatarButton->setStyleSheet("QToolButton#avatarButton{border-image:url(:/images/mystatus_bg_idle.png); }");
|
||||
ui.statusButton->setText(m_nickName + tr(" ") + tr("(Away)"));
|
||||
break;
|
||||
|
||||
case RS_STATUS_BUSY:
|
||||
ui.avatarButton->setStyleSheet("QToolButton#avatarButton{border-image:url(:/images/mystatus_bg_busy.png); }");
|
||||
ui.statusButton->setText(m_nickName + tr(" ") + tr("(Busy)"));
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -766,58 +766,58 @@ void PeersDialog::insertPeers()
|
||||
}
|
||||
}
|
||||
|
||||
if (bestPeerState) {
|
||||
QFont font;
|
||||
font.setBold(true);
|
||||
if (bestPeerState == 0) {
|
||||
// show as online
|
||||
bestPeerState = PEER_STATE_ONLINE;
|
||||
}
|
||||
|
||||
switch (bestPeerState) {
|
||||
case PEER_STATE_INACTIVE:
|
||||
gpgIcon = QIcon(IMAGE_INACTIVE);
|
||||
gpg_item -> setToolTip(COLUMN_NAME, tr("Peer Idle"));
|
||||
gpg_item -> setText(COLUMN_STATE, tr("Idle"));
|
||||
QFont font;
|
||||
font.setBold(true);
|
||||
|
||||
for(i = 0; i < COLUMN_COUNT; i++) {
|
||||
gpg_item -> setTextColor(i,(Qt::gray));
|
||||
gpg_item -> setFont(i,font);
|
||||
}
|
||||
break;
|
||||
switch (bestPeerState) {
|
||||
case PEER_STATE_INACTIVE:
|
||||
gpgIcon = QIcon(IMAGE_INACTIVE);
|
||||
gpg_item -> setToolTip(COLUMN_NAME, tr("Peer Idle"));
|
||||
gpg_item -> setText(COLUMN_STATE, tr("Idle"));
|
||||
|
||||
case PEER_STATE_ONLINE:
|
||||
gpgIcon = QIcon(IMAGE_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;
|
||||
for(i = 0; i < COLUMN_COUNT; i++) {
|
||||
gpg_item -> setTextColor(i,(Qt::gray));
|
||||
gpg_item -> setFont(i,font);
|
||||
}
|
||||
} else {
|
||||
break;
|
||||
|
||||
case PEER_STATE_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));
|
||||
|
Loading…
Reference in New Issue
Block a user