mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-07-16 02:03:07 -07:00
- Moved status bar code from the GUI to its own class for make GUI more readable
- Fix "Display current speed in title" feature - Fix Up/Down speed labels update in status bar
This commit is contained in:
parent
c30ec7bb6e
commit
54d7c6dc54
4 changed files with 148 additions and 121 deletions
122
src/GUI.cpp
122
src/GUI.cpp
|
@ -66,6 +66,7 @@
|
||||||
#include "torrentPersistentData.h"
|
#include "torrentPersistentData.h"
|
||||||
#include "TransferListFiltersWidget.h"
|
#include "TransferListFiltersWidget.h"
|
||||||
#include "propertieswidget.h"
|
#include "propertieswidget.h"
|
||||||
|
#include "statusbar.h"
|
||||||
|
|
||||||
using namespace libtorrent;
|
using namespace libtorrent;
|
||||||
enum TabIndex{TAB_TRANSFER, TAB_SEARCH, TAB_RSS};
|
enum TabIndex{TAB_TRANSFER, TAB_SEARCH, TAB_RSS};
|
||||||
|
@ -189,41 +190,14 @@ GUI::GUI(QWidget *parent, QStringList torrentCmdLine) : QMainWindow(parent), dis
|
||||||
}
|
}
|
||||||
connect(localServer, SIGNAL(newConnection()), this, SLOT(acceptConnection()));
|
connect(localServer, SIGNAL(newConnection()), this, SLOT(acceptConnection()));
|
||||||
// Start connection checking timer
|
// Start connection checking timer
|
||||||
checkConnect = new QTimer(this);
|
guiUpdater = new QTimer(this);
|
||||||
connect(checkConnect, SIGNAL(timeout()), this, SLOT(checkConnectionStatus()));
|
connect(guiUpdater, SIGNAL(timeout()), this, SLOT(updateGUI()));
|
||||||
checkConnect->start(5000);
|
guiUpdater->start(2000);
|
||||||
// Accept drag 'n drops
|
// Accept drag 'n drops
|
||||||
setAcceptDrops(true);
|
setAcceptDrops(true);
|
||||||
createKeyboardShortcuts();
|
createKeyboardShortcuts();
|
||||||
connecStatusLblIcon = new QLabel();
|
// Create status bar
|
||||||
connecStatusLblIcon->setFrameShape(QFrame::NoFrame);
|
status_bar = new StatusBar(QMainWindow::statusBar(), BTSession);
|
||||||
connecStatusLblIcon->setPixmap(QPixmap(QString::fromUtf8(":/Icons/skin/firewalled.png")));
|
|
||||||
connecStatusLblIcon->setToolTip(QString::fromUtf8("<b>")+tr("Connection status:")+QString::fromUtf8("</b><br>")+QString::fromUtf8("<i>")+tr("No direct connections. This may indicate network configuration problems.")+QString::fromUtf8("</i>"));
|
|
||||||
dlSpeedLbl = new QLabel(tr("DL: %1 KiB/s").arg("0.0"));
|
|
||||||
upSpeedLbl = new QLabel(tr("UP: %1 KiB/s").arg("0.0"));
|
|
||||||
ratioLbl = new QLabel(tr("Ratio: %1").arg("1.0"));
|
|
||||||
DHTLbl = new QLabel(tr("DHT: %1 nodes").arg(0));
|
|
||||||
statusSep1 = new QFrame();
|
|
||||||
statusSep1->setFixedWidth(1);
|
|
||||||
statusSep1->setFrameStyle(QFrame::Box);
|
|
||||||
statusSep2 = new QFrame();
|
|
||||||
statusSep2->setFixedWidth(1);
|
|
||||||
statusSep2->setFrameStyle(QFrame::Box);
|
|
||||||
statusSep3 = new QFrame();
|
|
||||||
statusSep3->setFixedWidth(1);
|
|
||||||
statusSep3->setFrameStyle(QFrame::Box);
|
|
||||||
statusSep4 = new QFrame();
|
|
||||||
statusSep4->setFixedWidth(1);
|
|
||||||
statusSep4->setFrameStyle(QFrame::Box);
|
|
||||||
QMainWindow::statusBar()->addPermanentWidget(DHTLbl);
|
|
||||||
QMainWindow::statusBar()->addPermanentWidget(statusSep1);
|
|
||||||
QMainWindow::statusBar()->addPermanentWidget(connecStatusLblIcon);
|
|
||||||
QMainWindow::statusBar()->addPermanentWidget(statusSep2);
|
|
||||||
QMainWindow::statusBar()->addPermanentWidget(dlSpeedLbl);
|
|
||||||
QMainWindow::statusBar()->addPermanentWidget(statusSep3);
|
|
||||||
QMainWindow::statusBar()->addPermanentWidget(upSpeedLbl);
|
|
||||||
QMainWindow::statusBar()->addPermanentWidget(statusSep4);
|
|
||||||
QMainWindow::statusBar()->addPermanentWidget(ratioLbl);
|
|
||||||
|
|
||||||
show();
|
show();
|
||||||
|
|
||||||
|
@ -242,14 +216,7 @@ GUI::GUI(QWidget *parent, QStringList torrentCmdLine) : QMainWindow(parent), dis
|
||||||
GUI::~GUI() {
|
GUI::~GUI() {
|
||||||
qDebug("GUI destruction");
|
qDebug("GUI destruction");
|
||||||
hide();
|
hide();
|
||||||
delete dlSpeedLbl;
|
delete status_bar;
|
||||||
delete upSpeedLbl;
|
|
||||||
delete ratioLbl;
|
|
||||||
delete DHTLbl;
|
|
||||||
delete statusSep1;
|
|
||||||
delete statusSep2;
|
|
||||||
delete statusSep3;
|
|
||||||
delete statusSep4;
|
|
||||||
if(rssWidget)
|
if(rssWidget)
|
||||||
delete rssWidget;
|
delete rssWidget;
|
||||||
delete searchEngine;
|
delete searchEngine;
|
||||||
|
@ -258,7 +225,7 @@ GUI::~GUI() {
|
||||||
delete transferList;
|
delete transferList;
|
||||||
delete hSplitter;
|
delete hSplitter;
|
||||||
delete vSplitter;
|
delete vSplitter;
|
||||||
delete checkConnect;
|
delete guiUpdater;
|
||||||
qDebug("1");
|
qDebug("1");
|
||||||
if(systrayCreator) {
|
if(systrayCreator) {
|
||||||
delete systrayCreator;
|
delete systrayCreator;
|
||||||
|
@ -270,7 +237,6 @@ GUI::~GUI() {
|
||||||
qDebug("2");
|
qDebug("2");
|
||||||
localServer->close();
|
localServer->close();
|
||||||
delete localServer;
|
delete localServer;
|
||||||
delete connecStatusLblIcon;
|
|
||||||
delete tabs;
|
delete tabs;
|
||||||
// HTTP Server
|
// HTTP Server
|
||||||
if(httpServer)
|
if(httpServer)
|
||||||
|
@ -302,25 +268,6 @@ void GUI::displayRSSTab(bool enable) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GUI::updateRatio() {
|
|
||||||
// Update ratio info
|
|
||||||
float ratio = 1.;
|
|
||||||
session_status sessionStatus = BTSession->getSessionStatus();
|
|
||||||
if(sessionStatus.total_payload_download == 0) {
|
|
||||||
if(sessionStatus.total_payload_upload == 0)
|
|
||||||
ratio = 1.;
|
|
||||||
else
|
|
||||||
ratio = 10.;
|
|
||||||
}else{
|
|
||||||
ratio = (double)sessionStatus.total_payload_upload / (double)sessionStatus.total_payload_download;
|
|
||||||
if(ratio > 10.)
|
|
||||||
ratio = 10.;
|
|
||||||
}
|
|
||||||
ratioLbl->setText(tr("Ratio: %1").arg(QString(QByteArray::number(ratio, 'f', 1))));
|
|
||||||
// Update DHT nodes
|
|
||||||
DHTLbl->setText(tr("DHT: %1 nodes").arg(QString::number(sessionStatus.dht_nodes)));
|
|
||||||
}
|
|
||||||
|
|
||||||
void GUI::on_actionWebsite_triggered() const {
|
void GUI::on_actionWebsite_triggered() const {
|
||||||
QDesktopServices::openUrl(QUrl(QString::fromUtf8("http://www.qbittorrent.org")));
|
QDesktopServices::openUrl(QUrl(QString::fromUtf8("http://www.qbittorrent.org")));
|
||||||
}
|
}
|
||||||
|
@ -769,7 +716,7 @@ void GUI::loadPreferences(bool configure_session) {
|
||||||
bool new_displaySpeedInTitle = Preferences::speedInTitleBar();
|
bool new_displaySpeedInTitle = Preferences::speedInTitleBar();
|
||||||
if(!new_displaySpeedInTitle && new_displaySpeedInTitle != displaySpeedInTitle) {
|
if(!new_displaySpeedInTitle && new_displaySpeedInTitle != displaySpeedInTitle) {
|
||||||
// Reset title
|
// Reset title
|
||||||
setWindowTitle(tr("qBittorrent %1", "e.g: qBittorrent v0.x").arg(QString::fromUtf8(VERSION)));
|
setWindowTitle(tr("qBittorrent %1", "e.g: qBittorrent vx.x").arg(QString::fromUtf8(VERSION)));
|
||||||
}
|
}
|
||||||
displaySpeedInTitle = new_displaySpeedInTitle;
|
displaySpeedInTitle = new_displaySpeedInTitle;
|
||||||
if(Preferences::isToolbarDisplayed()) {
|
if(Preferences::isToolbarDisplayed()) {
|
||||||
|
@ -826,40 +773,6 @@ void GUI::addUnauthenticatedTracker(QPair<QTorrentHandle,QString> tracker) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*void GUI::updateLists(bool force) {
|
|
||||||
if(isVisible() || force) {
|
|
||||||
// update global informations
|
|
||||||
dlSpeedLbl->setText(tr("DL: %1 KiB/s").arg(QString(QByteArray::number(BTSession->getPayloadDownloadRate()/1024., 'f', 1))));
|
|
||||||
upSpeedLbl->setText(tr("UP: %1 KiB/s").arg(QString(QByteArray::number(BTSession->getPayloadUploadRate()/1024., 'f', 1))));
|
|
||||||
std::vector<torrent_handle> torrents = BTSession->getTorrents();
|
|
||||||
std::vector<torrent_handle>::iterator torrentIT;
|
|
||||||
for(torrentIT = torrents.begin(); torrentIT != torrents.end(); torrentIT++) {
|
|
||||||
QTorrentHandle h = QTorrentHandle(*torrentIT);
|
|
||||||
if(!h.is_valid()) continue;
|
|
||||||
try {
|
|
||||||
if(h.is_seed()) {
|
|
||||||
// Update in finished list
|
|
||||||
finishedTorrentTab->updateTorrent(h);
|
|
||||||
} else {
|
|
||||||
// Update in download list
|
|
||||||
if(downloadingTorrentTab->updateTorrent(h)) {
|
|
||||||
// Torrent was added, we may need to remove it from finished tab
|
|
||||||
finishedTorrentTab->deleteTorrent(h.hash());
|
|
||||||
TorrentPersistentData::saveSeedStatus(h);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch(invalid_handle e) {
|
|
||||||
qDebug("Caught Invalid handle exception, lucky us.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(displaySpeedInTitle) {
|
|
||||||
QString dl_rate = QByteArray::number(BTSession->getSessionStatus().payload_download_rate/1024, 'f', 1);
|
|
||||||
QString up_rate = QByteArray::number(BTSession->getSessionStatus().payload_upload_rate/1024, 'f', 1);
|
|
||||||
setWindowTitle(tr("qBittorrent %1 (DL: %2KiB/s, UP: %3KiB/s)", "%1 is qBittorrent version").arg(QString::fromUtf8(VERSION)).arg(dl_rate).arg(up_rate));
|
|
||||||
}
|
|
||||||
}*/
|
|
||||||
|
|
||||||
// Called when a tracker requires authentication
|
// Called when a tracker requires authentication
|
||||||
void GUI::trackerAuthenticationRequired(QTorrentHandle& h) {
|
void GUI::trackerAuthenticationRequired(QTorrentHandle& h) {
|
||||||
if(unauthenticated_trackers.indexOf(QPair<QTorrentHandle,QString>(h, h.current_tracker())) < 0) {
|
if(unauthenticated_trackers.indexOf(QPair<QTorrentHandle,QString>(h, h.current_tracker())) < 0) {
|
||||||
|
@ -869,10 +782,7 @@ void GUI::trackerAuthenticationRequired(QTorrentHandle& h) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check connection status and display right icon
|
// Check connection status and display right icon
|
||||||
void GUI::checkConnectionStatus() {
|
void GUI::updateGUI() {
|
||||||
// qDebug("Checking connection status");
|
|
||||||
// Update Ratio
|
|
||||||
updateRatio();
|
|
||||||
// update global informations
|
// update global informations
|
||||||
if(systrayIntegration) {
|
if(systrayIntegration) {
|
||||||
#ifdef Q_WS_WIN
|
#ifdef Q_WS_WIN
|
||||||
|
@ -893,14 +803,10 @@ void GUI::checkConnectionStatus() {
|
||||||
#endif
|
#endif
|
||||||
myTrayIcon->setToolTip(html); // tray icon
|
myTrayIcon->setToolTip(html); // tray icon
|
||||||
}
|
}
|
||||||
session_status sessionStatus = BTSession->getSessionStatus();
|
if(displaySpeedInTitle) {
|
||||||
if(sessionStatus.has_incoming_connections) {
|
QString dl_rate = QByteArray::number(BTSession->getSessionStatus().payload_download_rate/1024, 'f', 1);
|
||||||
// Connection OK
|
QString up_rate = QByteArray::number(BTSession->getSessionStatus().payload_upload_rate/1024, 'f', 1);
|
||||||
connecStatusLblIcon->setPixmap(QPixmap(QString::fromUtf8(":/Icons/skin/connected.png")));
|
setWindowTitle(tr("qBittorrent %1 (DL: %2KiB/s, UP: %3KiB/s)", "%1 is qBittorrent version").arg(QString::fromUtf8(VERSION)).arg(dl_rate).arg(up_rate));
|
||||||
connecStatusLblIcon->setToolTip(QString::fromUtf8("<b>")+tr("Connection Status:")+QString::fromUtf8("</b><br>")+tr("Online"));
|
|
||||||
}else{
|
|
||||||
connecStatusLblIcon->setPixmap(QPixmap(QString::fromUtf8(":/Icons/skin/firewalled.png")));
|
|
||||||
connecStatusLblIcon->setToolTip(QString::fromUtf8("<b>")+tr("Connection status:")+QString::fromUtf8("</b><br>")+QString::fromUtf8("<i>")+tr("No direct connections. This may indicate network configuration problems.")+QString::fromUtf8("</i>"));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
16
src/GUI.h
16
src/GUI.h
|
@ -59,6 +59,7 @@ class TransferListWidget;
|
||||||
class TransferListFiltersWidget;
|
class TransferListFiltersWidget;
|
||||||
class QSplitter;
|
class QSplitter;
|
||||||
class PropertiesWidget;
|
class PropertiesWidget;
|
||||||
|
class StatusBar;
|
||||||
|
|
||||||
class GUI : public QMainWindow, private Ui::MainWindow{
|
class GUI : public QMainWindow, private Ui::MainWindow{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
@ -66,10 +67,11 @@ class GUI : public QMainWindow, private Ui::MainWindow{
|
||||||
private:
|
private:
|
||||||
// Bittorrent
|
// Bittorrent
|
||||||
bittorrent *BTSession;
|
bittorrent *BTSession;
|
||||||
QTimer *checkConnect;
|
QTimer *guiUpdater;
|
||||||
QList<QPair<QTorrentHandle,QString> > unauthenticated_trackers;
|
QList<QPair<QTorrentHandle,QString> > unauthenticated_trackers;
|
||||||
// GUI related
|
// GUI related
|
||||||
QTabWidget *tabs;
|
QTabWidget *tabs;
|
||||||
|
StatusBar *status_bar;
|
||||||
QPointer<options_imp> options;
|
QPointer<options_imp> options;
|
||||||
QSystemTrayIcon *myTrayIcon;
|
QSystemTrayIcon *myTrayIcon;
|
||||||
QPointer<QTimer> systrayCreator;
|
QPointer<QTimer> systrayCreator;
|
||||||
|
@ -79,19 +81,10 @@ class GUI : public QMainWindow, private Ui::MainWindow{
|
||||||
PropertiesWidget *properties;
|
PropertiesWidget *properties;
|
||||||
QSplitter *hSplitter;
|
QSplitter *hSplitter;
|
||||||
QSplitter *vSplitter;
|
QSplitter *vSplitter;
|
||||||
QLabel *connecStatusLblIcon;
|
|
||||||
bool systrayIntegration;
|
bool systrayIntegration;
|
||||||
bool displaySpeedInTitle;
|
bool displaySpeedInTitle;
|
||||||
bool force_exit;
|
bool force_exit;
|
||||||
//unsigned int refreshInterval;
|
//unsigned int refreshInterval;
|
||||||
QLabel *dlSpeedLbl;
|
|
||||||
QLabel *upSpeedLbl;
|
|
||||||
QLabel *ratioLbl;
|
|
||||||
QLabel *DHTLbl;
|
|
||||||
QFrame *statusSep1;
|
|
||||||
QFrame *statusSep2;
|
|
||||||
QFrame *statusSep3;
|
|
||||||
QFrame *statusSep4;
|
|
||||||
// Keyboard shortcuts
|
// Keyboard shortcuts
|
||||||
QShortcut *switchSearchShortcut;
|
QShortcut *switchSearchShortcut;
|
||||||
QShortcut *switchSearchShortcut2;
|
QShortcut *switchSearchShortcut2;
|
||||||
|
@ -141,7 +134,7 @@ class GUI : public QMainWindow, private Ui::MainWindow{
|
||||||
void on_actionSet_global_download_limit_triggered();
|
void on_actionSet_global_download_limit_triggered();
|
||||||
void on_actionDocumentation_triggered() const;
|
void on_actionDocumentation_triggered() const;
|
||||||
void on_actionOpen_triggered();
|
void on_actionOpen_triggered();
|
||||||
void checkConnectionStatus();
|
void updateGUI();
|
||||||
void loadPreferences(bool configure_session=true);
|
void loadPreferences(bool configure_session=true);
|
||||||
void processParams(const QStringList& params);
|
void processParams(const QStringList& params);
|
||||||
void addTorrent(QString path);
|
void addTorrent(QString path);
|
||||||
|
@ -161,7 +154,6 @@ class GUI : public QMainWindow, private Ui::MainWindow{
|
||||||
public slots:
|
public slots:
|
||||||
void trackerAuthenticationRequired(QTorrentHandle& h);
|
void trackerAuthenticationRequired(QTorrentHandle& h);
|
||||||
void setTabText(int index, QString text) const;
|
void setTabText(int index, QString text) const;
|
||||||
void updateRatio();
|
|
||||||
void showNotificationBaloon(QString title, QString msg) const;
|
void showNotificationBaloon(QString title, QString msg) const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
|
@ -194,7 +194,8 @@ HEADERS += GUI.h \
|
||||||
preferences.h \
|
preferences.h \
|
||||||
geoip.h \
|
geoip.h \
|
||||||
peeraddition.h \
|
peeraddition.h \
|
||||||
deletionconfirmationdlg.h
|
deletionconfirmationdlg.h \
|
||||||
|
statusbar.h
|
||||||
FORMS += MainWindow.ui \
|
FORMS += MainWindow.ui \
|
||||||
options.ui \
|
options.ui \
|
||||||
about.ui \
|
about.ui \
|
||||||
|
|
128
src/statusbar.h
Normal file
128
src/statusbar.h
Normal file
|
@ -0,0 +1,128 @@
|
||||||
|
/*
|
||||||
|
* Bittorrent Client using Qt4 and libtorrent.
|
||||||
|
* Copyright (C) 2006 Christophe Dumez
|
||||||
|
*
|
||||||
|
* 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.
|
||||||
|
*
|
||||||
|
* In addition, as a special exception, the copyright holders give permission to
|
||||||
|
* link this program with the OpenSSL project's "OpenSSL" library (or with
|
||||||
|
* modified versions of it that use the same license as the "OpenSSL" library),
|
||||||
|
* and distribute the linked executables. You must obey the GNU General Public
|
||||||
|
* License in all respects for all of the code used other than "OpenSSL". If you
|
||||||
|
* modify file(s), you may extend this exception to your version of the file(s),
|
||||||
|
* but you are not obligated to do so. If you do not wish to do so, delete this
|
||||||
|
* exception statement from your version.
|
||||||
|
*
|
||||||
|
* Contact : chris@qbittorrent.org
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef STATUSBAR_H
|
||||||
|
#define STATUSBAR_H
|
||||||
|
|
||||||
|
#include <QStatusBar>
|
||||||
|
#include <QFrame>
|
||||||
|
#include <QLabel>
|
||||||
|
#include <QTimer>
|
||||||
|
#include "bittorrent.h"
|
||||||
|
#include "misc.h"
|
||||||
|
|
||||||
|
class StatusBar: public QObject {
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
private:
|
||||||
|
QStatusBar *bar;
|
||||||
|
QLabel *dlSpeedLbl;
|
||||||
|
QLabel *upSpeedLbl;
|
||||||
|
QLabel *DHTLbl;
|
||||||
|
QFrame *statusSep1;
|
||||||
|
QFrame *statusSep2;
|
||||||
|
QFrame *statusSep3;
|
||||||
|
QFrame *statusSep4;
|
||||||
|
QLabel *connecStatusLblIcon;
|
||||||
|
QTimer *refreshTimer;
|
||||||
|
bittorrent *BTSession;
|
||||||
|
|
||||||
|
public:
|
||||||
|
StatusBar(QStatusBar *bar, bittorrent *BTSession): bar(bar), BTSession(BTSession) {
|
||||||
|
connecStatusLblIcon = new QLabel();
|
||||||
|
connecStatusLblIcon->setFrameShape(QFrame::NoFrame);
|
||||||
|
connecStatusLblIcon->setPixmap(QPixmap(QString::fromUtf8(":/Icons/skin/firewalled.png")));
|
||||||
|
connecStatusLblIcon->setToolTip(QString::fromUtf8("<b>")+tr("Connection status:")+QString::fromUtf8("</b><br>")+QString::fromUtf8("<i>")+tr("No direct connections. This may indicate network configuration problems.")+QString::fromUtf8("</i>"));
|
||||||
|
dlSpeedLbl = new QLabel(tr("Down: %1 KiB/s", "Download speed: x KiB/s").arg("0.0"));
|
||||||
|
upSpeedLbl = new QLabel(tr("Up: %1 KiB/s", "Upload speed: x KiB/s").arg("0.0"));
|
||||||
|
DHTLbl = new QLabel(tr("DHT: %1 nodes").arg(0));
|
||||||
|
statusSep1 = new QFrame();
|
||||||
|
statusSep1->setFixedWidth(1);
|
||||||
|
statusSep1->setFrameStyle(QFrame::Box);
|
||||||
|
statusSep2 = new QFrame();
|
||||||
|
statusSep2->setFixedWidth(1);
|
||||||
|
statusSep2->setFrameStyle(QFrame::Box);
|
||||||
|
statusSep3 = new QFrame();
|
||||||
|
statusSep3->setFixedWidth(1);
|
||||||
|
statusSep3->setFrameStyle(QFrame::Box);
|
||||||
|
statusSep4 = new QFrame();
|
||||||
|
bar->addPermanentWidget(DHTLbl);
|
||||||
|
bar->addPermanentWidget(statusSep1);
|
||||||
|
bar->addPermanentWidget(connecStatusLblIcon);
|
||||||
|
bar->addPermanentWidget(statusSep2);
|
||||||
|
bar->addPermanentWidget(dlSpeedLbl);
|
||||||
|
bar->addPermanentWidget(statusSep3);
|
||||||
|
bar->addPermanentWidget(upSpeedLbl);
|
||||||
|
|
||||||
|
refreshTimer = new QTimer(bar);
|
||||||
|
connect(refreshTimer, SIGNAL(timeout()), this, SLOT(refreshStatusBar()));
|
||||||
|
refreshTimer->start(1500);
|
||||||
|
}
|
||||||
|
|
||||||
|
~StatusBar() {
|
||||||
|
delete refreshTimer;
|
||||||
|
delete dlSpeedLbl;
|
||||||
|
delete upSpeedLbl;
|
||||||
|
delete DHTLbl;
|
||||||
|
delete statusSep1;
|
||||||
|
delete statusSep2;
|
||||||
|
delete statusSep3;
|
||||||
|
delete connecStatusLblIcon;
|
||||||
|
}
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void refreshStatusBar() {
|
||||||
|
// Update connection status
|
||||||
|
session_status sessionStatus = BTSession->getSessionStatus();
|
||||||
|
if(sessionStatus.has_incoming_connections) {
|
||||||
|
// Connection OK
|
||||||
|
connecStatusLblIcon->setPixmap(QPixmap(QString::fromUtf8(":/Icons/skin/connected.png")));
|
||||||
|
connecStatusLblIcon->setToolTip(QString::fromUtf8("<b>")+tr("Connection Status:")+QString::fromUtf8("</b><br>")+tr("Online"));
|
||||||
|
}else{
|
||||||
|
connecStatusLblIcon->setPixmap(QPixmap(QString::fromUtf8(":/Icons/skin/firewalled.png")));
|
||||||
|
connecStatusLblIcon->setToolTip(QString::fromUtf8("<b>")+tr("Connection status:")+QString::fromUtf8("</b><br>")+QString::fromUtf8("<i>")+tr("No direct connections. This may indicate network configuration problems.")+QString::fromUtf8("</i>"));
|
||||||
|
}
|
||||||
|
// Update Number of DHT nodes
|
||||||
|
if(BTSession->isDHTEnabled()) {
|
||||||
|
DHTLbl->setVisible(true);
|
||||||
|
statusSep1->setVisible(true);
|
||||||
|
DHTLbl->setText(tr("DHT: %1 nodes").arg(QString::number(sessionStatus.dht_nodes)));
|
||||||
|
} else {
|
||||||
|
DHTLbl->setVisible(false);
|
||||||
|
statusSep1->setVisible(false);
|
||||||
|
}
|
||||||
|
// Update speed labels
|
||||||
|
dlSpeedLbl->setText(tr("Down: %1 KiB/s", "i.e. Download speed:").arg(QString::number(BTSession->getPayloadDownloadRate()/1024., 'f', 1)));
|
||||||
|
upSpeedLbl->setText(tr("Up: %1 KiB/s", "i.e. Upload speed:").arg(QString::number(BTSession->getPayloadUploadRate()/1024., 'f', 1)));
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // STATUSBAR_H
|
Loading…
Add table
Add a link
Reference in a new issue