all repos — mgba @ 28504b308e9b35068661dcc9eb86bbbe830b6ef7

mGBA Game Boy Advance Emulator

Qt: Cleaner byte size formatting
Vicki Pfau vi@endrift.com
Mon, 01 Feb 2021 01:53:55 -0800
commit

28504b308e9b35068661dcc9eb86bbbe830b6ef7

parent

88212fc2deb72b3ab85313852b0b091edc88403b

1 files changed, 4 insertions(+), 4 deletions(-)

jump to
M src/platform/qt/utils.cppsrc/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) {