From 2d9f90c3b5becdfe54d37f5c89be73b810352681 Mon Sep 17 00:00:00 2001 From: buinsky Date: Sun, 27 Dec 2015 10:27:06 +0300 Subject: [PATCH 1/4] Follow project coding style. Issue #2192. --- src/gui/statusbar.cpp | 200 +++++++++++++++++++++--------------------- src/gui/statusbar.h | 25 +++--- 2 files changed, 113 insertions(+), 112 deletions(-) diff --git a/src/gui/statusbar.cpp b/src/gui/statusbar.cpp index 177bf1e7e..937e24245 100644 --- a/src/gui/statusbar.cpp +++ b/src/gui/statusbar.cpp @@ -54,86 +54,86 @@ StatusBar::StatusBar(QStatusBar *bar) Preferences* const pref = Preferences::instance(); connect(BitTorrent::Session::instance(), SIGNAL(speedLimitModeChanged(bool)), this, SLOT(updateAltSpeedsBtn(bool))); - container = new QWidget(bar); - layout = new QHBoxLayout(container); - layout->setContentsMargins(0, 0, 0, 0); + m_container = new QWidget(bar); + m_layout = new QHBoxLayout(m_container); + m_layout->setContentsMargins(0,0,0,0); - container->setLayout(layout); - connecStatusLblIcon = new QPushButton(bar); - connecStatusLblIcon->setFlat(true); - connecStatusLblIcon->setFocusPolicy(Qt::NoFocus); - connecStatusLblIcon->setCursor(Qt::PointingHandCursor); - connecStatusLblIcon->setIcon(QIcon(":/icons/skin/firewalled.png")); - connecStatusLblIcon->setToolTip(QString::fromUtf8("") + tr("Connection status:") + QString::fromUtf8("
") + QString::fromUtf8("") + tr("No direct connections. This may indicate network configuration problems.") + QString::fromUtf8("")); - dlSpeedLbl = new QPushButton(bar); - dlSpeedLbl->setIcon(QIcon(":/icons/skin/download.png")); - connect(dlSpeedLbl, SIGNAL(clicked()), this, SLOT(capDownloadSpeed())); - dlSpeedLbl->setFlat(true); - dlSpeedLbl->setFocusPolicy(Qt::NoFocus); - dlSpeedLbl->setCursor(Qt::PointingHandCursor); + m_container->setLayout(m_layout); + m_connecStatusLblIcon = new QPushButton(bar); + m_connecStatusLblIcon->setFlat(true); + m_connecStatusLblIcon->setFocusPolicy(Qt::NoFocus); + m_connecStatusLblIcon->setCursor(Qt::PointingHandCursor); + m_connecStatusLblIcon->setIcon(QIcon(":/icons/skin/firewalled.png")); + m_connecStatusLblIcon->setToolTip(QString::fromUtf8("") + tr("Connection status:") + QString::fromUtf8("
") + QString::fromUtf8("") + tr("No direct connections. This may indicate network configuration problems.") + QString::fromUtf8("")); + m_dlSpeedLbl = new QPushButton(bar); + m_dlSpeedLbl->setIcon(QIcon(":/icons/skin/download.png")); + connect(m_dlSpeedLbl, SIGNAL(clicked()), this, SLOT(capDownloadSpeed())); + m_dlSpeedLbl->setFlat(true); + m_dlSpeedLbl->setFocusPolicy(Qt::NoFocus); + m_dlSpeedLbl->setCursor(Qt::PointingHandCursor); - upSpeedLbl = new QPushButton(bar); - upSpeedLbl->setIcon(QIcon(":/icons/skin/seeding.png")); - connect(upSpeedLbl, SIGNAL(clicked()), this, SLOT(capUploadSpeed())); - upSpeedLbl->setFlat(true); - upSpeedLbl->setFocusPolicy(Qt::NoFocus); - upSpeedLbl->setCursor(Qt::PointingHandCursor); - DHTLbl = new QLabel(tr("DHT: %1 nodes").arg(0), bar); - DHTLbl->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Preferred); + m_upSpeedLbl = new QPushButton(bar); + m_upSpeedLbl->setIcon(QIcon(":/icons/skin/seeding.png")); + connect(m_upSpeedLbl, SIGNAL(clicked()), this, SLOT(capUploadSpeed())); + m_upSpeedLbl->setFlat(true); + m_upSpeedLbl->setFocusPolicy(Qt::NoFocus); + m_upSpeedLbl->setCursor(Qt::PointingHandCursor); + m_DHTLbl = new QLabel(tr("DHT: %1 nodes").arg(0), bar); + m_DHTLbl->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Preferred); - altSpeedsBtn = new QPushButton(bar); - altSpeedsBtn->setFlat(true); - altSpeedsBtn->setFocusPolicy(Qt::NoFocus); - altSpeedsBtn->setCursor(Qt::PointingHandCursor); + m_altSpeedsBtn = new QPushButton(bar); + m_altSpeedsBtn->setFlat(true); + m_altSpeedsBtn->setFocusPolicy(Qt::NoFocus); + m_altSpeedsBtn->setCursor(Qt::PointingHandCursor); updateAltSpeedsBtn(pref->isAltBandwidthEnabled()); - connect(altSpeedsBtn, SIGNAL(clicked()), this, SLOT(toggleAlternativeSpeeds())); + connect(m_altSpeedsBtn, SIGNAL(clicked()), this, SLOT(toggleAlternativeSpeeds())); // Because on some platforms the default icon size is bigger // and it will result in taller/fatter statusbar, even if the // icons are actually 16x16 - connecStatusLblIcon->setIconSize(QSize(16, 16)); - dlSpeedLbl->setIconSize(QSize(16, 16)); - upSpeedLbl->setIconSize(QSize(16, 16)); - altSpeedsBtn->setIconSize(QSize(28, 16)); + m_connecStatusLblIcon->setIconSize(QSize(16, 16)); + m_dlSpeedLbl->setIconSize(QSize(16, 16)); + m_upSpeedLbl->setIconSize(QSize(16, 16)); + m_altSpeedsBtn->setIconSize(QSize(28, 16)); // Set to the known maximum width(plus some padding) // so the speed widgets will take the rest of the space - connecStatusLblIcon->setMaximumWidth(16 + 6); - altSpeedsBtn->setMaximumWidth(28 + 6); + m_connecStatusLblIcon->setMaximumWidth(16 + 6); + m_altSpeedsBtn->setMaximumWidth(28 + 6); - statusSep1 = new QFrame(bar); - statusSep1->setFrameStyle(QFrame::VLine); - statusSep1->setFrameShadow(QFrame::Raised); - statusSep2 = new QFrame(bar); - statusSep2->setFrameStyle(QFrame::VLine); - statusSep2->setFrameShadow(QFrame::Raised); - statusSep3 = new QFrame(bar); - statusSep3->setFrameStyle(QFrame::VLine); - statusSep3->setFrameShadow(QFrame::Raised); - statusSep4 = new QFrame(bar); - statusSep4->setFrameStyle(QFrame::VLine); - statusSep4->setFrameShadow(QFrame::Raised); - layout->addWidget(DHTLbl); - layout->addWidget(statusSep1); - layout->addWidget(connecStatusLblIcon); - layout->addWidget(statusSep2); - layout->addWidget(altSpeedsBtn); - layout->addWidget(statusSep4); - layout->addWidget(dlSpeedLbl); - layout->addWidget(statusSep3); - layout->addWidget(upSpeedLbl); + m_statusSep1 = new QFrame(bar); + m_statusSep1->setFrameStyle(QFrame::VLine); + m_statusSep1->setFrameShadow(QFrame::Raised); + m_statusSep2 = new QFrame(bar); + m_statusSep2->setFrameStyle(QFrame::VLine); + m_statusSep2->setFrameShadow(QFrame::Raised); + m_statusSep3 = new QFrame(bar); + m_statusSep3->setFrameStyle(QFrame::VLine); + m_statusSep3->setFrameShadow(QFrame::Raised); + m_statusSep4 = new QFrame(bar); + m_statusSep4->setFrameStyle(QFrame::VLine); + m_statusSep4->setFrameShadow(QFrame::Raised); + m_layout->addWidget(m_DHTLbl); + m_layout->addWidget(m_statusSep1); + m_layout->addWidget(m_connecStatusLblIcon); + m_layout->addWidget(m_statusSep2); + m_layout->addWidget(m_altSpeedsBtn); + m_layout->addWidget(m_statusSep4); + m_layout->addWidget(m_dlSpeedLbl); + m_layout->addWidget(m_statusSep3); + m_layout->addWidget(m_upSpeedLbl); - bar->addPermanentWidget(container); - container->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); + bar->addPermanentWidget(m_container); + m_container->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); bar->setStyleSheet("QWidget {margin: 0;}"); - container->adjustSize(); + m_container->adjustSize(); bar->adjustSize(); // Is DHT enabled - DHTLbl->setVisible(pref->isDHTEnabled()); - refreshTimer = new QTimer(bar); + m_DHTLbl->setVisible(pref->isDHTEnabled()); + m_refreshTimer = new QTimer(bar); refreshStatusBar(); - connect(refreshTimer, SIGNAL(timeout()), this, SLOT(refreshStatusBar())); - refreshTimer->start(1500); + connect(m_refreshTimer, SIGNAL(timeout()), this, SLOT(refreshStatusBar())); + m_refreshTimer->start(1500); } StatusBar::~StatusBar() @@ -143,28 +143,28 @@ StatusBar::~StatusBar() QPushButton* StatusBar::connectionStatusButton() const { - return connecStatusLblIcon; + return m_connecStatusLblIcon; } void StatusBar::showRestartRequired() { // Restart required notification - const QString restart_text = tr("qBittorrent needs to be restarted"); + const QString restartText = tr("qBittorrent needs to be restarted"); QLabel *restartIconLbl = new QLabel(m_bar); - restartIconLbl->setPixmap(QPixmap(":/icons/oxygen/dialog-warning.png").scaled(QSize(24, 24))); - restartIconLbl->setToolTip(restart_text); + restartIconLbl->setPixmap(QPixmap(":/icons/oxygen/dialog-warning.png").scaled(QSize(24,24))); + restartIconLbl->setToolTip(restartText); m_bar->insertWidget(0, restartIconLbl); QLabel *restartLbl = new QLabel(m_bar); restartLbl->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Preferred); m_bar->insertWidget(1, restartLbl); QFontMetrics fm(restartLbl->font()); - restartLbl->setText(fm.elidedText(restart_text, Qt::ElideRight, restartLbl->width())); + restartLbl->setText(fm.elidedText(restartText, Qt::ElideRight, restartLbl->width())); Logger::instance()->addMessage(tr("qBittorrent was just updated and needs to be restarted for the changes to be effective."), Log::CRITICAL); } void StatusBar::stopTimer() { - refreshTimer->stop(); + m_refreshTimer->stop(); } void StatusBar::refreshStatusBar() @@ -172,28 +172,28 @@ void StatusBar::refreshStatusBar() // Update connection status const BitTorrent::SessionStatus sessionStatus = BitTorrent::Session::instance()->status(); if (!BitTorrent::Session::instance()->isListening()) { - connecStatusLblIcon->setIcon(QIcon(QString::fromUtf8(":/icons/skin/disconnected.png"))); - 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.")); + 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.")); } else { if (sessionStatus.hasIncomingConnections()) { // Connection OK - connecStatusLblIcon->setIcon(QIcon(QString::fromUtf8(":/icons/skin/connected.png"))); - connecStatusLblIcon->setToolTip(QString::fromUtf8("") + tr("Connection Status:") + QString::fromUtf8("
") + tr("Online")); + m_connecStatusLblIcon->setIcon(QIcon(QString::fromUtf8(":/icons/skin/connected.png"))); + m_connecStatusLblIcon->setToolTip(QString::fromUtf8("") + tr("Connection Status:") + QString::fromUtf8("
") + tr("Online")); } else { - connecStatusLblIcon->setIcon(QIcon(QString::fromUtf8(":/icons/skin/firewalled.png"))); - connecStatusLblIcon->setToolTip(QString::fromUtf8("") + tr("Connection status:") + QString::fromUtf8("
") + QString::fromUtf8("") + tr("No direct connections. This may indicate network configuration problems.") + QString::fromUtf8("")); + m_connecStatusLblIcon->setIcon(QIcon(QString::fromUtf8(":/icons/skin/firewalled.png"))); + 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 if (BitTorrent::Session::instance()->isDHTEnabled()) { - DHTLbl->setVisible(true); + m_DHTLbl->setVisible(true); //statusSep1->setVisible(true); - DHTLbl->setText(tr("DHT: %1 nodes").arg(QString::number(sessionStatus.dhtNodes()))); + m_DHTLbl->setText(tr("DHT: %1 nodes").arg(QString::number(sessionStatus.dhtNodes()))); } else { - DHTLbl->setVisible(false); + m_DHTLbl->setVisible(false); //statusSep1->setVisible(false); } // Update speed labels @@ -201,25 +201,25 @@ void StatusBar::refreshStatusBar() int speedLimit = BitTorrent::Session::instance()->downloadRateLimit(); if (speedLimit) speedLbl = "[" + Utils::Misc::friendlyUnit(speedLimit, true) + "] " + speedLbl; - dlSpeedLbl->setText(speedLbl); + m_dlSpeedLbl->setText(speedLbl); speedLimit = BitTorrent::Session::instance()->uploadRateLimit(); speedLbl = Utils::Misc::friendlyUnit(sessionStatus.payloadUploadRate(), true) + " (" + Utils::Misc::friendlyUnit(sessionStatus.totalPayloadUpload()) + ")"; if (speedLimit) speedLbl = "[" + Utils::Misc::friendlyUnit(speedLimit, true) + "] " + speedLbl; - upSpeedLbl->setText(speedLbl); + m_upSpeedLbl->setText(speedLbl); } void StatusBar::updateAltSpeedsBtn(bool alternative) { if (alternative) { - altSpeedsBtn->setIcon(QIcon(":/icons/slow.png")); - altSpeedsBtn->setToolTip(tr("Click to switch to regular speed limits")); - altSpeedsBtn->setDown(true); + m_altSpeedsBtn->setIcon(QIcon(":/icons/slow.png")); + m_altSpeedsBtn->setToolTip(tr("Click to switch to regular speed limits")); + m_altSpeedsBtn->setDown(true); } else { - altSpeedsBtn->setIcon(QIcon(":/icons/slow_off.png")); - altSpeedsBtn->setToolTip(tr("Click to switch to alternative speed limits")); - altSpeedsBtn->setDown(false); + m_altSpeedsBtn->setIcon(QIcon(":/icons/slow_off.png")); + m_altSpeedsBtn->setToolTip(tr("Click to switch to alternative speed limits")); + m_altSpeedsBtn->setDown(false); } refreshStatusBar(); } @@ -235,12 +235,12 @@ void StatusBar::toggleAlternativeSpeeds() void StatusBar::capDownloadSpeed() { bool ok = false; - int cur_limit = BitTorrent::Session::instance()->downloadRateLimit(); - long new_limit = SpeedLimitDialog::askSpeedLimit(&ok, tr("Global Download Speed Limit"), cur_limit); + int curLimit = BitTorrent::Session::instance()->downloadRateLimit(); + long newLimit = SpeedLimitDialog::askSpeedLimit(&ok, tr("Global Download Speed Limit"), curLimit); if (ok) { Preferences* const pref = Preferences::instance(); bool alt = pref->isAltBandwidthEnabled(); - if (new_limit <= 0) { + if (newLimit <= 0) { qDebug("Setting global download rate limit to Unlimited"); BitTorrent::Session::instance()->setDownloadRateLimit(-1); if (!alt) @@ -249,12 +249,12 @@ void StatusBar::capDownloadSpeed() pref->setAltGlobalDownloadLimit(-1); } else { - qDebug("Setting global download rate limit to %.1fKb/s", new_limit / 1024.); - BitTorrent::Session::instance()->setDownloadRateLimit(new_limit); + qDebug("Setting global download rate limit to %.1fKb/s", newLimit / 1024.); + BitTorrent::Session::instance()->setDownloadRateLimit(newLimit); if (!alt) - pref->setGlobalDownloadLimit(new_limit / 1024.); + pref->setGlobalDownloadLimit(newLimit / 1024.); else - pref->setAltGlobalDownloadLimit(new_limit / 1024.); + pref->setAltGlobalDownloadLimit(newLimit / 1024.); } refreshStatusBar(); } @@ -263,12 +263,12 @@ void StatusBar::capDownloadSpeed() void StatusBar::capUploadSpeed() { bool ok = false; - int cur_limit = BitTorrent::Session::instance()->uploadRateLimit(); - long new_limit = SpeedLimitDialog::askSpeedLimit(&ok, tr("Global Upload Speed Limit"), cur_limit); + int curLimit = BitTorrent::Session::instance()->uploadRateLimit(); + long newLimit = SpeedLimitDialog::askSpeedLimit(&ok, tr("Global Upload Speed Limit"), curLimit); if (ok) { Preferences* const pref = Preferences::instance(); bool alt = pref->isAltBandwidthEnabled(); - if (new_limit <= 0) { + if (newLimit <= 0) { qDebug("Setting global upload rate limit to Unlimited"); BitTorrent::Session::instance()->setUploadRateLimit(-1); if (!alt) @@ -277,12 +277,12 @@ void StatusBar::capUploadSpeed() Preferences::instance()->setAltGlobalUploadLimit(-1); } else { - qDebug("Setting global upload rate limit to %.1fKb/s", new_limit / 1024.); - BitTorrent::Session::instance()->setUploadRateLimit(new_limit); + qDebug("Setting global upload rate limit to %.1fKb/s", newLimit / 1024.); + BitTorrent::Session::instance()->setUploadRateLimit(newLimit); if (!alt) - Preferences::instance()->setGlobalUploadLimit(new_limit / 1024.); + Preferences::instance()->setGlobalUploadLimit(newLimit / 1024.); else - Preferences::instance()->setAltGlobalUploadLimit(new_limit / 1024.); + Preferences::instance()->setAltGlobalUploadLimit(newLimit / 1024.); } refreshStatusBar(); } diff --git a/src/gui/statusbar.h b/src/gui/statusbar.h index a5ad3be5f..0d7ceff5d 100644 --- a/src/gui/statusbar.h +++ b/src/gui/statusbar.h @@ -61,18 +61,19 @@ public slots: private: QStatusBar *m_bar; - QPushButton *dlSpeedLbl; - QPushButton *upSpeedLbl; - QLabel *DHTLbl; - QFrame *statusSep1; - QFrame *statusSep2; - QFrame *statusSep3; - QFrame *statusSep4; - QPushButton *connecStatusLblIcon; - QPushButton *altSpeedsBtn; - QTimer *refreshTimer; - QWidget *container; - QHBoxLayout *layout; + QPushButton *m_dlSpeedLbl; + QPushButton *m_upSpeedLbl; + QLabel *m_DHTLbl; + QFrame *m_statusSep1; + QFrame *m_statusSep2; + QFrame *m_statusSep3; + QFrame *m_statusSep4; + QPushButton *m_connecStatusLblIcon; + QPushButton *m_altSpeedsBtn; + QTimer *m_refreshTimer; + QWidget *m_container; + QHBoxLayout *m_layout; + }; #endif // STATUSBAR_H From 99aeacf9b02647f08be3cdf8165e8a30c0812e70 Mon Sep 17 00:00:00 2001 From: buinsky Date: Sun, 27 Dec 2015 10:49:53 +0300 Subject: [PATCH 2/4] Refactoring of StatusBar::refreshStatusBar function --- src/gui/statusbar.cpp | 24 +++++++++++++++++------- src/gui/statusbar.h | 8 ++++++++ 2 files changed, 25 insertions(+), 7 deletions(-) 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 From 3361f1cd806d7eac7afae3c9e25067c8a1ea6a88 Mon Sep 17 00:00:00 2001 From: buinsky Date: Wed, 13 Jan 2016 22:44:06 +0300 Subject: [PATCH 3/4] GUI: Change the order of the values of speed labels --- src/gui/statusbar.cpp | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/gui/statusbar.cpp b/src/gui/statusbar.cpp index c20ef1427..4e4c4ce84 100644 --- a/src/gui/statusbar.cpp +++ b/src/gui/statusbar.cpp @@ -65,12 +65,15 @@ StatusBar::StatusBar(QStatusBar *bar) m_connecStatusLblIcon->setCursor(Qt::PointingHandCursor); m_connecStatusLblIcon->setIcon(QIcon(":/icons/skin/firewalled.png")); m_connecStatusLblIcon->setToolTip(QString::fromUtf8("") + tr("Connection status:") + QString::fromUtf8("
") + QString::fromUtf8("") + tr("No direct connections. This may indicate network configuration problems.") + QString::fromUtf8("")); + m_dlSpeedLbl = new QPushButton(bar); m_dlSpeedLbl->setIcon(QIcon(":/icons/skin/download.png")); connect(m_dlSpeedLbl, SIGNAL(clicked()), this, SLOT(capDownloadSpeed())); m_dlSpeedLbl->setFlat(true); m_dlSpeedLbl->setFocusPolicy(Qt::NoFocus); m_dlSpeedLbl->setCursor(Qt::PointingHandCursor); + m_dlSpeedLbl->setStyleSheet("text-align:left;"); + m_dlSpeedLbl->setMinimumWidth(200); m_upSpeedLbl = new QPushButton(bar); m_upSpeedLbl->setIcon(QIcon(":/icons/skin/seeding.png")); @@ -78,6 +81,9 @@ StatusBar::StatusBar(QStatusBar *bar) m_upSpeedLbl->setFlat(true); m_upSpeedLbl->setFocusPolicy(Qt::NoFocus); m_upSpeedLbl->setCursor(Qt::PointingHandCursor); + m_upSpeedLbl->setStyleSheet("text-align:left;"); + m_upSpeedLbl->setMinimumWidth(200); + m_DHTLbl = new QLabel(tr("DHT: %1 nodes").arg(0), bar); m_DHTLbl->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Preferred); @@ -124,7 +130,6 @@ StatusBar::StatusBar(QStatusBar *bar) m_layout->addWidget(m_upSpeedLbl); bar->addPermanentWidget(m_container); - m_container->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); bar->setStyleSheet("QWidget {margin: 0;}"); m_container->adjustSize(); bar->adjustSize(); @@ -199,15 +204,17 @@ void StatusBar::updateDHTNodesNumber(const BitTorrent::SessionStatus &sessionSta 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); int speedLimit = BitTorrent::Session::instance()->downloadRateLimit(); if (speedLimit) - speedLbl = "[" + Utils::Misc::friendlyUnit(speedLimit, true) + "] " + speedLbl; + speedLbl += " [" + Utils::Misc::friendlyUnit(speedLimit, true) + "]"; + speedLbl += " (" + Utils::Misc::friendlyUnit(sessionStatus.totalPayloadDownload()) + ")"; m_dlSpeedLbl->setText(speedLbl); speedLimit = BitTorrent::Session::instance()->uploadRateLimit(); - speedLbl = Utils::Misc::friendlyUnit(sessionStatus.payloadUploadRate(), true) + " (" + Utils::Misc::friendlyUnit(sessionStatus.totalPayloadUpload()) + ")"; + speedLbl = Utils::Misc::friendlyUnit(sessionStatus.payloadUploadRate(), true); if (speedLimit) - speedLbl = "[" + Utils::Misc::friendlyUnit(speedLimit, true) + "] " + speedLbl; + speedLbl += " [" + Utils::Misc::friendlyUnit(speedLimit, true) + "]"; + speedLbl += " (" + Utils::Misc::friendlyUnit(sessionStatus.totalPayloadUpload()) + ")"; m_upSpeedLbl->setText(speedLbl); } From dbf995480a6f503744f4a82a4659462ece90bf8f Mon Sep 17 00:00:00 2001 From: buinsky Date: Wed, 13 Jan 2016 23:12:28 +0300 Subject: [PATCH 4/4] WebUI: Change the order of the values of speed labels --- src/webui/www/private/index.html | 5 +++-- src/webui/www/public/css/Layout.css | 9 +++++++-- src/webui/www/public/scripts/client.js | 14 ++++++-------- 3 files changed, 16 insertions(+), 12 deletions(-) diff --git a/src/webui/www/private/index.html b/src/webui/www/private/index.html index 95262b825..8c2855988 100644 --- a/src/webui/www/private/index.html +++ b/src/webui/www/private/index.html @@ -136,9 +136,10 @@ QBT_TR(Alternative speed limits)QBT_TR - + - + + diff --git a/src/webui/www/public/css/Layout.css b/src/webui/www/public/css/Layout.css index c9d8bf7a4..b533fc2b0 100644 --- a/src/webui/www/public/css/Layout.css +++ b/src/webui/www/public/css/Layout.css @@ -420,9 +420,14 @@ div.toolbox.divider { /* Have to specify div here for IE6's sake */ background: url(../images/skin/spinner.gif) no-repeat; width: 16px; height: 16px; -} +} #desktopFooter td { vertical-align: top; - text-align: center; + text-align: left; } + +td.speedLabel { + cursor:pointer; + min-width: 18em; +} \ No newline at end of file diff --git a/src/webui/www/public/scripts/client.js b/src/webui/www/public/scripts/client.js index 2498ceeae..58caa7767 100644 --- a/src/webui/www/public/scripts/client.js +++ b/src/webui/www/public/scripts/client.js @@ -373,17 +373,15 @@ window.addEvent('load', function () { } var processServerState = function () { - var transfer_info = ""; + var transfer_info = friendlyUnit(serverState.dl_info_speed, true); if (serverState.dl_rate_limit > 0) - transfer_info += "[" + friendlyUnit(serverState.dl_rate_limit, true) + "] "; - transfer_info += friendlyUnit(serverState.dl_info_speed, true); - transfer_info += " (" + friendlyUnit(serverState.dl_info_data, false) + ")" + transfer_info += " [" + friendlyUnit(serverState.dl_rate_limit, true) + "]"; + transfer_info += " (" + friendlyUnit(serverState.dl_info_data, false) + ")"; $("DlInfos").set('html', transfer_info); - transfer_info = ""; + transfer_info = friendlyUnit(serverState.up_info_speed, true); if (serverState.up_rate_limit > 0) - transfer_info += "[" + friendlyUnit(serverState.up_rate_limit, true) + "] "; - transfer_info += friendlyUnit(serverState.up_info_speed, true) - transfer_info += " (" + friendlyUnit(serverState.up_info_data, false) + ")" + transfer_info += " [" + friendlyUnit(serverState.up_rate_limit, true) + "]"; + transfer_info += " (" + friendlyUnit(serverState.up_info_data, false) + ")"; $("UpInfos").set('html', transfer_info); if (speedInTitle) { document.title = "QBT_TR([D:%1 U:%2])QBT_TR".replace("%1", friendlyUnit(serverState.dl_info_speed, true)).replace("%2", friendlyUnit(serverState.up_info_speed, true));