mirror of
https://github.com/strawberrymusicplayer/strawberry
synced 2025-02-03 10:57:33 +01:00
Replace use of QString::sprintf
This commit is contained in:
parent
ab85b716bb
commit
b5a897bb4d
@ -196,9 +196,8 @@ static void verticalGradientHelper(QPainter *p, const QRect &spanRect, const QRe
|
||||
void StyleHelper::verticalGradient(QPainter *painter, const QRect &spanRect, const QRect &clipRect, bool lightColored) {
|
||||
|
||||
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());
|
||||
QString key = QString::asprintf("mh_vertical %d %d %d %d %d", spanRect.width(), spanRect.height(), clipRect.width(), clipRect.height(), keyColor.rgb());
|
||||
|
||||
QPixmap pixmap;
|
||||
if (!QPixmapCache::find(key, &pixmap)) {
|
||||
@ -253,9 +252,8 @@ static void horizontalGradientHelper(QPainter *p, const QRect &spanRect, const Q
|
||||
void StyleHelper::horizontalGradient(QPainter *painter, const QRect &spanRect, const QRect &clipRect, bool lightColored) {
|
||||
|
||||
if (StyleHelper::usePixmapCache()) {
|
||||
QString key;
|
||||
QColor keyColor = baseColor(lightColored);
|
||||
key.sprintf("mh_horizontal %d %d %d %d %d %d", spanRect.width(), spanRect.height(), clipRect.width(), clipRect.height(), keyColor.rgb(), spanRect.x());
|
||||
QString key = QString::asprintf("mh_horizontal %d %d %d %d %d %d", spanRect.width(), spanRect.height(), clipRect.width(), clipRect.height(), keyColor.rgb(), spanRect.x());
|
||||
|
||||
QPixmap pixmap;
|
||||
if (!QPixmapCache::find(key, &pixmap)) {
|
||||
@ -294,8 +292,7 @@ void StyleHelper::drawArrow(QStyle::PrimitiveElement element, QPainter *painter,
|
||||
QRect r = option->rect;
|
||||
int size = qMin(r.height(), r.width());
|
||||
QPixmap pixmap;
|
||||
QString pixmapName;
|
||||
pixmapName.sprintf("StyleHelper::drawArrow-%d-%d-%d-%f", element, size, enabled, devicePixelRatio);
|
||||
QString pixmapName = QString::asprintf("StyleHelper::drawArrow-%d-%d-%d-%f", element, size, enabled, devicePixelRatio);
|
||||
if (!QPixmapCache::find(pixmapName, &pixmap)) {
|
||||
QImage image(size * devicePixelRatio, size * devicePixelRatio, QImage::Format_ARGB32_Premultiplied);
|
||||
image.fill(Qt::transparent);
|
||||
@ -336,8 +333,7 @@ void StyleHelper::drawArrow(QStyle::PrimitiveElement element, QPainter *painter,
|
||||
void StyleHelper::menuGradient(QPainter *painter, const QRect &spanRect, const QRect &clipRect) {
|
||||
|
||||
if (StyleHelper::usePixmapCache()) {
|
||||
QString key;
|
||||
key.sprintf("mh_menu %d %d %d %d %d", spanRect.width(), spanRect.height(), clipRect.width(), clipRect.height(), StyleHelper::baseColor().rgb());
|
||||
QString key = QString::asprintf("mh_menu %d %d %d %d %d", spanRect.width(), spanRect.height(), clipRect.width(), clipRect.height(), StyleHelper::baseColor().rgb());
|
||||
|
||||
QPixmap pixmap;
|
||||
if (!QPixmapCache::find(key, &pixmap)) {
|
||||
|
@ -119,8 +119,8 @@ QString PrettyTime(int seconds) {
|
||||
seconds %= 60;
|
||||
|
||||
QString ret;
|
||||
if (hours) ret.sprintf("%d:%02d:%02d", hours, minutes, seconds);
|
||||
else ret.sprintf("%d:%02d", minutes, seconds);
|
||||
if (hours) ret = QString("%d:%02d:%02d").arg(hours).arg(minutes).arg(seconds);
|
||||
else ret = QString("%d:%02d").arg(minutes).arg(seconds);
|
||||
|
||||
return ret;
|
||||
|
||||
@ -186,11 +186,11 @@ QString PrettySize(quint64 bytes) {
|
||||
if (bytes <= 1000)
|
||||
ret = QString::number(bytes) + " bytes";
|
||||
else if (bytes <= 1000 * 1000)
|
||||
ret.sprintf("%.1f KB", float(bytes) / 1000);
|
||||
ret = QString("%.1f KB").arg(float(bytes) / 1000);
|
||||
else if (bytes <= 1000 * 1000 * 1000)
|
||||
ret.sprintf("%.1f MB", float(bytes) / (1000 * 1000));
|
||||
ret = QString("%.1f MB").arg(float(bytes) / (1000 * 1000));
|
||||
else
|
||||
ret.sprintf("%.1f GB", float(bytes) / (1000 * 1000 * 1000));
|
||||
ret = QString("%.1f GB").arg(float(bytes) / (1000 * 1000 * 1000));
|
||||
}
|
||||
return ret;
|
||||
|
||||
|
@ -220,8 +220,7 @@ QString iMobileDeviceConnection::GetUnusedFilename(Itdb_iTunesDB *itdb, const So
|
||||
// Get the total number of F.. directories
|
||||
int total_musicdirs = 0;
|
||||
for ( ; ; ++total_musicdirs) {
|
||||
QString dir;
|
||||
dir.sprintf("/iTunes_Control/Music/F%02d", total_musicdirs);
|
||||
QString dir = QString("/iTunes_Control/Music/F%02d").arg(total_musicdirs);
|
||||
|
||||
if (!Exists(dir))
|
||||
break;
|
||||
@ -234,8 +233,7 @@ QString iMobileDeviceConnection::GetUnusedFilename(Itdb_iTunesDB *itdb, const So
|
||||
|
||||
// Pick one at random
|
||||
const int dir_num = qrand() % total_musicdirs;
|
||||
QString dir;
|
||||
dir.sprintf("/iTunes_Control/Music/F%02d", dir_num);
|
||||
QString dir = QString("/iTunes_Control/Music/F%02d").arg(dir_num);
|
||||
|
||||
if (!Exists(dir)) {
|
||||
qLog(Warning) << "Music directory doesn't exist:" << dir;
|
||||
@ -252,7 +250,7 @@ QString iMobileDeviceConnection::GetUnusedFilename(Itdb_iTunesDB *itdb, const So
|
||||
static const int kRandMax = 999999;
|
||||
QString filename;
|
||||
forever {
|
||||
filename.sprintf("libgpod%06d", qrand() % kRandMax);
|
||||
filename = QString("libgpod%06d").arg(qrand() % kRandMax);
|
||||
filename += "." + extension;
|
||||
|
||||
if (!Exists(dir + "/" + filename))
|
||||
|
@ -526,8 +526,7 @@ void BackendSettingsPage::DeviceStringChanged() {
|
||||
void BackendSettingsPage::RgPreampChanged(int value) {
|
||||
|
||||
float db = float(value) / 10 - 15;
|
||||
QString db_str;
|
||||
db_str.sprintf("%+.1f dB", db);
|
||||
QString db_str = QString("%+.1f dB").arg(db);
|
||||
ui_->label_replaygainpreamp->setText(db_str);
|
||||
|
||||
}
|
||||
|
@ -490,8 +490,7 @@ void FancyTabWidget::paintEvent(QPaintEvent *pe) {
|
||||
QRect backgroundRect = rect();
|
||||
backgroundRect.setWidth(tabBar()->width());
|
||||
|
||||
QString key;
|
||||
key.sprintf("mh_vertical %d %d %d %d %d", backgroundRect.width(), backgroundRect.height(), bg_color_.rgb(), (bg_gradient_ ? 1 : 0), (background_pixmap_.isNull() ? 0 : 1));
|
||||
QString key = QString::asprintf("mh_vertical %d %d %d %d %d", backgroundRect.width(), backgroundRect.height(), bg_color_.rgb(), (bg_gradient_ ? 1 : 0), (background_pixmap_.isNull() ? 0 : 1));
|
||||
|
||||
QPixmap pixmap;
|
||||
if (!QPixmapCache::find(key, &pixmap)) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user