mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-08-13 01:57:07 -07:00
Follow project coding style. Issue #2192.
This commit is contained in:
parent
e35a7ef9d3
commit
f410b29c99
2 changed files with 270 additions and 248 deletions
|
@ -30,6 +30,12 @@
|
||||||
|
|
||||||
#include "statusbar.h"
|
#include "statusbar.h"
|
||||||
|
|
||||||
|
#include <QStatusBar>
|
||||||
|
#include <QFrame>
|
||||||
|
#include <QLabel>
|
||||||
|
#include <QTimer>
|
||||||
|
#include <QPushButton>
|
||||||
|
#include <QHBoxLayout>
|
||||||
#include <QFontMetrics>
|
#include <QFontMetrics>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
|
@ -130,15 +136,18 @@ StatusBar::StatusBar(QStatusBar *bar)
|
||||||
refreshTimer->start(1500);
|
refreshTimer->start(1500);
|
||||||
}
|
}
|
||||||
|
|
||||||
StatusBar::~StatusBar() {
|
StatusBar::~StatusBar()
|
||||||
|
{
|
||||||
qDebug() << Q_FUNC_INFO;
|
qDebug() << Q_FUNC_INFO;
|
||||||
}
|
}
|
||||||
|
|
||||||
QPushButton* StatusBar::connectionStatusButton() const {
|
QPushButton* StatusBar::connectionStatusButton() const
|
||||||
|
{
|
||||||
return connecStatusLblIcon;
|
return connecStatusLblIcon;
|
||||||
}
|
}
|
||||||
|
|
||||||
void StatusBar::showRestartRequired() {
|
void StatusBar::showRestartRequired()
|
||||||
|
{
|
||||||
// Restart required notification
|
// Restart required notification
|
||||||
const QString restart_text = tr("qBittorrent needs to be restarted");
|
const QString restart_text = tr("qBittorrent needs to be restarted");
|
||||||
QLabel *restartIconLbl = new QLabel(m_bar);
|
QLabel *restartIconLbl = new QLabel(m_bar);
|
||||||
|
@ -153,22 +162,26 @@ void StatusBar::showRestartRequired() {
|
||||||
Logger::instance()->addMessage(tr("qBittorrent was just updated and needs to be restarted for the changes to be effective."), Log::CRITICAL);
|
Logger::instance()->addMessage(tr("qBittorrent was just updated and needs to be restarted for the changes to be effective."), Log::CRITICAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
void StatusBar::stopTimer() {
|
void StatusBar::stopTimer()
|
||||||
|
{
|
||||||
refreshTimer->stop();
|
refreshTimer->stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
void StatusBar::refreshStatusBar() {
|
void StatusBar::refreshStatusBar()
|
||||||
|
{
|
||||||
// Update connection status
|
// Update connection status
|
||||||
const BitTorrent::SessionStatus sessionStatus = BitTorrent::Session::instance()->status();
|
const BitTorrent::SessionStatus sessionStatus = BitTorrent::Session::instance()->status();
|
||||||
if (!BitTorrent::Session::instance()->isListening()) {
|
if (!BitTorrent::Session::instance()->isListening()) {
|
||||||
connecStatusLblIcon->setIcon(QIcon(QString::fromUtf8(":/icons/skin/disconnected.png")));
|
connecStatusLblIcon->setIcon(QIcon(QString::fromUtf8(":/icons/skin/disconnected.png")));
|
||||||
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."));
|
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."));
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
if (sessionStatus.hasIncomingConnections()) {
|
if (sessionStatus.hasIncomingConnections()) {
|
||||||
// Connection OK
|
// Connection OK
|
||||||
connecStatusLblIcon->setIcon(QIcon(QString::fromUtf8(":/icons/skin/connected.png")));
|
connecStatusLblIcon->setIcon(QIcon(QString::fromUtf8(":/icons/skin/connected.png")));
|
||||||
connecStatusLblIcon->setToolTip(QString::fromUtf8("<b>") + tr("Connection Status:") + QString::fromUtf8("</b><br>") + tr("Online"));
|
connecStatusLblIcon->setToolTip(QString::fromUtf8("<b>") + tr("Connection Status:") + QString::fromUtf8("</b><br>") + tr("Online"));
|
||||||
}else{
|
}
|
||||||
|
else {
|
||||||
connecStatusLblIcon->setIcon(QIcon(QString::fromUtf8(":/icons/skin/firewalled.png")));
|
connecStatusLblIcon->setIcon(QIcon(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>"));
|
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>"));
|
||||||
}
|
}
|
||||||
|
@ -178,7 +191,8 @@ void StatusBar::refreshStatusBar() {
|
||||||
DHTLbl->setVisible(true);
|
DHTLbl->setVisible(true);
|
||||||
//statusSep1->setVisible(true);
|
//statusSep1->setVisible(true);
|
||||||
DHTLbl->setText(tr("DHT: %1 nodes").arg(QString::number(sessionStatus.dhtNodes())));
|
DHTLbl->setText(tr("DHT: %1 nodes").arg(QString::number(sessionStatus.dhtNodes())));
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
DHTLbl->setVisible(false);
|
DHTLbl->setVisible(false);
|
||||||
//statusSep1->setVisible(false);
|
//statusSep1->setVisible(false);
|
||||||
}
|
}
|
||||||
|
@ -195,12 +209,14 @@ void StatusBar::refreshStatusBar() {
|
||||||
upSpeedLbl->setText(speedLbl);
|
upSpeedLbl->setText(speedLbl);
|
||||||
}
|
}
|
||||||
|
|
||||||
void StatusBar::updateAltSpeedsBtn(bool alternative) {
|
void StatusBar::updateAltSpeedsBtn(bool alternative)
|
||||||
|
{
|
||||||
if (alternative) {
|
if (alternative) {
|
||||||
altSpeedsBtn->setIcon(QIcon(":/icons/slow.png"));
|
altSpeedsBtn->setIcon(QIcon(":/icons/slow.png"));
|
||||||
altSpeedsBtn->setToolTip(tr("Click to switch to regular speed limits"));
|
altSpeedsBtn->setToolTip(tr("Click to switch to regular speed limits"));
|
||||||
altSpeedsBtn->setDown(true);
|
altSpeedsBtn->setDown(true);
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
altSpeedsBtn->setIcon(QIcon(":/icons/slow_off.png"));
|
altSpeedsBtn->setIcon(QIcon(":/icons/slow_off.png"));
|
||||||
altSpeedsBtn->setToolTip(tr("Click to switch to alternative speed limits"));
|
altSpeedsBtn->setToolTip(tr("Click to switch to alternative speed limits"));
|
||||||
altSpeedsBtn->setDown(false);
|
altSpeedsBtn->setDown(false);
|
||||||
|
@ -208,14 +224,16 @@ void StatusBar::updateAltSpeedsBtn(bool alternative) {
|
||||||
refreshStatusBar();
|
refreshStatusBar();
|
||||||
}
|
}
|
||||||
|
|
||||||
void StatusBar::toggleAlternativeSpeeds() {
|
void StatusBar::toggleAlternativeSpeeds()
|
||||||
|
{
|
||||||
Preferences* const pref = Preferences::instance();
|
Preferences* const pref = Preferences::instance();
|
||||||
if (pref->isSchedulerEnabled())
|
if (pref->isSchedulerEnabled())
|
||||||
m_bar->showMessage(tr("Manual change of rate limits mode. The scheduler is disabled."), 5000);
|
m_bar->showMessage(tr("Manual change of rate limits mode. The scheduler is disabled."), 5000);
|
||||||
BitTorrent::Session::instance()->changeSpeedLimitMode(!pref->isAltBandwidthEnabled());
|
BitTorrent::Session::instance()->changeSpeedLimitMode(!pref->isAltBandwidthEnabled());
|
||||||
}
|
}
|
||||||
|
|
||||||
void StatusBar::capDownloadSpeed() {
|
void StatusBar::capDownloadSpeed()
|
||||||
|
{
|
||||||
bool ok = false;
|
bool ok = false;
|
||||||
int cur_limit = BitTorrent::Session::instance()->downloadRateLimit();
|
int cur_limit = BitTorrent::Session::instance()->downloadRateLimit();
|
||||||
long new_limit = SpeedLimitDialog::askSpeedLimit(&ok, tr("Global Download Speed Limit"), cur_limit);
|
long new_limit = SpeedLimitDialog::askSpeedLimit(&ok, tr("Global Download Speed Limit"), cur_limit);
|
||||||
|
@ -229,7 +247,8 @@ void StatusBar::capDownloadSpeed() {
|
||||||
pref->setGlobalDownloadLimit(-1);
|
pref->setGlobalDownloadLimit(-1);
|
||||||
else
|
else
|
||||||
pref->setAltGlobalDownloadLimit(-1);
|
pref->setAltGlobalDownloadLimit(-1);
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
qDebug("Setting global download rate limit to %.1fKb/s", new_limit / 1024.);
|
qDebug("Setting global download rate limit to %.1fKb/s", new_limit / 1024.);
|
||||||
BitTorrent::Session::instance()->setDownloadRateLimit(new_limit);
|
BitTorrent::Session::instance()->setDownloadRateLimit(new_limit);
|
||||||
if (!alt)
|
if (!alt)
|
||||||
|
@ -241,7 +260,8 @@ void StatusBar::capDownloadSpeed() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void StatusBar::capUploadSpeed() {
|
void StatusBar::capUploadSpeed()
|
||||||
|
{
|
||||||
bool ok = false;
|
bool ok = false;
|
||||||
int cur_limit = BitTorrent::Session::instance()->uploadRateLimit();
|
int cur_limit = BitTorrent::Session::instance()->uploadRateLimit();
|
||||||
long new_limit = SpeedLimitDialog::askSpeedLimit(&ok, tr("Global Upload Speed Limit"), cur_limit);
|
long new_limit = SpeedLimitDialog::askSpeedLimit(&ok, tr("Global Upload Speed Limit"), cur_limit);
|
||||||
|
@ -255,7 +275,8 @@ void StatusBar::capUploadSpeed() {
|
||||||
Preferences::instance()->setGlobalUploadLimit(-1);
|
Preferences::instance()->setGlobalUploadLimit(-1);
|
||||||
else
|
else
|
||||||
Preferences::instance()->setAltGlobalUploadLimit(-1);
|
Preferences::instance()->setAltGlobalUploadLimit(-1);
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
qDebug("Setting global upload rate limit to %.1fKb/s", new_limit / 1024.);
|
qDebug("Setting global upload rate limit to %.1fKb/s", new_limit / 1024.);
|
||||||
BitTorrent::Session::instance()->setUploadRateLimit(new_limit);
|
BitTorrent::Session::instance()->setUploadRateLimit(new_limit);
|
||||||
if (!alt)
|
if (!alt)
|
||||||
|
|
|
@ -31,15 +31,17 @@
|
||||||
#ifndef STATUSBAR_H
|
#ifndef STATUSBAR_H
|
||||||
#define STATUSBAR_H
|
#define STATUSBAR_H
|
||||||
|
|
||||||
#include <QStatusBar>
|
#include <QObject>
|
||||||
#include <QFrame>
|
|
||||||
#include <QLabel>
|
|
||||||
#include <QTimer>
|
|
||||||
#include <QGridLayout>
|
|
||||||
#include <QPushButton>
|
|
||||||
#include <QHBoxLayout>
|
|
||||||
|
|
||||||
class StatusBar: public QObject {
|
class QStatusBar;
|
||||||
|
class QFrame;
|
||||||
|
class QLabel;
|
||||||
|
class QTimer;
|
||||||
|
class QPushButton;
|
||||||
|
class QHBoxLayout;
|
||||||
|
|
||||||
|
class StatusBar: public QObject
|
||||||
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -71,7 +73,6 @@ private:
|
||||||
QTimer *refreshTimer;
|
QTimer *refreshTimer;
|
||||||
QWidget *container;
|
QWidget *container;
|
||||||
QHBoxLayout *layout;
|
QHBoxLayout *layout;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // STATUSBAR_H
|
#endif // STATUSBAR_H
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue