From 317f1263fbddcc7b2db24c8bca84d79df63a9fc3 Mon Sep 17 00:00:00 2001 From: Lioncash <mathew1800@gmail.com> Date: Mon, 20 May 2019 14:44:13 -0400 Subject: [PATCH] yuzu/util: Specify string conversions explicitly Allows the util code to build with implicit string conversions disabled. --- src/yuzu/util/util.cpp | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/yuzu/util/util.cpp b/src/yuzu/util/util.cpp index 62c080aff..ef31bc2d2 100644 --- a/src/yuzu/util/util.cpp +++ b/src/yuzu/util/util.cpp @@ -8,7 +8,7 @@ #include "yuzu/util/util.h" QFont GetMonospaceFont() { - QFont font("monospace"); + QFont font(QStringLiteral("monospace")); // Automatic fallback to a monospace font on on platforms without a font called "monospace" font.setStyleHint(QFont::Monospace); font.setFixedPitch(true); @@ -16,14 +16,16 @@ QFont GetMonospaceFont() { } QString ReadableByteSize(qulonglong size) { - static const std::array<const char*, 6> units = {"B", "KiB", "MiB", "GiB", "TiB", "PiB"}; - if (size == 0) - return "0"; - int digit_groups = std::min<int>(static_cast<int>(std::log10(size) / std::log10(1024)), - static_cast<int>(units.size())); - return QString("%L1 %2") + static constexpr std::array units{"B", "KiB", "MiB", "GiB", "TiB", "PiB"}; + if (size == 0) { + return QStringLiteral("0"); + } + + const int digit_groups = std::min(static_cast<int>(std::log10(size) / std::log10(1024)), + static_cast<int>(units.size())); + return QStringLiteral("%L1 %2") .arg(size / std::pow(1024, digit_groups), 0, 'f', 1) - .arg(units[digit_groups]); + .arg(QString::fromUtf8(units[digit_groups])); } QPixmap CreateCirclePixmapFromColor(const QColor& color) {