mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2024-11-29 05:48:47 +03:00
Refactoring of StatusBar::refreshStatusBar function
This commit is contained in:
parent
2d9f90c3b5
commit
99aeacf9b0
2 changed files with 25 additions and 7 deletions
|
@ -167,10 +167,8 @@ void StatusBar::stopTimer()
|
||||||
m_refreshTimer->stop();
|
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()) {
|
if (!BitTorrent::Session::instance()->isListening()) {
|
||||||
m_connecStatusLblIcon->setIcon(QIcon(QString::fromUtf8(":/icons/skin/disconnected.png")));
|
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."));
|
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()
|
||||||
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>"));
|
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()) {
|
if (BitTorrent::Session::instance()->isDHTEnabled()) {
|
||||||
m_DHTLbl->setVisible(true);
|
m_DHTLbl->setVisible(true);
|
||||||
//statusSep1->setVisible(true);
|
|
||||||
m_DHTLbl->setText(tr("DHT: %1 nodes").arg(QString::number(sessionStatus.dhtNodes())));
|
m_DHTLbl->setText(tr("DHT: %1 nodes").arg(QString::number(sessionStatus.dhtNodes())));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
m_DHTLbl->setVisible(false);
|
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()) + ")";
|
QString speedLbl = Utils::Misc::friendlyUnit(sessionStatus.payloadDownloadRate(), true) + " (" + Utils::Misc::friendlyUnit(sessionStatus.totalPayloadDownload()) + ")";
|
||||||
int speedLimit = BitTorrent::Session::instance()->downloadRateLimit();
|
int speedLimit = BitTorrent::Session::instance()->downloadRateLimit();
|
||||||
if (speedLimit)
|
if (speedLimit)
|
||||||
|
@ -209,6 +211,14 @@ void StatusBar::refreshStatusBar()
|
||||||
m_upSpeedLbl->setText(speedLbl);
|
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)
|
void StatusBar::updateAltSpeedsBtn(bool alternative)
|
||||||
{
|
{
|
||||||
if (alternative) {
|
if (alternative) {
|
||||||
|
|
|
@ -40,6 +40,11 @@ class QTimer;
|
||||||
class QPushButton;
|
class QPushButton;
|
||||||
class QHBoxLayout;
|
class QHBoxLayout;
|
||||||
|
|
||||||
|
namespace BitTorrent
|
||||||
|
{
|
||||||
|
class SessionStatus;
|
||||||
|
}
|
||||||
|
|
||||||
class StatusBar: public QObject
|
class StatusBar: public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
@ -74,6 +79,9 @@ private:
|
||||||
QWidget *m_container;
|
QWidget *m_container;
|
||||||
QHBoxLayout *m_layout;
|
QHBoxLayout *m_layout;
|
||||||
|
|
||||||
|
void updateConnectionStatus(const BitTorrent::SessionStatus &sessionStatus);
|
||||||
|
void updateDHTNodesNumber(const BitTorrent::SessionStatus &sessionStatus);
|
||||||
|
void updateSpeedLabels(const BitTorrent::SessionStatus &sessionStatus);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // STATUSBAR_H
|
#endif // STATUSBAR_H
|
||||||
|
|
Loading…
Reference in a new issue