Browse Source

Refactoring of StatusBar::refreshStatusBar function

adaptive-webui-19844
buinsky 9 years ago
parent
commit
99aeacf9b0
  1. 24
      src/gui/statusbar.cpp
  2. 8
      src/gui/statusbar.h

24
src/gui/statusbar.cpp

@ -167,10 +167,8 @@ void StatusBar::stopTimer() @@ -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("<b>") + tr("Connection Status:") + QString::fromUtf8("</b><br>") + tr("Offline. This usually means that qBittorrent failed to listen on the selected port for incoming connections."));
@ -186,17 +184,21 @@ void StatusBar::refreshStatusBar() @@ -186,17 +184,21 @@ void StatusBar::refreshStatusBar()
m_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
}
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() @@ -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) {

8
src/gui/statusbar.h

@ -40,6 +40,11 @@ class QTimer; @@ -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: @@ -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

Loading…
Cancel
Save