mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-02-25 01:10:19 -05:00
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:
parent
e42ce13454
commit
c6ac65efe5
@ -50,6 +50,8 @@
|
|||||||
#include "gui/connect/InviteDialog.h"
|
#include "gui/connect/InviteDialog.h"
|
||||||
#include "gui/connect/AddFriendDialog.h"
|
#include "gui/connect/AddFriendDialog.h"
|
||||||
|
|
||||||
|
#include <sstream>
|
||||||
|
#include <iomanip>
|
||||||
|
|
||||||
#define FONT QFont(tr("Arial"), 8)
|
#define FONT QFont(tr("Arial"), 8)
|
||||||
|
|
||||||
@ -211,6 +213,7 @@ MainWindow::MainWindow(QWidget* parent, Qt::WFlags flags)
|
|||||||
#ifdef RS_RELEASE_VERSION
|
#ifdef RS_RELEASE_VERSION
|
||||||
//addAction(new QAction(QIcon(IMAGE_BLOCK), tr("Unfinished"), ui.toolBar), SLOT(showApplWindow()));
|
//addAction(new QAction(QIcon(IMAGE_BLOCK), tr("Unfinished"), ui.toolBar), SLOT(showApplWindow()));
|
||||||
|
|
||||||
|
|
||||||
#else
|
#else
|
||||||
addAction(new QAction(QIcon(IMAGE_BLOCK), tr("Unfinished"), ui.toolBar), SLOT(showApplWindow()));
|
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();
|
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
|
#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);
|
//servicegrp->actions()[0]->setChecked(true);
|
||||||
|
|
||||||
/* Create the actions that will go in the tray menu */
|
/* 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)));
|
SLOT(toggleVisibility(QSystemTrayIcon::ActivationReason)));
|
||||||
trayIcon->show();
|
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. */
|
/** Creates a new action associated with a config page. */
|
||||||
QAction* MainWindow::createPageAction(QIcon img, QString text, QActionGroup *group)
|
QAction* MainWindow::createPageAction(QIcon img, QString text, QActionGroup *group)
|
||||||
{
|
{
|
||||||
|
@ -115,6 +115,7 @@ public slots:
|
|||||||
private slots:
|
private slots:
|
||||||
|
|
||||||
void updateMenu();
|
void updateMenu();
|
||||||
|
void updateStatus();
|
||||||
|
|
||||||
void toggleVisibility(QSystemTrayIcon::ActivationReason e);
|
void toggleVisibility(QSystemTrayIcon::ActivationReason e);
|
||||||
void toggleVisibilitycontextmenu();
|
void toggleVisibilitycontextmenu();
|
||||||
@ -189,6 +190,9 @@ private:
|
|||||||
QAction *toggleVisibilityAction, *toolAct;
|
QAction *toggleVisibilityAction, *toolAct;
|
||||||
QMenu *menu;
|
QMenu *menu;
|
||||||
|
|
||||||
|
QLabel *statusRates;
|
||||||
|
QLabel *statusPeers;
|
||||||
|
|
||||||
/** Qt Designer generated object */
|
/** Qt Designer generated object */
|
||||||
Ui::MainWindow ui;
|
Ui::MainWindow ui;
|
||||||
};
|
};
|
||||||
|
@ -259,6 +259,7 @@ virtual int ConfigRemoveSharedDir( std::string dir ) = 0;
|
|||||||
virtual int ConfigSetIncomingDir( std::string dir ) = 0;
|
virtual int ConfigSetIncomingDir( std::string dir ) = 0;
|
||||||
|
|
||||||
virtual int ConfigSetDataRates( int total, int indiv ) = 0;
|
virtual int ConfigSetDataRates( int total, int indiv ) = 0;
|
||||||
|
virtual int ConfigGetDataRates( float &inKb, float &outKb) = 0;
|
||||||
virtual int ConfigSetBootPrompt( bool on ) = 0;
|
virtual int ConfigSetBootPrompt( bool on ) = 0;
|
||||||
virtual void ConfigFinalSave( ) = 0;
|
virtual void ConfigFinalSave( ) = 0;
|
||||||
virtual void rsGlobalShutDown( ) = 0;
|
virtual void rsGlobalShutDown( ) = 0;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user