mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
New class "StatusDefs" for status information like strings, images, fonts and colors.
Removed the status string function from the lib. Removed static strings like " - " and " : " from translation. Removed not needed images. Fixed german translation in MessengerWindow, PeersDialog and PopupChatDialog. git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@3472 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
d05d723af1
commit
60746b5702
@ -42,6 +42,8 @@ const uint32_t RS_STATUS_BUSY = 0x0002;
|
||||
const uint32_t RS_STATUS_ONLINE = 0x0003;
|
||||
const uint32_t RS_STATUS_INACTIVE = 0x0004;
|
||||
|
||||
const uint32_t RS_STATUS_COUNT = 0x0005; // count of status
|
||||
|
||||
//! data object for peer status information
|
||||
/*!
|
||||
* data object used for peer status information
|
||||
@ -95,14 +97,6 @@ class RsStatus
|
||||
* @return will return false if status info does not belong to client
|
||||
*/
|
||||
virtual bool sendStatus(std::string id, uint32_t status) = 0;
|
||||
|
||||
/**
|
||||
* translates the status field of a peer to a string
|
||||
* @status the status id that needs to be translated
|
||||
* @statusString the string translation is passed here
|
||||
*/
|
||||
virtual void getStatusString(uint32_t status, std::string& statusString) = 0;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
@ -56,26 +56,3 @@ bool p3Status::sendStatus(std::string id, uint32_t status){
|
||||
|
||||
return mStatusSrv->sendStatus(id, status);
|
||||
}
|
||||
|
||||
void p3Status::getStatusString(uint32_t status, std::string& statusString){
|
||||
|
||||
switch (status) {
|
||||
case RS_STATUS_OFFLINE:
|
||||
statusString = "Offline";
|
||||
break;
|
||||
case RS_STATUS_AWAY:
|
||||
statusString = "Away";
|
||||
break;
|
||||
case RS_STATUS_BUSY:
|
||||
statusString = "Busy";
|
||||
break;
|
||||
case RS_STATUS_ONLINE:
|
||||
statusString = "Online";
|
||||
break;
|
||||
case RS_STATUS_INACTIVE:
|
||||
statusString = "Inactive";
|
||||
break;
|
||||
default:
|
||||
statusString.erase();
|
||||
}
|
||||
}
|
||||
|
@ -48,8 +48,6 @@ public:
|
||||
virtual bool getStatus(std::string &id, StatusInfo &statusInfo);
|
||||
virtual bool sendStatus(std::string id, uint32_t status);
|
||||
|
||||
virtual void getStatusString(uint32_t status, std::string& statusString);
|
||||
|
||||
private:
|
||||
|
||||
p3StatusService* mStatusSrv;
|
||||
|
@ -278,6 +278,7 @@ HEADERS += rshare.h \
|
||||
gui/common/vmessagebox.h \
|
||||
gui/common/rwindow.h \
|
||||
gui/common/html.h \
|
||||
gui/common/StatusDefs.h \
|
||||
gui/MessagesDialog.h \
|
||||
gui/help/browser/helpbrowser.h \
|
||||
gui/help/browser/helptextbrowser.h \
|
||||
@ -467,6 +468,7 @@ SOURCES += main.cpp \
|
||||
gui/common/vmessagebox.cpp \
|
||||
gui/common/rwindow.cpp \
|
||||
gui/common/html.cpp \
|
||||
gui/common/StatusDefs.cpp \
|
||||
gui/settings/rsharesettings.cpp \
|
||||
gui/settings/RsharePeerSettings.cpp \
|
||||
gui/settings/rsettings.cpp \
|
||||
@ -651,6 +653,7 @@ minimal {
|
||||
gui/settings/rsettings.cpp \
|
||||
gui/settings/rsharesettings.cpp \
|
||||
gui/common/rwindow.cpp \
|
||||
gui/common/StatusDefs.cpp \
|
||||
gui/LogoBar.cpp \
|
||||
gui/RsAutoUpdatePage.cpp \
|
||||
gui/common/vmessagebox.cpp \
|
||||
@ -681,6 +684,7 @@ minimal {
|
||||
gui/settings/rsettings.h \
|
||||
gui/settings/rsharesettings.h \
|
||||
gui/common/rwindow.h \
|
||||
gui/common/StatusDefs.h \
|
||||
gui/LogoBar.h \
|
||||
gui/RsAutoUpdatePage.h \
|
||||
gui/common/vmessagebox.h \
|
||||
|
@ -74,6 +74,7 @@
|
||||
#include "util/rsversion.h"
|
||||
#include "settings/rsettingswin.h"
|
||||
#include "settings/rsharesettings.h"
|
||||
#include "common/StatusDefs.h"
|
||||
|
||||
#include <sstream>
|
||||
#include <iomanip>
|
||||
@ -1004,22 +1005,19 @@ void MainWindow::initializeStatusObject(QObject *pObject, bool bConnect)
|
||||
/* initialize menu */
|
||||
QActionGroup *pGroup = new QActionGroup(pMenu);
|
||||
|
||||
rsStatus->getStatusString(RS_STATUS_ONLINE, statusString);
|
||||
QAction *pAction = new QAction(QIcon(":/images/im-user.png"), tr(statusString.c_str()), pMenu);
|
||||
QAction *pAction = new QAction(QIcon(StatusDefs::imageIM(RS_STATUS_ONLINE)), StatusDefs::name(RS_STATUS_ONLINE), pMenu);
|
||||
pAction->setData(RS_STATUS_ONLINE);
|
||||
pAction->setCheckable(true);
|
||||
pMenu->addAction(pAction);
|
||||
pGroup->addAction(pAction);
|
||||
|
||||
rsStatus->getStatusString(RS_STATUS_BUSY, statusString);
|
||||
pAction = new QAction(QIcon(":/images/im-user-busy.png"), tr(statusString.c_str()), pMenu);
|
||||
pAction = new QAction(QIcon(StatusDefs::imageIM(RS_STATUS_BUSY)), StatusDefs::name(RS_STATUS_BUSY), pMenu);
|
||||
pAction->setData(RS_STATUS_BUSY);
|
||||
pAction->setCheckable(true);
|
||||
pMenu->addAction(pAction);
|
||||
pGroup->addAction(pAction);
|
||||
|
||||
rsStatus->getStatusString(RS_STATUS_AWAY, statusString);
|
||||
pAction = new QAction(QIcon(":/images/im-user-away.png"), tr(statusString.c_str()), pMenu);
|
||||
pAction = new QAction(QIcon(StatusDefs::imageIM(RS_STATUS_AWAY)), StatusDefs::name(RS_STATUS_AWAY), pMenu);
|
||||
pAction->setData(RS_STATUS_AWAY);
|
||||
pAction->setCheckable(true);
|
||||
pMenu->addAction(pAction);
|
||||
@ -1032,12 +1030,9 @@ void MainWindow::initializeStatusObject(QObject *pObject, bool bConnect)
|
||||
/* initialize combobox */
|
||||
QComboBox *pComboBox = dynamic_cast<QComboBox*>(pObject);
|
||||
if (pComboBox) {
|
||||
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);
|
||||
pComboBox->addItem(QIcon(StatusDefs::imageIM(RS_STATUS_ONLINE)), StatusDefs::name(RS_STATUS_ONLINE), RS_STATUS_ONLINE);
|
||||
pComboBox->addItem(QIcon(StatusDefs::imageIM(RS_STATUS_BUSY)), StatusDefs::name(RS_STATUS_BUSY), RS_STATUS_BUSY);
|
||||
pComboBox->addItem(QIcon(StatusDefs::imageIM(RS_STATUS_AWAY)), StatusDefs::name(RS_STATUS_AWAY), RS_STATUS_AWAY);
|
||||
|
||||
if (bConnect) {
|
||||
connect(pComboBox, SIGNAL(activated(int)), this, SLOT(statusChangedComboBox(int)));
|
||||
|
@ -25,6 +25,7 @@
|
||||
#include <QTimer>
|
||||
#include <QFileDialog>
|
||||
#include "common/vmessagebox.h"
|
||||
#include "common/StatusDefs.h"
|
||||
|
||||
#include <retroshare/rsiface.h>
|
||||
#include <retroshare/rspeers.h>
|
||||
@ -69,13 +70,6 @@
|
||||
#define IMAGE_CONNECT2 ":/images/reload24.png"
|
||||
#define IMAGE_PASTELINK ":/images/pasterslink.png"
|
||||
|
||||
/* Images for Status icons */
|
||||
#define IMAGE_ONLINE ":/images/im-user.png"
|
||||
#define IMAGE_OFFLINE ":/images/im-user-offline.png"
|
||||
#define IMAGE_AWAY ":/images/im-user-away.png"
|
||||
#define IMAGE_BUSY ":/images/im-user-busy.png"
|
||||
#define IMAGE_INACTIVE ":/images/im-user-inactive.png"
|
||||
|
||||
#define COLUMN_COUNT 3
|
||||
#define COLUMN_NAME 0
|
||||
#define COLUMN_STATE 1
|
||||
@ -225,7 +219,7 @@ MessengerWindow::MessengerWindow(QWidget* parent, Qt::WFlags flags)
|
||||
std::string ownId = rsPeers->getOwnId();
|
||||
if (rsPeers->getPeerDetails(ownId, pd)) {
|
||||
/* calculate only once */
|
||||
m_nickName = QString::fromStdString(pd.name) + tr(" - ") + QString::fromStdString(pd.location);
|
||||
m_nickName = QString::fromStdString(pd.name) + " - " + QString::fromStdString(pd.location);
|
||||
#ifdef MINIMAL_RSGUI
|
||||
ui.statusButton->setText(m_nickName);
|
||||
#endif
|
||||
@ -599,11 +593,11 @@ void MessengerWindow::insertPeers()
|
||||
}
|
||||
#endif // MINIMAL_RSGUI
|
||||
if (sCustomString.isEmpty()) {
|
||||
sslItem -> setText( COLUMN_NAME, tr("location : ") + QString::fromStdString(sslDetail.location) + " " + QString::fromStdString(sslDetail.autoconnect));
|
||||
sslItem -> setToolTip( COLUMN_NAME, tr("location : ") + QString::fromStdString(sslDetail.location));
|
||||
sslItem -> setText( COLUMN_NAME, tr("location") + " : " + QString::fromStdString(sslDetail.location) + " " + QString::fromStdString(sslDetail.autoconnect));
|
||||
sslItem -> setToolTip( COLUMN_NAME, tr("location") + " : " + QString::fromStdString(sslDetail.location));
|
||||
} else {
|
||||
sslItem -> setText( COLUMN_NAME, tr("location : ") + QString::fromStdString(sslDetail.location) + " " + QString::fromStdString(sslDetail.autoconnect) );
|
||||
sslItem -> setToolTip( COLUMN_NAME, tr("location : ") + QString::fromStdString(sslDetail.location) + tr(" - ") + sCustomString);
|
||||
sslItem -> setText( COLUMN_NAME, tr("location") + " : " + QString::fromStdString(sslDetail.location) + " " + QString::fromStdString(sslDetail.autoconnect) );
|
||||
sslItem -> setToolTip( COLUMN_NAME, tr("location") + " : " + QString::fromStdString(sslDetail.location) + " - " + sCustomString);
|
||||
|
||||
/* store custom state string */
|
||||
sslCustomStateStrings[sslDetail.id] = sCustomString;
|
||||
@ -621,8 +615,8 @@ void MessengerWindow::insertPeers()
|
||||
QFont font1;
|
||||
font1.setBold(true);
|
||||
|
||||
gpg_item->setIcon(COLUMN_NAME,(QIcon(IMAGE_ONLINE)));
|
||||
gpg_item->setToolTip(COLUMN_NAME, tr("Peer Online"));
|
||||
gpg_item->setIcon(COLUMN_NAME,(StatusDefs::images(RS_STATUS_ONLINE)));
|
||||
gpg_item->setToolTip(COLUMN_NAME, StatusDefs::tooltip(RS_STATUS_ONLINE));
|
||||
gpg_item->setData(COLUMN_NAME, ROLE_SORT, BuildStateSortString(sortState, gpg_item->text(COLUMN_NAME), PEER_STATE_ONLINE));
|
||||
|
||||
for(i = 0; i < COLUMN_COUNT; i++) {
|
||||
@ -680,11 +674,11 @@ void MessengerWindow::insertPeers()
|
||||
|
||||
if (gpg_connected) {
|
||||
gpg_item->setHidden(false);
|
||||
//gpg_item -> setText(COLUMN_STATE, tr("Online")); // set to online regardless on update
|
||||
|
||||
#ifndef MINIMAL_RSGUI
|
||||
int bestPeerState = 0; // for gpg item
|
||||
std::string bestSslId; // for gpg item
|
||||
unsigned int bestRSState = 0; // for gpg item
|
||||
|
||||
std::list<StatusInfo>::iterator it = statusInfo.begin();
|
||||
for(; it != statusInfo.end() ; it++){
|
||||
@ -697,9 +691,7 @@ void MessengerWindow::insertPeers()
|
||||
|
||||
int peerState = 0;
|
||||
|
||||
std::string status;
|
||||
rsStatus->getStatusString(it->status, status);
|
||||
gpg_item -> setText(COLUMN_STATE, QString::fromStdString(status));
|
||||
gpg_item -> setText(COLUMN_STATE, StatusDefs::name(it->status));
|
||||
|
||||
unsigned char *data = NULL;
|
||||
int size = 0 ;
|
||||
@ -739,10 +731,12 @@ void MessengerWindow::insertPeers()
|
||||
/* first ssl contact */
|
||||
bestPeerState = peerState;
|
||||
bestSslId = *cont_it;
|
||||
bestRSState = it->status;
|
||||
} else if (peerState < bestPeerState) {
|
||||
/* higher state */
|
||||
bestPeerState = peerState;
|
||||
bestSslId = *cont_it;
|
||||
bestRSState = it->status;
|
||||
} else if (peerState == bestPeerState) {
|
||||
/* equal state */
|
||||
|
||||
@ -769,59 +763,20 @@ void MessengerWindow::insertPeers()
|
||||
if (bestPeerState == 0) {
|
||||
// show as online
|
||||
bestPeerState = PEER_STATE_ONLINE;
|
||||
bestRSState = RS_STATUS_ONLINE;
|
||||
}
|
||||
|
||||
QFont font;
|
||||
font.setBold(true);
|
||||
|
||||
QString stateString;
|
||||
|
||||
switch (bestPeerState) {
|
||||
case PEER_STATE_INACTIVE:
|
||||
gpgIcon = QIcon(IMAGE_INACTIVE);
|
||||
gpg_item -> setToolTip(COLUMN_NAME, tr("Peer Idle"));
|
||||
stateString = tr("Idle");
|
||||
|
||||
QColor textColor = StatusDefs::textColor(bestRSState);
|
||||
QFont font = StatusDefs::font(bestRSState);
|
||||
for(i = 0; i < COLUMN_COUNT; i++) {
|
||||
gpg_item -> setTextColor(i,(Qt::gray));
|
||||
gpg_item -> setFont(i,font);
|
||||
gpg_item -> setTextColor(i, textColor);
|
||||
gpg_item -> setFont(i, font);
|
||||
}
|
||||
break;
|
||||
|
||||
case PEER_STATE_ONLINE:
|
||||
gpgIcon = QIcon(IMAGE_ONLINE);
|
||||
gpg_item -> setToolTip(COLUMN_NAME, tr("Peer Online"));
|
||||
stateString = tr("Online");
|
||||
gpgIcon = QIcon(StatusDefs::imageIM(bestRSState));
|
||||
|
||||
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));
|
||||
gpg_item -> setToolTip(COLUMN_NAME, StatusDefs::tooltip(bestRSState));
|
||||
|
||||
std::map<std::string, QString>::iterator customStateString = sslCustomStateStrings.find(bestSslId);
|
||||
if (customStateString == sslCustomStateStrings.end()) {
|
||||
@ -835,6 +790,9 @@ void MessengerWindow::insertPeers()
|
||||
// }
|
||||
|
||||
/* use state string for location */
|
||||
QString stateString;
|
||||
stateString = StatusDefs::name(bestRSState);
|
||||
|
||||
if (stateString.isEmpty()) {
|
||||
/* show only the name */
|
||||
gpg_item->setText(COLUMN_NAME, QString::fromStdString(detail.name));
|
||||
@ -855,7 +813,6 @@ void MessengerWindow::insertPeers()
|
||||
gpg_item->setText(COLUMN_NAME, QString::fromStdString(detail.name));
|
||||
gpgIcon = QIcon(IMAGE_AVAIBLE);
|
||||
gpg_item->setData(COLUMN_NAME, ROLE_SORT, BuildStateSortString(sortState, gpg_item->text(COLUMN_NAME), PEER_STATE_ONLINE));
|
||||
//gpg_item -> setText(COLUMN_STATE, tr("Available"));
|
||||
QFont font;
|
||||
font.setBold(true);
|
||||
for(i = 0; i < COLUMN_COUNT; i++) {
|
||||
@ -865,14 +822,14 @@ void MessengerWindow::insertPeers()
|
||||
} else {
|
||||
gpg_item->setHidden(hideOfflineFriends);
|
||||
gpg_item->setText(COLUMN_NAME, QString::fromStdString(detail.name));
|
||||
gpgIcon = QIcon(IMAGE_OFFLINE);
|
||||
gpgIcon = QIcon(StatusDefs::imageIM(RS_STATUS_OFFLINE));
|
||||
gpg_item->setData(COLUMN_NAME, ROLE_SORT, BuildStateSortString(sortState, gpg_item->text(COLUMN_NAME), PEER_STATE_OFFLINE));
|
||||
//gpg_item -> setText(COLUMN_STATE, tr("Offline"));
|
||||
QFont font;
|
||||
font.setBold(false);
|
||||
|
||||
QColor textColor = StatusDefs::textColor(RS_STATUS_OFFLINE);
|
||||
QFont font = StatusDefs::font(RS_STATUS_OFFLINE);
|
||||
for(i = 0; i < COLUMN_COUNT; i++) {
|
||||
gpg_item -> setTextColor(i,(Qt::black));
|
||||
gpg_item -> setFont(i,font);
|
||||
gpg_item -> setTextColor(i, textColor);
|
||||
gpg_item -> setFont(i, font);
|
||||
}
|
||||
}
|
||||
|
||||
@ -882,7 +839,6 @@ void MessengerWindow::insertPeers()
|
||||
|
||||
gpg_item -> setIcon(COLUMN_NAME, gpgIcon);
|
||||
|
||||
|
||||
/* add gpg item to the list. If item is already in the list, it won't be duplicated thanks to Qt */
|
||||
peertreeWidget->addTopLevelItem(gpg_item);
|
||||
|
||||
@ -1207,9 +1163,8 @@ void MessengerWindow::updateOwnStatus(const QString &peer_id, int 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()) + ")");
|
||||
|
||||
ui.statusButton->setText(m_nickName + " (" + StatusDefs::name(status) + ")");
|
||||
|
||||
switch (status) {
|
||||
case RS_STATUS_OFFLINE:
|
||||
|
@ -251,7 +251,7 @@ p, li { white-space: pre-wrap; }
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
<string/>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="images.qrc">
|
||||
|
@ -29,6 +29,7 @@
|
||||
#include <QDropEvent>
|
||||
#include <QFileDialog>
|
||||
#include "common/vmessagebox.h"
|
||||
#include "common/StatusDefs.h"
|
||||
#include <gui/mainpagestack.h>
|
||||
|
||||
#include "retroshare/rsinit.h"
|
||||
@ -73,14 +74,7 @@
|
||||
#define IMAGE_MSG ":/images/message-mail.png"
|
||||
#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/identity24idle.png"
|
||||
#define IMAGE_OFFLINE ":/images/user/identityoffline24.png"
|
||||
#define IMAGE_OFFLINE2 ":/images/user/identitylightgrey24.png"
|
||||
#define IMAGE_AVAILABLE ":/images/user/identityavaiblecyan24.png"
|
||||
#define IMAGE_UNREACHABLE ":/images/user/identityunreachable24.png"
|
||||
#define IMAGE_CONNECT2 ":/images/reload24.png"
|
||||
#define IMAGE_PASTELINK ":/images/pasterslink.png"
|
||||
|
||||
@ -652,9 +646,9 @@ void PeersDialog::insertPeers()
|
||||
if (sslDetail.state & RS_PEER_STATE_CONNECTED) {
|
||||
customStateString = rsMsgs->getCustomStateString(sslDetail.id);
|
||||
}
|
||||
sText = tr("location : ") + QString::fromStdString(sslDetail.location);
|
||||
sText = tr("location") + " : " + QString::fromStdString(sslDetail.location);
|
||||
if (customStateString.empty() == false) {
|
||||
sText += tr(" - ") + QString::fromStdString(customStateString);
|
||||
sText += " - " + QString::fromStdString(customStateString);
|
||||
}
|
||||
sslItem -> setText( COLUMN_NAME, sText);
|
||||
sslItem -> setToolTip( COLUMN_NAME, sText);
|
||||
@ -715,11 +709,11 @@ void PeersDialog::insertPeers()
|
||||
|
||||
int bestPeerState = 0; // for gpg item
|
||||
std::string bestSslId; // for gpg item
|
||||
unsigned int bestRSState = 0; // for gpg item
|
||||
|
||||
std::list<StatusInfo>::iterator it;
|
||||
for(it = statusInfo.begin(); it != statusInfo.end() ; it++) {
|
||||
|
||||
|
||||
// don't forget the kids
|
||||
std::list<std::string>::iterator cont_it;
|
||||
for (cont_it = sslContacts.begin(); cont_it != sslContacts.end(); cont_it++) {
|
||||
@ -728,9 +722,7 @@ void PeersDialog::insertPeers()
|
||||
|
||||
int peerState = 0;
|
||||
|
||||
std::string status;
|
||||
rsStatus->getStatusString(it->status, status);
|
||||
gpg_item -> setText(COLUMN_INFO, QString::fromStdString(status));
|
||||
gpg_item -> setText(COLUMN_INFO, StatusDefs::name(it->status));
|
||||
|
||||
switch (it->status) {
|
||||
case RS_STATUS_INACTIVE:
|
||||
@ -755,10 +747,12 @@ void PeersDialog::insertPeers()
|
||||
/* first ssl contact */
|
||||
bestPeerState = peerState;
|
||||
bestSslId = *cont_it;
|
||||
bestRSState = it->status;
|
||||
} else if (peerState < bestPeerState) {
|
||||
/* higher state */
|
||||
bestPeerState = peerState;
|
||||
bestSslId = *cont_it;
|
||||
bestRSState = it->status;
|
||||
} else if (peerState == bestPeerState) {
|
||||
/* equal state ... use first */
|
||||
}
|
||||
@ -769,57 +763,20 @@ void PeersDialog::insertPeers()
|
||||
if (bestPeerState == 0) {
|
||||
// show as online
|
||||
bestPeerState = PEER_STATE_ONLINE;
|
||||
bestRSState = RS_STATUS_ONLINE;
|
||||
}
|
||||
|
||||
QFont font;
|
||||
font.setBold(true);
|
||||
|
||||
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"));
|
||||
|
||||
QColor textColor = StatusDefs::textColor(bestRSState);
|
||||
QFont font = StatusDefs::font(bestRSState);
|
||||
for(i = 0; i < COLUMN_COUNT; i++) {
|
||||
gpg_item -> setTextColor(i,(Qt::gray));
|
||||
gpg_item -> setFont(i,font);
|
||||
}
|
||||
break;
|
||||
|
||||
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;
|
||||
gpg_item -> setTextColor(i, textColor);
|
||||
gpg_item -> setFont(i, font);
|
||||
}
|
||||
|
||||
gpgIcon = QIcon(StatusDefs::imageUser(bestRSState));
|
||||
|
||||
gpg_item -> setText(COLUMN_STATE, StatusDefs::name(bestRSState));
|
||||
gpg_item -> setToolTip(COLUMN_NAME, StatusDefs::tooltip(bestRSState));
|
||||
gpg_item -> setData(COLUMN_STATE, ROLE_SORT, BuildStateSortString(true, gpg_item->text(COLUMN_NAME), bestPeerState));
|
||||
} else if (gpg_online) {
|
||||
gpg_item->setHidden(bHideUnconnected);
|
||||
@ -834,14 +791,15 @@ void PeersDialog::insertPeers()
|
||||
}
|
||||
} else {
|
||||
gpg_item->setHidden(bHideUnconnected);
|
||||
gpgIcon = QIcon(IMAGE_OFFLINE);
|
||||
gpg_item -> setText(COLUMN_STATE, tr("Offline"));
|
||||
gpgIcon = QIcon(StatusDefs::imageUser(RS_STATUS_OFFLINE));
|
||||
gpg_item -> setText(COLUMN_STATE, StatusDefs::name(RS_STATUS_OFFLINE));
|
||||
gpg_item -> setData(COLUMN_STATE, ROLE_SORT, BuildStateSortString(true, gpg_item->text(COLUMN_NAME), PEER_STATE_OFFLINE));
|
||||
QFont font;
|
||||
font.setBold(false);
|
||||
|
||||
QColor textColor = StatusDefs::textColor(RS_STATUS_OFFLINE);
|
||||
QFont font = StatusDefs::font(RS_STATUS_OFFLINE);
|
||||
for(i = 0; i < COLUMN_COUNT; i++) {
|
||||
gpg_item -> setTextColor(i,(Qt::black));
|
||||
gpg_item -> setFont(i,font);
|
||||
gpg_item -> setTextColor(i, textColor);
|
||||
gpg_item -> setFont(i, font);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1417,7 +1417,7 @@ p, li { white-space: pre-wrap; }
|
||||
<normaloff>:/images/new_forum16.png</normaloff>:/images/new_forum16.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Create New Forum</string>
|
||||
<string>Create new Forum</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Create new Forum</string>
|
||||
@ -1432,7 +1432,7 @@ p, li { white-space: pre-wrap; }
|
||||
<normaloff>:/images/add_channel24.png</normaloff>:/images/add_channel24.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Create New Channel</string>
|
||||
<string>Create new Channel</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Create new Channel</string>
|
||||
|
@ -48,6 +48,7 @@
|
||||
#include "gui/settings/RsharePeerSettings.h"
|
||||
#include "gui/notifyqt.h"
|
||||
#include "../RsAutoUpdatePage.h"
|
||||
#include "gui/common/StatusDefs.h"
|
||||
|
||||
#include "gui/feeds/AttachFileItem.h"
|
||||
#include "gui/msgs/MessageComposer.h"
|
||||
@ -146,7 +147,7 @@ PopupChatDialog::PopupChatDialog(std::string id, std::string name,
|
||||
//ui.textBrowser->setOpenExternalLinks ( false );
|
||||
//ui.textBrowser->setOpenLinks ( false );
|
||||
|
||||
QString title = tr("RetroShare - ") + QString::fromStdString(name);
|
||||
QString title = tr("RetroShare") + " - " + QString::fromStdString(name);
|
||||
setWindowTitle(title);
|
||||
|
||||
setWindowIcon(QIcon(IMAGE_WINDOW));
|
||||
@ -385,7 +386,7 @@ void PopupChatDialog::chatFriend(std::string id)
|
||||
|
||||
if (!oneLocationConnected) {
|
||||
/* info dialog */
|
||||
if ((QMessageBox::question(NULL, tr("Friend Not Online"),tr("Your Friend is offline \nDo you want to send them a Message instead"),QMessageBox::Yes|QMessageBox::No, QMessageBox::Yes))== QMessageBox::Yes) {
|
||||
if ((QMessageBox::question(NULL, tr("Friend not Online"),tr("Your Friend is offline \nDo you want to send them a Message instead"),QMessageBox::Yes|QMessageBox::No, QMessageBox::Yes))== QMessageBox::Yes) {
|
||||
MessageComposer::msgFriend(id);
|
||||
}
|
||||
}
|
||||
@ -1101,8 +1102,6 @@ void PopupChatDialog::updateStatus(const QString &peer_id, int status)
|
||||
std::string stdPeerId = peer_id.toStdString();
|
||||
|
||||
/* set font size for status */
|
||||
QString statusString("<span style=\"font-size:11pt; font-weight:500;""\">%1</span>");
|
||||
|
||||
if (stdPeerId == dialogId) {
|
||||
// the peers status has changed
|
||||
switch (status) {
|
||||
@ -1111,7 +1110,6 @@ void PopupChatDialog::updateStatus(const QString &peer_id, int status)
|
||||
ui.avatarlabel->setEnabled(false);
|
||||
ui.infoframe->setVisible(true);
|
||||
ui.infolabel->setText( QString::fromStdString(dialogName) + " " + tr("apears to be Offline.") +"\n" + tr("Messages you send will be lost and not delivered, rs-Mail this contact instead."));
|
||||
ui.friendnamelabel->setText( QString::fromStdString(dialogName) + " " + statusString.arg( tr("(Offline)") )) ;
|
||||
break;
|
||||
|
||||
case RS_STATUS_INACTIVE:
|
||||
@ -1119,14 +1117,12 @@ void PopupChatDialog::updateStatus(const QString &peer_id, int status)
|
||||
ui.avatarlabel->setEnabled(true);
|
||||
ui.infoframe->setVisible(true);
|
||||
ui.infolabel->setText( QString::fromStdString(dialogName) + " " + tr("is Idle and may not reply"));
|
||||
ui.friendnamelabel->setText( QString::fromStdString(dialogName) + " " + statusString.arg( tr("(Idle)") )) ;
|
||||
break;
|
||||
|
||||
case RS_STATUS_ONLINE:
|
||||
ui.avatarlabel->setStyleSheet("QLabel#avatarlabel{ border-image:url(:/images/avatarstatus_bg_online.png); }");
|
||||
ui.avatarlabel->setEnabled(true);
|
||||
ui.infoframe->setVisible(false);
|
||||
ui.friendnamelabel->setText( QString::fromStdString(dialogName) + " " + statusString.arg( tr("(Online)") )) ;
|
||||
break;
|
||||
|
||||
case RS_STATUS_AWAY:
|
||||
@ -1134,7 +1130,6 @@ void PopupChatDialog::updateStatus(const QString &peer_id, int status)
|
||||
ui.avatarlabel->setEnabled(true);
|
||||
ui.infolabel->setText( QString::fromStdString(dialogName) + " " + tr("is Away and may not reply"));
|
||||
ui.infoframe->setVisible(true);
|
||||
ui.friendnamelabel->setText( QString::fromStdString(dialogName) + " " + statusString.arg( tr("(Away)") )) ;
|
||||
break;
|
||||
|
||||
case RS_STATUS_BUSY:
|
||||
@ -1142,9 +1137,12 @@ void PopupChatDialog::updateStatus(const QString &peer_id, int status)
|
||||
ui.avatarlabel->setEnabled(true);
|
||||
ui.infolabel->setText( QString::fromStdString(dialogName) + " " + tr("is Busy and may not reply"));
|
||||
ui.infoframe->setVisible(true);
|
||||
ui.friendnamelabel->setText( QString::fromStdString(dialogName) + " " + statusString.arg( tr("(Busy)") )) ;
|
||||
break;
|
||||
}
|
||||
|
||||
QString statusString("<span style=\"font-size:11pt; font-weight:500;""\">%1</span>");
|
||||
ui.friendnamelabel->setText( QString::fromStdString(dialogName) + " (" + statusString.arg(StatusDefs::name(status)) + ")") ;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
140
retroshare-gui/src/gui/common/StatusDefs.cpp
Normal file
140
retroshare-gui/src/gui/common/StatusDefs.cpp
Normal file
@ -0,0 +1,140 @@
|
||||
/****************************************************************
|
||||
* This file is distributed under the following license:
|
||||
*
|
||||
* Copyright (c) 2010, RetroShare Team
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
****************************************************************/
|
||||
|
||||
#include <QCoreApplication>
|
||||
#include <retroshare/rsstatus.h>
|
||||
|
||||
#include "StatusDefs.h"
|
||||
|
||||
const QString StatusDefs::name(unsigned int status)
|
||||
{
|
||||
switch (status) {
|
||||
case RS_STATUS_OFFLINE:
|
||||
return QObject::tr("Offline");
|
||||
case RS_STATUS_AWAY:
|
||||
return QObject::tr("Away");
|
||||
case RS_STATUS_BUSY:
|
||||
return QObject::tr("Busy");
|
||||
case RS_STATUS_ONLINE:
|
||||
return QObject::tr("Online");
|
||||
case RS_STATUS_INACTIVE:
|
||||
return QObject::tr("Idle");
|
||||
}
|
||||
|
||||
std::cerr << "StatusDefs::name: Unknown status requested " << status;
|
||||
return "";
|
||||
}
|
||||
|
||||
const char *StatusDefs::imageIM(unsigned int status)
|
||||
{
|
||||
switch (status) {
|
||||
case RS_STATUS_OFFLINE:
|
||||
return ":/images/im-user-offline.png";
|
||||
case RS_STATUS_AWAY:
|
||||
return ":/images/im-user-away.png";
|
||||
case RS_STATUS_BUSY:
|
||||
return ":/images/im-user-busy.png";
|
||||
case RS_STATUS_ONLINE:
|
||||
return ":/images/im-user.png";
|
||||
case RS_STATUS_INACTIVE:
|
||||
return ":/images/im-user-inactive.png";
|
||||
}
|
||||
|
||||
std::cerr << "StatusDefs::imageIM: Unknown status requested " << status;
|
||||
return "";
|
||||
}
|
||||
|
||||
const char *StatusDefs::imageUser(unsigned int status)
|
||||
{
|
||||
switch (status) {
|
||||
case RS_STATUS_OFFLINE:
|
||||
return ":/images/user/identityoffline24.png";
|
||||
case RS_STATUS_AWAY:
|
||||
return ":/images/user/identity24away.png";
|
||||
case RS_STATUS_BUSY:
|
||||
return ":/images/user/identity24busy.png";
|
||||
case RS_STATUS_ONLINE:
|
||||
return ":/images/user/identity24.png";
|
||||
case RS_STATUS_INACTIVE:
|
||||
return ":/images/user/identity24idle.png";
|
||||
}
|
||||
|
||||
std::cerr << "StatusDefs::imageUser: Unknown status requested " << status;
|
||||
return "";
|
||||
}
|
||||
|
||||
const QString StatusDefs::tooltip(unsigned int status)
|
||||
{
|
||||
switch (status) {
|
||||
case RS_STATUS_OFFLINE:
|
||||
return QObject::tr("Peer is offline");
|
||||
case RS_STATUS_AWAY:
|
||||
return QObject::tr("Peer is away");
|
||||
case RS_STATUS_BUSY:
|
||||
return QObject::tr("Peer is busy");
|
||||
case RS_STATUS_ONLINE:
|
||||
return QObject::tr("Peer is online");
|
||||
case RS_STATUS_INACTIVE:
|
||||
return QObject::tr("Peer is idle");
|
||||
}
|
||||
|
||||
std::cerr << "StatusDefs::tooltip: Unknown status requested " << status;
|
||||
return "";
|
||||
}
|
||||
|
||||
const QColor StatusDefs::textColor(unsigned int status)
|
||||
{
|
||||
switch (status) {
|
||||
case RS_STATUS_OFFLINE:
|
||||
return Qt::black;
|
||||
case RS_STATUS_AWAY:
|
||||
return Qt::gray;
|
||||
case RS_STATUS_BUSY:
|
||||
return Qt::gray;
|
||||
case RS_STATUS_ONLINE:
|
||||
return Qt::darkBlue;
|
||||
case RS_STATUS_INACTIVE:
|
||||
return Qt::gray;
|
||||
}
|
||||
|
||||
std::cerr << "StatusDefs::textColor: Unknown status requested " << status;
|
||||
return Qt::black;
|
||||
}
|
||||
|
||||
const QFont StatusDefs::font(unsigned int status)
|
||||
{
|
||||
QFont font;
|
||||
|
||||
switch (status) {
|
||||
case RS_STATUS_AWAY:
|
||||
case RS_STATUS_BUSY:
|
||||
case RS_STATUS_ONLINE:
|
||||
case RS_STATUS_INACTIVE:
|
||||
font.setBold(true);
|
||||
return font;
|
||||
case RS_STATUS_OFFLINE:
|
||||
font.setBold(false);
|
||||
return font;
|
||||
}
|
||||
|
||||
std::cerr << "StatusDefs::font: Unknown status requested " << status;
|
||||
return font;
|
||||
}
|
42
retroshare-gui/src/gui/common/StatusDefs.h
Normal file
42
retroshare-gui/src/gui/common/StatusDefs.h
Normal file
@ -0,0 +1,42 @@
|
||||
/****************************************************************
|
||||
* This file is distributed under the following license:
|
||||
*
|
||||
* Copyright (c) 2010, RetroShare Team
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
****************************************************************/
|
||||
|
||||
|
||||
#ifndef _STATUSDEFS_H
|
||||
#define _STATUSDEFS_H
|
||||
|
||||
#include <QColor>
|
||||
#include <QFont>
|
||||
|
||||
class StatusDefs
|
||||
{
|
||||
public:
|
||||
static const QString name(unsigned int status);
|
||||
static const char* imageIM(unsigned int status);
|
||||
static const char* imageUser(unsigned int status);
|
||||
static const QString tooltip(unsigned int status);
|
||||
|
||||
static const QColor textColor(unsigned int status);
|
||||
static const QFont font(unsigned int status);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -423,9 +423,7 @@
|
||||
<file>images/user/identity24away.png</file>
|
||||
<file>images/user/identity24busy.png</file>
|
||||
<file>images/user/identity24idle.png</file>
|
||||
<file>images/user/identitylightgrey24.png</file>
|
||||
<file>images/user/identityavaiblecyan24.png</file>
|
||||
<file>images/user/identityunreachable24.png</file>
|
||||
<file>images/user/agt_forum24.png</file>
|
||||
<file>images/user/identity32.png</file>
|
||||
<file>images/user/identitygray16.png</file>
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 1.3 KiB |
Binary file not shown.
Before Width: | Height: | Size: 1005 B |
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user