Use static_cast

This commit is contained in:
Jonas Kvinge
2021-03-21 18:53:02 +01:00
parent f91a679cdf
commit 59bffed47f
80 changed files with 241 additions and 242 deletions

View File

@@ -454,13 +454,13 @@ void AlbumCoverChoiceController::ShowCover(const Song &song, const QPixmap &pixm
// Resize differently if monitor is in portrait mode
if (desktop_width < desktop_height) {
const int new_width = static_cast<double>(desktop_width) * 0.95;
const int new_width = static_cast<int>(static_cast<double>(desktop_width) * 0.95);
if (new_width < pixmap.width()) {
label->setPixmap(pixmap.scaledToWidth(new_width, Qt::SmoothTransformation));
}
}
else {
const int new_height = static_cast<double>(desktop_height) * 0.85;
const int new_height = static_cast<int>(static_cast<double>(desktop_height) * 0.85);
if (new_height < pixmap.height()) {
label->setPixmap(pixmap.scaledToHeight(new_height, Qt::SmoothTransformation));
}

View File

@@ -376,7 +376,7 @@ float AlbumCoverFetcherSearch::ScoreImage(const QSize size) const {
const float size_score = std::sqrt(float(size.width() * size.height())) / kTargetSize;
// A 1:1 image scores 1.0, anything else scores less
const float aspect_score = 1.0 - float(std::max(size.width(), size.height()) - std::min(size.width(), size.height())) / std::max(size.height(), size.width());
const float aspect_score = float(1.0) - float(std::max(size.width(), size.height()) - std::min(size.width(), size.height())) / std::max(size.height(), size.width());
return size_score + aspect_score;

View File

@@ -577,7 +577,7 @@ void AlbumCoverManager::UpdateStatusText() {
}
statusBar()->showMessage(message);
progress_bar_->setValue(fetch_statistics_.chosen_images_ + fetch_statistics_.missing_images_);
progress_bar_->setValue(static_cast<int>(fetch_statistics_.chosen_images_ + fetch_statistics_.missing_images_));
if (cover_fetching_tasks_.isEmpty()) {
QTimer::singleShot(2000, statusBar(), &QStatusBar::clearMessage);

View File

@@ -439,7 +439,7 @@ void DiscogsCoverProvider::HandleReleaseReply(QNetworkReply *reply, const int se
int width = obj_image["width"].toInt();
int height = obj_image["height"].toInt();
if (width < 300 || height < 300) continue;
const float aspect_score = 1.0 - float(std::max(width, height) - std::min(width, height)) / std::max(height, width);
const float aspect_score = float(1.0) - float(std::max(width, height) - std::min(width, height)) / std::max(height, width);
if (aspect_score < 0.85) continue;
CoverProviderSearchResult result;
result.artist = artist;

View File

@@ -79,7 +79,7 @@ SpotifyCoverProvider::SpotifyCoverProvider(Application *app, QObject *parent) :
if (!refresh_token_.isEmpty()) {
qint64 time = expires_in_ - (QDateTime::currentDateTime().toSecsSinceEpoch() - login_time_);
if (time < 6) time = 6;
refresh_login_timer_.setInterval(time * kMsecPerSec);
refresh_login_timer_.setInterval(static_cast<int>(time * kMsecPerSec));
refresh_login_timer_.start();
}
@@ -344,7 +344,7 @@ void SpotifyCoverProvider::AccessTokenRequestFinished(QNetworkReply *reply) {
s.endGroup();
if (expires_in_ > 0) {
refresh_login_timer_.setInterval(expires_in_ * kMsecPerSec);
refresh_login_timer_.setInterval(static_cast<int>(expires_in_ * kMsecPerSec));
refresh_login_timer_.start();
}