Merge pull request #7852 from Morph1984/new-uuid

common: Revise and fix the UUID implementation
This commit is contained in:
bunnei
2022-02-10 21:52:13 -07:00
committed by GitHub
31 changed files with 373 additions and 196 deletions

View File

@ -33,10 +33,10 @@ constexpr std::array<u8, 107> backup_jpeg{
0x01, 0x01, 0x00, 0x00, 0x3f, 0x00, 0xd2, 0xcf, 0x20, 0xff, 0xd9,
};
QString GetImagePath(Common::UUID uuid) {
QString GetImagePath(const Common::UUID& uuid) {
const auto path =
Common::FS::GetYuzuPath(Common::FS::YuzuPath::NANDDir) /
fmt::format("system/save/8000000000000010/su/avators/{}.jpg", uuid.FormatSwitch());
fmt::format("system/save/8000000000000010/su/avators/{}.jpg", uuid.FormattedString());
return QString::fromStdString(Common::FS::PathToUTF8String(path));
}
@ -55,10 +55,10 @@ QString FormatUserEntryText(const QString& username, Common::UUID uuid) {
return ConfigureProfileManager::tr("%1\n%2",
"%1 is the profile username, %2 is the formatted UUID (e.g. "
"00112233-4455-6677-8899-AABBCCDDEEFF))")
.arg(username, QString::fromStdString(uuid.FormatSwitch()));
.arg(username, QString::fromStdString(uuid.FormattedString()));
}
QPixmap GetIcon(Common::UUID uuid) {
QPixmap GetIcon(const Common::UUID& uuid) {
QPixmap icon{GetImagePath(uuid)};
if (!icon) {
@ -200,7 +200,7 @@ void ConfigureProfileManager::AddUser() {
return;
}
const auto uuid = Common::UUID::Generate();
const auto uuid = Common::UUID::MakeRandom();
profile_manager->CreateNewUser(uuid, username.toStdString());
item_model->appendRow(new QStandardItem{GetIcon(uuid), FormatUserEntryText(username, uuid)});