diff --git a/src/citra_qt/configuration/config.cpp b/src/citra_qt/configuration/config.cpp index c28f0d828..68e58e63b 100644 --- a/src/citra_qt/configuration/config.cpp +++ b/src/citra_qt/configuration/config.cpp @@ -113,7 +113,7 @@ void Config::ReadValues() { Settings::LoadProfile(Settings::values.current_input_profile_index); - qt_config->endArray(); + qt_config->endGroup(); qt_config->beginGroup("Core"); Settings::values.use_cpu_jit = ReadSetting("use_cpu_jit", true).toBool(); diff --git a/src/citra_qt/configuration/configure_dialog.cpp b/src/citra_qt/configuration/configure_dialog.cpp index 1d55f8934..3527b8589 100644 --- a/src/citra_qt/configuration/configure_dialog.cpp +++ b/src/citra_qt/configuration/configure_dialog.cpp @@ -42,7 +42,7 @@ void ConfigureDialog::applyConfiguration() { ui->generalTab->applyConfiguration(); ui->systemTab->applyConfiguration(); ui->inputTab->applyConfiguration(); - ui->inputTab->applyProfile(); + ui->inputTab->ApplyProfile(); ui->graphicsTab->applyConfiguration(); ui->audioTab->applyConfiguration(); ui->cameraTab->applyConfiguration(); diff --git a/src/citra_qt/configuration/configure_input.cpp b/src/citra_qt/configuration/configure_input.cpp index 80db5c29f..437265763 100644 --- a/src/citra_qt/configuration/configure_input.cpp +++ b/src/citra_qt/configuration/configure_input.cpp @@ -224,11 +224,14 @@ ConfigureInput::ConfigureInput(QWidget* parent) QDialog* motion_touch_dialog = new ConfigureMotionTouch(this); return motion_touch_dialog->exec(); }); + + ui->buttonDelete->setEnabled(ui->profile->count() > 1); + connect(ui->buttonClearAll, &QPushButton::released, [this] { ClearAll(); }); connect(ui->buttonRestoreDefaults, &QPushButton::released, [this]() { restoreDefaults(); }); - connect(ui->buttonNew, &QPushButton::released, [this] { newProfile(); }); - connect(ui->buttonDelete, &QPushButton::released, [this] { deleteProfile(); }); - connect(ui->buttonRename, &QPushButton::released, [this] { renameProfile(); }); + connect(ui->buttonNew, &QPushButton::released, [this] { NewProfile(); }); + connect(ui->buttonDelete, &QPushButton::released, [this] { DeleteProfile(); }); + connect(ui->buttonRename, &QPushButton::released, [this] { RenameProfile(); }); connect(ui->profile, static_cast(&QComboBox::currentIndexChanged), [this](int i) { @@ -269,7 +272,7 @@ void ConfigureInput::applyConfiguration() { [](const Common::ParamPackage& param) { return param.Serialize(); }); } -void ConfigureInput::applyProfile() { +void ConfigureInput::ApplyProfile() { Settings::values.current_input_profile_index = ui->profile->currentIndex(); } @@ -390,7 +393,7 @@ void ConfigureInput::retranslateUi() { ui->retranslateUi(this); } -void ConfigureInput::newProfile() { +void ConfigureInput::NewProfile() { const QString name = QInputDialog::getText(this, tr("New Profile"), tr("Enter the name for the new profile.")); if (name.isEmpty()) { @@ -402,13 +405,10 @@ void ConfigureInput::newProfile() { ui->profile->addItem(name); ui->profile->setCurrentIndex(Settings::values.current_input_profile_index); loadConfiguration(); + ui->buttonDelete->setEnabled(ui->profile->count() > 1); } -void ConfigureInput::deleteProfile() { - if (ui->profile->count() == 1) { - QMessageBox::critical(this, tr("Citra"), tr("You need to have 1 profile at least")); - return; - } +void ConfigureInput::DeleteProfile() { const auto answer = QMessageBox::question( this, tr("Delete Profile"), tr("Delete profile %1?").arg(ui->profile->currentText())); if (answer != QMessageBox::Yes) { @@ -419,9 +419,10 @@ void ConfigureInput::deleteProfile() { ui->profile->setCurrentIndex(0); Settings::DeleteProfile(index); loadConfiguration(); + ui->buttonDelete->setEnabled(ui->profile->count() > 1); } -void ConfigureInput::renameProfile() { +void ConfigureInput::RenameProfile() { const QString new_name = QInputDialog::getText(this, tr("Rename Profile"), tr("New name:")); if (new_name.isEmpty()) { return; diff --git a/src/citra_qt/configuration/configure_input.h b/src/citra_qt/configuration/configure_input.h index 7c4b02f7a..1e55fd272 100644 --- a/src/citra_qt/configuration/configure_input.h +++ b/src/citra_qt/configuration/configure_input.h @@ -40,7 +40,7 @@ public: void loadConfiguration(); // Save the current input profile index - void applyProfile(); + void ApplyProfile(); private: std::unique_ptr ui; @@ -96,7 +96,7 @@ private: void keyPressEvent(QKeyEvent* event) override; /// input profiles - void newProfile(); - void deleteProfile(); - void renameProfile(); + void NewProfile(); + void DeleteProfile(); + void RenameProfile(); }; diff --git a/src/core/settings.cpp b/src/core/settings.cpp index 8ac3b17c8..a286d149b 100644 --- a/src/core/settings.cpp +++ b/src/core/settings.cpp @@ -101,29 +101,31 @@ void LogSettings() { } void LoadProfile(int index) { - values.current_input_profile = values.input_profiles[index]; - values.current_input_profile_index = index; + Settings::values.current_input_profile = Settings::values.input_profiles[index]; + Settings::values.current_input_profile_index = index; } void SaveProfile(int index) { - values.input_profiles[index] = values.current_input_profile; + Settings::values.input_profiles[index] = Settings::values.current_input_profile; } void CreateProfile(std::string name) { - InputProfile profile = values.current_input_profile; + Settings::InputProfile profile = values.current_input_profile; profile.name = std::move(name); - values.input_profiles.push_back(std::move(profile)); - values.current_input_profile_index = static_cast(values.input_profiles.size()) - 1; - LoadProfile(values.current_input_profile_index); + Settings::values.input_profiles.push_back(std::move(profile)); + Settings::values.current_input_profile_index = + static_cast(Settings::values.input_profiles.size()) - 1; + Settings::LoadProfile(Settings::values.current_input_profile_index); } void DeleteProfile(int index) { - values.input_profiles.erase(values.input_profiles.begin() + index); - LoadProfile(0); + Settings::values.input_profiles.erase(Settings::values.input_profiles.begin() + index); + Settings::LoadProfile(0); } void RenameCurrentProfile(std::string new_name) { - values.input_profiles[values.current_input_profile_index].name = std::move(new_name); + Settings::values.input_profiles[Settings::values.current_input_profile_index].name = + std::move(new_name); } } // namespace Settings