Added Status Bar functionality: Data Rates, and numbers of Peers Online.

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@591 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
drbob 2008-06-10 00:48:18 +00:00
parent e42ce13454
commit c6ac65efe5
3 changed files with 52 additions and 4 deletions

View File

@ -50,6 +50,8 @@
#include "gui/connect/InviteDialog.h"
#include "gui/connect/AddFriendDialog.h"
#include <sstream>
#include <iomanip>
#define FONT QFont(tr("Arial"), 8)
@ -211,6 +213,7 @@ MainWindow::MainWindow(QWidget* parent, Qt::WFlags flags)
#ifdef RS_RELEASE_VERSION
//addAction(new QAction(QIcon(IMAGE_BLOCK), tr("Unfinished"), ui.toolBar), SLOT(showApplWindow()));
#else
addAction(new QAction(QIcon(IMAGE_BLOCK), tr("Unfinished"), ui.toolBar), SLOT(showApplWindow()));
@ -251,12 +254,13 @@ MainWindow::MainWindow(QWidget* parent, Qt::WFlags flags)
ui.toolBarservice->addSeparator();
statusBar()->addWidget(new QLabel(tr("Users: 0 Files: 0 ")));
statusBar()->addPermanentWidget(new QLabel(tr("Down: 0.0 Up: 0.0 ")));
statusBar()->addPermanentWidget(new QLabel(tr("Connections: 0/45 ")));
#endif
//statusBar()->addWidget(new QLabel(tr("Users: 0 Files: 0 ")));
statusBar()->addPermanentWidget(statusRates = new QLabel(tr("Down: 0.0 Up: 0.0 ")));
statusBar()->addPermanentWidget(statusPeers = new QLabel(tr("Connections: 0/0/0 ")));
//servicegrp->actions()[0]->setChecked(true);
/* Create the actions that will go in the tray menu */
@ -304,9 +308,48 @@ MainWindow::MainWindow(QWidget* parent, Qt::WFlags flags)
SLOT(toggleVisibility(QSystemTrayIcon::ActivationReason)));
trayIcon->show();
QTimer *timer = new QTimer(this);
timer->connect(timer, SIGNAL(timeout()), this, SLOT(updateStatus()));
timer->start(5113);
}
void MainWindow::updateStatus()
{
/* set users/friends/network */
float downKb = 0;
float upKb = 0;
rsicontrol -> ConfigGetDataRates(downKb, upKb);
std::ostringstream out;
out << "Down: " << std::setprecision(2) << std::fixed << downKb << " (kB/s) Up: " << std::setprecision(2) << std::fixed << upKb << " (kB/s) ";
std::list<std::string> ids;
rsPeers->getOnlineList(ids);
int online = ids.size();
ids.clear();
rsPeers->getFriendList(ids);
int friends = ids.size();
ids.clear();
rsPeers->getOthersList(ids);
int others = 1 + ids.size();
std::ostringstream out2;
out << "Online/Friends/Network: " << online << "/" << friends << "/" << others << " ";
/* set uploads/download rates */
if (statusRates)
statusRates -> setText(QString::fromStdString(out.str()));
if (statusPeers)
statusPeers -> setText(QString::fromStdString(out2.str()));
}
/** Creates a new action associated with a config page. */
QAction* MainWindow::createPageAction(QIcon img, QString text, QActionGroup *group)
{

View File

@ -115,6 +115,7 @@ public slots:
private slots:
void updateMenu();
void updateStatus();
void toggleVisibility(QSystemTrayIcon::ActivationReason e);
void toggleVisibilitycontextmenu();
@ -188,6 +189,9 @@ private:
QSystemTrayIcon *trayIcon;
QAction *toggleVisibilityAction, *toolAct;
QMenu *menu;
QLabel *statusRates;
QLabel *statusPeers;
/** Qt Designer generated object */
Ui::MainWindow ui;

View File

@ -259,6 +259,7 @@ virtual int ConfigRemoveSharedDir( std::string dir ) = 0;
virtual int ConfigSetIncomingDir( std::string dir ) = 0;
virtual int ConfigSetDataRates( int total, int indiv ) = 0;
virtual int ConfigGetDataRates( float &inKb, float &outKb) = 0;
virtual int ConfigSetBootPrompt( bool on ) = 0;
virtual void ConfigFinalSave( ) = 0;
virtual void rsGlobalShutDown( ) = 0;