Browse Source
[qt, util] Change default units from units of 1024 (MiB, KiB) to 1000 (MB, KB) (#2882)
Better for readability of these units? Perhaps
Signed-off-by: lizzie <lizzie@eden-emu.dev>
Co-authored-by: crueter <crueter@eden-emu.dev>
Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/2882
Reviewed-by: crueter <crueter@eden-emu.dev>
Reviewed-by: Maufeat <sahyno1996@gmail.com>
Reviewed-by: Caio Oliveira <caiooliveirafarias0@gmail.com>
Reviewed-by: CamilleLaVey <camillelavey99@gmail.com>
Co-authored-by: lizzie <lizzie@eden-emu.dev>
Co-committed-by: lizzie <lizzie@eden-emu.dev>
pull/3160/head
lizzie
2 weeks ago
committed by
crueter
No known key found for this signature in database
GPG Key ID: 425ACD2D4830EBC6
3 changed files with
9 additions and
22 deletions
-
src/frontend_common/data_manager.cpp
-
src/frontend_common/data_manager.h
-
src/yuzu/util/util.cpp
|
|
|
@ -49,16 +49,13 @@ u64 ClearDir(DataDir dir, const std::string &user_id) |
|
|
|
return result; |
|
|
|
} |
|
|
|
|
|
|
|
const std::string ReadableBytesSize(u64 size) |
|
|
|
{ |
|
|
|
static constexpr std::array units{"B", "KiB", "MiB", "GiB", "TiB", "PiB"}; |
|
|
|
if (size == 0) { |
|
|
|
std::string ReadableBytesSize(u64 size) noexcept { |
|
|
|
std::array<std::string_view, 6> const units{"B", "KB", "MB", "GB", "TB", "PB"}; |
|
|
|
u64 const base = 1000; |
|
|
|
if (size == 0) |
|
|
|
return "0 B"; |
|
|
|
} |
|
|
|
|
|
|
|
const int digit_groups = (std::min) (static_cast<int>(std::log10(size) / std::log10(1024)), |
|
|
|
static_cast<int>(units.size())); |
|
|
|
return fmt::format("{:.1f} {}", size / std::pow(1024, digit_groups), units[digit_groups]); |
|
|
|
auto const digit_groups = std::min<u64>(u64(std::log10(size) / std::log10(base)), u64(units.size())); |
|
|
|
return fmt::format("{:.1f} {}", size / std::pow(base, digit_groups), units[digit_groups]); |
|
|
|
} |
|
|
|
|
|
|
|
u64 DataDirSize(DataDir dir) |
|
|
|
|
|
|
|
@ -16,8 +16,7 @@ const std::filesystem::path GetDataDir(DataDir dir, const std::string &user_id = |
|
|
|
const std::string GetDataDirString(DataDir dir, const std::string &user_id = ""); |
|
|
|
|
|
|
|
u64 ClearDir(DataDir dir, const std::string &user_id = ""); |
|
|
|
|
|
|
|
const std::string ReadableBytesSize(u64 size); |
|
|
|
std::string ReadableBytesSize(u64 size) noexcept; |
|
|
|
|
|
|
|
u64 DataDirSize(DataDir dir); |
|
|
|
|
|
|
|
|
|
|
|
@ -4,7 +4,6 @@ |
|
|
|
// SPDX-FileCopyrightText: 2015 Citra Emulator Project
|
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
|
|
|
|
#include <array>
|
|
|
|
#include <cmath>
|
|
|
|
#include <QPainter>
|
|
|
|
|
|
|
|
@ -12,6 +11,7 @@ |
|
|
|
#include "common/logging/log.h"
|
|
|
|
#include "core/frontend/applets/profile_select.h"
|
|
|
|
#include "core/hle/service/acc/profile_manager.h"
|
|
|
|
#include "frontend_common/data_manager.h"
|
|
|
|
#include "qt_common/qt_common.h"
|
|
|
|
#include "yuzu/util/util.h"
|
|
|
|
|
|
|
|
@ -29,16 +29,7 @@ QFont GetMonospaceFont() { |
|
|
|
} |
|
|
|
|
|
|
|
QString ReadableByteSize(qulonglong size) { |
|
|
|
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(QString::fromUtf8(units[digit_groups])); |
|
|
|
return QString::fromStdString(FrontendCommon::DataManager::ReadableBytesSize(size)); |
|
|
|
} |
|
|
|
|
|
|
|
QPixmap CreateCirclePixmapFromColor(const QColor& color) { |
|
|
|
|