Remove use of C-style casts

This commit is contained in:
staticssleever668
2021-10-11 23:28:28 +03:00
committed by Jonas Kvinge
parent 637772f8f0
commit b38ad81928
41 changed files with 84 additions and 84 deletions

View File

@@ -126,7 +126,7 @@ void FreeSpaceBar::DrawBar(QPainter *p, const QRect r) {
p->setRenderHint(QPainter::Antialiasing, true);
QRect bar_rect(r);
bar_rect.setWidth(static_cast<int>(float(bar_rect.width()) * (float(total_ - free_) / total_)));
bar_rect.setWidth(static_cast<int>(static_cast<float>(bar_rect.width()) * (static_cast<float>(total_ - free_) / static_cast<float>(total_))));
QLinearGradient background_gradient(r.topLeft(), r.bottomLeft());
background_gradient.setColorAt(0, kColorBg1);
@@ -150,7 +150,7 @@ void FreeSpaceBar::DrawBar(QPainter *p, const QRect r) {
if (additional_ > 0) {
QRect additional_rect(bar_rect);
additional_rect.setLeft(bar_rect.right());
additional_rect.setWidth(static_cast<int>(float(r.width()) * (float(qMin(free_, additional_)) / total_) + 1));
additional_rect.setWidth(static_cast<int>(static_cast<float>(r.width()) * (static_cast<float>(qMin(free_, additional_)) / total_) + 1));
QLinearGradient additional_gradient(additional_rect.topLeft(), additional_rect.bottomLeft());
additional_gradient.setColorAt(0, kColorAdd1);

View File

@@ -82,7 +82,7 @@ void MultiLoadingIndicator::UpdateText() {
task_text[0] = task_text[0].toLower();
if (task.progress_max > 0) {
int percentage = static_cast<int>(float(task.progress) / task.progress_max * 100);
int percentage = static_cast<int>(static_cast<float>(task.progress) / task.progress_max * 100);
task_text += QString(" %1%").arg(percentage);
}

View File

@@ -44,7 +44,7 @@ RatingPainter::RatingPainter() {
// Generate the 10 states, better to do it now than on the fly
for (int i = 0; i < kStarCount * 2 + 1; ++i) {
const double rating = double(i) / double(2.0);
const double rating = static_cast<double>(i) / static_cast<double>(2.0);
// Clear the pixmap
stars_[i] = QPixmap(kStarSize * kStarCount, kStarSize);
@@ -86,14 +86,14 @@ QRect RatingPainter::Contents(const QRect rect) {
double RatingPainter::RatingForPos(const QPoint pos, const QRect rect) {
const QRect contents = Contents(rect);
const double raw = double(pos.x() - contents.left()) / contents.width();
const double raw = static_cast<double>(pos.x() - contents.left()) / contents.width();
// Check if the position was to the right or left of the rectangle.
if (raw < 0) return 0;
if (raw > 1) return 1;
// Round to the nearest 0.1
return double(lround(raw * kStarCount * 2)) / (kStarCount * 2);
return static_cast<double>(lround(raw * kStarCount * 2)) / (kStarCount * 2);
}

View File

@@ -328,7 +328,7 @@ void VolumeSlider::paintEvent(QPaintEvent*) {
QPainter p(this);
const int padding = 7;
const int offset = int(double((width() - 2 * padding) * value()) / maximum());
const int offset = static_cast<int>(static_cast<double>((width() - 2 * padding) * value()) / maximum());
// If theme changed since last paintEvent, redraw the volume pixmap with new theme colors
if (previous_theme_text_color_ != palette().color(QPalette::WindowText)) {