mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-11 07:18:08 +00:00
Follow project coding style. Issue #2192.
This commit is contained in:
parent
e35a7ef9d3
commit
f410b29c99
@ -30,6 +30,12 @@
|
||||
|
||||
#include "statusbar.h"
|
||||
|
||||
#include <QStatusBar>
|
||||
#include <QFrame>
|
||||
#include <QLabel>
|
||||
#include <QTimer>
|
||||
#include <QPushButton>
|
||||
#include <QHBoxLayout>
|
||||
#include <QFontMetrics>
|
||||
#include <QDebug>
|
||||
|
||||
@ -130,15 +136,18 @@ StatusBar::StatusBar(QStatusBar *bar)
|
||||
refreshTimer->start(1500);
|
||||
}
|
||||
|
||||
StatusBar::~StatusBar() {
|
||||
StatusBar::~StatusBar()
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO;
|
||||
}
|
||||
|
||||
QPushButton* StatusBar::connectionStatusButton() const {
|
||||
QPushButton* StatusBar::connectionStatusButton() const
|
||||
{
|
||||
return connecStatusLblIcon;
|
||||
}
|
||||
|
||||
void StatusBar::showRestartRequired() {
|
||||
void StatusBar::showRestartRequired()
|
||||
{
|
||||
// Restart required notification
|
||||
const QString restart_text = tr("qBittorrent needs to be restarted");
|
||||
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);
|
||||
}
|
||||
|
||||
void StatusBar::stopTimer() {
|
||||
void StatusBar::stopTimer()
|
||||
{
|
||||
refreshTimer->stop();
|
||||
}
|
||||
|
||||
void StatusBar::refreshStatusBar() {
|
||||
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("<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()) {
|
||||
// Connection OK
|
||||
connecStatusLblIcon->setIcon(QIcon(QString::fromUtf8(":/icons/skin/connected.png")));
|
||||
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->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);
|
||||
//statusSep1->setVisible(true);
|
||||
DHTLbl->setText(tr("DHT: %1 nodes").arg(QString::number(sessionStatus.dhtNodes())));
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
DHTLbl->setVisible(false);
|
||||
//statusSep1->setVisible(false);
|
||||
}
|
||||
@ -195,12 +209,14 @@ void StatusBar::refreshStatusBar() {
|
||||
upSpeedLbl->setText(speedLbl);
|
||||
}
|
||||
|
||||
void StatusBar::updateAltSpeedsBtn(bool alternative) {
|
||||
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);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
altSpeedsBtn->setIcon(QIcon(":/icons/slow_off.png"));
|
||||
altSpeedsBtn->setToolTip(tr("Click to switch to alternative speed limits"));
|
||||
altSpeedsBtn->setDown(false);
|
||||
@ -208,14 +224,16 @@ void StatusBar::updateAltSpeedsBtn(bool alternative) {
|
||||
refreshStatusBar();
|
||||
}
|
||||
|
||||
void StatusBar::toggleAlternativeSpeeds() {
|
||||
void StatusBar::toggleAlternativeSpeeds()
|
||||
{
|
||||
Preferences* const pref = Preferences::instance();
|
||||
if (pref->isSchedulerEnabled())
|
||||
m_bar->showMessage(tr("Manual change of rate limits mode. The scheduler is disabled."), 5000);
|
||||
BitTorrent::Session::instance()->changeSpeedLimitMode(!pref->isAltBandwidthEnabled());
|
||||
}
|
||||
|
||||
void StatusBar::capDownloadSpeed() {
|
||||
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);
|
||||
@ -229,7 +247,8 @@ void StatusBar::capDownloadSpeed() {
|
||||
pref->setGlobalDownloadLimit(-1);
|
||||
else
|
||||
pref->setAltGlobalDownloadLimit(-1);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
qDebug("Setting global download rate limit to %.1fKb/s", new_limit / 1024.);
|
||||
BitTorrent::Session::instance()->setDownloadRateLimit(new_limit);
|
||||
if (!alt)
|
||||
@ -241,7 +260,8 @@ void StatusBar::capDownloadSpeed() {
|
||||
}
|
||||
}
|
||||
|
||||
void StatusBar::capUploadSpeed() {
|
||||
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);
|
||||
@ -255,7 +275,8 @@ void StatusBar::capUploadSpeed() {
|
||||
Preferences::instance()->setGlobalUploadLimit(-1);
|
||||
else
|
||||
Preferences::instance()->setAltGlobalUploadLimit(-1);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
qDebug("Setting global upload rate limit to %.1fKb/s", new_limit / 1024.);
|
||||
BitTorrent::Session::instance()->setUploadRateLimit(new_limit);
|
||||
if (!alt)
|
||||
|
@ -31,15 +31,17 @@
|
||||
#ifndef STATUSBAR_H
|
||||
#define STATUSBAR_H
|
||||
|
||||
#include <QStatusBar>
|
||||
#include <QFrame>
|
||||
#include <QLabel>
|
||||
#include <QTimer>
|
||||
#include <QGridLayout>
|
||||
#include <QPushButton>
|
||||
#include <QHBoxLayout>
|
||||
#include <QObject>
|
||||
|
||||
class StatusBar: public QObject {
|
||||
class QStatusBar;
|
||||
class QFrame;
|
||||
class QLabel;
|
||||
class QTimer;
|
||||
class QPushButton;
|
||||
class QHBoxLayout;
|
||||
|
||||
class StatusBar: public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
@ -71,7 +73,6 @@ private:
|
||||
QTimer *refreshTimer;
|
||||
QWidget *container;
|
||||
QHBoxLayout *layout;
|
||||
|
||||
};
|
||||
|
||||
#endif // STATUSBAR_H
|
||||
|
Loading…
Reference in New Issue
Block a user