all repos — mgba @ 88212fc2deb72b3ab85313852b0b091edc88403b

mGBA Game Boy Advance Emulator

src/platform/qt/utils.cpp (view raw)

 1/* Copyright (c) 2013-2017 Jeffrey Pfau
 2 *
 3 * This Source Code Form is subject to the terms of the Mozilla Public
 4 * License, v. 2.0. If a copy of the MPL was not distributed with this
 5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 6#include "utils.h"
 7
 8#include <QObject>
 9
10namespace QGBA {
11
12QString niceSizeFormat(size_t filesize) {
13	double size = filesize;
14	QString unit = "B";
15	if (size >= 1024.0) {
16		size /= 1024.0;
17		unit = "kiB";
18	}
19	if (size >= 1024.0) {
20		size /= 1024.0;
21		unit = "MiB";
22	}
23	return QString("%0 %1").arg(size, 0, 'f', 1).arg(unit);
24}
25QString nicePlatformFormat(mPlatform platform) {
26	switch (platform) {
27#ifdef M_CORE_GBA
28	case mPLATFORM_GBA:
29		return QObject::tr("GBA");
30#endif
31#ifdef M_CORE_GB
32	case mPLATFORM_GB:
33		return QObject::tr("GB");
34#endif
35	default:
36		return QObject::tr("?");
37	}
38}
39
40}