[qt] fix user dialogue not 'OK'ing' with empty UUIDs

Signed-off-by: lizzie <lizzie@eden-emu.dev>
This commit is contained in:
lizzie 2026-01-27 19:59:48 +00:00
parent c974f3e0fb
commit 385d52133e
1 changed files with 16 additions and 7 deletions

View File

@ -78,6 +78,11 @@ QPixmap GetIcon(const Common::UUID& uuid) {
QString GetProfileUsernameFromUser(QWidget* parent, const QString& title, const QString& text) {
return LimitableInputDialog::GetText(parent, title, text, 1, int(Service::Account::profile_username_size));
}
QString GetProfileUuidFromUser(QWidget* parent, const QString& title, const QString& text) {
return LimitableInputDialog::GetText(parent, title, text, 0, int(Common::UUID));
}
} // Anonymous namespace
ConfigureProfileManager::ConfigureProfileManager(Core::System& system_, QWidget* parent)
@ -210,7 +215,7 @@ void ConfigureProfileManager::AddUser() {
if (username.isEmpty())
return;
auto const uuid_str = GetProfileUsernameFromUser(this, tr("New User UUID"), tr("Enter a UUID (leave empty to autogenerate):"));
auto const uuid_str = GetProfileUuidFromUser(this, tr("New User UUID"), tr("Enter a UUID (optional):"));
auto uuid = Common::UUID::MakeRandom();
if (uuid_str.length() > 0) {
if (size_t(uuid_str.length()) != uuid.uuid.size())
@ -226,8 +231,6 @@ void ConfigureProfileManager::AddUser() {
void ConfigureProfileManager::RenameUser() {
const auto user = tree_view->currentIndex().row();
const auto uuid = profile_manager.GetUser(user);
ASSERT(uuid);
Service::Account::ProfileBase profile{};
if (!profile_manager.GetProfileBase(*uuid, profile))
@ -238,6 +241,15 @@ void ConfigureProfileManager::RenameUser() {
return;
}
auto const uuid_str = GetProfileUuidFromUser(this, tr("New User UUID"), tr("Enter a UUID (optional):"));
auto uuid = profile_manager.GetUser(user);
if (uuid_str.length() > 0) {
if (size_t(uuid_str.length()) != uuid.uuid.size())
return;
for (size_t i = 0; i < size_t(uuid_str.length()); ++i)
uuid.uuid[i] = u8(uuid_str[i].toLatin1());
}
const auto username_std = new_username.toStdString();
std::fill(profile.username.begin(), profile.username.end(), '\0');
std::copy(username_std.begin(), username_std.end(), profile.username.begin());
@ -245,10 +257,7 @@ void ConfigureProfileManager::RenameUser() {
profile_manager.SetProfileBase(*uuid, profile);
profile_manager.WriteUserSaveFile();
item_model->setItem(
user, 0,
new QStandardItem{GetIcon(*uuid),
FormatUserEntryText(QString::fromStdString(username_std), *uuid)});
item_model->setItem(user, 0, new QStandardItem{GetIcon(*uuid), FormatUserEntryText(QString::fromStdString(username_std), *uuid)});
UpdateCurrentUser();
}