From 28504b308e9b35068661dcc9eb86bbbe830b6ef7 Mon Sep 17 00:00:00 2001 From: Vicki Pfau Date: Mon, 1 Feb 2021 01:53:55 -0800 Subject: [PATCH] Qt: Cleaner byte size formatting --- src/platform/qt/utils.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/platform/qt/utils.cpp b/src/platform/qt/utils.cpp index 94b230361..31845e140 100644 --- a/src/platform/qt/utils.cpp +++ b/src/platform/qt/utils.cpp @@ -11,16 +11,16 @@ namespace QGBA { QString niceSizeFormat(size_t filesize) { double size = filesize; - QString unit = "B"; + QString unit = QObject::tr("%1 byte"); if (size >= 1024.0) { size /= 1024.0; - unit = "kiB"; + unit = QObject::tr("%1 kiB"); } if (size >= 1024.0) { size /= 1024.0; - unit = "MiB"; + unit = QObject::tr("%1 MiB"); } - return QString("%0 %1").arg(size, 0, 'f', 1).arg(unit); + return unit.arg(size, 0, 'f', int(size * 10) % 10 ? 1 : 0); } QString nicePlatformFormat(mPlatform platform) { switch (platform) {