Remove use of C-style casts

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

View File

@@ -1370,7 +1370,7 @@ void MainWindow::TrackSkipped(PlaylistItemPtr item) {
Song song = item->Metadata();
const qint64 position = app_->player()->engine()->position_nanosec();
const qint64 length = app_->player()->engine()->length_nanosec();
const float percentage = (length == 0 ? 1 : float(position) / length);
const float percentage = (length == 0 ? 1 : static_cast<float>(position) / static_cast<float>(length));
const qint64 seconds_left = (length - position) / kNsecPerSec;
const qint64 seconds_total = length / kNsecPerSec;
@@ -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>(double(position) / length * 100));
tray_icon_->SetProgress(static_cast<int>(static_cast<double>(position) / length * 100));
}
@@ -1641,10 +1641,10 @@ void MainWindow::UpdateTrackPosition() {
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);
const int position = std::floor(static_cast<float>(app_->player()->engine()->position_nanosec()) / kNsecPerSec + 0.5);
// Update the tray icon every 10 seconds
if (position % 10 == 0) tray_icon_->SetProgress(static_cast<int>(double(position) / length * 100));
if (position % 10 == 0) tray_icon_->SetProgress(static_cast<int>(static_cast<double>(position) / length * 100));
// Send Scrobble
if (app_->scrobbler()->IsEnabled() && item->Metadata().is_metadata_good()) {
@@ -1664,7 +1664,7 @@ void MainWindow::UpdateTrackSliderPosition() {
PlaylistItemPtr item(app_->player()->GetCurrentItem());
const int slider_position = std::floor(float(app_->player()->engine()->position_nanosec()) / kNsecPerMsec);
const int slider_position = std::floor(static_cast<float>(app_->player()->engine()->position_nanosec()) / kNsecPerMsec);
const int slider_length = static_cast<int>(app_->player()->engine()->length_nanosec() / kNsecPerMsec);
// Update the slider

View File

@@ -369,7 +369,7 @@ QPixmap StyleHelper::disabledSideBarIcon(const QPixmap &enabledicon) {
auto scanLine = reinterpret_cast<QRgb*>(im.scanLine(y));
for (int x=0; x<im.width(); ++x) {
QRgb pixel = *scanLine;
char intensity = char(qGray(pixel));
char intensity = static_cast<char>(qGray(pixel));
*scanLine = qRgba(intensity, intensity, intensity, qAlpha(pixel));
++scanLine;
}

View File

@@ -45,7 +45,7 @@ QPixmap SystemTrayIcon::CreateIcon(const QPixmap &icon, const QPixmap &grey_icon
if (trayicon_progress_) {
// The angle of the line that's used to cover the icon.
// Centered on rect.topLeft()
double angle = double(100 - song_progress_) / 100.0 * M_PI_2;
double angle = static_cast<double>(100 - song_progress_) / 100.0 * M_PI_2;
double length = sqrt(pow(rect.width(), 2.0) + pow(rect.height(), 2.0));
QPolygon mask;

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", float(bytes) / 1000);
ret = QString::asprintf("%.1f KB", static_cast<float>(bytes) / 1000);
}
else if (bytes <= 1000 * 1000 * 1000) {
ret = QString::asprintf("%.1f MB", float(bytes) / (1000 * 1000));
ret = QString::asprintf("%.1f MB", static_cast<float>(bytes) / (1000 * 1000));
}
else {
ret = QString::asprintf("%.1f GB", float(bytes) / (1000 * 1000 * 1000));
ret = QString::asprintf("%.1f GB", static_cast<float>(bytes) / (1000 * 1000 * 1000));
}
}
return ret;
@@ -482,8 +482,8 @@ QByteArray Hmac(const QByteArray &key, const QByteArray &data, const QCryptograp
const int kBlockSize = 64; // bytes
Q_ASSERT(key.length() <= kBlockSize);
QByteArray inner_padding(kBlockSize, char(0x36));
QByteArray outer_padding(kBlockSize, char(0x5c));
QByteArray inner_padding(kBlockSize, static_cast<char>(0x36));
QByteArray outer_padding(kBlockSize, static_cast<char>(0x5c));
for (int i = 0; i < key.length(); ++i) {
inner_padding[i] = inner_padding[i] ^ key[i];

View File

@@ -80,7 +80,7 @@ ITaskbarList3 *Windows7ThumbBar::CreateTaskbarList() {
static const GUID CLSID_ITaskbarList = { 0x56FDF344,0xFD6D,0x11d0,{0x95,0x8A,0x00,0x60,0x97,0xC9,0xA0,0x90}};
// Create the taskbar list
HRESULT hr = CoCreateInstance(CLSID_ITaskbarList, nullptr, CLSCTX_ALL, IID_ITaskbarList3, (void**)&taskbar_list);
HRESULT hr = CoCreateInstance(CLSID_ITaskbarList, nullptr, CLSCTX_ALL, IID_ITaskbarList3, reinterpret_cast<void**>(&taskbar_list));
if (hr != S_OK) {
qLog(Warning) << "Error creating the ITaskbarList3 interface" << Qt::hex << DWORD (hr);
return nullptr;