From ad5694c8e5752638972ce4908ce048eaf3eb7013 Mon Sep 17 00:00:00 2001 From: defnax Date: Sun, 15 Jun 2008 15:34:56 +0000 Subject: [PATCH] added new source statusbar folder added for show each vote with the correct icon in Link Cloud git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@608 b45a01b8-16f6-495d-af2f-9b41ad6348cc --- retroshare-gui/src/RetroShare.pro | 4 +- retroshare-gui/src/gui/LinksDialog.cpp | 5 ++ retroshare-gui/src/gui/MainWindow.cpp | 12 ++- retroshare-gui/src/gui/MainWindow.h | 3 + .../src/gui/statusbar/peerstatus.cpp | 90 +++++++++++++++++++ retroshare-gui/src/gui/statusbar/peerstatus.h | 45 ++++++++++ 6 files changed, 155 insertions(+), 4 deletions(-) create mode 100644 retroshare-gui/src/gui/statusbar/peerstatus.cpp create mode 100644 retroshare-gui/src/gui/statusbar/peerstatus.h diff --git a/retroshare-gui/src/RetroShare.pro b/retroshare-gui/src/RetroShare.pro index 2c6a80b02..6035a20a8 100644 --- a/retroshare-gui/src/RetroShare.pro +++ b/retroshare-gui/src/RetroShare.pro @@ -135,6 +135,7 @@ HEADERS += rshare.h \ gui/Settings/DirectoriesPage.h \ gui/Settings/ServerPage.h \ gui/Settings/NetworkPage.h \ + gui/statusbar/peerstatus.h \ gui/authdlg/AuthorizationDialog.h \ gui/advsearch/advancedsearchdialog.h \ gui/advsearch/expressionwidget.h \ @@ -293,7 +294,8 @@ SOURCES += main.cpp \ gui/Settings/GeneralPage.cpp \ gui/Settings/DirectoriesPage.cpp \ gui/Settings/ServerPage.cpp \ - gui/Settings/NetworkPage.cpp \ + gui/Settings/NetworkPage.cpp \ + gui/statusbar/peerstatus.cpp \ gui/toaster/ChatToaster.cpp \ gui/toaster/MessageToaster.cpp \ gui/toaster/CallToaster.cpp \ diff --git a/retroshare-gui/src/gui/LinksDialog.cpp b/retroshare-gui/src/gui/LinksDialog.cpp index 004913dd2..43b22348d 100644 --- a/retroshare-gui/src/gui/LinksDialog.cpp +++ b/retroshare-gui/src/gui/LinksDialog.cpp @@ -396,26 +396,31 @@ void LinksDialog::updateLinks() if (cit->score > 1) { peerScore = "[+2] "; + child -> setIcon(0,(QIcon(IMAGE_GREAT))); //peerScore = "[+2 Great Link] "; } else if (cit->score == 1) { peerScore = "[+1] "; + child -> setIcon(0,(QIcon(IMAGE_GOOD))); //peerScore = "[+1 Good] "; } else if (cit->score == 0) { peerScore = "[+0] "; + child -> setIcon(0,(QIcon(IMAGE_OK))); //peerScore = "[+0 Okay] "; } else if (cit->score == -1) { peerScore = "[-1] "; + child -> setIcon(0,(QIcon(IMAGE_SUX))); //peerScore = "[-1 Not Worth It] "; } else //if (cit->score < -1) { peerScore = "[-2 BAD] "; + child -> setIcon(0,(QIcon(IMAGE_BADLINK))); //peerScore = "[-2 BAD Link] "; } diff --git a/retroshare-gui/src/gui/MainWindow.cpp b/retroshare-gui/src/gui/MainWindow.cpp index 4bc068c0d..3bee30131 100644 --- a/retroshare-gui/src/gui/MainWindow.cpp +++ b/retroshare-gui/src/gui/MainWindow.cpp @@ -40,6 +40,7 @@ #include "games/qbackgammon/bgwindow.h" #include "smplayer.h" +#include "statusbar/peerstatus.h" #include "Preferences/PreferencesWindow.h" #include "Settings/gsettingswin.h" #include "util/rsversion.h" @@ -213,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 @@ -257,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"))); - //statusPeers->setPixmap(QPixmap::QPixmap(":/images/.png")); statusBar()->addPermanentWidget(statusRates = new QLabel(tr("Down: 0.0 | Up: 0.0 "))); //statusBar()->addPermanentWidget(statusPeers = new QLabel(tr("Online: 0 |Friends: 0|Network: 0"))); @@ -352,6 +353,11 @@ void MainWindow::updateStatus() } +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 20e2b5ec7..303f00b8d 100644 --- a/retroshare-gui/src/gui/MainWindow.h +++ b/retroshare-gui/src/gui/MainWindow.h @@ -116,6 +116,7 @@ private slots: void updateMenu(); void updateStatus(); + void peerstat(); void toggleVisibility(QSystemTrayIcon::ActivationReason e); void toggleVisibilitycontextmenu(); @@ -192,6 +193,8 @@ private: QLabel *statusRates; QLabel *statusPeers; + + class PeerStatus *peerstatus; /** Qt Designer generated object */ Ui::MainWindow ui; diff --git a/retroshare-gui/src/gui/statusbar/peerstatus.cpp b/retroshare-gui/src/gui/statusbar/peerstatus.cpp new file mode 100644 index 000000000..61032219d --- /dev/null +++ b/retroshare-gui/src/gui/statusbar/peerstatus.cpp @@ -0,0 +1,90 @@ +/**************************************************************** + * RetroShare is distributed under the following license: + * + * Copyright (C) 2008 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 "peerstatus.h" + +#include +#include + +#include +#include +#include +#include +#include + +#include "rsiface/rsiface.h" +#include "rsiface/rspeers.h" + +#include +#include + +PeerStatus::PeerStatus(QWidget *parent) + : QWidget(parent) +{ + QHBoxLayout *hbox = new QHBoxLayout(); + hbox->setMargin(0); + hbox->setSpacing(6); + + iconLabel = new QLabel( this ); + iconLabel->setPixmap(QPixmap::QPixmap(":/images/user.png")); + // iconLabel doesn't change over time, so we didn't need a minimum size + hbox->addWidget(iconLabel); + + statusPeers = new QLabel( tr("Online: 0 |Friends: 0|Network: 0"), this ); + //statusPeers->setMinimumSize( statusPeers->frameSize().width() + 0, 0 ); + hbox->addWidget(statusPeers); + + setLayout( hbox ); + + QTimer *timer2 = new QTimer(this); + timer2->connect(timer2, SIGNAL(timeout()), this, SLOT(setPeerStatus())); + timer2->start(5113); +} + +PeerStatus::~PeerStatus() +{ +} + +void PeerStatus::setPeerStatus() +{ + /* set users/friends/network */ + + 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 << " "; + + + if (statusPeers) + statusPeers -> setText(QString::fromStdString(out2.str())); + +} + + diff --git a/retroshare-gui/src/gui/statusbar/peerstatus.h b/retroshare-gui/src/gui/statusbar/peerstatus.h new file mode 100644 index 000000000..426ae78a3 --- /dev/null +++ b/retroshare-gui/src/gui/statusbar/peerstatus.h @@ -0,0 +1,45 @@ +/**************************************************************** + * RetroShare is distributed under the following license: + * + * Copyright (C) 2008 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 PEERSTATUS_H +#define PEERSTATUS_H +#include "gui/MainWindow.h" + + +#include + + +class PeerStatus : public QWidget +{ +Q_OBJECT +public: + PeerStatus(QWidget *parent = 0); + + ~PeerStatus(); + + void setPeerStatus( ); + + +private: + class QLabel *iconLabel, *statusPeers; + +}; + +#endif