Fix narrowing conversions

This commit is contained in:
Jonas Kvinge
2021-10-30 02:21:29 +02:00
parent a704412dee
commit 79ac53b2d9
111 changed files with 376 additions and 373 deletions

View File

@@ -108,7 +108,7 @@ void DeleteFiles::ProcessSomeFiles() {
// We process files in batches so we can be cancelled part-way through.
const int n = qMin(songs_.count(), progress_ + kBatchSize);
const qint64 n = qMin(songs_.count(), static_cast<qint64>(progress_ + kBatchSize));
for (; progress_ < n; ++progress_) {
task_manager_->SetTaskProgress(task_id_, progress_, songs_.count());

View File

@@ -380,7 +380,7 @@ MainWindow::MainWindow(Application *app, std::shared_ptr<SystemTrayIcon> tray_ic
app_->player()->SetEqualizer(equalizer_.get());
app_->player()->Init();
EngineChanged(app_->player()->engine()->type());
int volume = app_->player()->GetVolume();
int volume = static_cast<int>(app_->player()->GetVolume());
ui_->volume->setValue(volume);
VolumeChanged(volume);
@@ -1375,7 +1375,7 @@ void MainWindow::TrackSkipped(PlaylistItemPtr item) {
const qint64 seconds_left = (length - position) / kNsecPerSec;
const qint64 seconds_total = length / kNsecPerSec;
if (((0.05 * seconds_total > 60 && percentage < 0.98) || percentage < 0.95) && seconds_left > 5) { // Never count the skip if under 5 seconds left
if (((0.05 * static_cast<double>(seconds_total) > 60.0 && percentage < 0.98) || percentage < 0.95) && seconds_left > 5) { // Never count the skip if under 5 seconds left
app_->collection_backend()->IncrementSkipCountAsync(song.id(), percentage);
}
}
@@ -1630,7 +1630,7 @@ void MainWindow::Seeked(const qint64 microseconds) {
const qint64 position = microseconds / kUsecPerSec;
const qint64 length = app_->player()->GetCurrentItem()->Metadata().length_nanosec() / kNsecPerSec;
tray_icon_->SetProgress(static_cast<int>(static_cast<double>(position) / length * 100));
tray_icon_->SetProgress(static_cast<int>(static_cast<double>(position) / static_cast<double>(length) * 100.0));
}
@@ -1641,10 +1641,10 @@ void MainWindow::UpdateTrackPosition() {
const qint64 length = (item->Metadata().length_nanosec() / kNsecPerSec);
if (length <= 0) return;
const int position = std::floor(static_cast<float>(app_->player()->engine()->position_nanosec()) / kNsecPerSec + 0.5);
const int position = std::floor(static_cast<float>(app_->player()->engine()->position_nanosec()) / static_cast<float>(kNsecPerSec) + 0.5);
// Update the tray icon every 10 seconds
if (position % 10 == 0) tray_icon_->SetProgress(static_cast<int>(static_cast<double>(position) / length * 100));
if (position % 10 == 0) tray_icon_->SetProgress(static_cast<int>(static_cast<double>(position) / static_cast<double>(length) * 100.0));
// Send Scrobble
if (app_->scrobbler()->IsEnabled() && item->Metadata().is_metadata_good()) {
@@ -1816,7 +1816,7 @@ void MainWindow::PlaylistRightClick(const QPoint global_pos, const QModelIndex &
// Are any of the selected songs editable or queued?
QModelIndexList selection = ui_->playlist->view()->selectionModel()->selectedRows();
bool cue_selected = false;
int selected = ui_->playlist->view()->selectionModel()->selectedRows().count();
qint64 selected = ui_->playlist->view()->selectionModel()->selectedRows().count();
int editable = 0;
int in_queue = 0;
int not_in_queue = 0;
@@ -2433,7 +2433,7 @@ void MainWindow::CommandlineOptionsReceived(const CommandlineOptions &options) {
if (options.set_volume() != -1) app_->player()->SetVolume(options.set_volume());
if (options.volume_modifier() != 0) {
app_->player()->SetVolume(app_->player()->GetVolume() +options.volume_modifier());
app_->player()->SetVolume(app_->player()->GetVolume() + options.volume_modifier());
}
if (options.seek_to() != -1) {
@@ -3183,8 +3183,8 @@ void MainWindow::FocusSearchField() {
qobuz_view_->FocusSearchField();
}
#endif
else if (!ui_->playlist->SearchFieldHasFocus()) {
ui_->playlist->FocusSearchField();
}
else if (!ui_->playlist->SearchFieldHasFocus()) {
ui_->playlist->FocusSearchField();
}
}

View File

@@ -632,11 +632,11 @@ void Player::EngineStateChanged(const Engine::State state) {
}
void Player::SetVolume(const int value) {
void Player::SetVolume(const uint value) {
int old_volume = engine_->volume();
uint old_volume = engine_->volume();
int volume = qBound(0, value, 100);
uint volume = qBound(0U, value, 100U);
settings_.setValue("volume", volume);
engine_->SetVolume(volume);
@@ -646,9 +646,9 @@ void Player::SetVolume(const int value) {
}
int Player::GetVolume() const { return engine_->volume(); }
uint Player::GetVolume() const { return engine_->volume(); }
void Player::PlayAt(const int index, const qint64 offset_nanosec, Engine::TrackChangeFlags change, const Playlist::AutoScroll autoscroll, const bool reshuffle, const bool force_inform) {
void Player::PlayAt(const int index, const quint64 offset_nanosec, Engine::TrackChangeFlags change, const Playlist::AutoScroll autoscroll, const bool reshuffle, const bool force_inform) {
pause_time_ = QDateTime();
play_offset_nanosec_ = offset_nanosec;
@@ -696,7 +696,7 @@ void Player::CurrentMetadataChanged(const Song &metadata) {
}
void Player::SeekTo(const qint64 seconds) {
void Player::SeekTo(const quint64 seconds) {
const qint64 length_nanosec = engine_->length_nanosec();
@@ -705,7 +705,7 @@ void Player::SeekTo(const qint64 seconds) {
return;
}
const qint64 nanosec = qBound(0LL, seconds * kNsecPerSec, length_nanosec);
const qint64 nanosec = qBound(0LL, static_cast<qint64>(seconds) * kNsecPerSec, length_nanosec);
engine_->Seek(nanosec);
qLog(Debug) << "Track seeked to" << nanosec << "ns - updating scrobble point";
@@ -766,7 +766,7 @@ void Player::Mute() {
if (!volume_control_) return;
const int current_volume = engine_->volume();
const uint current_volume = engine_->volume();
if (current_volume == 0) {
SetVolume(volume_before_mute_);

View File

@@ -61,7 +61,7 @@ class PlayerInterface : public QObject {
virtual EngineBase *engine() const = 0;
virtual Engine::State GetState() const = 0;
virtual int GetVolume() const = 0;
virtual uint GetVolume() const = 0;
virtual PlaylistItemPtr GetCurrentItem() const = 0;
virtual PlaylistItemPtr GetItemAt(const int pos) const = 0;
@@ -73,7 +73,7 @@ class PlayerInterface : public QObject {
virtual void ReloadSettings() = 0;
// Manual track change to the specified track
virtual void PlayAt(const int index, const qint64 offset_nanosec, Engine::TrackChangeFlags change, const Playlist::AutoScroll autoscroll, const bool reshuffle, const bool force_inform = false) = 0;
virtual void PlayAt(const int index, const quint64 offset_nanosec, Engine::TrackChangeFlags change, const Playlist::AutoScroll autoscroll, const bool reshuffle, const bool force_inform = false) = 0;
// If there's currently a song playing, pause it, otherwise play the track that was playing last, or the first one on the playlist
virtual void PlayPause(const quint64 offset_nanosec = 0, const Playlist::AutoScroll autoscroll = Playlist::AutoScroll_Always) = 0;
@@ -84,10 +84,10 @@ class PlayerInterface : public QObject {
virtual void Next() = 0;
virtual void Previous() = 0;
virtual void PlayPlaylist(const QString &playlist_name) = 0;
virtual void SetVolume(const int value) = 0;
virtual void SetVolume(const uint value) = 0;
virtual void VolumeUp() = 0;
virtual void VolumeDown() = 0;
virtual void SeekTo(const qint64 seconds) = 0;
virtual void SeekTo(const quint64 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.
@@ -111,7 +111,7 @@ class PlayerInterface : public QObject {
void Error(QString message = QString());
void PlaylistFinished();
void VolumeEnabled(bool);
void VolumeChanged(int volume);
void VolumeChanged(uint volume);
void TrackSkipped(PlaylistItemPtr old_track);
// Emitted when there's a manual change to the current's track position.
void Seeked(qint64 microseconds);
@@ -141,7 +141,7 @@ class Player : public PlayerInterface {
EngineBase *engine() const override { return engine_.get(); }
Engine::State GetState() const override { return last_state_; }
int GetVolume() const override;
uint GetVolume() const override;
PlaylistItemPtr GetCurrentItem() const override { return current_item_; }
PlaylistItemPtr GetItemAt(const int pos) const override;
@@ -159,17 +159,17 @@ class Player : public PlayerInterface {
public slots:
void ReloadSettings() override;
void PlayAt(const int index, const qint64 offset_nanosec, Engine::TrackChangeFlags change, const Playlist::AutoScroll autoscroll, const bool reshuffle, const bool force_inform = false) override;
void PlayAt(const int index, const quint64 offset_nanosec, Engine::TrackChangeFlags change, const Playlist::AutoScroll autoscroll, const bool reshuffle, const bool force_inform = false) override;
void PlayPause(const quint64 offset_nanosec = 0, const Playlist::AutoScroll autoscroll = Playlist::AutoScroll_Always) override;
void PlayPauseHelper() override { PlayPause(play_offset_nanosec_); }
void RestartOrPrevious() override;
void Next() override;
void Previous() override;
void PlayPlaylist(const QString &playlist_name) override;
void SetVolume(const int value) override;
void SetVolume(const uint value) override;
void VolumeUp() override { SetVolume(GetVolume() + 5); }
void VolumeDown() override { SetVolume(GetVolume() - 5); }
void SeekTo(const qint64 seconds) override;
void SeekTo(const quint64 seconds) override;
void SeekForward() override;
void SeekBackward() override;
@@ -235,7 +235,7 @@ class Player : public PlayerInterface {
QMap<QString, UrlHandler*> url_handlers_;
QList<QUrl> loading_async_;
int volume_before_mute_;
uint volume_before_mute_;
QDateTime last_pressed_previous_;
bool continue_on_error_;

View File

@@ -202,7 +202,7 @@ struct Song::Private : public QSharedData {
QString basefilename_;
QUrl url_;
FileType filetype_;
int filesize_;
qint64 filesize_;
qint64 mtime_;
qint64 ctime_;
bool unavailable_;
@@ -331,7 +331,7 @@ int Song::directory_id() const { return d->directory_id_; }
const QUrl &Song::url() const { return d->url_; }
const QString &Song::basefilename() const { return d->basefilename_; }
Song::FileType Song::filetype() const { return d->filetype_; }
int Song::filesize() const { return d->filesize_; }
qint64 Song::filesize() const { return d->filesize_; }
qint64 Song::mtime() const { return d->mtime_; }
qint64 Song::ctime() const { return d->ctime_; }
@@ -421,7 +421,7 @@ QString Song::sortable(const QString &v) {
for (const auto &i : kArticles) {
if (copy.startsWith(i)) {
int ilen = i.length();
qint64 ilen = i.length();
return copy.right(copy.length() - ilen) + ", " + copy.left(ilen - 1);
}
}
@@ -458,7 +458,7 @@ void Song::set_directory_id(int v) { d->directory_id_ = v; }
void Song::set_url(const QUrl &v) { d->url_ = v; }
void Song::set_basefilename(const QString &v) { d->basefilename_ = v; }
void Song::set_filetype(FileType v) { d->filetype_ = v; }
void Song::set_filesize(int v) { d->filesize_ = v; }
void Song::set_filesize(qint64 v) { d->filesize_ = v; }
void Song::set_mtime(qint64 v) { d->mtime_ = v; }
void Song::set_ctime(qint64 v) { d->ctime_ = v; }
void Song::set_unavailable(bool v) { d->unavailable_ = v; }
@@ -846,11 +846,11 @@ void Song::InitFromProtobuf(const spb::tagreader::SongMetadata &pb) {
d->grouping_ = QStringFromStdString(pb.grouping());
d->comment_ = QStringFromStdString(pb.comment());
d->lyrics_ = QStringFromStdString(pb.lyrics());
set_length_nanosec(pb.length_nanosec());
set_length_nanosec(static_cast<qint64>(pb.length_nanosec()));
d->bitrate_ = pb.bitrate();
d->samplerate_ = pb.samplerate();
d->bitdepth_ = pb.bitdepth();
set_url(QUrl::fromEncoded(QByteArray(pb.url().data(), pb.url().size())));
set_url(QUrl::fromEncoded(QByteArray(pb.url().data(), static_cast<qint64>(pb.url().size()))));
d->basefilename_ = QStringFromStdString(pb.basefilename());
d->filetype_ = static_cast<FileType>(pb.filetype());
d->filesize_ = pb.filesize();
@@ -868,7 +868,7 @@ void Song::InitFromProtobuf(const spb::tagreader::SongMetadata &pb) {
}
if (pb.has_art_automatic()) {
QByteArray art_automatic(pb.art_automatic().data(), pb.art_automatic().size());
QByteArray art_automatic(pb.art_automatic().data(), static_cast<qint64>(pb.art_automatic().size()));
if (!art_automatic.isEmpty()) set_art_automatic(QUrl::fromLocalFile(art_automatic));
}
@@ -1028,7 +1028,7 @@ void Song::InitFromQuery(const SqlRow &q, bool reliable_metadata, int col) {
d->filetype_ = FileType(q.value(x).toInt());
}
else if (Song::kColumns.value(i) == "filesize") {
d->filesize_ = toint(x);
d->filesize_ = tolonglong(x);
}
else if (Song::kColumns.value(i) == "mtime") {
d->mtime_ = tolonglong(x);
@@ -1200,8 +1200,8 @@ void Song::InitFromItdb(Itdb_Track *track, const QString &prefix) {
d->mtime_ = track->time_modified;
d->ctime_ = track->time_added;
d->playcount_ = track->playcount;
d->skipcount_ = track->skipcount;
d->playcount_ = static_cast<int>(track->playcount);
d->skipcount_ = static_cast<int>(track->skipcount);
d->lastplayed_ = track->time_played;
if (itdb_track_has_thumbnails(track) && !d->artist_.isEmpty() && !d->title_.isEmpty()) {
@@ -1236,7 +1236,7 @@ void Song::ToItdb(Itdb_Track *track) const {
track->grouping = strdup(d->grouping_.toUtf8().constData());
track->comment = strdup(d->comment_.toUtf8().constData());
track->tracklen = length_nanosec() / kNsecPerMsec;
track->tracklen = static_cast<int>(length_nanosec() / kNsecPerMsec);
track->bitrate = d->bitrate_;
track->samplerate = d->samplerate_;
@@ -1244,7 +1244,7 @@ void Song::ToItdb(Itdb_Track *track) const {
track->type1 = (d->filetype_ == FileType_MPEG ? 1 : 0);
track->type2 = (d->filetype_ == FileType_MPEG ? 1 : 0);
track->mediatype = 1; // Audio
track->size = d->filesize_;
track->size = static_cast<uint>(d->filesize_);
track->time_modified = d->mtime_;
track->time_added = d->ctime_;
@@ -1270,17 +1270,17 @@ void Song::InitFromMTP(const LIBMTP_track_t *track, const QString &host) {
d->url_ = QUrl(QString("mtp://%1/%2").arg(host, QString::number(track->item_id)));
d->basefilename_ = QString::number(track->item_id);
d->filesize_ = track->filesize;
d->filesize_ = static_cast<qint64>(track->filesize);
d->mtime_ = track->modificationdate;
d->ctime_ = track->modificationdate;
set_length_nanosec(track->duration * kNsecPerMsec);
d->samplerate_ = track->samplerate;
d->samplerate_ = static_cast<int>(track->samplerate);
d->bitdepth_ = 0;
d->bitrate_ = track->bitrate;
d->bitrate_ = static_cast<int>(track->bitrate);
d->playcount_ = track->usecount;
d->playcount_ = static_cast<int>(track->usecount);
switch (track->filetype) {
case LIBMTP_FILETYPE_WAV: d->filetype_ = FileType_WAV; break;
@@ -1319,7 +1319,7 @@ void Song::ToMTP(LIBMTP_track_t *track) const {
track->filename = strdup(d->basefilename_.toUtf8().constData());
track->filesize = d->filesize_;
track->filesize = static_cast<quint64>(d->filesize_);
track->modificationdate = d->mtime_;
track->duration = length_nanosec() / kNsecPerMsec;

View File

@@ -237,7 +237,7 @@ class Song {
const QUrl &url() const;
const QString &basefilename() const;
FileType filetype() const;
int filesize() const;
qint64 filesize() const;
qint64 mtime() const;
qint64 ctime() const;
@@ -354,7 +354,7 @@ class Song {
void set_url(const QUrl &v);
void set_basefilename(const QString &v);
void set_filetype(FileType v);
void set_filesize(int v);
void set_filesize(qint64 v);
void set_mtime(qint64 v);
void set_ctime(qint64 v);
void set_unavailable(bool v);

View File

@@ -552,7 +552,7 @@ GstPadProbeReturn SongLoader::DataReady(GstPad*, GstPadProbeInfo *info, gpointer
gst_buffer_map(buffer, &map, GST_MAP_READ);
// Append the data to the buffer
instance->buffer_.append(reinterpret_cast<const char*>(map.data), map.size);
instance->buffer_.append(reinterpret_cast<const char*>(map.data), static_cast<qint64>(map.size));
qLog(Debug) << "Received total" << instance->buffer_.size() << "bytes";
gst_buffer_unmap(buffer, &map);

View File

@@ -91,7 +91,7 @@ QColor StyleHelper::notTooBrightHighlightColor() {
QColor highlightColor = QApplication::palette().highlight().color();
if (0.5 * highlightColor.saturationF() + 0.75 - highlightColor.valueF() < 0) {
highlightColor.setHsvF(highlightColor.hsvHueF(), 0.1 + highlightColor.saturationF() * 2.0, highlightColor.valueF());
highlightColor.setHsvF(highlightColor.hsvHueF(), 0.1F + highlightColor.saturationF() * 2.0F, highlightColor.valueF());
}
return highlightColor;
@@ -133,10 +133,10 @@ QColor StyleHelper::highlightColor(bool lightColored) {
QColor result = baseColor(lightColored);
if (lightColored) {
result.setHsv(result.hue(), clamp(result.saturation()), clamp(result.value() * 1.06));
result.setHsv(result.hue(), clamp(static_cast<float>(result.saturation())), clamp(static_cast<float>(result.value()) * 1.06F));
}
else {
result.setHsv(result.hue(), clamp(result.saturation()), clamp(result.value() * 1.16));
result.setHsv(result.hue(), clamp(static_cast<float>(result.saturation())), clamp(static_cast<float>(result.value()) * 1.16F));
}
return result;
@@ -146,7 +146,7 @@ QColor StyleHelper::highlightColor(bool lightColored) {
QColor StyleHelper::shadowColor(bool lightColored) {
QColor result = baseColor(lightColored);
result.setHsv(result.hue(), clamp(result.saturation() * 1.1), clamp(result.value() * 0.70));
result.setHsv(result.hue(), clamp(static_cast<float>(result.saturation()) * 1.1F), clamp(static_cast<float>(result.value()) * 0.70F));
return result;
}
@@ -162,7 +162,7 @@ QColor StyleHelper::borderColor(bool lightColored) {
QColor StyleHelper::toolBarBorderColor() {
const QColor base = baseColor();
return QColor::fromHsv(base.hue(), base.saturation(), clamp(base.value() * 0.80F));
return QColor::fromHsv(base.hue(), base.saturation(), clamp(static_cast<float>(base.value()) * 0.80F));
}
@@ -172,7 +172,7 @@ void StyleHelper::setBaseColor(const QColor &newcolor) {
m_requestedBaseColor = newcolor;
QColor color;
color.setHsv(newcolor.hue(), newcolor.saturation() * 0.7, 64 + newcolor.value() / 3);
color.setHsv(newcolor.hue(), static_cast<int>(static_cast<float>(newcolor.saturation()) * 0.7F), 64 + newcolor.value() / 3);
if (color.isValid() && color != m_baseColor) {
m_baseColor = color;
@@ -303,7 +303,7 @@ void StyleHelper::drawArrow(QStyle::PrimitiveElement element, QPainter *painter,
QPixmap pixmap;
QString pixmapName = QString::asprintf("StyleHelper::drawArrow-%d-%d-%d-%f", element, size, (enabled ? 1 : 0), devicePixelRatio);
if (!QPixmapCache::find(pixmapName, &pixmap)) {
QImage image(size * devicePixelRatio, size * devicePixelRatio, QImage::Format_ARGB32_Premultiplied);
QImage image(size * static_cast<int>(devicePixelRatio), size * static_cast<int>(devicePixelRatio), QImage::Format_ARGB32_Premultiplied);
image.fill(Qt::transparent);
QPainter p(&image);
@@ -325,7 +325,7 @@ void StyleHelper::drawArrow(QStyle::PrimitiveElement element, QPainter *painter,
drawCommonStyleArrow(image.rect(), m_IconsDisabledColor);
}
else {
drawCommonStyleArrow(image.rect().translated(0, devicePixelRatio), toolBarDropShadowColor());
drawCommonStyleArrow(image.rect().translated(0, static_cast<int>(devicePixelRatio)), toolBarDropShadowColor());
drawCommonStyleArrow(image.rect(), m_IconsBaseColor);
}
p.end();
@@ -434,7 +434,7 @@ void StyleHelper::tintImage(QImage &img, const QColor &tintColor) {
if (alpha > 0) {
c.toHsl();
qreal l = c.lightnessF();
float l = c.lightnessF();
QColor newColor = QColor::fromHslF(tintColor.hslHueF(), tintColor.hslSaturationF(), l);
newColor.setAlpha(alpha);
img.setPixel(x, y, newColor.rgba());

View File

@@ -223,7 +223,7 @@ QByteArray TagReaderClient::LoadEmbeddedArtBlocking(const QString &filename) {
TagReaderReply *reply = LoadEmbeddedArt(filename);
if (reply->WaitForFinished()) {
const std::string &data_str = reply->message().load_embedded_art_response().data();
ret = QByteArray(data_str.data(), data_str.size());
ret = QByteArray(data_str.data(), static_cast<qint64>(data_str.size()));
}
QMetaObject::invokeMethod(reply, "deleteLater", Qt::QueuedConnection);
@@ -240,7 +240,7 @@ QImage TagReaderClient::LoadEmbeddedArtAsImageBlocking(const QString &filename)
TagReaderReply *reply = LoadEmbeddedArt(filename);
if (reply->WaitForFinished()) {
const std::string &data_str = reply->message().load_embedded_art_response().data();
ret.loadFromData(QByteArray(data_str.data(), data_str.size()));
ret.loadFromData(QByteArray(data_str.data(), static_cast<qint64>(data_str.size())));
}
QMetaObject::invokeMethod(reply, "deleteLater", Qt::QueuedConnection);

View File

@@ -79,7 +79,7 @@ void TaskManager::SetTaskBlocksCollectionScans(const int id) {
}
void TaskManager::SetTaskProgress(const int id, const qint64 progress, const qint64 max) {
void TaskManager::SetTaskProgress(const int id, const quint64 progress, const quint64 max) {
{
QMutexLocker l(&mutex_);
@@ -93,7 +93,7 @@ void TaskManager::SetTaskProgress(const int id, const qint64 progress, const qin
emit TasksChanged();
}
void TaskManager::IncreaseTaskProgress(const int id, const qint64 progress, const qint64 max) {
void TaskManager::IncreaseTaskProgress(const int id, const quint64 progress, const quint64 max) {
{
QMutexLocker l(&mutex_);
@@ -134,7 +134,7 @@ void TaskManager::SetTaskFinished(const int id) {
}
int TaskManager::GetTaskProgress(int id) {
quint64 TaskManager::GetTaskProgress(int id) {
{
QMutexLocker l(&mutex_);

View File

@@ -41,8 +41,8 @@ class TaskManager : public QObject {
Task() : id(0), progress(0), progress_max(0), blocks_collection_scans(false) {}
int id;
QString name;
qint64 progress;
qint64 progress_max;
quint64 progress;
quint64 progress_max;
bool blocks_collection_scans;
};
@@ -64,10 +64,10 @@ class TaskManager : public QObject {
int StartTask(const QString &name);
void SetTaskBlocksCollectionScans(const int id);
void SetTaskProgress(const int id, const qint64 progress, const qint64 max = 0);
void IncreaseTaskProgress(const int id, const qint64 progress, const qint64 max = 0);
void SetTaskProgress(const int id, const quint64 progress, const quint64 max = 0);
void IncreaseTaskProgress(const int id, const quint64 progress, const quint64 max = 0);
void SetTaskFinished(const int id);
int GetTaskProgress(const int id);
quint64 GetTaskProgress(const int id);
signals:
void TasksChanged();

View File

@@ -191,13 +191,13 @@ QString PrettySize(const quint64 bytes) {
ret = QString::number(bytes) + " bytes";
}
else if (bytes <= 1000 * 1000) {
ret = QString::asprintf("%.1f KB", static_cast<float>(bytes) / 1000);
ret = QString::asprintf("%.1f KB", static_cast<float>(bytes) / 1000.0F);
}
else if (bytes <= 1000 * 1000 * 1000) {
ret = QString::asprintf("%.1f MB", static_cast<float>(bytes) / (1000 * 1000));
ret = QString::asprintf("%.1f MB", static_cast<float>(bytes) / (1000.0F * 1000.0F));
}
else {
ret = QString::asprintf("%.1f GB", static_cast<float>(bytes) / (1000 * 1000 * 1000));
ret = QString::asprintf("%.1f GB", static_cast<float>(bytes) / (1000.0F * 1000.0F * 1000.0F));
}
}
return ret;
@@ -746,7 +746,7 @@ QString GetRandomString(const int len, const QString &UseCharacters) {
QString randstr;
for (int i = 0; i < len; ++i) {
#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)
const int index = QRandomGenerator::global()->bounded(0, UseCharacters.length());
const qint64 index = QRandomGenerator::global()->bounded(0, UseCharacters.length());
#else
const int index = qrand() % UseCharacters.length();
#endif
@@ -767,7 +767,7 @@ QString DesktopEnvironment() {
if (!qEnvironmentVariableIsEmpty("GNOME_DESKTOP_SESSION_ID")) return "Gnome";
QString session = GetEnv("DESKTOP_SESSION");
int slash = session.lastIndexOf('/');
qint64 slash = session.lastIndexOf('/');
if (slash != -1) {
QSettings desktop_file(QString(session + ".desktop"), QSettings::IniFormat);
desktop_file.beginGroup("Desktop Entry");
@@ -864,7 +864,7 @@ QString ReplaceMessage(const QString &message, const Song &song, const QString &
QString copy(message);
// Replace the first line
int pos = 0;
qint64 pos = 0;
QRegularExpressionMatch match;
for (match = variable_replacer.match(message, pos); match.hasMatch(); match = variable_replacer.match(message, pos)) {
pos = match.capturedStart();
@@ -873,7 +873,7 @@ QString ReplaceMessage(const QString &message, const Song &song, const QString &
pos += match.capturedLength();
}
int index_of = copy.indexOf(QRegularExpression(" - (>|$)"));
qint64 index_of = copy.indexOf(QRegularExpression(" - (>|$)"));
if (index_of >= 0) copy = copy.remove(index_of, 3);
return copy;
@@ -1039,4 +1039,3 @@ ScopedWCharArray::ScopedWCharArray(const QString &str)
str.toWCharArray(data_.get());
data_[chars_] = '\0';
}

View File

@@ -159,13 +159,13 @@ class ScopedWCharArray {
wchar_t *get() const { return data_.get(); }
explicit operator wchar_t*() const { return get(); }
int characters() const { return chars_; }
int bytes() const { return (chars_ + 1) *sizeof(wchar_t); }
qint64 characters() const { return chars_; }
qint64 bytes() const { return (chars_ + 1) *sizeof(wchar_t); }
private:
Q_DISABLE_COPY(ScopedWCharArray)
int chars_;
qint64 chars_;
std::unique_ptr<wchar_t[]> data_;
};