diff --git a/retroshare-gui/src/gui/MainWindow.cpp b/retroshare-gui/src/gui/MainWindow.cpp index 3bee30131..cf3846158 100644 --- a/retroshare-gui/src/gui/MainWindow.cpp +++ b/retroshare-gui/src/gui/MainWindow.cpp @@ -96,7 +96,7 @@ ****/ #define RS_RELEASE_VERSION 1 - + /** Constructor */ MainWindow::MainWindow(QWidget* parent, Qt::WFlags flags) : QMainWindow(parent, flags) @@ -214,7 +214,7 @@ MainWindow::MainWindow(QWidget* parent, Qt::WFlags flags) connect(transfersDialog, SIGNAL(playFiles( QStringList )), this, SLOT(playFiles( QStringList ))); #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 @@ -258,9 +258,9 @@ MainWindow::MainWindow(QWidget* parent, Qt::WFlags flags) ui.toolBarservice->addSeparator(); #endif - //peerstatus = new PeerStatus(); - //statusBar()->addWidget(peerstatus); - statusBar()->addWidget(statusPeers = new QLabel(tr("Online: 0 |Friends: 0|Network: 0"))); + peerstatus = new PeerStatus(); + statusBar()->addWidget(peerstatus); + //statusBar()->addWidget(statusPeers = new QLabel(tr("Online: 0 |Friends: 0|Network: 0"))); statusBar()->addPermanentWidget(statusRates = new QLabel(tr("Down: 0.0 | Up: 0.0 "))); //statusBar()->addPermanentWidget(statusPeers = new QLabel(tr("Online: 0 |Friends: 0|Network: 0"))); @@ -328,36 +328,15 @@ void MainWindow::updateStatus() std::ostringstream out; out << "Down: " << std::setprecision(2) << std::fixed << downKb << " (kB/s) | Up: " << std::setprecision(2) << std::fixed << upKb << " (kB/s) "; - std::list 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; - out2 << "Online: " << online << "| Friends: " << friends << "| Network: " << others << " "; - /* set uploads/download rates */ - if (statusRates) statusRates -> setText(QString::fromStdString(out.str())); - if (statusPeers) - statusPeers -> setText(QString::fromStdString(out2.str())); + if (peerstatus) + peerstatus->setPeerStatus(); } -void MainWindow::peerstat() -{ - peerstatus->setPeerStatus(); -} - /** Creates a new action associated with a config page. */ QAction* MainWindow::createPageAction(QIcon img, QString text, QActionGroup *group) diff --git a/retroshare-gui/src/gui/MainWindow.h b/retroshare-gui/src/gui/MainWindow.h index 303f00b8d..cb4958da1 100644 --- a/retroshare-gui/src/gui/MainWindow.h +++ b/retroshare-gui/src/gui/MainWindow.h @@ -56,6 +56,8 @@ class SMPlayer; +class PeerStatus; + class MainWindow : public QMainWindow { Q_OBJECT @@ -116,7 +118,6 @@ private slots: void updateMenu(); void updateStatus(); - void peerstat(); void toggleVisibility(QSystemTrayIcon::ActivationReason e); void toggleVisibilitycontextmenu(); @@ -192,9 +193,7 @@ private: QMenu *menu; QLabel *statusRates; - QLabel *statusPeers; - - class PeerStatus *peerstatus; + PeerStatus *peerstatus; /** Qt Designer generated object */ Ui::MainWindow ui; diff --git a/retroshare-gui/src/gui/MessengerWindow.cpp b/retroshare-gui/src/gui/MessengerWindow.cpp index 93f88d2d1..da68d1a1f 100644 --- a/retroshare-gui/src/gui/MessengerWindow.cpp +++ b/retroshare-gui/src/gui/MessengerWindow.cpp @@ -296,7 +296,8 @@ void MessengerWindow::connectfriend2() if (!i) return; - if (isOnline) + std::string id = (i -> text(4)).toStdString(); + if (rsPeers->isOnline(id)) { std::cerr << "MessengerWindow::connectfriend2() Already online" << std::endl; } @@ -368,7 +369,7 @@ void MessengerWindow::chatfriend2() std::string name = (i -> text(0)).toStdString(); std::string id = (i -> text(4)).toStdString(); - if (!isOnline) + if (!(rsPeers->isOnline(id))) { /* info dialog */ QMessageBox::StandardButton sb = QMessageBox::question ( NULL, diff --git a/retroshare-gui/src/gui/statusbar/peerstatus.cpp b/retroshare-gui/src/gui/statusbar/peerstatus.cpp index 61032219d..c71ded199 100644 --- a/retroshare-gui/src/gui/statusbar/peerstatus.cpp +++ b/retroshare-gui/src/gui/statusbar/peerstatus.cpp @@ -52,10 +52,7 @@ PeerStatus::PeerStatus(QWidget *parent) hbox->addWidget(statusPeers); setLayout( hbox ); - - QTimer *timer2 = new QTimer(this); - timer2->connect(timer2, SIGNAL(timeout()), this, SLOT(setPeerStatus())); - timer2->start(5113); + } PeerStatus::~PeerStatus() @@ -79,7 +76,7 @@ void PeerStatus::setPeerStatus() int others = 1 + ids.size(); std::ostringstream out2; - out2 << "Online: " << online << "| Friends: " << friends << "| Network: " << others << " "; + out2 << "Online: " << online << " | Friends: " << friends << " | Network: " << others << " "; if (statusPeers) diff --git a/retroshare-gui/src/gui/statusbar/peerstatus.h b/retroshare-gui/src/gui/statusbar/peerstatus.h index 426ae78a3..814491c91 100644 --- a/retroshare-gui/src/gui/statusbar/peerstatus.h +++ b/retroshare-gui/src/gui/statusbar/peerstatus.h @@ -33,7 +33,7 @@ public: PeerStatus(QWidget *parent = 0); ~PeerStatus(); - + void setPeerStatus( ); diff --git a/retroshare-gui/src/rsiface/rspeers.h b/retroshare-gui/src/rsiface/rspeers.h index 2556ce0e7..a92717f57 100644 --- a/retroshare-gui/src/rsiface/rspeers.h +++ b/retroshare-gui/src/rsiface/rspeers.h @@ -125,6 +125,7 @@ virtual bool getOnlineList(std::list &ids) = 0; virtual bool getFriendList(std::list &ids) = 0; virtual bool getOthersList(std::list &ids) = 0; +virtual bool isOnline(std::string id) = 0; virtual bool isFriend(std::string id) = 0; virtual std::string getPeerName(std::string id) = 0; virtual bool getPeerDetails(std::string id, RsPeerDetails &d) = 0;