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

@ -220,7 +220,7 @@ void SingleApplicationPrivate::startSecondary() {
}
bool SingleApplicationPrivate::connectToPrimary(const qint64 timeout, const ConnectionType connectionType) {
bool SingleApplicationPrivate::connectToPrimary(const int timeout, const ConnectionType connectionType) {
QElapsedTimer time;
time.start();
@ -241,7 +241,7 @@ bool SingleApplicationPrivate::connectToPrimary(const qint64 timeout, const Conn
socket_->connectToServer(blockServerName_);
if (socket_->state() == QLocalSocket::ConnectingState) {
socket_->waitForConnected(timeout - time.elapsed());
socket_->waitForConnected(static_cast<int>(timeout - time.elapsed()));
}
// If connected break out of the loop
@ -277,7 +277,7 @@ bool SingleApplicationPrivate::connectToPrimary(const qint64 timeout, const Conn
socket_->write(header);
socket_->write(initMsg);
bool result = socket_->waitForBytesWritten(timeout - time.elapsed());
bool result = socket_->waitForBytesWritten(static_cast<int>(timeout - time.elapsed()));
socket_->flush();
return result;

View File

@ -85,7 +85,7 @@ class SingleApplicationPrivate : public QObject {
void initializeMemoryBlock();
void startPrimary();
void startSecondary();
bool connectToPrimary(const qint64 msecs, const ConnectionType connectionType);
bool connectToPrimary(const int timeout, const ConnectionType connectionType);
quint16 blockChecksum();
qint64 primaryPid();
QString primaryUser();

View File

@ -220,7 +220,7 @@ void SingleCoreApplicationPrivate::startSecondary() {
}
bool SingleCoreApplicationPrivate::connectToPrimary(const qint64 timeout, const ConnectionType connectionType) {
bool SingleCoreApplicationPrivate::connectToPrimary(const int timeout, const ConnectionType connectionType) {
QElapsedTimer time;
time.start();
@ -241,7 +241,7 @@ bool SingleCoreApplicationPrivate::connectToPrimary(const qint64 timeout, const
socket_->connectToServer(blockServerName_);
if (socket_->state() == QLocalSocket::ConnectingState) {
socket_->waitForConnected(timeout - time.elapsed());
socket_->waitForConnected(static_cast<int>(timeout - time.elapsed()));
}
// If connected break out of the loop
@ -277,7 +277,7 @@ bool SingleCoreApplicationPrivate::connectToPrimary(const qint64 timeout, const
socket_->write(header);
socket_->write(initMsg);
bool result = socket_->waitForBytesWritten(timeout - time.elapsed());
bool result = socket_->waitForBytesWritten(timeout - static_cast<int>(time.elapsed()));
socket_->flush();
return result;

View File

@ -85,7 +85,7 @@ class SingleCoreApplicationPrivate : public QObject {
void initializeMemoryBlock();
void startPrimary();
void startSecondary();
bool connectToPrimary(const qint64 msecs, const ConnectionType connectionType);
bool connectToPrimary(const int timeout, const ConnectionType connectionType);
quint16 blockChecksum();
qint64 primaryPid();
QString primaryUser();

View File

@ -35,12 +35,12 @@
#include "analyzerbase.h"
#include "fht.h"
const uint BlockAnalyzer::kHeight = 2;
const uint BlockAnalyzer::kWidth = 4;
const uint BlockAnalyzer::kMinRows = 3; // arbituary
const uint BlockAnalyzer::kMinColumns = 32; // arbituary
const uint BlockAnalyzer::kMaxColumns = 256; // must be 2**n
const uint BlockAnalyzer::kFadeSize = 90;
const int BlockAnalyzer::kHeight = 2;
const int BlockAnalyzer::kWidth = 4;
const int BlockAnalyzer::kMinRows = 3; // arbituary
const int BlockAnalyzer::kMinColumns = 32; // arbituary
const int BlockAnalyzer::kMaxColumns = 256; // must be 2**n
const int BlockAnalyzer::kFadeSize = 90;
const char *BlockAnalyzer::kName = QT_TRANSLATE_NOOP("AnalyzerContainer", "Block analyzer");
@ -74,11 +74,11 @@ void BlockAnalyzer::resizeEvent(QResizeEvent *e) {
background_ = QPixmap(size());
canvas_ = QPixmap(size());
const uint oldRows = rows_;
const int oldRows = rows_;
// all is explained in analyze()..
// +1 to counter -1 in maxSizes, trust me we need this!
columns_ = qMin(static_cast<uint>(static_cast<double>(width() + 1) / (kWidth + 1)) + 1, kMaxColumns);
columns_ = qMin(static_cast<int>(static_cast<double>(width() + 1) / (kWidth + 1)) + 1, kMaxColumns);
rows_ = static_cast<uint>(static_cast<double>(height() + 1) / (kHeight + 1));
// this is the y-offset for drawing from the top of the widget
@ -94,9 +94,9 @@ void BlockAnalyzer::resizeEvent(QResizeEvent *e) {
yscale_.resize(rows_ + 1);
const uint PRE = 1, PRO = 1; // PRE and PRO allow us to restrict the range somewhat
const int PRE = 1, PRO = 1; // PRE and PRO allow us to restrict the range somewhat
for (uint z = 0; z < rows_; ++z)
for (int z = 0; z < rows_; ++z)
yscale_[z] = 1 - (log10(PRE + z) / log10(PRE + rows_ + PRO));
yscale_[rows_] = 0;
@ -115,7 +115,7 @@ void BlockAnalyzer::determineStep() {
// I calculated the value 30 based on some trial and error
// the fall time of 30 is too slow on framerates above 50fps
const double fallTime = timeout() < 20 ? 20 * rows_ : 30 * rows_;
const double fallTime = static_cast<double>(timeout() < 20 ? 20 * rows_ : 30 * rows_);
step_ = double(rows_ * timeout()) / fallTime;
@ -164,12 +164,12 @@ void BlockAnalyzer::analyze(QPainter &p, const Analyzer::Scope &s, bool new_fram
// Paint the background
canvas_painter.drawPixmap(0, 0, background_);
for (uint y, x = 0; x < scope_.size(); ++x) {
for (int y, x = 0; x < static_cast<int>(scope_.size()); ++x) {
// determine y
for (y = 0; scope_[x] < yscale_[y]; ++y) continue;
// This is opposite to what you'd think, higher than y means the bar is lower than y (physically)
if (static_cast<float>(y) > store_[x])
if (static_cast<double>(y) > store_[x])
y = static_cast<int>(store_[x] += step_);
else
store_[x] = y;
@ -182,8 +182,8 @@ void BlockAnalyzer::analyze(QPainter &p, const Analyzer::Scope &s, bool new_fram
}
if (fade_intensity_[x] > 0) {
const uint offset = --fade_intensity_[x];
const uint y2 = y_ + (fade_pos_[x] * (kHeight + 1));
const int offset = --fade_intensity_[x];
const int y2 = y_ + (fade_pos_[x] * (kHeight + 1));
canvas_painter.drawPixmap(x * (kWidth + 1), y2, fade_bars_[offset], 0, 0, kWidth, height() - y2);
}
@ -200,7 +200,7 @@ void BlockAnalyzer::analyze(QPainter &p, const Analyzer::Scope &s, bool new_fram
}
static inline void adjustToLimits(int &b, int &f, uint &amount) {
static inline void adjustToLimits(int &b, int &f, int &amount) {
// with a range of 0-255 and maximum adjustment of amount, maximise the difference between f and b
@ -235,8 +235,8 @@ static inline void adjustToLimits(int &b, int &f, uint &amount) {
* It won't modify the hue of fg unless absolutely necessary
* @return the adjusted form of fg
*/
QColor ensureContrast(const QColor &bg, const QColor &fg, uint amount = 150);
QColor ensureContrast(const QColor &bg, const QColor &fg, uint amount) {
QColor ensureContrast(const QColor &bg, const QColor &fg, int amount = 150);
QColor ensureContrast(const QColor &bg, const QColor &fg, int amount) {
class OutputOnExit {
public:
@ -278,9 +278,9 @@ QColor ensureContrast(const QColor &bg, const QColor &fg, uint amount) {
// check the saturation for the two colours is sufficient that hue alone can
// provide sufficient contrast
if (ds > static_cast<int>(amount) / 2 && (bs > 125 && fs > 125))
if (ds > amount / 2 && (bs > 125 && fs > 125))
return fg;
else if (dv > static_cast<int>(amount) / 2 && (bv > 125 && fv > 125))
else if (dv > amount / 2 && (bv > 125 && fv > 125))
return fg;
}
@ -295,11 +295,11 @@ QColor ensureContrast(const QColor &bg, const QColor &fg, uint amount) {
}
// test that there is available value to honor our contrast requirement
if (255 - dv < static_cast<int>(amount)) {
if (255 - dv < amount) {
// we have to modify the value and saturation of fg
// adjustToLimits( bv, fv, amount );
// see if we need to adjust the saturation
if (static_cast<int>(amount) > 0) adjustToLimits(bs, fs, amount);
if (amount > 0) adjustToLimits(bs, fs, amount);
// see if we need to adjust the hue
if (static_cast<int>(amount) > 0)
@ -312,13 +312,13 @@ QColor ensureContrast(const QColor &bg, const QColor &fg, uint amount) {
return QColor::fromHsv(fh, fs, bv - static_cast<int>(amount));
if (fv < bv && fv > static_cast<int>(amount))
return QColor::fromHsv(fh, fs, fv - static_cast<int>(amount));
return QColor::fromHsv(fh, fs, fv - amount);
if (fv > bv && (255 - fv > static_cast<int>(amount)))
return QColor::fromHsv(fh, fs, fv + static_cast<int>(amount));
return QColor::fromHsv(fh, fs, fv + amount);
if (fv < bv && (255 - bv > static_cast<int>(amount)))
return QColor::fromHsv(fh, fs, bv + static_cast<int>(amount));
return QColor::fromHsv(fh, fs, bv + amount);
return Qt::blue;
}
@ -338,7 +338,7 @@ void BlockAnalyzer::paletteChange(const QPalette&) {
bar()->fill(bg);
QPainter p(bar());
for (int y = 0; static_cast<uint>(y) < rows_; ++y)
for (int y = 0; y < rows_; ++y)
// graduate the fg color
p.fillRect(0, y * (kHeight + 1), kWidth, kHeight, QColor(r + static_cast<int>(dr * y), g + static_cast<int>(dg * y), b + static_cast<int>(db * y)));
@ -360,7 +360,7 @@ void BlockAnalyzer::paletteChange(const QPalette&) {
for (uint y = 0; y < kFadeSize; ++y) {
fade_bars_[y].fill(palette().color(QPalette::Window));
QPainter f(&fade_bars_[y]);
for (int z = 0; static_cast<uint>(z) < rows_; ++z) {
for (int z = 0; z < rows_; ++z) {
const double Y = 1.0 - (log10(kFadeSize - y) / log10(kFadeSize));
f.fillRect(0, z * (kHeight + 1), kWidth, kHeight, QColor(r2 + static_cast<int>(dr2 * Y), g2 + static_cast<int>(dg2 * Y), b2 + static_cast<int>(db2 * Y)));
}
@ -386,8 +386,8 @@ void BlockAnalyzer::drawBackground() {
if (!p.paintEngine()) return;
for (int x = 0; static_cast<uint>(x) < columns_; ++x)
for (int y = 0; static_cast<uint>(y) < rows_; ++y)
for (int x = 0; x < columns_; ++x)
for (int y = 0; y < rows_; ++y)
p.fillRect(x * (kWidth + 1), y * (kHeight + 1) + y_, kWidth, kHeight, bgdark);
}

View File

@ -43,12 +43,12 @@ class BlockAnalyzer : public Analyzer::Base {
public:
Q_INVOKABLE explicit BlockAnalyzer(QWidget*);
static const uint kHeight;
static const uint kWidth;
static const uint kMinRows;
static const uint kMinColumns;
static const uint kMaxColumns;
static const uint kFadeSize;
static const int kHeight;
static const int kWidth;
static const int kMinRows;
static const int kMinColumns;
static const int kMaxColumns;
static const int kFadeSize;
static const char *kName;
@ -65,21 +65,21 @@ class BlockAnalyzer : public Analyzer::Base {
private:
QPixmap *bar() { return &barpixmap_; }
uint columns_, rows_; // number of rows and columns of blocks
uint y_; // y-offset from top of widget
int columns_, rows_; // number of rows and columns of blocks
int y_; // y-offset from top of widget
QPixmap barpixmap_;
QPixmap topbarpixmap_;
QPixmap background_;
QPixmap canvas_;
Analyzer::Scope scope_; // so we don't create a vector every frame
QVector<float> store_; // current bar heights
QVector<float> yscale_;
QVector<double> store_; // current bar heights
QVector<double> yscale_;
QVector<QPixmap> fade_bars_;
QVector<uint> fade_pos_;
QVector<int> fade_pos_;
QVector<int> fade_intensity_;
float step_; // rows to fall per frame
double step_; // rows to fall per frame
};
#endif // BLOCKANALYZER_H

View File

@ -39,9 +39,9 @@
using Analyzer::Scope;
const uint BoomAnalyzer::kColumnWidth = 4;
const uint BoomAnalyzer::kMaxBandCount = 256;
const uint BoomAnalyzer::kMinBandCount = 32;
const int BoomAnalyzer::kColumnWidth = 4;
const int BoomAnalyzer::kMaxBandCount = 256;
const int BoomAnalyzer::kMinBandCount = 32;
const char* BoomAnalyzer::kName = QT_TRANSLATE_NOOP("AnalyzerContainer", "Boom analyzer");
@ -80,10 +80,10 @@ void BoomAnalyzer::resizeEvent(QResizeEvent* e) {
const uint HEIGHT = height() - 2;
const double h = 1.2 / HEIGHT;
bands_ = qMin(static_cast<uint>(static_cast<double>(width() + 1) / (kColumnWidth + 1)) + 1, kMaxBandCount);
bands_ = qMin(static_cast<int>(static_cast<double>(width() + 1) / (kColumnWidth + 1)) + 1, kMaxBandCount);
scope_.resize(bands_);
F_ = static_cast<double>(HEIGHT) / (log10(256) * 1.1 /*<- max. amplitude*/);
F_ = double(HEIGHT) / (log10(256) * double(1.1) /*<- max. amplitude*/);
barPixmap_ = QPixmap(kColumnWidth - 2, HEIGHT);
canvas_ = QPixmap(size());
@ -106,7 +106,7 @@ void BoomAnalyzer::transform(Scope& s) {
fht_->spectrum(s.data());
fht_->scale(s.data(), 1.0 / 50);
s.resize(scope_.size() <= kMaxBandCount / 2 ? kMaxBandCount / 2 : scope_.size());
s.resize(scope_.size() <= static_cast<quint64>(kMaxBandCount) / 2 ? kMaxBandCount / 2 : scope_.size());
}
@ -116,7 +116,7 @@ void BoomAnalyzer::analyze(QPainter& p, const Scope& scope, bool new_frame) {
p.drawPixmap(0, 0, canvas_);
return;
}
float h;
double h;
const uint MAX_HEIGHT = height() - 1;
QPainter canvas_painter(&canvas_);
@ -124,7 +124,7 @@ void BoomAnalyzer::analyze(QPainter& p, const Scope& scope, bool new_frame) {
Analyzer::interpolate(scope, scope_);
for (uint i = 0, x = 0, y; i < bands_; ++i, x += kColumnWidth + 1) {
for (int i = 0, x = 0, y; i < bands_; ++i, x += kColumnWidth + 1) {
h = log10(scope_[i] * 256.0) * F_;
if (h > MAX_HEIGHT) h = MAX_HEIGHT;
@ -157,13 +157,13 @@ void BoomAnalyzer::analyze(QPainter& p, const Scope& scope, bool new_frame) {
}
}
y = height() - uint(bar_height_[i]);
y = height() - static_cast<int>(bar_height_[i]);
canvas_painter.drawPixmap(x + 1, y, barPixmap_, 0, y, -1, -1);
canvas_painter.setPen(fg_);
if (bar_height_[i] > 0)
canvas_painter.drawRect(x, y, kColumnWidth - 1, height() - y - 1);
y = height() - uint(peak_height_[i]);
y = height() - static_cast<int>(peak_height_[i]);
canvas_painter.setPen(palette().color(QPalette::Midlight));
canvas_painter.drawLine(x, y, x + kColumnWidth - 1, y);
}

View File

@ -54,19 +54,19 @@ class BoomAnalyzer : public Analyzer::Base {
protected:
void resizeEvent(QResizeEvent *e) override;
static const uint kColumnWidth;
static const uint kMaxBandCount;
static const uint kMinBandCount;
static const int kColumnWidth;
static const int kMaxBandCount;
static const int kMinBandCount;
uint bands_;
int bands_;
Analyzer::Scope scope_;
QColor fg_;
double K_barHeight_, F_peakSpeed_, F_;
std::vector<float> bar_height_;
std::vector<float> peak_height_;
std::vector<float> peak_speed_;
std::vector<double> bar_height_;
std::vector<double> peak_height_;
std::vector<double> peak_speed_;
QPixmap barPixmap_;
QPixmap canvas_;

View File

@ -112,7 +112,7 @@ void Rainbow::RainbowAnalyzer::resizeEvent(QResizeEvent* e) {
void Rainbow::RainbowAnalyzer::analyze(QPainter& p, const Analyzer::Scope& s, bool new_frame) {
// Discard the second half of the transform
const int scope_size = s.size() / 2;
const int scope_size = static_cast<int>(s.size() / 2);
if ((new_frame && is_playing_) || (buffer_[0].isNull() && buffer_[1].isNull())) {
// Transform the music into rainbows!

View File

@ -758,7 +758,7 @@ SongList CollectionBackend::GetSongsByForeignId(const QStringList &ids, const QS
QVector<Song> ret(ids.count());
while (q.next()) {
const QString foreign_id = q.value(Song::kColumns.count() + 1).toString();
const QString foreign_id = q.value(static_cast<int>(Song::kColumns.count()) + 1).toString();
const int index = ids.indexOf(foreign_id);
if (index == -1) continue;
@ -1484,7 +1484,7 @@ void CollectionBackend::UpdatePlayCount(const QString &artist, const QString &ti
}
void CollectionBackend::UpdateSongRating(const int id, const float rating) {
void CollectionBackend::UpdateSongRating(const int id, const double rating) {
if (id == -1) return;
@ -1494,7 +1494,7 @@ void CollectionBackend::UpdateSongRating(const int id, const float rating) {
}
void CollectionBackend::UpdateSongsRating(const QList<int> &id_list, const float rating) {
void CollectionBackend::UpdateSongsRating(const QList<int> &id_list, const double rating) {
if (id_list.isEmpty()) return;
@ -1516,10 +1516,10 @@ void CollectionBackend::UpdateSongsRating(const QList<int> &id_list, const float
}
void CollectionBackend::UpdateSongRatingAsync(const int id, const float rating) {
metaObject()->invokeMethod(this, "UpdateSongRating", Qt::QueuedConnection, Q_ARG(int, id), Q_ARG(float, rating));
void CollectionBackend::UpdateSongRatingAsync(const int id, const double rating) {
metaObject()->invokeMethod(this, "UpdateSongRating", Qt::QueuedConnection, Q_ARG(int, id), Q_ARG(double, rating));
}
void CollectionBackend::UpdateSongsRatingAsync(const QList<int>& ids, const float rating) {
metaObject()->invokeMethod(this, "UpdateSongsRating", Qt::QueuedConnection, Q_ARG(QList<int>, ids), Q_ARG(float, rating));
void CollectionBackend::UpdateSongsRatingAsync(const QList<int>& ids, const double rating) {
metaObject()->invokeMethod(this, "UpdateSongsRating", Qt::QueuedConnection, Q_ARG(QList<int>, ids), Q_ARG(double, rating));
}

View File

@ -193,8 +193,8 @@ class CollectionBackend : public CollectionBackendInterface {
void AddOrUpdateSongsAsync(const SongList &songs);
void UpdateSongRatingAsync(const int id, const float rating);
void UpdateSongsRatingAsync(const QList<int> &ids, const float rating);
void UpdateSongRatingAsync(const int id, const double rating);
void UpdateSongsRatingAsync(const QList<int> &ids, const double rating);
public slots:
void Exit();
@ -220,8 +220,8 @@ class CollectionBackend : public CollectionBackendInterface {
void UpdateLastPlayed(const QString &artist, const QString &album, const QString &title, const qint64 lastplayed);
void UpdatePlayCount(const QString &artist, const QString &title, const int playcount);
void UpdateSongRating(const int id, const float rating);
void UpdateSongsRating(const QList<int> &id_list, const float rating);
void UpdateSongRating(const int id, const double rating);
void UpdateSongsRating(const QList<int> &id_list, const double rating);
signals:
void DirectoryDiscovered(Directory, SubdirectoryList);

View File

@ -186,7 +186,7 @@ void CollectionModel::ReloadSettings() {
use_disk_cache_ = s.value(CollectionSettingsPage::kSettingsDiskCacheEnable, false).toBool();
QPixmapCache::setCacheLimit(MaximumCacheSize(&s, CollectionSettingsPage::kSettingsCacheSize, CollectionSettingsPage::kSettingsCacheSizeUnit, CollectionSettingsPage::kSettingsCacheSizeDefault) / 1024);
QPixmapCache::setCacheLimit(static_cast<int>(MaximumCacheSize(&s, CollectionSettingsPage::kSettingsCacheSize, CollectionSettingsPage::kSettingsCacheSizeUnit, CollectionSettingsPage::kSettingsCacheSizeDefault) / 1024));
if (sIconCache) {
sIconCache->setMaximumCacheSize(MaximumCacheSize(&s, CollectionSettingsPage::kSettingsDiskCacheSize, CollectionSettingsPage::kSettingsDiskCacheSizeUnit, CollectionSettingsPage::kSettingsDiskCacheSizeDefault));

View File

@ -92,7 +92,7 @@ CollectionQuery::CollectionQuery(const QueryOptions &options)
}
if (options.max_age() != -1) {
int cutoff = QDateTime::currentDateTime().toSecsSinceEpoch() - options.max_age();
qint64 cutoff = QDateTime::currentDateTime().toSecsSinceEpoch() - options.max_age();
where_clauses_ << "ctime > ?";
bound_values_ << cutoff;

View File

@ -1599,11 +1599,11 @@ void MainWindow::FilePathChanged(const QString &path) {
settings_.setValue("file_path", path);
}
void MainWindow::Seeked(const qlonglong microseconds) {
void MainWindow::Seeked(const qint64 microseconds) {
const int position = microseconds / kUsecPerSec;
const int length = app_->player()->GetCurrentItem()->Metadata().length_nanosec() / kNsecPerSec;
if (tray_icon_) tray_icon_->SetProgress(double(position) / length * 100);
const qint64 position = microseconds / kUsecPerSec;
const qint64 length = app_->player()->GetCurrentItem()->Metadata().length_nanosec() / kNsecPerSec;
if (tray_icon_) tray_icon_->SetProgress(static_cast<int>(double(position) / length * 100));
}
@ -1612,18 +1612,18 @@ void MainWindow::UpdateTrackPosition() {
PlaylistItemPtr item(app_->player()->GetCurrentItem());
if (!item) return;
const int length = (item->Metadata().length_nanosec() / kNsecPerSec);
const qint64 length = (item->Metadata().length_nanosec() / kNsecPerSec);
if (length <= 0) return;
const int position = std::floor(float(app_->player()->engine()->position_nanosec()) / kNsecPerSec + 0.5);
// Update the tray icon every 10 seconds
if (tray_icon_ && position % 10 == 0) tray_icon_->SetProgress(double(position) / length * 100);
if (tray_icon_ && position % 10 == 0) tray_icon_->SetProgress(static_cast<int>(double(position) / length * 100));
// Send Scrobble
if (app_->scrobbler()->IsEnabled() && item->Metadata().is_metadata_good()) {
Playlist *playlist = app_->playlist_manager()->active();
if (playlist && !playlist->scrobbled()) {
const int scrobble_point = (playlist->scrobble_point_nanosec() / kNsecPerSec);
const qint64 scrobble_point = (playlist->scrobble_point_nanosec() / kNsecPerSec);
if (position >= scrobble_point) {
app_->scrobbler()->Scrobble(item->Metadata(), scrobble_point);
playlist->set_scrobbled(true);
@ -1637,8 +1637,8 @@ void MainWindow::UpdateTrackSliderPosition() {
PlaylistItemPtr item(app_->player()->GetCurrentItem());
const int slider_position = std::floor(float(app_->player()->engine()->position_nanosec()) / kNsecPerMsec);
const int slider_length = app_->player()->engine()->length_nanosec() / kNsecPerMsec;
const qint64 slider_position = std::floor(float(app_->player()->engine()->position_nanosec()) / kNsecPerMsec);
const qint64 slider_length = app_->player()->engine()->length_nanosec() / kNsecPerMsec;
// Update the slider
ui_->track_slider->SetValue(slider_position, slider_length);

View File

@ -200,7 +200,7 @@ class MainWindow : public QMainWindow, public PlatformInterface {
void ToggleShowHide();
void ToggleHide();
void Seeked(const qlonglong microseconds);
void Seeked(const qint64 microseconds);
void UpdateTrackPosition();
void UpdateTrackSliderPosition();

View File

@ -412,9 +412,9 @@ void Mpris2::AlbumCoverLoaded(const Song &song, const AlbumCoverLoaderResult &re
double Mpris2::Volume() const { return app_->player()->GetVolume() / 100.0; }
void Mpris2::SetVolume(double value) { app_->player()->SetVolume(value * 100); }
void Mpris2::SetVolume(double value) { app_->player()->SetVolume(static_cast<int>(value * 100)); }
qlonglong Mpris2::Position() const {
qint64 Mpris2::Position() const {
return app_->player()->engine()->position_nanosec() / kNsecPerUsec;
}
@ -479,13 +479,16 @@ void Mpris2::Play() {
}
}
void Mpris2::Seek(qlonglong offset) {
void Mpris2::Seek(qint64 offset) {
if (CanSeek()) {
app_->player()->SeekTo(app_->player()->engine()->position_nanosec() / kNsecPerSec + offset / kUsecPerSec);
}
}
void Mpris2::SetPosition(const QDBusObjectPath &trackId, qlonglong offset) {
void Mpris2::SetPosition(const QDBusObjectPath &trackId, qint64 offset) {
if (CanSeek() && trackId.path() == current_track_id() && offset >= 0) {
offset *= kNsecPerUsec;
@ -493,6 +496,7 @@ void Mpris2::SetPosition(const QDBusObjectPath &trackId, qlonglong offset) {
app_->player()->SeekTo(offset / kNsecPerSec);
}
}
}
void Mpris2::OpenUri(const QString &uri) {

View File

@ -98,7 +98,7 @@ class Mpris2 : public QObject {
Q_PROPERTY(bool Shuffle READ Shuffle WRITE SetShuffle)
Q_PROPERTY(QVariantMap Metadata READ Metadata)
Q_PROPERTY(double Volume READ Volume WRITE SetVolume)
Q_PROPERTY(qlonglong Position READ Position)
Q_PROPERTY(qint64 Position READ Position)
Q_PROPERTY(double MinimumRate READ MinimumRate)
Q_PROPERTY(double MaximumRate READ MaximumRate)
Q_PROPERTY(bool CanGoNext READ CanGoNext)
@ -146,7 +146,7 @@ class Mpris2 : public QObject {
QVariantMap Metadata() const;
double Volume() const;
void SetVolume(double value);
qlonglong Position() const;
qint64 Position() const;
double MaximumRate() const;
double MinimumRate() const;
bool CanGoNext() const;
@ -163,8 +163,8 @@ class Mpris2 : public QObject {
void PlayPause();
void Stop();
void Play();
void Seek(qlonglong offset);
void SetPosition(const QDBusObjectPath &trackId, qlonglong offset);
void Seek(qint64 offset);
void SetPosition(const QDBusObjectPath &trackId, qint64 offset);
void OpenUri(const QString &uri);
// TrackList Properties
@ -188,7 +188,7 @@ class Mpris2 : public QObject {
signals:
// Player
void Seeked(qlonglong position);
void Seeked(qint64 position);
// TrackList
void TrackListReplaced(Track_Ids Tracks, QDBusObjectPath CurrentTrack);

View File

@ -633,7 +633,7 @@ void Player::CurrentMetadataChanged(const Song &metadata) {
}
void Player::SeekTo(const int seconds) {
void Player::SeekTo(const qint64 seconds) {
const qint64 length_nanosec = engine_->length_nanosec();

View File

@ -87,7 +87,7 @@ class PlayerInterface : public QObject {
virtual void SetVolume(const int value) = 0;
virtual void VolumeUp() = 0;
virtual void VolumeDown() = 0;
virtual void SeekTo(const int seconds) = 0;
virtual void SeekTo(const qint64 seconds) = 0;
// Moves the position of the currently playing song five seconds forward.
virtual void SeekForward() = 0;
// Moves the position of the currently playing song five seconds backwards.
@ -113,7 +113,7 @@ class PlayerInterface : public QObject {
void VolumeChanged(int volume);
void TrackSkipped(PlaylistItemPtr old_track);
// Emitted when there's a manual change to the current's track position.
void Seeked(qlonglong microseconds);
void Seeked(qint64 microseconds);
// Emitted when Player has processed a request to play another song.
// This contains the URL of the song and a flag saying whether it was able to play the song.
@ -168,7 +168,7 @@ class Player : public PlayerInterface {
void SetVolume(const int value) override;
void VolumeUp() override { SetVolume(GetVolume() + 5); }
void VolumeDown() override { SetVolume(GetVolume() - 5); }
void SeekTo(const int seconds) override;
void SeekTo(const qint64 seconds) override;
void SeekForward() override;
void SeekBackward() override;

View File

@ -41,7 +41,7 @@ gulong CheckedGConnect(gpointer source, const char *signal, GCallback callback,
GSignalQuery query;
g_signal_query(signal_id, &query);
// The signature for a signal callback is always: return_type callback(gpointer data1, params..., gpointer data2);
int signal_params = query.n_params + 2;
int signal_params = static_cast<int>(query.n_params) + 2;
if (signal_params != callback_param_count) {
qFatal("Connecting callback to signal with different parameters counts");
return 0;

View File

@ -214,7 +214,7 @@ struct Song::Private : public QSharedData {
QString cue_path_; // If the song has a CUE, this contains it's path.
float rating_; // Database rating, not read from tags.
double rating_; // Database rating, not read from tags.
QUrl stream_url_; // Temporary stream url set by url handler.
QImage image_; // Album Cover image set by album cover loader.
@ -360,7 +360,7 @@ const QImage &Song::image() const { return d->image_; }
const QString &Song::cue_path() const { return d->cue_path_; }
bool Song::has_cue() const { return !d->cue_path_.isEmpty(); }
float Song::rating() const { return d->rating_; }
double Song::rating() const { return d->rating_; }
bool Song::is_collection_song() const { return d->source_ == Source_Collection; }
bool Song::is_metadata_good() const { return !d->url_.isEmpty() && !d->artist_.isEmpty() && !d->title_.isEmpty(); }
@ -461,7 +461,7 @@ void Song::set_art_automatic(const QUrl &v) { d->art_automatic_ = v; }
void Song::set_art_manual(const QUrl &v) { d->art_manual_ = v; }
void Song::set_cue_path(const QString &v) { d->cue_path_ = v; }
void Song::set_rating(float v) { d->rating_ = v; }
void Song::set_rating(double v) { d->rating_ = v; }
void Song::set_stream_url(const QUrl &v) { d->stream_url_ = v; }
void Song::set_image(const QImage &i) { d->image_ = i; }
@ -844,7 +844,7 @@ void Song::ToProtobuf(spb::tagreader::SongMetadata *pb) const {
#define tostr(n) (q.value(n).isNull() ? QString() : q.value(n).toString())
#define toint(n) (q.value(n).isNull() ? -1 : q.value(n).toInt())
#define tolonglong(n) (q.value(n).isNull() ? -1 : q.value(n).toLongLong())
#define tofloat(n) (q.value(n).isNull() ? -1 : q.value(n).toDouble())
#define todouble(n) (q.value(n).isNull() ? -1 : q.value(n).toDouble())
void Song::InitFromQuery(const SqlRow &q, bool reliable_metadata, int col) {
@ -1013,7 +1013,7 @@ void Song::InitFromQuery(const SqlRow &q, bool reliable_metadata, int col) {
}
else if (Song::kColumns.value(i) == "rating") {
d->rating_ = tofloat(x);
d->rating_ = todouble(x);
}
else {
@ -1029,7 +1029,7 @@ void Song::InitFromQuery(const SqlRow &q, bool reliable_metadata, int col) {
#undef tostr
#undef toint
#undef tolonglong
#undef tofloat
#undef todouble
}
@ -1474,7 +1474,7 @@ QString Song::SampleRateBitDepthToText() const {
QString Song::PrettyRating() const {
float rating = d->rating_;
double rating = d->rating_;
if (rating == -1.0f) return "0";

View File

@ -243,7 +243,7 @@ class Song {
const QString &cue_path() const;
bool has_cue() const;
float rating() const;
double rating() const;
const QString &effective_album() const;
int effective_originalyear() const;
@ -356,7 +356,7 @@ class Song {
void set_cue_path(const QString &v);
void set_rating(const float v);
void set_rating(const double v);
void set_stream_url(const QUrl &v);
void set_image(const QImage &i);

View File

@ -61,7 +61,7 @@ QPixmap SystemTrayIcon::CreateIcon(const QPixmap &icon, const QPixmap &grey_icon
QPolygon mask;
mask << rect.topLeft();
mask << rect.topLeft() + QPoint(length * sin(angle), length * cos(angle));
mask << rect.topLeft() + QPoint(static_cast<int>(length * sin(angle)), static_cast<int>(length * cos(angle)));
if (song_progress() > 50) mask << rect.bottomRight();

View File

@ -128,7 +128,7 @@ QString PrettyTime(int seconds) {
}
QString PrettyTimeNanosec(qint64 nanoseconds) {
return PrettyTime(nanoseconds / kNsecPerSec);
return PrettyTime(static_cast<int>(nanoseconds / kNsecPerSec));
}
QString WordyTime(quint64 seconds) {
@ -139,7 +139,7 @@ QString WordyTime(quint64 seconds) {
QStringList parts;
if (days) parts << (days == 1 ? tr("1 day") : tr("%1 days").arg(days));
parts << PrettyTime(seconds - days * 60 * 60 * 24);
parts << PrettyTime(static_cast<int>(seconds - days * 60 * 60 * 24));
return parts.join(" ");

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();
}

View File

@ -849,7 +849,7 @@ void DeviceManager::TasksChanged() {
DeviceInfo *info = IndexToItem(idx);
if (task.progress_max)
info->task_percentage_ = float(task.progress) / task.progress_max * 100;
info->task_percentage_ = static_cast<int>(float(task.progress) / task.progress_max * 100);
else
info->task_percentage_ = 0;

View File

@ -169,7 +169,7 @@ void DeviceProperties::UpdateHardwareInfo() {
ui_->hardware_info_stack->setCurrentWidget(ui_->hardware_info_page);
ui_->hardware_info->clear();
ui_->hardware_info->setRowCount(2 + info.count());
ui_->hardware_info->setRowCount(2 + static_cast<int>(info.count()));
int row = 0;
AddHardwareInfo(row++, tr("Model"), lister->DeviceModel(id));

View File

@ -90,7 +90,7 @@ DeleteConfirmationDialog::DeleteConfirmationDialog(const QStringList &files, QWi
QScreen *screen = (window() && window()->windowHandle() ? window()->windowHandle()->screen() : QGuiApplication::primaryScreen());
#endif
if (screen) {
max_width = screen->geometry().size().width() / 0.5;
max_width = static_cast<int>(screen->geometry().size().width() / 0.5);
max_height = static_cast<int>(float(screen->geometry().size().height()) / float(1.5));
}
int min_width = std::min(list->sizeHintForColumn(0) + 100, max_width);

View File

@ -115,7 +115,7 @@ void Engine::Base::ReloadSettings() {
rg_enabled_ = s.value("rgenabled", false).toBool();
rg_mode_ = s.value("rgmode", 0).toInt();
rg_preamp_ = s.value("rgpreamp", 0.0).toDouble();
rg_preamp_ = s.value("rgpreamp", 0.0).toFloat();
rg_compression_ = s.value("rgcompression", true).toBool();
fadeout_enabled_ = s.value("FadeoutEnabled", false).toBool();

View File

@ -860,7 +860,7 @@ void GstEngine::UpdateScope(const int chunk_length) {
gst_buffer_map(latest_buffer_, &map, GST_MAP_READ);
// Determine where to split the buffer
int chunk_density = (map.size * kNsecPerMsec) / GST_BUFFER_DURATION(latest_buffer_);
int chunk_density = static_cast<int>((map.size * kNsecPerMsec) / GST_BUFFER_DURATION(latest_buffer_));
int chunk_size = chunk_length * chunk_density;

View File

@ -353,9 +353,9 @@ bool GstEnginePipeline::InitAudioBin() {
const int index_in_eq = i + 1;
GstObject *band = GST_OBJECT(gst_child_proxy_get_child_by_index(GST_CHILD_PROXY(equalizer_), index_in_eq));
const float frequency = kEqBandFrequencies[i];
const float bandwidth = frequency - last_band_frequency;
last_band_frequency = frequency;
const float frequency = static_cast<float>(kEqBandFrequencies[i]);
const float bandwidth = frequency - static_cast<float>(last_band_frequency);
last_band_frequency = static_cast<int>(frequency);
g_object_set(G_OBJECT(band), "freq", frequency, "bandwidth", bandwidth, "gain", 0.0f, nullptr);
g_object_unref(G_OBJECT(band));
@ -628,8 +628,8 @@ GstPadProbeReturn GstEnginePipeline::HandoffCallback(GstPad *pad, GstPadProbeInf
gst_buffer_map(buf, &map_info, GST_MAP_READ);
int32_t *s = reinterpret_cast<int32_t*>(map_info.data);
int samples = (map_info.size / sizeof(int32_t)) / channels;
int buf16_size = samples * sizeof(int16_t) * channels;
int samples = static_cast<int>((map_info.size / sizeof(int32_t)) / channels);
int buf16_size = samples * static_cast<int>(sizeof(int16_t)) * channels;
int16_t *d = static_cast<int16_t*>(g_malloc(buf16_size));
memset(d, 0, buf16_size);
for (int i = 0 ; i < (samples * channels) ; ++i) {
@ -649,12 +649,12 @@ GstPadProbeReturn GstEnginePipeline::HandoffCallback(GstPad *pad, GstPadProbeInf
gst_buffer_map(buf, &map_info, GST_MAP_READ);
float *s = reinterpret_cast<float*>(map_info.data);
int samples = (map_info.size / sizeof(float)) / channels;
int buf16_size = samples * sizeof(int16_t) * channels;
int samples = static_cast<int>((map_info.size / sizeof(float)) / channels);
int buf16_size = samples * static_cast<int>(sizeof(int16_t)) * channels;
int16_t *d = static_cast<int16_t*>(g_malloc(buf16_size));
memset(d, 0, buf16_size);
for (int i = 0 ; i < (samples * channels) ; ++i) {
float sample_float = (s[i] * 32768.0);
float sample_float = (s[i] * float(32768.0));
d[i] = static_cast<int16_t>(sample_float);
}
gst_buffer_unmap(buf, &map_info);
@ -671,8 +671,8 @@ GstPadProbeReturn GstEnginePipeline::HandoffCallback(GstPad *pad, GstPadProbeInf
char *s24 = reinterpret_cast<char*>(map_info.data);
char *s24e = s24 + map_info.size;
int samples = (map_info.size / sizeof(char)) / channels;
int buf16_size = samples * sizeof(int16_t) * channels;
int samples = static_cast<int>((map_info.size / sizeof(char)) / channels);
int buf16_size = samples * static_cast<int>(sizeof(int16_t)) * channels;
int16_t *s16 = static_cast<int16_t*>(g_malloc(buf16_size));
memset(s16, 0, buf16_size);
for (int i = 0 ; i < (samples * channels) ; ++i) {
@ -1129,7 +1129,7 @@ void GstEnginePipeline::SetVolumeModifier(const qreal mod) {
void GstEnginePipeline::UpdateVolume() {
if (!volume_) return;
float vol = double(volume_percent_) * 0.01 * volume_modifier_;
double vol = double(volume_percent_) * double(0.01) * volume_modifier_;
g_object_set(G_OBJECT(volume_), "volume", vol, nullptr);
}
@ -1163,7 +1163,7 @@ void GstEnginePipeline::UpdateEqualizer() {
// Update band gains
for (int i = 0; i < kEqBandCount; ++i) {
float gain = eq_enabled_ ? eq_band_gains_[i] : 0.0;
float gain = eq_enabled_ ? eq_band_gains_[i] : float(0.0);
if (gain < 0)
gain *= 0.24;
else
@ -1178,7 +1178,7 @@ void GstEnginePipeline::UpdateEqualizer() {
// Update preamp
float preamp = 1.0;
if (eq_enabled_) preamp = float(eq_preamp_ + 100) * 0.01; // To scale from 0.0 to 2.0
if (eq_enabled_) preamp = float(eq_preamp_ + 100) * float(0.01); // To scale from 0.0 to 2.0
g_object_set(G_OBJECT(equalizer_preamp_), "volume", preamp, nullptr);
@ -1186,10 +1186,10 @@ void GstEnginePipeline::UpdateEqualizer() {
void GstEnginePipeline::StartFader(const qint64 duration_nanosec, const QTimeLine::Direction direction, const QEasingCurve::Type shape, const bool use_fudge_timer) {
const int duration_msec = duration_nanosec / kNsecPerMsec;
const qint64 duration_msec = duration_nanosec / kNsecPerMsec;
// If there's already another fader running then start from the same time that one was already at.
int start_time = direction == QTimeLine::Forward ? 0 : duration_msec;
qint64 start_time = direction == QTimeLine::Forward ? 0 : duration_msec;
if (fader_ && fader_->state() == QTimeLine::Running) {
if (duration_msec == fader_->duration()) {
start_time = fader_->currentTime();

View File

@ -177,7 +177,7 @@ void VLCEngine::Seek(const quint64 offset_nanosec) {
if (!Initialized()) return;
int offset = (offset_nanosec / kNsecPerMsec);
int offset = static_cast<int>(offset_nanosec / kNsecPerMsec);
uint len = length();
if (len == 0) return;

View File

@ -277,7 +277,7 @@ Equalizer::Params Equalizer::current_params() const {
}
float Equalizer::stereo_balance() const {
return qBound(-1.0f, ui_->stereo_balance_slider->value() / 100.0f, 1.0f);
return qBound(-1.0f, static_cast<float>(ui_->stereo_balance_slider->value()) / 100.0f, 1.0f);
}
void Equalizer::StereoBalancerEnabledChangedSlot(const bool enabled) {

View File

@ -59,7 +59,7 @@ EqualizerSlider::~EqualizerSlider() {
void EqualizerSlider::OnValueChanged(int value) {
// Converting % to dB as per GstEnginePipeline::UpdateEqualizer():
float gain = (value < 0) ? value * 0.24 : value * 0.12;
float gain = (static_cast<int>(value) < 0) ? static_cast<float>(value) * float(0.24) : float(value) * float(0.12);
ui_->gain->setText(tr("%1 dB").arg(gain)); // Gain [dB]
emit ValueChanged(value);

View File

@ -191,7 +191,7 @@ QList<QKeySequence> GlobalShortcutsBackendKDE::ToKeySequenceList(const QList<int
}
void GlobalShortcutsBackendKDE::GlobalShortcutPressed(const QString &component_unique, const QString &shortcut_unique, qlonglong) {
void GlobalShortcutsBackendKDE::GlobalShortcutPressed(const QString &component_unique, const QString &shortcut_unique, qint64) {
if (QCoreApplication::applicationName() == component_unique && actions_.contains(shortcut_unique)) {
for (QAction *action : actions_.values(shortcut_unique)) {

View File

@ -57,7 +57,7 @@ class GlobalShortcutsBackendKDE : public GlobalShortcutsBackend {
private slots:
void RegisterFinished(QDBusPendingCallWatcher *watcher);
void GlobalShortcutPressed(const QString &component_unique, const QString &shortcut_unique, qlonglong);
void GlobalShortcutPressed(const QString &component_unique, const QString &shortcut_unique, qint64);
private:
static const char *kKdePath;

View File

@ -54,7 +54,7 @@ InternetPlaylistItem::InternetPlaylistItem(InternetService *service, const Song
bool InternetPlaylistItem::InitFromQuery(const SqlRow &query) {
metadata_.InitFromQuery(query, false, (Song::kColumns.count() + 1) * 1);
metadata_.InitFromQuery(query, false, (static_cast<int>(Song::kColumns.count()) + 1) * 1);
InitMetadata();
return true;

View File

@ -82,8 +82,8 @@ class InternetService : public QObject {
signals:
void ExitFinished();
void Login();
void Logout();
void RequestLogin();
void RequestLogout();
void LoginWithCredentials(QString api_token, QString username, QString password);
void LoginWithHostname(QString hostname, int, QString username, QString password);
void LoginSuccess();

View File

@ -175,7 +175,7 @@ QByteArray MoodbarBuilder::Finish(int width) {
for (int i = 0; i < width; ++i) {
Rgb rgb;
const int start = i * frames_.count() / width;
const int start = i * static_cast<int>(frames_.count()) / width;
const int end = std::max((i + 1) * static_cast<int>(frames_.count()) / width, start + 1);
for (int j = start; j < end; j++) {
@ -187,9 +187,9 @@ QByteArray MoodbarBuilder::Finish(int width) {
const int n = end - start;
*(data++) = rgb.r / n;
*(data++) = rgb.g / n;
*(data++) = rgb.b / n;
*(data++) = char(rgb.r / n);
*(data++) = char(rgb.g / n);
*(data++) = char(rgb.b / n);
}
return ret;

View File

@ -36,7 +36,7 @@ const int MoodbarRenderer::kNumHues = 12;
ColorVector MoodbarRenderer::Colors(const QByteArray &data, const MoodbarStyle style, const QPalette &palette) {
const int samples = data.size() / 3;
const int samples = static_cast<int>(data.size() / 3);
// Set some parameters based on the moodbar style
StyleProperties properties;
@ -119,8 +119,8 @@ void MoodbarRenderer::Render(const ColorVector &colors, QPainter *p, const QRect
int g = 0;
int b = 0;
int start = x * colors.size() / rect.width();
int end = (x + 1) * colors.size() / rect.width();
int start = x * static_cast<int>(colors.size() / rect.width());
int end = (x + 1) * static_cast<int>(colors.size() / rect.width());
if (start == end) end = qMin(start + 1, colors.size() - 1);

View File

@ -157,7 +157,7 @@ QString Chromaprinter::CreateFingerprint() {
ChromaprintContext *chromaprint = chromaprint_new(CHROMAPRINT_ALGORITHM_DEFAULT);
chromaprint_start(chromaprint, kDecodeRate, kDecodeChannels);
chromaprint_feed(chromaprint, reinterpret_cast<int16_t *>(data.data()), data.size() / 2);
chromaprint_feed(chromaprint, reinterpret_cast<int16_t*>(data.data()), static_cast<int>(data.size() / 2));
chromaprint_finish(chromaprint);
int size = 0;

View File

@ -95,7 +95,7 @@ void TagFetcher::FingerprintFound(const int index) {
}
emit Progress(song, tr("Identifying song"));
acoustid_client_->Start(index, fingerprint, song.length_nanosec() / kNsecPerMsec);
acoustid_client_->Start(index, fingerprint, static_cast<int>(song.length_nanosec() / kNsecPerMsec));
}

View File

@ -309,7 +309,7 @@ Song::FileType Organize::CheckTranscode(Song::FileType original_type) const {
void Organize::SetSongProgress(float progress, bool transcoded) {
const int max = transcoded ? 50 : 100;
current_copy_progress_ = (transcoded ? 50 : 0) + qBound(0, static_cast<int>(progress * max), max - 1);
current_copy_progress_ = (transcoded ? 50 : 0) + qBound(0, static_cast<int>(progress * float(max)), max - 1);
UpdateProgress();
}

View File

@ -259,7 +259,7 @@ void OrganizeDialog::AdjustSize() {
int max_width = 0;
int max_height = 0;
if (screen) {
max_width = screen->geometry().size().width() / 0.5;
max_width = static_cast<int>(float(screen->geometry().size().width()) / float(0.5));
max_height = static_cast<int>(float(screen->geometry().size().height()) / float(1.5));
}

View File

@ -244,7 +244,7 @@ void OSDPretty::Load() {
s.beginGroup(kSettingsGroup);
foreground_color_ = QColor(s.value("foreground_color", 0).toInt());
background_color_ = QColor(s.value("background_color", kPresetBlue).toInt());
background_opacity_ = s.value("background_opacity", 0.85).toDouble();
background_opacity_ = s.value("background_opacity", 0.85).toFloat();
font_.fromString(s.value("font", "Verdana,9,-1,5,50,0,0,0,0,0").toString());
disable_duration_ = s.value("disable_duration", false).toBool();

View File

@ -672,7 +672,7 @@ void Playlist::set_current_row(const int i, const AutoScroll autoscroll, const b
// Compute the number of new items that have to be inserted
// This is not necessarily 1 because the user might have added or removed items manually.
// Note that the future excludes the current item.
const int count = dynamic_history_length() + 1 + dynamic_playlist_->GetDynamicFuture() - items_.count();
const int count = static_cast<int>(dynamic_history_length() + 1 + dynamic_playlist_->GetDynamicFuture() - items_.count());
if (count > 0) {
InsertDynamicItems(count);
}
@ -925,7 +925,7 @@ void Playlist::MoveItemsWithoutUndo(int start, const QList<int> &dest_rows) {
}
if (start < 0) {
start = items_.count() - dest_rows.count();
start = static_cast<int>(items_.count() - dest_rows.count());
}
// Take the items out of the list first
@ -1009,7 +1009,7 @@ void Playlist::InsertItems(const PlaylistItemList &itemsIn, const int pos, const
}
}
const int start = pos == -1 ? items_.count() : pos;
const int start = pos == -1 ? static_cast<int>(items_.count()) : pos;
if (items.count() > kUndoItemLimit) {
// Too big to keep in the undo stack. Also clear the stack because it might have been invalidated.
@ -1028,8 +1028,8 @@ void Playlist::InsertItemsWithoutUndo(const PlaylistItemList &items, const int p
if (items.isEmpty()) return;
const int start = pos == -1 ? items_.count() : pos;
const int end = start + items.count() - 1;
const int start = pos == -1 ? static_cast<int>(items_.count()) : pos;
const int end = start + static_cast<int>(items.count()) - 1;
beginInsertRows(QModelIndex(), start, end);
for (int i = start; i <= end; ++i) {

View File

@ -245,7 +245,7 @@ QList<Song> PlaylistBackend::GetPlaylistSongs(int playlist) {
PlaylistItemPtr PlaylistBackend::NewPlaylistItemFromQuery(const SqlRow &row, std::shared_ptr<NewSongFromQueryState> state) {
// The song tables get joined first, plus one each for the song ROWIDs
const int playlist_row = (Song::kColumns.count() + 1) * kSongTableJoins;
const int playlist_row = static_cast<int>(Song::kColumns.count() + 1) * kSongTableJoins;
PlaylistItemPtr item(PlaylistItem::NewFromSource(Song::Source(row.value(playlist_row).toInt())));
if (item) {

View File

@ -94,9 +94,9 @@ void QueuedItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &op
bool ok = false;
const int queue_pos = idx.data(Playlist::Role_QueuePosition).toInt(&ok);
if (ok && queue_pos != -1) {
float opacity = kQueueOpacitySteps - qMin(kQueueOpacitySteps, queue_pos);
float opacity = static_cast<float>(kQueueOpacitySteps - qMin(kQueueOpacitySteps, queue_pos));
opacity /= kQueueOpacitySteps;
opacity *= 1.0 - kQueueOpacityLowerBound;
opacity *= float(1.0) - float(kQueueOpacityLowerBound);
opacity += kQueueOpacityLowerBound;
painter->setOpacity(opacity);
@ -533,7 +533,7 @@ QString RatingItemDelegate::displayText(const QVariant &value, const QLocale&) c
if (value.isNull() || value.toDouble() <= 0) return QString();
// Round to the nearest 0.5
const double rating = float(int(value.toDouble() * RatingPainter::kStarCount * 2 + 0.5)) / 2;
const double rating = double(int(value.toDouble() * RatingPainter::kStarCount * 2 + 0.5)) / 2;
return QString::number(rating, 'f', 1);

View File

@ -171,8 +171,7 @@ class RatingComparatorDecorator : public SearchTermComparator {
public:
explicit RatingComparatorDecorator(SearchTermComparator *cmp) : cmp_(cmp) {}
bool Matches(const QString &element) const override {
return cmp_->Matches(
QString::number(static_cast<int>(element.toDouble() * 10.0 + 0.5)));
return cmp_->Matches(QString::number(static_cast<int>(element.toDouble() * 10.0 + 0.5)));
}
private:
QScopedPointer<SearchTermComparator> cmp_;

View File

@ -51,7 +51,7 @@ void InsertItems::redo() {
}
void InsertItems::undo() {
const int start = pos_ == -1 ? playlist_->rowCount() - items_.count() : pos_;
const int start = pos_ == -1 ? static_cast<int>(playlist_->rowCount() - items_.count()) : pos_;
playlist_->RemoveItemsWithoutUndo(start, items_.count());
}
@ -79,7 +79,7 @@ void RemoveItems::redo() {
}
void RemoveItems::undo() {
for (int i = ranges_.count() - 1; i >= 0; --i)
for (int i = static_cast<int>(ranges_.count() - 1); i >= 0; --i)
playlist_->InsertItemsWithoutUndo(ranges_[i].items_, ranges_[i].pos_);
}

View File

@ -560,7 +560,7 @@ void PlaylistView::UpdateCachedCurrentRowPixmap(QStyleOptionViewItem option, con
cached_current_row_row_ = idx.row();
option.rect.moveTo(0, 0);
cached_current_row_ = QPixmap(option.rect.width() * device_pixel_ratio_, option.rect.height() * device_pixel_ratio_);
cached_current_row_ = QPixmap(static_cast<int>(option.rect.width() * device_pixel_ratio_), static_cast<int>(option.rect.height() * device_pixel_ratio_));
cached_current_row_.setDevicePixelRatio(device_pixel_ratio_);
cached_current_row_.fill(Qt::transparent);
@ -1032,7 +1032,7 @@ void PlaylistView::paintEvent(QPaintEvent *event) {
if (drop_indicator_row_ != -1) {
if (cached_tree_.isNull()) {
cached_tree_ = QPixmap(size().width() * device_pixel_ratio_, size().height() * device_pixel_ratio_);
cached_tree_ = QPixmap(static_cast<int>(size().width() * device_pixel_ratio_), static_cast<int>(size().height() * device_pixel_ratio_));
cached_tree_.setDevicePixelRatio(device_pixel_ratio_);
cached_tree_.fill(Qt::transparent);
@ -1279,7 +1279,7 @@ bool PlaylistView::eventFilter(QObject *object, QEvent *event) {
if (event->type() == QEvent::Enter && (object == horizontalScrollBar() || object == verticalScrollBar())) {
return false;
}
return QObject::eventFilter(object, event);
return QAbstractItemView::eventFilter(object, event);
}

View File

@ -33,7 +33,7 @@ SongPlaylistItem::SongPlaylistItem(const Song::Source source) : PlaylistItem(sou
SongPlaylistItem::SongPlaylistItem(const Song &song) : PlaylistItem(song.source()), song_(song) {}
bool SongPlaylistItem::InitFromQuery(const SqlRow &query) {
song_.InitFromQuery(query, false, (Song::kColumns.count()+1));
song_.InitFromQuery(query, false, (static_cast<int>(Song::kColumns.count()) + 1));
return true;
}

View File

@ -347,7 +347,7 @@ qint64 CueParser::IndexToMarker(const QString &index) const {
}
QStringList splitted = re_match.capturedTexts().mid(1, -1);
qlonglong frames = splitted.at(0).toLongLong() * 60 * 75 + splitted.at(1).toLongLong() * 75 + splitted.at(2).toLongLong();
qint64 frames = splitted.at(0).toLongLong() * 60 * 75 + splitted.at(1).toLongLong() * 75 + splitted.at(2).toLongLong();
return (frames * kNsecPerSec) / 75;
}

View File

@ -60,8 +60,6 @@ class QobuzRequest : public QobuzBaseRequest {
void Search(const int search_id, const QString &search_text);
signals:
void Login();
void Login(QString username, QString password, QString token);
void LoginSuccess();
void LoginFailure(QString failure_reason);
void Results(int id, SongList songs, QString error);

View File

@ -151,7 +151,7 @@ QobuzService::QobuzService(Application *app, QObject *parent)
timer_login_attempt_->setSingleShot(true);
QObject::connect(timer_login_attempt_, &QTimer::timeout, this, &QobuzService::ResetLoginAttempts);
QObject::connect(this, &QobuzService::Login, this, &QobuzService::SendLogin);
QObject::connect(this, &QobuzService::RequestLogin, this, &QobuzService::SendLogin);
QObject::connect(this, &QobuzService::LoginWithCredentials, this, &QobuzService::SendLoginWithCredentials);
QObject::connect(this, &QobuzService::AddArtists, favorite_request_, &QobuzFavoriteRequest::AddArtists);
@ -479,7 +479,7 @@ void QobuzService::TryLogin() {
return;
}
emit Login();
emit RequestLogin();
}

View File

@ -227,11 +227,11 @@ void QobuzStreamURLRequest::StreamURLReceived() {
}
int samplerate = -1;
if (json_obj.contains("sampling_rate")) {
samplerate = json_obj["sampling_rate"].toDouble() * 1000;
samplerate = static_cast<int>(json_obj["sampling_rate"].toDouble()) * 1000;
}
int bit_depth = -1;
if (json_obj.contains("bit_depth")) {
bit_depth = json_obj["bit_depth"].toDouble();
bit_depth = static_cast<int>(json_obj["bit_depth"].toDouble());
}
emit StreamURLFinished(original_url_, url, filetype, samplerate, bit_depth, duration);

View File

@ -265,7 +265,7 @@ void Queue::Clear() {
if (source_indexes_.isEmpty()) return;
beginRemoveRows(QModelIndex(), 0, source_indexes_.count() - 1);
beginRemoveRows(QModelIndex(), 0, static_cast<int>(source_indexes_.count() - 1));
source_indexes_.clear();
endRemoveRows();
@ -285,7 +285,7 @@ void Queue::Move(const QList<int> &proxy_rows, int pos) {
}
// Put the items back in
const int start = pos == -1 ? source_indexes_.count() : pos;
const int start = pos == -1 ? static_cast<int>(source_indexes_.count()) : pos;
for (int i = start; i < start + moved_items.count(); ++i) {
source_indexes_.insert(i, moved_items[i - start]);
}
@ -390,8 +390,8 @@ bool Queue::dropMimeData(const QMimeData *data, Qt::DropAction action, int row,
}
if (!source_indexes.isEmpty()) {
const int insert_point = row == -1 ? source_indexes_.count() : row;
beginInsertRows(QModelIndex(), insert_point, insert_point + source_indexes.count() - 1);
const int insert_point = row == -1 ? static_cast<int>(source_indexes_.count()) : row;
beginInsertRows(QModelIndex(), insert_point, insert_point + static_cast<int>(source_indexes.count() - 1));
for (int i = 0 ; i < source_indexes.count() ; ++i) {
source_indexes_.insert(insert_point + i, source_indexes[i]);
}

View File

@ -146,7 +146,7 @@ void QueueView::MoveDown() {
if (indexes.isEmpty() || indexes.last().row() == current_playlist_->queue()->rowCount()-1)
return;
for (int i = indexes.count() - 1; i >= 0; --i) {
for (int i = static_cast<int>(indexes.count() - 1); i >= 0; --i) {
current_playlist_->queue()->MoveDown(indexes[i].row());
}

View File

@ -126,7 +126,7 @@ void ListenBrainzScrobbler::LoadSession() {
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();
}
@ -334,7 +334,7 @@ void ListenBrainzScrobbler::AuthenticateReplyFinished(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();
}
@ -519,7 +519,7 @@ void ListenBrainzScrobbler::Scrobble(const Song &song) {
Submit();
}
else if (!timer_submit_.isActive()) {
timer_submit_.setInterval(app_->scrobbler()->SubmitDelay() * 60 * kMsecPerSec);
timer_submit_.setInterval(static_cast<int>(app_->scrobbler()->SubmitDelay() * 60 * kMsecPerSec));
timer_submit_.start();
}
}
@ -531,7 +531,7 @@ void ListenBrainzScrobbler::DoSubmit() {
if (!submitted_ && cache_->Count() > 0) {
submitted_ = true;
if (!timer_submit_.isActive()) {
timer_submit_.setInterval(app_->scrobbler()->SubmitDelay() * 60 * kMsecPerSec);
timer_submit_.setInterval(static_cast<int>(app_->scrobbler()->SubmitDelay() * 60 * kMsecPerSec));
timer_submit_.start();
}
}

View File

@ -551,7 +551,7 @@ void ScrobblingAPI20::Scrobble(const Song &song) {
Submit();
}
else if (!timer_submit_.isActive()) {
timer_submit_.setInterval(app_->scrobbler()->SubmitDelay() * 60 * kMsecPerSec);
timer_submit_.setInterval(static_cast<int>(app_->scrobbler()->SubmitDelay() * 60 * kMsecPerSec));
timer_submit_.start();
}
}
@ -563,7 +563,7 @@ void ScrobblingAPI20::DoSubmit() {
if (!submitted_ && cache()->Count() > 0) {
submitted_ = true;
if (!timer_submit_.isActive()) {
timer_submit_.setInterval(app_->scrobbler()->SubmitDelay() * 60 * kMsecPerSec);
timer_submit_.setInterval(static_cast<int>(app_->scrobbler()->SubmitDelay() * 60 * kMsecPerSec));
timer_submit_.start();
}
}
@ -717,7 +717,7 @@ void ScrobblingAPI20::ScrobbleRequestFinished(QNetworkReply *reply, QList<quint6
return;
}
for (const QJsonValue value : array_scrobble) {
for (const QJsonValue value : qAsConst(array_scrobble)) {
if (!value.isObject()) {
Error("Json scrobbles scrobble array value is not an object.", value);

View File

@ -93,7 +93,7 @@ void SubsonicScrobbler::Scrobble(const Song &song) {
Submit();
}
else if (!timer_submit_.isActive()) {
timer_submit_.setInterval(app_->scrobbler()->SubmitDelay() * 60 * kMsecPerSec);
timer_submit_.setInterval(static_cast<int>(app_->scrobbler()->SubmitDelay() * 60 * kMsecPerSec));
timer_submit_.start();
}
}

View File

@ -116,7 +116,7 @@ void BackendSettingsPage::Load() {
ui_->checkbox_replaygain->setChecked(s.value("rgenabled", false).toBool());
ui_->combobox_replaygainmode->setCurrentIndex(s.value("rgmode", 0).toInt());
ui_->stickslider_replaygainpreamp->setValue(s.value("rgpreamp", 0.0).toDouble() * 10 + 150);
ui_->stickslider_replaygainpreamp->setValue(static_cast<int>(s.value("rgpreamp", 0.0).toDouble() * 10 + 150));
ui_->checkbox_replaygaincompression->setChecked(s.value("rgcompression", true).toBool());
#if defined(HAVE_ALSA)

View File

@ -186,7 +186,7 @@ void NotificationsSettingsPage::Load() {
// Pretty OSD
pretty_popup_->ReloadSettings();
ui_->notifications_opacity->setValue(pretty_popup_->background_opacity() * 100);
ui_->notifications_opacity->setValue(static_cast<int>(pretty_popup_->background_opacity() * 100));
QRgb color = pretty_popup_->background_color();
if (color == OSDPretty::kPresetBlue)

View File

@ -130,7 +130,7 @@ QByteArray TidalBaseRequest::GetReplyData(QNetworkReply *reply, const bool send_
qLog(Error) << "Tidal:" << error;
qLog(Info) << "Tidal:" << "Attempting to login.";
NeedLogin();
service_->Login();
emit service_->RequestLogin();
}
else {
Error(error);

View File

@ -79,8 +79,6 @@ class TidalRequest : public TidalBaseRequest {
};
signals:
void Login();
void Login(QString username, QString password, QString token);
void LoginSuccess();
void LoginFailure(QString failure_reason);
void Results(int id, SongList songs, QString error);

View File

@ -164,7 +164,7 @@ TidalService::TidalService(Application *app, QObject *parent)
timer_refresh_login_->setSingleShot(true);
QObject::connect(timer_refresh_login_, &QTimer::timeout, this, &TidalService::RequestNewAccessToken);
QObject::connect(this, &TidalService::Login, this, &TidalService::SendLogin);
QObject::connect(this, &TidalService::RequestLogin, this, &TidalService::SendLogin);
QObject::connect(this, &TidalService::LoginWithCredentials, this, &TidalService::SendLoginWithCredentials);
QObject::connect(this, &TidalService::AddArtists, favorite_request_, &TidalFavoriteRequest::AddArtists);
@ -253,7 +253,7 @@ void TidalService::LoadSession() {
if (!refresh_token_.isEmpty()) {
qint64 time = expires_in_ - (QDateTime::currentDateTime().toSecsSinceEpoch() - login_time_);
if (time < 6) time = 6;
timer_refresh_login_->setInterval(time * kMsecPerSec);
timer_refresh_login_->setInterval(static_cast<int>(time * kMsecPerSec));
timer_refresh_login_->start();
}
@ -513,7 +513,7 @@ void TidalService::AccessTokenRequestFinished(QNetworkReply *reply) {
s.endGroup();
if (expires_in_ > 0) {
timer_refresh_login_->setInterval(expires_in_ * kMsecPerSec);
timer_refresh_login_->setInterval(static_cast<int>(expires_in_ * kMsecPerSec));
timer_refresh_login_->start();
}
@ -712,7 +712,7 @@ void TidalService::TryLogin() {
return;
}
emit Login();
emit RequestLogin();
}

View File

@ -92,5 +92,5 @@ void TranscoderOptionsMP3::QualitySliderChanged(int value) {
}
void TranscoderOptionsMP3::QualitySpinboxChanged(double value) {
ui_->quality_slider->setValue(value * 100);
ui_->quality_slider->setValue(static_cast<int>(value * 100));
}

View File

@ -57,7 +57,7 @@ void TranscoderOptionsVorbis::Load() {
GET_BITRATE(max_bitrate, "max-bitrate");
#undef GET_BITRATE
ui_->quality_slider->setValue(s.value("quality", 1.0).toDouble() * 10);
ui_->quality_slider->setValue(static_cast<int>(s.value("quality", 1.0).toDouble() * 10));
ui_->managed->setChecked(s.value("managed", false).toBool());
ui_->max_bitrate_slider->setValue(max_bitrate);
ui_->min_bitrate_slider->setValue(min_bitrate);

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(float(bar_rect.width()) * (float(total_ - free_) / total_));
bar_rect.setWidth(static_cast<int>(float(bar_rect.width()) * (float(total_ - free_) / 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_) {
QRect additional_rect(bar_rect);
additional_rect.setLeft(bar_rect.right());
additional_rect.setWidth(float(r.width()) * (float(qMin(free_, additional_)) / total_) + 1);
additional_rect.setWidth(static_cast<int>(float(r.width()) * (float(qMin(free_, additional_)) / total_) + 1));
QLinearGradient additional_gradient(additional_rect.topLeft(), additional_rect.bottomLeft());
additional_gradient.setColorAt(0, kColorAdd1);

View File

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

View File

@ -367,7 +367,7 @@ void PlayingWidget::UpdateHeight() {
case LargeSongDetails:
if (fit_width_) cover_loader_options_.desired_height_ = width();
else cover_loader_options_.desired_height_ = qMin(kMaxCoverSize, width());
total_height_ = kTopBorder + cover_loader_options_.desired_height_ + kBottomOffset + details_->size().height();
total_height_ = kTopBorder + cover_loader_options_.desired_height_ + kBottomOffset + static_cast<int>(details_->size().height());
break;
}

View File

@ -42,7 +42,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 float rating = float(i) / 2.0;
const double rating = double(i) / double(2.0);
// Clear the pixmap
stars_[i] = QPixmap(kStarSize * kStarCount, kStarSize);
@ -91,7 +91,7 @@ double RatingPainter::RatingForPos(const QPoint &pos, const QRect &rect) {
}
void RatingPainter::Paint(QPainter* painter, const QRect &rect, float rating) const {
void RatingPainter::Paint(QPainter* painter, const QRect &rect, double rating) const {
QSize size(qMin(kStarSize * kStarCount, rect.width()), qMin(kStarSize, rect.height()));
QPoint pos(rect.center() - QPoint(size.width() / 2, size.height() / 2));
@ -118,7 +118,7 @@ QSize RatingWidget::sizeHint() const {
}
void RatingWidget::set_rating(const float rating) {
void RatingWidget::set_rating(const double rating) {
rating_ = rating;
update();

View File

@ -35,7 +35,7 @@ class RatingPainter {
static QRect Contents(const QRect &rect);
static double RatingForPos(const QPoint &pos, const QRect &rect);
void Paint(QPainter *painter, const QRect &rect, float rating) const;
void Paint(QPainter *painter, const QRect &rect, double rating) const;
private:
QPixmap stars_[kStarCount * 2 + 1];
@ -43,18 +43,18 @@ class RatingPainter {
class RatingWidget : public QWidget {
Q_OBJECT
Q_PROPERTY(float rating READ rating WRITE set_rating)
Q_PROPERTY(double rating READ rating WRITE set_rating)
public:
RatingWidget(QWidget *parent = nullptr);
QSize sizeHint() const override;
float rating() const { return rating_; }
void set_rating(const float rating);
double rating() const { return rating_; }
void set_rating(const double rating);
signals:
void RatingChanged(float);
void RatingChanged(double);
protected:
void paintEvent(QPaintEvent*) override;
@ -64,8 +64,8 @@ class RatingWidget : public QWidget {
private:
RatingPainter painter_;
float rating_;
float hover_rating_;
double rating_;
double hover_rating_;
};
#endif // RATINGWIDGET_H

View File

@ -128,7 +128,7 @@ void TrackSlider::SetValue(const int elapsed, const int total) {
setting_value_ = false;
UpdateTimes(elapsed / kMsecPerSec);
UpdateTimes(static_cast<int>(elapsed / kMsecPerSec));
}
@ -137,13 +137,13 @@ void TrackSlider::UpdateTimes(const int elapsed) {
ui_->elapsed->setText(Utilities::PrettyTime(elapsed));
// Update normally if showing remaining time
if (show_remaining_time_) {
ui_->remaining->setText("-" + Utilities::PrettyTime((ui_->slider->maximum() / kMsecPerSec) - elapsed));
ui_->remaining->setText("-" + Utilities::PrettyTime(static_cast<int>((ui_->slider->maximum() / kMsecPerSec) - elapsed)));
}
else {
// Check if slider maximum value is changed before updating
if (slider_maximum_value_ != ui_->slider->maximum() || !ui_->slider->isEnabled()) {
slider_maximum_value_ = ui_->slider->maximum();
ui_->remaining->setText(Utilities::PrettyTime((ui_->slider->maximum() / kMsecPerSec)));
ui_->remaining->setText(Utilities::PrettyTime(static_cast<int>((ui_->slider->maximum() / kMsecPerSec))));
}
}
setEnabled(true);
@ -169,14 +169,14 @@ void TrackSlider::SetCanSeek(const bool can_seek) {
void TrackSlider::Seek(const int gap) {
if (ui_->slider->isEnabled())
ui_->slider->setValue(ui_->slider->value() + gap * kMsecPerSec);
ui_->slider->setValue(static_cast<int>(ui_->slider->value() + gap * kMsecPerSec));
}
void TrackSlider::ValueMaybeChanged(const int value) {
if (setting_value_) return;
UpdateTimes(value / kMsecPerSec);
emit ValueChangedSeconds(value / kMsecPerSec);
UpdateTimes(static_cast<int>(value / kMsecPerSec));
emit ValueChangedSeconds(static_cast<int>(value / kMsecPerSec));
}
bool TrackSlider::event(QEvent *e) {
@ -200,7 +200,7 @@ void TrackSlider::ToggleTimeDisplay() {
// We set the value to -1 because the label must be updated
slider_maximum_value_ = -1;
}
UpdateTimes(ui_->slider->value() / kMsecPerSec);
UpdateTimes(static_cast<int>(ui_->slider->value() / kMsecPerSec));
// Save this setting
QSettings s;

View File

@ -88,12 +88,12 @@ void TrackSliderPopup::UpdatePixmap() {
#else
const int text_width = qMax(font_metrics_.width(text_), small_font_metrics_.width(small_text_));
#endif
const QRect text_rect1(kBlurRadius + kTextMargin, kBlurRadius + kTextMargin, text_width + 2, font_metrics_.height());
const QRect text_rect2(kBlurRadius + kTextMargin, text_rect1.bottom(), text_width, small_font_metrics_.height());
const QRect text_rect1(static_cast<int>(kBlurRadius) + kTextMargin, static_cast<int>(kBlurRadius) + kTextMargin, text_width + 2, font_metrics_.height());
const QRect text_rect2(static_cast<int>(kBlurRadius) + kTextMargin, text_rect1.bottom(), text_width, small_font_metrics_.height());
const int bubble_bottom = text_rect2.bottom() + kTextMargin;
const QRect total_rect(0, 0, text_rect1.right() + kBlurRadius + kTextMargin, kBlurRadius + bubble_bottom + kPointLength);
const QRect bubble_rect(kBlurRadius, kBlurRadius, total_rect.width() - kBlurRadius * 2, bubble_bottom - kBlurRadius);
const QRect total_rect(0, 0, text_rect1.right() + static_cast<int>(kBlurRadius) + kTextMargin, static_cast<int>(kBlurRadius) + bubble_bottom + kPointLength);
const QRect bubble_rect(static_cast<int>(kBlurRadius), static_cast<int>(kBlurRadius), total_rect.width() - static_cast<int>(kBlurRadius) * 2, bubble_bottom - static_cast<int>(kBlurRadius));
if (background_cache_.size() != total_rect.size()) {
const QColor highlight(palette().color(QPalette::Active, QPalette::Highlight));
@ -101,9 +101,9 @@ void TrackSliderPopup::UpdatePixmap() {
const QColor bg_color_2(highlight.darker(120));
QPolygon pointy;
pointy << QPoint(total_rect.width()/2 - kPointWidth, bubble_bottom)
<< QPoint(total_rect.width()/2, total_rect.bottom() - kBlurRadius)
<< QPoint(total_rect.width()/2 + kPointWidth, bubble_bottom);
pointy << QPoint(total_rect.width() / 2 - kPointWidth, bubble_bottom)
<< QPoint(total_rect.width() / 2, total_rect.bottom() - static_cast<int>(kBlurRadius))
<< QPoint(total_rect.width() / 2 + kPointWidth, bubble_bottom);
QPolygon inner_pointy;
inner_pointy << QPoint(pointy[0].x() + 1, pointy[0].y() - 1)
@ -178,5 +178,5 @@ void TrackSliderPopup::UpdatePixmap() {
}
void TrackSliderPopup::UpdatePosition() {
move(pos_.x() - pixmap_.width() / 2, pos_.y() - pixmap_.height() + kBlurRadius);
move(pos_.x() - pixmap_.width() / 2, pos_.y() - pixmap_.height() + static_cast<int>(kBlurRadius));
}

View File

@ -104,7 +104,7 @@ void TrackSliderSlider::mouseMoveEvent(QMouseEvent *e) {
int slider_min = gr.x();
int slider_max = gr.right() - slider_length + 1;
mouse_hover_seconds_ = QStyle::sliderValueFromPosition(minimum() / kMsecPerSec, maximum() / kMsecPerSec, e->pos().x() - slider_length / 2 - slider_min + 1, slider_max - slider_min);
mouse_hover_seconds_ = QStyle::sliderValueFromPosition(minimum() / static_cast<int>(kMsecPerSec), maximum() / static_cast<int>(kMsecPerSec), e->pos().x() - slider_length / 2 - slider_min + 1, slider_max - slider_min);
#ifndef Q_OS_MACOS
popup_->SetText(Utilities::PrettyTime(mouse_hover_seconds_));
@ -172,7 +172,7 @@ void TrackSliderSlider::UpdateDeltaTime() {
#ifndef Q_OS_MACOS
if (popup_->isVisible()) {
int delta_seconds = mouse_hover_seconds_ - (value() / kMsecPerSec);
int delta_seconds = mouse_hover_seconds_ - (value() / static_cast<int>(kMsecPerSec));
popup_->SetSmallText(Utilities::PrettyTimeDelta(delta_seconds));
}
#endif