mirror of https://github.com/PCSX2/pcsx2.git
Added rename input profile function
This commit is contained in:
parent
843566eb49
commit
234b8f6abf
|
@ -38,6 +38,7 @@ ControllerSettingsWindow::ControllerSettingsWindow()
|
||||||
connect(m_ui.buttonBox, &QDialogButtonBox::rejected, this, &ControllerSettingsWindow::close);
|
connect(m_ui.buttonBox, &QDialogButtonBox::rejected, this, &ControllerSettingsWindow::close);
|
||||||
connect(m_ui.newProfile, &QPushButton::clicked, this, &ControllerSettingsWindow::onNewProfileClicked);
|
connect(m_ui.newProfile, &QPushButton::clicked, this, &ControllerSettingsWindow::onNewProfileClicked);
|
||||||
connect(m_ui.applyProfile, &QPushButton::clicked, this, &ControllerSettingsWindow::onApplyProfileClicked);
|
connect(m_ui.applyProfile, &QPushButton::clicked, this, &ControllerSettingsWindow::onApplyProfileClicked);
|
||||||
|
connect(m_ui.renameProfile, &QPushButton::clicked, this, &ControllerSettingsWindow::onRenameProfileClicked);
|
||||||
connect(m_ui.deleteProfile, &QPushButton::clicked, this, &ControllerSettingsWindow::onDeleteProfileClicked);
|
connect(m_ui.deleteProfile, &QPushButton::clicked, this, &ControllerSettingsWindow::onDeleteProfileClicked);
|
||||||
connect(m_ui.mappingSettings, &QPushButton::clicked, this, &ControllerSettingsWindow::onMappingSettingsClicked);
|
connect(m_ui.mappingSettings, &QPushButton::clicked, this, &ControllerSettingsWindow::onMappingSettingsClicked);
|
||||||
connect(m_ui.restoreDefaults, &QPushButton::clicked, this, &ControllerSettingsWindow::onRestoreDefaultsClicked);
|
connect(m_ui.restoreDefaults, &QPushButton::clicked, this, &ControllerSettingsWindow::onRestoreDefaultsClicked);
|
||||||
|
@ -176,6 +177,48 @@ void ControllerSettingsWindow::onApplyProfileClicked()
|
||||||
switchProfile({});
|
switchProfile({});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ControllerSettingsWindow::onRenameProfileClicked()
|
||||||
|
{
|
||||||
|
const QString profile_name(QInputDialog::getText(this, tr("Rename Input Profile"),
|
||||||
|
tr("Enter the new name for the input profile:").arg(m_profile_name)));
|
||||||
|
|
||||||
|
if (profile_name.isEmpty())
|
||||||
|
return;
|
||||||
|
|
||||||
|
std::string old_profile_name(m_profile_name.toStdString());
|
||||||
|
std::string old_profile_path(VMManager::GetInputProfilePath(m_profile_name.toStdString()));
|
||||||
|
std::string profile_path(VMManager::GetInputProfilePath(profile_name.toStdString()));
|
||||||
|
if (FileSystem::FileExists(profile_path.c_str()))
|
||||||
|
{
|
||||||
|
QMessageBox::critical(this, tr("Error"), tr("A profile with the name '%1' already exists.").arg(profile_name));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!FileSystem::RenamePath(old_profile_path.c_str(), profile_path.c_str()))
|
||||||
|
{
|
||||||
|
QMessageBox::critical(this, tr("Error"), tr("Failed to rename '%1'.").arg(QString::fromStdString(old_profile_path)));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string game_settings_dir(EmuFolders::GameSettings);
|
||||||
|
for (const auto& game_settings : std::filesystem::recursive_directory_iterator(game_settings_dir))
|
||||||
|
{
|
||||||
|
std::string game_settings_path(game_settings.path().string());
|
||||||
|
std::unique_ptr<INISettingsInterface> update_sif(std::make_unique<INISettingsInterface>(std::move(game_settings_path)));
|
||||||
|
|
||||||
|
update_sif->Load();
|
||||||
|
|
||||||
|
if (!old_profile_name.compare(update_sif->GetStringValue("EmuCore", "InputProfileName")))
|
||||||
|
{
|
||||||
|
update_sif->SetStringValue("EmuCore", "InputProfileName", profile_name.toUtf8());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
refreshProfileList();
|
||||||
|
switchProfile({profile_name});
|
||||||
|
}
|
||||||
|
|
||||||
void ControllerSettingsWindow::onDeleteProfileClicked()
|
void ControllerSettingsWindow::onDeleteProfileClicked()
|
||||||
{
|
{
|
||||||
if (QMessageBox::question(this, tr("Delete Input Profile"),
|
if (QMessageBox::question(this, tr("Delete Input Profile"),
|
||||||
|
@ -451,6 +494,7 @@ void ControllerSettingsWindow::createWidgets()
|
||||||
}
|
}
|
||||||
|
|
||||||
m_ui.applyProfile->setEnabled(isEditingProfile());
|
m_ui.applyProfile->setEnabled(isEditingProfile());
|
||||||
|
m_ui.renameProfile->setEnabled(isEditingProfile());
|
||||||
m_ui.deleteProfile->setEnabled(isEditingProfile());
|
m_ui.deleteProfile->setEnabled(isEditingProfile());
|
||||||
m_ui.restoreDefaults->setEnabled(isEditingGlobalSettings());
|
m_ui.restoreDefaults->setEnabled(isEditingGlobalSettings());
|
||||||
}
|
}
|
||||||
|
|
|
@ -76,6 +76,7 @@ private Q_SLOTS:
|
||||||
void onCurrentProfileChanged(int index);
|
void onCurrentProfileChanged(int index);
|
||||||
void onNewProfileClicked();
|
void onNewProfileClicked();
|
||||||
void onApplyProfileClicked();
|
void onApplyProfileClicked();
|
||||||
|
void onRenameProfileClicked();
|
||||||
void onDeleteProfileClicked();
|
void onDeleteProfileClicked();
|
||||||
void onMappingSettingsClicked();
|
void onMappingSettingsClicked();
|
||||||
void onRestoreDefaultsClicked();
|
void onRestoreDefaultsClicked();
|
||||||
|
|
|
@ -113,6 +113,16 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="renameProfile">
|
||||||
|
<property name="text">
|
||||||
|
<string>Rename Profile</string>
|
||||||
|
</property>
|
||||||
|
<property name="icon">
|
||||||
|
<iconset theme="pencil-line"/>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QPushButton" name="deleteProfile">
|
<widget class="QPushButton" name="deleteProfile">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
|
|
Loading…
Reference in New Issue