diff --git a/src/gui/statusbar.cpp b/src/gui/statusbar.cpp
index 937e24245..c20ef1427 100644
--- a/src/gui/statusbar.cpp
+++ b/src/gui/statusbar.cpp
@@ -167,10 +167,8 @@ void StatusBar::stopTimer()
m_refreshTimer->stop();
}
-void StatusBar::refreshStatusBar()
+void StatusBar::updateConnectionStatus(const BitTorrent::SessionStatus &sessionStatus)
{
- // Update connection status
- const BitTorrent::SessionStatus sessionStatus = BitTorrent::Session::instance()->status();
if (!BitTorrent::Session::instance()->isListening()) {
m_connecStatusLblIcon->setIcon(QIcon(QString::fromUtf8(":/icons/skin/disconnected.png")));
m_connecStatusLblIcon->setToolTip(QString::fromUtf8("") + tr("Connection Status:") + QString::fromUtf8("
") + tr("Offline. This usually means that qBittorrent failed to listen on the selected port for incoming connections."));
@@ -186,17 +184,21 @@ void StatusBar::refreshStatusBar()
m_connecStatusLblIcon->setToolTip(QString::fromUtf8("") + tr("Connection status:") + QString::fromUtf8("
") + QString::fromUtf8("") + tr("No direct connections. This may indicate network configuration problems.") + QString::fromUtf8(""));
}
}
- // Update Number of DHT nodes
+}
+
+void StatusBar::updateDHTNodesNumber(const BitTorrent::SessionStatus &sessionStatus)
+{
if (BitTorrent::Session::instance()->isDHTEnabled()) {
m_DHTLbl->setVisible(true);
- //statusSep1->setVisible(true);
m_DHTLbl->setText(tr("DHT: %1 nodes").arg(QString::number(sessionStatus.dhtNodes())));
}
else {
m_DHTLbl->setVisible(false);
- //statusSep1->setVisible(false);
}
- // Update speed labels
+}
+
+void StatusBar::updateSpeedLabels(const BitTorrent::SessionStatus &sessionStatus)
+{
QString speedLbl = Utils::Misc::friendlyUnit(sessionStatus.payloadDownloadRate(), true) + " (" + Utils::Misc::friendlyUnit(sessionStatus.totalPayloadDownload()) + ")";
int speedLimit = BitTorrent::Session::instance()->downloadRateLimit();
if (speedLimit)
@@ -209,6 +211,14 @@ void StatusBar::refreshStatusBar()
m_upSpeedLbl->setText(speedLbl);
}
+void StatusBar::refreshStatusBar()
+{
+ const BitTorrent::SessionStatus sessionStatus = BitTorrent::Session::instance()->status();
+ updateConnectionStatus(sessionStatus);
+ updateDHTNodesNumber(sessionStatus);
+ updateSpeedLabels(sessionStatus);
+}
+
void StatusBar::updateAltSpeedsBtn(bool alternative)
{
if (alternative) {
diff --git a/src/gui/statusbar.h b/src/gui/statusbar.h
index 0d7ceff5d..5efea8a5d 100644
--- a/src/gui/statusbar.h
+++ b/src/gui/statusbar.h
@@ -40,6 +40,11 @@ class QTimer;
class QPushButton;
class QHBoxLayout;
+namespace BitTorrent
+{
+ class SessionStatus;
+}
+
class StatusBar: public QObject
{
Q_OBJECT
@@ -74,6 +79,9 @@ private:
QWidget *m_container;
QHBoxLayout *m_layout;
+ void updateConnectionStatus(const BitTorrent::SessionStatus &sessionStatus);
+ void updateDHTNodesNumber(const BitTorrent::SessionStatus &sessionStatus);
+ void updateSpeedLabels(const BitTorrent::SessionStatus &sessionStatus);
};
#endif // STATUSBAR_H