diff --git a/src/citra_qt/configuration/configure_input.cpp b/src/citra_qt/configuration/configure_input.cpp index cd7e17f04b..8443dd643b 100644 --- a/src/citra_qt/configuration/configure_input.cpp +++ b/src/citra_qt/configuration/configure_input.cpp @@ -437,6 +437,11 @@ void ConfigureInput::NewProfile() { if (name.isEmpty()) { return; } + if (IsProfileNameDuplicate(name)) { + WarnProposedProfileNameIsDuplicate(); + return; + } + applyConfiguration(); Settings::SaveProfile(ui->profile->currentIndex()); Settings::CreateProfile(name.toStdString()); @@ -465,6 +470,20 @@ void ConfigureInput::RenameProfile() { if (new_name.isEmpty()) { return; } + if (IsProfileNameDuplicate(new_name)) { + WarnProposedProfileNameIsDuplicate(); + return; + } + ui->profile->setItemText(ui->profile->currentIndex(), new_name); Settings::RenameCurrentProfile(new_name.toStdString()); } + +bool ConfigureInput::IsProfileNameDuplicate(const QString& name) const { + return ui->profile->findText(name, Qt::MatchFixedString | Qt::MatchCaseSensitive) != -1; +} + +void ConfigureInput::WarnProposedProfileNameIsDuplicate() { + QMessageBox::warning(this, tr("Duplicate profile name"), + tr("Profile name already exists. Please choose a different name.")); +} diff --git a/src/citra_qt/configuration/configure_input.h b/src/citra_qt/configuration/configure_input.h index 36e44d52b0..c844f61905 100644 --- a/src/citra_qt/configuration/configure_input.h +++ b/src/citra_qt/configuration/configure_input.h @@ -119,4 +119,7 @@ private: void NewProfile(); void DeleteProfile(); void RenameProfile(); + + bool IsProfileNameDuplicate(const QString& name) const; + void WarnProposedProfileNameIsDuplicate(); };