Merge pull request #6507 from jonaski/sprintf

Replace use of QString::sprintf with QString::asprintf
This commit is contained in:
John Maguire 2020-01-05 00:40:43 +00:00 committed by GitHub
commit 7d2c622d0f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 19 additions and 15 deletions

View File

@ -98,10 +98,11 @@ QString PrettyTime(int seconds, bool always_show_hours) {
QString ret;
if (hours || always_show_hours)
ret.sprintf("%d:%02d:%02d", hours, minutes,
seconds); // NOLINT(runtime/printf)
ret = QString::asprintf("%d:%02d:%02d", hours, minutes,
seconds); // NOLINT(runtime/printf)
else
ret.sprintf("%d:%02d", minutes, seconds); // NOLINT(runtime/printf)
ret = QString::asprintf("%d:%02d", minutes,
seconds); // NOLINT(runtime/printf)
return ret;
}
@ -165,15 +166,18 @@ QString PrettySize(quint64 bytes) {
if (bytes <= 1000)
ret = QString::number(bytes) + " bytes";
else if (bytes <= 1000 * 1000)
ret.sprintf("%.1f KB",
static_cast<float>(bytes) / 1000); // NOLINT(runtime/printf)
ret = QString::asprintf(
"%.1f KB",
static_cast<float>(bytes) / 1000); // NOLINT(runtime/printf)
else if (bytes <= 1000 * 1000 * 1000)
ret.sprintf("%.1f MB", static_cast<float>(bytes) /
(1000 * 1000)); // NOLINT(runtime/printf)
ret = QString::asprintf(
"%.1f MB",
static_cast<float>(bytes) / (1000 * 1000)); // NOLINT(runtime/printf)
else
ret.sprintf("%.1f GB",
static_cast<float>(bytes) /
(1000 * 1000 * 1000)); // NOLINT(runtime/printf)
ret = QString::asprintf(
"%.1f GB",
static_cast<float>(bytes) /
(1000 * 1000 * 1000)); // NOLINT(runtime/printf)
}
return ret;
}

View File

@ -700,7 +700,7 @@ QList<QUrl> MacDeviceLister::MakeDeviceUrls(const QString& serial) {
if (IsMTPSerial(serial)) {
const MTPDevice& device = mtp_devices_[serial];
QString str;
str.sprintf("gphoto2://usb-%d-%d/", device.bus, device.address);
str = QString::asprintf("gphoto2://usb-%d-%d/", device.bus, device.address);
QUrlQuery url_query;
url_query.addQueryItem("vendor", device.vendor);
url_query.addQueryItem("vendor_id", QString::number(device.vendor_id));

View File

@ -159,7 +159,7 @@ void PlaybackSettingsPage::Save() {
void PlaybackSettingsPage::RgPreampChanged(int value) {
float db = float(value) / 10 - 15;
QString db_str;
db_str.sprintf("%+.1f dB", db);
db_str = QString::asprintf("%+.1f dB", db);
ui_->replaygain_preamp_label->setText(db_str);
}

View File

@ -137,9 +137,9 @@ void StyleHelper::verticalGradient(QPainter* painter, const QRect& spanRect,
if (StyleHelper::usePixmapCache()) {
QString key;
QColor keyColor = baseColor(lightColored);
key.sprintf("mh_vertical %d %d %d %d %d", spanRect.width(),
spanRect.height(), clipRect.width(), clipRect.height(),
keyColor.rgb());
key = QString::asprintf("mh_vertical %d %d %d %d %d", spanRect.width(),
spanRect.height(), clipRect.width(),
clipRect.height(), keyColor.rgb());
;
QPixmap pixmap;