profile: Migrate to the new UUID implementation

This commit is contained in:
Morph
2022-02-05 12:29:09 -05:00
parent d94dcaefa0
commit dfe11d72e3
14 changed files with 131 additions and 127 deletions

View File

@ -19,21 +19,21 @@
#include "yuzu/util/controller_navigation.h"
namespace {
QString FormatUserEntryText(const QString& username, Common::UUID uuid) {
QString FormatUserEntryText(const QString& username, Common::NewUUID uuid) {
return QtProfileSelectionDialog::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()));
}
QString GetImagePath(Common::UUID uuid) {
QString GetImagePath(Common::NewUUID 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));
}
QPixmap GetIcon(Common::UUID uuid) {
QPixmap GetIcon(Common::NewUUID uuid) {
QPixmap icon{GetImagePath(uuid)};
if (!icon) {
@ -163,11 +163,11 @@ QtProfileSelector::QtProfileSelector(GMainWindow& parent) {
QtProfileSelector::~QtProfileSelector() = default;
void QtProfileSelector::SelectProfile(
std::function<void(std::optional<Common::UUID>)> callback_) const {
std::function<void(std::optional<Common::NewUUID>)> callback_) const {
callback = std::move(callback_);
emit MainWindowSelectProfile();
}
void QtProfileSelector::MainWindowFinishedSelection(std::optional<Common::UUID> uuid) {
void QtProfileSelector::MainWindowFinishedSelection(std::optional<Common::NewUUID> uuid) {
callback(uuid);
}

View File

@ -66,13 +66,14 @@ public:
explicit QtProfileSelector(GMainWindow& parent);
~QtProfileSelector() override;
void SelectProfile(std::function<void(std::optional<Common::UUID>)> callback_) const override;
void SelectProfile(
std::function<void(std::optional<Common::NewUUID>)> callback_) const override;
signals:
void MainWindowSelectProfile() const;
private:
void MainWindowFinishedSelection(std::optional<Common::UUID> uuid);
void MainWindowFinishedSelection(std::optional<Common::NewUUID> uuid);
mutable std::function<void(std::optional<Common::UUID>)> callback;
mutable std::function<void(std::optional<Common::NewUUID>)> callback;
};

View File

@ -33,14 +33,14 @@ 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::NewUUID& 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));
}
QString GetAccountUsername(const Service::Account::ProfileManager& manager, Common::UUID uuid) {
QString GetAccountUsername(const Service::Account::ProfileManager& manager, Common::NewUUID uuid) {
Service::Account::ProfileBase profile{};
if (!manager.GetProfileBase(uuid, profile)) {
return {};
@ -51,14 +51,14 @@ QString GetAccountUsername(const Service::Account::ProfileManager& manager, Comm
return QString::fromStdString(text);
}
QString FormatUserEntryText(const QString& username, Common::UUID uuid) {
QString FormatUserEntryText(const QString& username, Common::NewUUID 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::NewUUID& 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::NewUUID::MakeRandom();
profile_manager->CreateNewUser(uuid, username.toStdString());
item_model->appendRow(new QStandardItem{GetIcon(uuid), FormatUserEntryText(username, uuid)});

View File

@ -1688,7 +1688,7 @@ void GMainWindow::OnGameListOpenFolder(u64 program_id, GameListOpenTarget target
const auto user_save_data_path = FileSys::SaveDataFactory::GetFullPath(
*system, FileSys::SaveDataSpaceId::NandUser, FileSys::SaveDataType::SaveData,
program_id, user_id->uuid, 0);
program_id, user_id->AsU128(), 0);
path = Common::FS::ConcatPathSafe(nand_dir, user_save_data_path);
} else {

View File

@ -153,7 +153,7 @@ signals:
void ErrorDisplayFinished();
void ProfileSelectorFinishedSelection(std::optional<Common::UUID> uuid);
void ProfileSelectorFinishedSelection(std::optional<Common::NewUUID> uuid);
void SoftwareKeyboardSubmitNormalText(Service::AM::Applets::SwkbdResult result,
std::u16string submitted_text, bool confirmed);