mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2025-12-20 23:47:23 -06:00
Replace C-style casts with C++ ones
This commit is contained in:
@@ -1092,7 +1092,7 @@ bool MainWindow::event(QEvent *e)
|
||||
if (isMinimized()) {
|
||||
qDebug("minimisation");
|
||||
if (m_systrayIcon && Preferences::instance()->minimizeToTray()) {
|
||||
qDebug("Has active window: %d", (int)(qApp->activeWindow() != 0));
|
||||
qDebug() << "Has active window:" << (qApp->activeWindow() != nullptr);
|
||||
// Check if there is a modal window
|
||||
bool hasModalWindow = false;
|
||||
foreach (QWidget *widget, QApplication::allWidgets()) {
|
||||
|
||||
@@ -37,7 +37,7 @@ MessageBoxRaised::MessageBoxRaised(QMessageBox::Icon icon, const QString &title,
|
||||
QMessageBox::StandardButton MessageBoxRaised::impl(const QMessageBox::Icon &icon, QWidget *parent, const QString &title, const QString &text, QMessageBox::StandardButtons buttons, QMessageBox::StandardButton defaultButton) {
|
||||
MessageBoxRaised dlg(icon, title, text, buttons, parent);
|
||||
dlg.setDefaultButton(defaultButton);
|
||||
return (QMessageBox::StandardButton)dlg.exec();
|
||||
return static_cast<QMessageBox::StandardButton>(dlg.exec());
|
||||
}
|
||||
|
||||
QMessageBox::StandardButton MessageBoxRaised::critical(QWidget *parent, const QString &title, const QString &text, QMessageBox::StandardButtons buttons, QMessageBox::StandardButton defaultButton) {
|
||||
|
||||
@@ -577,7 +577,7 @@ void OptionsDialog::saveOptions()
|
||||
session->setBandwidthSchedulerEnabled(m_ui->check_schedule->isChecked());
|
||||
pref->setSchedulerStartTime(m_ui->schedule_from->time());
|
||||
pref->setSchedulerEndTime(m_ui->schedule_to->time());
|
||||
pref->setSchedulerDays((scheduler_days)m_ui->schedule_days->currentIndex());
|
||||
pref->setSchedulerDays(static_cast<scheduler_days>(m_ui->schedule_days->currentIndex()));
|
||||
|
||||
auto proxyConfigManager = Net::ProxyConfigurationManager::instance();
|
||||
Net::ProxyConfiguration proxyConf;
|
||||
@@ -967,7 +967,7 @@ void OptionsDialog::loadOptions()
|
||||
m_ui->check_schedule->setChecked(session->isBandwidthSchedulerEnabled());
|
||||
m_ui->schedule_from->setTime(pref->getSchedulerStartTime());
|
||||
m_ui->schedule_to->setTime(pref->getSchedulerEndTime());
|
||||
m_ui->schedule_days->setCurrentIndex((int)pref->getSchedulerDays());
|
||||
m_ui->schedule_days->setCurrentIndex(static_cast<int>(pref->getSchedulerDays()));
|
||||
// End Speed preferences
|
||||
|
||||
// Bittorrent preferences
|
||||
@@ -1024,7 +1024,7 @@ void OptionsDialog::loadOptions()
|
||||
m_ui->checkBypassLocalAuth->setChecked(!pref->isWebUiLocalAuthEnabled());
|
||||
|
||||
m_ui->checkDynDNS->setChecked(pref->isDynDNSEnabled());
|
||||
m_ui->comboDNSService->setCurrentIndex((int)pref->getDynDNSService());
|
||||
m_ui->comboDNSService->setCurrentIndex(static_cast<int>(pref->getDynDNSService()));
|
||||
m_ui->domainNameTxt->setText(pref->getDynDomainName());
|
||||
m_ui->DNSUsernameTxt->setText(pref->getDynDNSUsername());
|
||||
m_ui->DNSPasswordTxt->setText(pref->getDynDNSPassword());
|
||||
|
||||
@@ -117,9 +117,9 @@ void PowerManagementInhibitor::RequestBusy()
|
||||
|
||||
QList<QVariant> args;
|
||||
args << "qBittorrent";
|
||||
if (m_use_gsm) args << (uint)0;
|
||||
if (m_use_gsm) args << 0u;
|
||||
args << "Active torrents are presented";
|
||||
if (m_use_gsm) args << (uint)8;
|
||||
if (m_use_gsm) args << 8u;
|
||||
call.setArguments(args);
|
||||
|
||||
QDBusPendingCall pcall = QDBusConnection::sessionBus().asyncCall(call, 1000);
|
||||
|
||||
@@ -67,7 +67,7 @@ class PreviewListDelegate: public QItemDelegate {
|
||||
qreal progress = index.data().toDouble()*100.;
|
||||
newopt.rect = opt.rect;
|
||||
newopt.text = ((progress == 100.0) ? QString("100%") : Utils::String::fromDouble(progress, 1) + "%");
|
||||
newopt.progress = (int)progress;
|
||||
newopt.progress = static_cast<int>(progress);
|
||||
newopt.maximum = 100;
|
||||
newopt.minimum = 0;
|
||||
newopt.state |= QStyle::State_Enabled;
|
||||
|
||||
@@ -44,7 +44,7 @@ QVector<float> PieceAvailabilityBar::intToFloatVector(const QVector<int> &vecin,
|
||||
QVector<float> result(reqSize, 0.0);
|
||||
if (vecin.isEmpty()) return result;
|
||||
|
||||
const float ratio = vecin.size() / (float)reqSize;
|
||||
const float ratio = static_cast<float>(vecin.size()) / reqSize;
|
||||
|
||||
const int maxElement = *std::max_element(vecin.begin(), vecin.end());
|
||||
|
||||
@@ -112,7 +112,7 @@ QVector<float> PieceAvailabilityBar::intToFloatVector(const QVector<int> &vecin,
|
||||
value /= ratio * maxElement;
|
||||
|
||||
// float precision sometimes gives > 1, because in not possible to store irrational numbers
|
||||
value = qMin(value, (float)1.0);
|
||||
value = qMin(value, 1.0f);
|
||||
|
||||
result[x] = value;
|
||||
}
|
||||
|
||||
@@ -71,7 +71,7 @@ void StatsDialog::update()
|
||||
// Global ratio
|
||||
m_ui->labelGlobalRatio->setText(
|
||||
((atd > 0) && (atu > 0))
|
||||
? Utils::String::fromDouble((qreal)atu / (qreal)atd, 2)
|
||||
? Utils::String::fromDouble(static_cast<qreal>(atu) / atd, 2)
|
||||
: "-");
|
||||
// Cache hits
|
||||
qreal readRatio = cs.readRatio;
|
||||
|
||||
@@ -82,9 +82,9 @@ void TorrentContentModel::updateFilesProgress(const QVector<qreal> &fp)
|
||||
|
||||
void TorrentContentModel::updateFilesPriorities(const QVector<int> &fprio)
|
||||
{
|
||||
Q_ASSERT(m_filesIndex.size() == (int)fprio.size());
|
||||
Q_ASSERT(m_filesIndex.size() == fprio.size());
|
||||
// XXX: Why is this necessary?
|
||||
if (m_filesIndex.size() != (int)fprio.size())
|
||||
if (m_filesIndex.size() != fprio.size())
|
||||
return;
|
||||
|
||||
emit layoutAboutToBeChanged();
|
||||
|
||||
@@ -162,7 +162,7 @@ void TransferListDelegate::paint(QPainter * painter, const QStyleOptionViewItem
|
||||
qreal progress = index.data().toDouble() * 100.;
|
||||
newopt.rect = opt.rect;
|
||||
newopt.text = ((progress == 100.0) ? QString("100%") : Utils::String::fromDouble(progress, 1) + "%");
|
||||
newopt.progress = (int)progress;
|
||||
newopt.progress = static_cast<int>(progress);
|
||||
newopt.maximum = 100;
|
||||
newopt.minimum = 0;
|
||||
newopt.state |= QStyle::State_Enabled;
|
||||
|
||||
@@ -449,7 +449,7 @@ void TransferListWidget::setDlLimitSelectedTorrents()
|
||||
if (!ok) return;
|
||||
|
||||
foreach (BitTorrent::TorrentHandle *const torrent, TorrentsList) {
|
||||
qDebug("Applying download speed limit of %ld Kb/s to torrent %s", (long) (newLimit / 1024.), qPrintable(torrent->hash()));
|
||||
qDebug("Applying download speed limit of %ld Kb/s to torrent %s", (newLimit / 1024l), qPrintable(torrent->hash()));
|
||||
torrent->setDownloadLimit(newLimit);
|
||||
}
|
||||
}
|
||||
@@ -474,7 +474,7 @@ void TransferListWidget::setUpLimitSelectedTorrents()
|
||||
if (!ok) return;
|
||||
|
||||
foreach (BitTorrent::TorrentHandle *const torrent, TorrentsList) {
|
||||
qDebug("Applying upload speed limit of %ld Kb/s to torrent %s", (long) (newLimit / 1024.), qPrintable(torrent->hash()));
|
||||
qDebug("Applying upload speed limit of %ld Kb/s to torrent %s", (newLimit / 1024l), qPrintable(torrent->hash()));
|
||||
torrent->setUploadLimit(newLimit);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user