mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-22 20:44:15 +00:00
Make use of chrono literals from std library
This commit is contained in:
parent
2a5dbe840c
commit
6de72ecc77
@ -29,6 +29,7 @@
|
||||
|
||||
#include <QtGlobal>
|
||||
|
||||
#include <chrono>
|
||||
#include <cstdlib>
|
||||
#include <memory>
|
||||
|
||||
@ -79,6 +80,8 @@ Q_IMPORT_PLUGIN(QICOPlugin)
|
||||
#include "gui/utils.h"
|
||||
#endif
|
||||
|
||||
using namespace std::chrono_literals;
|
||||
|
||||
void displayVersion();
|
||||
bool userAgreesWithLegalNotice();
|
||||
void displayBadArgMessage(const QString &message);
|
||||
@ -284,7 +287,7 @@ void showSplashScreen()
|
||||
painter.drawText(224 - painter.fontMetrics().horizontalAdvance(version), 270, version);
|
||||
QSplashScreen *splash = new QSplashScreen(splashImg);
|
||||
splash->show();
|
||||
QTimer::singleShot(1500, splash, &QObject::deleteLater);
|
||||
QTimer::singleShot(1500ms, splash, &QObject::deleteLater);
|
||||
qApp->processEvents();
|
||||
}
|
||||
#endif // DISABLE_GUI
|
||||
|
@ -29,14 +29,16 @@
|
||||
|
||||
#include "bandwidthscheduler.h"
|
||||
|
||||
#include <chrono>
|
||||
#include <utility>
|
||||
|
||||
#include <QDate>
|
||||
#include <QTime>
|
||||
#include <QTimer>
|
||||
|
||||
#include "base/preferences.h"
|
||||
|
||||
using namespace std::chrono_literals;
|
||||
|
||||
BandwidthScheduler::BandwidthScheduler(QObject *parent)
|
||||
: QObject(parent)
|
||||
, m_lastAlternative(false)
|
||||
@ -51,7 +53,7 @@ void BandwidthScheduler::start()
|
||||
|
||||
// Timeout regularly to accommodate for external system clock changes
|
||||
// eg from the user or from a timesync utility
|
||||
m_timer.start(30000);
|
||||
m_timer.start(30s);
|
||||
}
|
||||
|
||||
bool BandwidthScheduler::isTimeForAlternative() const
|
||||
|
@ -30,6 +30,7 @@
|
||||
#include "session.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <chrono>
|
||||
#include <cstdint>
|
||||
#include <ctime>
|
||||
#include <queue>
|
||||
@ -107,6 +108,7 @@
|
||||
#include "torrentimpl.h"
|
||||
#include "tracker.h"
|
||||
|
||||
using namespace std::chrono_literals;
|
||||
using namespace BitTorrent;
|
||||
|
||||
const Path CATEGORIES_FILE_NAME {u"categories.json"_qs};
|
||||
@ -442,11 +444,11 @@ Session::Session(QObject *parent)
|
||||
m_port = Utils::Random::rand(1024, 65535);
|
||||
|
||||
m_recentErroredTorrentsTimer->setSingleShot(true);
|
||||
m_recentErroredTorrentsTimer->setInterval(1000);
|
||||
m_recentErroredTorrentsTimer->setInterval(1s);
|
||||
connect(m_recentErroredTorrentsTimer, &QTimer::timeout
|
||||
, this, [this]() { m_recentErroredTorrents.clear(); });
|
||||
|
||||
m_seedingLimitTimer->setInterval(10000);
|
||||
m_seedingLimitTimer->setInterval(10s);
|
||||
connect(m_seedingLimitTimer, &QTimer::timeout, this, &Session::processShareLimits);
|
||||
|
||||
initializeNativeSession();
|
||||
@ -497,7 +499,7 @@ Session::Session(QObject *parent)
|
||||
const int saveInterval = saveResumeDataInterval();
|
||||
if (saveInterval > 0)
|
||||
{
|
||||
m_resumeDataTimer->setInterval(saveInterval * 60 * 1000);
|
||||
m_resumeDataTimer->setInterval(std::chrono::minutes(saveInterval));
|
||||
m_resumeDataTimer->start();
|
||||
}
|
||||
|
||||
@ -2907,7 +2909,7 @@ void Session::setSaveResumeDataInterval(const int value)
|
||||
|
||||
if (value > 0)
|
||||
{
|
||||
m_resumeDataTimer->setInterval(value * 60 * 1000);
|
||||
m_resumeDataTimer->setInterval(std::chrono::minutes(value));
|
||||
m_resumeDataTimer->start();
|
||||
}
|
||||
else
|
||||
@ -5243,7 +5245,6 @@ void Session::handleSessionStatsAlert(const lt::session_stats_alert *p)
|
||||
{
|
||||
Q_ASSERT(current >= previous);
|
||||
Q_ASSERT(interval >= 0);
|
||||
using namespace std::chrono_literals;
|
||||
return (((current - previous) * lt::microseconds(1s).count()) / interval);
|
||||
};
|
||||
|
||||
|
@ -40,7 +40,7 @@
|
||||
using namespace std::chrono_literals;
|
||||
using namespace BitTorrent;
|
||||
|
||||
const qint64 SAVE_INTERVAL = std::chrono::milliseconds(15min).count();
|
||||
const int SAVE_INTERVAL = std::chrono::milliseconds(15min).count();
|
||||
|
||||
Statistics::Statistics(Session *session)
|
||||
: QObject(session)
|
||||
|
@ -31,6 +31,7 @@
|
||||
#include "server.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <chrono>
|
||||
|
||||
#include <QNetworkProxy>
|
||||
#include <QSslCipher>
|
||||
@ -44,11 +45,13 @@
|
||||
#include "base/utils/net.h"
|
||||
#include "connection.h"
|
||||
|
||||
using namespace std::chrono_literals;
|
||||
|
||||
namespace
|
||||
{
|
||||
const int KEEP_ALIVE_DURATION = 7 * 1000; // milliseconds
|
||||
const int KEEP_ALIVE_DURATION = std::chrono::milliseconds(7s).count();
|
||||
const int CONNECTIONS_LIMIT = 500;
|
||||
const int CONNECTIONS_SCAN_INTERVAL = 2; // seconds
|
||||
const std::chrono::seconds CONNECTIONS_SCAN_INTERVAL {2};
|
||||
|
||||
QList<QSslCipher> safeCipherList()
|
||||
{
|
||||
@ -81,7 +84,7 @@ Server::Server(IRequestHandler *requestHandler, QObject *parent)
|
||||
|
||||
auto *dropConnectionTimer = new QTimer(this);
|
||||
connect(dropConnectionTimer, &QTimer::timeout, this, &Server::dropTimedOutConnection);
|
||||
dropConnectionTimer->start(CONNECTIONS_SCAN_INTERVAL * 1000);
|
||||
dropConnectionTimer->start(CONNECTIONS_SCAN_INTERVAL);
|
||||
}
|
||||
|
||||
void Server::incomingConnection(const qintptr socketDescriptor)
|
||||
|
@ -37,8 +37,11 @@
|
||||
#include "base/net/downloadmanager.h"
|
||||
#include "base/version.h"
|
||||
|
||||
using namespace std::chrono_literals;
|
||||
using namespace Net;
|
||||
|
||||
const std::chrono::seconds IP_CHECK_INTERVAL = 30min;
|
||||
|
||||
DNSUpdater::DNSUpdater(QObject *parent)
|
||||
: QObject(parent)
|
||||
, m_state(OK)
|
||||
@ -52,14 +55,14 @@ DNSUpdater::DNSUpdater(QObject *parent)
|
||||
m_lastIP = QHostAddress(pref->getDNSLastIP());
|
||||
|
||||
// Start IP checking timer
|
||||
m_ipCheckTimer.setInterval(IP_CHECK_INTERVAL_MS);
|
||||
m_ipCheckTimer.setInterval(IP_CHECK_INTERVAL);
|
||||
connect(&m_ipCheckTimer, &QTimer::timeout, this, &DNSUpdater::checkPublicIP);
|
||||
m_ipCheckTimer.start();
|
||||
|
||||
// Check lastUpdate to avoid flooding
|
||||
if (!m_lastIPCheckTime.isValid()
|
||||
|| (m_lastIPCheckTime.secsTo(QDateTime::currentDateTime()) * 1000 > IP_CHECK_INTERVAL_MS))
|
||||
{
|
||||
|| (m_lastIPCheckTime.secsTo(QDateTime::currentDateTime()) > IP_CHECK_INTERVAL.count()))
|
||||
{
|
||||
checkPublicIP();
|
||||
}
|
||||
}
|
||||
|
@ -68,8 +68,6 @@ namespace Net
|
||||
FATAL
|
||||
};
|
||||
|
||||
static const int IP_CHECK_INTERVAL_MS = 1800000; // 30 min
|
||||
|
||||
QString getUpdateUrl() const;
|
||||
void processIPUpdateReply(const QString &reply);
|
||||
|
||||
|
@ -30,6 +30,8 @@
|
||||
|
||||
#include "rss_session.h"
|
||||
|
||||
#include <chrono>
|
||||
|
||||
#include <QDebug>
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonObject>
|
||||
@ -48,7 +50,6 @@
|
||||
#include "rss_folder.h"
|
||||
#include "rss_item.h"
|
||||
|
||||
const int MsecsPerMin = 60000;
|
||||
const QString CONF_FOLDER_NAME = u"rss"_qs;
|
||||
const QString DATA_FOLDER_NAME = u"rss/articles"_qs;
|
||||
const QString FEEDS_FILE_NAME = u"feeds.json"_qs;
|
||||
@ -92,7 +93,7 @@ Session::Session()
|
||||
connect(&m_refreshTimer, &QTimer::timeout, this, &Session::refresh);
|
||||
if (isProcessingEnabled())
|
||||
{
|
||||
m_refreshTimer.start(refreshInterval() * MsecsPerMin);
|
||||
m_refreshTimer.start(std::chrono::minutes(refreshInterval()));
|
||||
refresh();
|
||||
}
|
||||
|
||||
@ -433,7 +434,7 @@ void Session::setProcessingEnabled(const bool enabled)
|
||||
m_storeProcessingEnabled = enabled;
|
||||
if (enabled)
|
||||
{
|
||||
m_refreshTimer.start(refreshInterval() * MsecsPerMin);
|
||||
m_refreshTimer.start(std::chrono::minutes(refreshInterval()));
|
||||
refresh();
|
||||
}
|
||||
else
|
||||
@ -480,7 +481,7 @@ void Session::setRefreshInterval(const int refreshInterval)
|
||||
if (m_storeRefreshInterval != refreshInterval)
|
||||
{
|
||||
m_storeRefreshInterval = refreshInterval;
|
||||
m_refreshTimer.start(m_storeRefreshInterval * MsecsPerMin);
|
||||
m_refreshTimer.start(std::chrono::minutes(m_storeRefreshInterval));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -29,6 +29,8 @@
|
||||
|
||||
#include "searchhandler.h"
|
||||
|
||||
#include <chrono>
|
||||
|
||||
#include <QMetaObject>
|
||||
#include <QProcess>
|
||||
#include <QTimer>
|
||||
@ -40,6 +42,8 @@
|
||||
#include "base/utils/fs.h"
|
||||
#include "searchpluginmanager.h"
|
||||
|
||||
using namespace std::chrono_literals;
|
||||
|
||||
namespace
|
||||
{
|
||||
enum SearchResultColumn
|
||||
@ -85,7 +89,7 @@ SearchHandler::SearchHandler(const QString &pattern, const QString &category, co
|
||||
|
||||
m_searchTimeout->setSingleShot(true);
|
||||
connect(m_searchTimeout, &QTimer::timeout, this, &SearchHandler::cancelSearch);
|
||||
m_searchTimeout->start(180000); // 3 min
|
||||
m_searchTimeout->start(3min);
|
||||
|
||||
// deferred start allows clients to handle starting-related signals
|
||||
QMetaObject::invokeMethod(this, [this]() { m_searchProcess->start(QIODevice::ReadOnly); }
|
||||
|
@ -29,7 +29,9 @@
|
||||
|
||||
#include "settingsstorage.h"
|
||||
|
||||
#include <chrono>
|
||||
#include <memory>
|
||||
|
||||
#include <QFile>
|
||||
#include <QHash>
|
||||
|
||||
@ -39,6 +41,8 @@
|
||||
#include "profile.h"
|
||||
#include "utils/fs.h"
|
||||
|
||||
using namespace std::chrono_literals;
|
||||
|
||||
namespace
|
||||
{
|
||||
// Encapsulates serialization of settings in "atomic" way.
|
||||
@ -73,7 +77,7 @@ SettingsStorage::SettingsStorage()
|
||||
: m_data {TransactionalSettings(u"qBittorrent"_qs).read()}
|
||||
{
|
||||
m_timer.setSingleShot(true);
|
||||
m_timer.setInterval(5 * 1000);
|
||||
m_timer.setInterval(5s);
|
||||
connect(&m_timer, &QTimer::timeout, this, &SettingsStorage::save);
|
||||
}
|
||||
|
||||
|
@ -63,7 +63,7 @@
|
||||
|
||||
using namespace std::chrono_literals;
|
||||
|
||||
const std::chrono::duration WATCH_INTERVAL = 10s;
|
||||
const std::chrono::seconds WATCH_INTERVAL {10};
|
||||
const int MAX_FAILED_RETRIES = 5;
|
||||
const QString CONF_FILE_NAME = u"watched_folders.json"_qs;
|
||||
|
||||
@ -478,7 +478,7 @@ void TorrentFilesWatcher::Worker::removeWatchedFolder(const Path &path)
|
||||
|
||||
void TorrentFilesWatcher::Worker::scheduleWatchedFolderProcessing(const Path &path)
|
||||
{
|
||||
QTimer::singleShot(2000, this, [this, path]()
|
||||
QTimer::singleShot(2s, this, [this, path]()
|
||||
{
|
||||
processWatchedFolder(path);
|
||||
});
|
||||
|
@ -1762,7 +1762,7 @@ void MainWindow::createTrayIcon(const int retries)
|
||||
if (retries > 0)
|
||||
{
|
||||
LogMsg(tr("System tray icon is not available, retrying..."), Log::WARNING);
|
||||
QTimer::singleShot(std::chrono::seconds(2), this, [this, retries]()
|
||||
QTimer::singleShot(2s, this, [this, retries]()
|
||||
{
|
||||
if (Preferences::instance()->systemTrayEnabled())
|
||||
createTrayIcon(retries - 1);
|
||||
|
@ -267,7 +267,7 @@ quint64 SpeedPlotView::maxYValue() const
|
||||
if (!m_properties[static_cast<GraphID>(id)].enable)
|
||||
continue;
|
||||
|
||||
milliseconds duration {0ms};
|
||||
milliseconds duration {0};
|
||||
for (int i = static_cast<int>(queue.size()) - 1; i >= 0; --i)
|
||||
{
|
||||
maxYValue = std::max(maxYValue, queue[i].data[id]);
|
||||
@ -360,7 +360,7 @@ void SpeedPlotView::paintEvent(QPaintEvent *)
|
||||
continue;
|
||||
|
||||
QVector<QPoint> points;
|
||||
milliseconds duration {0ms};
|
||||
milliseconds duration {0};
|
||||
|
||||
for (int i = static_cast<int>(queue.size()) - 1; i >= 0; --i)
|
||||
{
|
||||
|
@ -111,7 +111,7 @@ private:
|
||||
private:
|
||||
const milliseconds m_resolution;
|
||||
const milliseconds m_maxDuration;
|
||||
milliseconds m_currentDuration {0ms};
|
||||
milliseconds m_currentDuration {0};
|
||||
int m_counter = 0;
|
||||
SampleData m_accumulator {};
|
||||
DataCircularBuffer m_sink {};
|
||||
|
@ -32,7 +32,6 @@
|
||||
#include <QHBoxLayout>
|
||||
#include <QLabel>
|
||||
#include <QMenu>
|
||||
#include <QTimer>
|
||||
#include <QVBoxLayout>
|
||||
|
||||
#include "base/bittorrent/session.h"
|
||||
|
@ -29,6 +29,8 @@
|
||||
|
||||
#include "shutdownconfirmdialog.h"
|
||||
|
||||
#include <chrono>
|
||||
|
||||
#include <QDialogButtonBox>
|
||||
#include <QIcon>
|
||||
#include <QPushButton>
|
||||
@ -38,6 +40,8 @@
|
||||
#include "ui_shutdownconfirmdialog.h"
|
||||
#include "utils.h"
|
||||
|
||||
using namespace std::chrono_literals;
|
||||
|
||||
ShutdownConfirmDialog::ShutdownConfirmDialog(QWidget *parent, const ShutdownDialogAction &action)
|
||||
: QDialog(parent)
|
||||
, m_ui(new Ui::ShutdownConfirmDialog)
|
||||
@ -64,7 +68,7 @@ ShutdownConfirmDialog::ShutdownConfirmDialog(QWidget *parent, const ShutdownDial
|
||||
setWindowFlags(windowFlags() | Qt::WindowStaysOnTopHint);
|
||||
move(Utils::Gui::screenCenter(this));
|
||||
|
||||
m_timer.setInterval(1000); // 1sec
|
||||
m_timer.setInterval(1s);
|
||||
connect(&m_timer, &QTimer::timeout, this, &ShutdownConfirmDialog::updateSeconds);
|
||||
}
|
||||
|
||||
|
@ -31,6 +31,7 @@
|
||||
#include "appcontroller.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <chrono>
|
||||
|
||||
#include <QCoreApplication>
|
||||
#include <QDebug>
|
||||
@ -62,6 +63,8 @@
|
||||
#include "base/version.h"
|
||||
#include "../webapplication.h"
|
||||
|
||||
using namespace std::chrono_literals;
|
||||
|
||||
void AppController::webapiVersionAction()
|
||||
{
|
||||
setResult(API_VERSION.toString());
|
||||
@ -93,7 +96,7 @@ void AppController::shutdownAction()
|
||||
// Special case handling for shutdown, we
|
||||
// need to reply to the Web UI before
|
||||
// actually shutting down.
|
||||
QTimer::singleShot(100, qApp, &QCoreApplication::quit);
|
||||
QTimer::singleShot(100ms, qApp, &QCoreApplication::quit);
|
||||
}
|
||||
|
||||
void AppController::preferencesAction()
|
||||
|
Loading…
x
Reference in New Issue
Block a user