configure_general.cpp 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. // Copyright 2016 Citra Emulator Project
  2. // Licensed under GPLv2 or any later version
  3. // Refer to the license.txt file included.
  4. #include "core/core.h"
  5. #include "core/hle/service/am/am.h"
  6. #include "core/hle/service/am/applet_ae.h"
  7. #include "core/hle/service/am/applet_oe.h"
  8. #include "core/hle/service/sm/sm.h"
  9. #include "core/settings.h"
  10. #include "ui_configure_general.h"
  11. #include "yuzu/configuration/configure_general.h"
  12. #include "yuzu/ui_settings.h"
  13. ConfigureGeneral::ConfigureGeneral(QWidget* parent)
  14. : QWidget(parent), ui(new Ui::ConfigureGeneral) {
  15. ui->setupUi(this);
  16. for (const auto& theme : UISettings::themes) {
  17. ui->theme_combobox->addItem(theme.first, theme.second);
  18. }
  19. this->setConfiguration();
  20. ui->use_cpu_jit->setEnabled(!Core::System::GetInstance().IsPoweredOn());
  21. }
  22. ConfigureGeneral::~ConfigureGeneral() = default;
  23. void ConfigureGeneral::setConfiguration() {
  24. ui->toggle_deepscan->setChecked(UISettings::values.gamedir_deepscan);
  25. ui->toggle_check_exit->setChecked(UISettings::values.confirm_before_closing);
  26. ui->theme_combobox->setCurrentIndex(ui->theme_combobox->findData(UISettings::values.theme));
  27. ui->use_cpu_jit->setChecked(Settings::values.use_cpu_jit);
  28. ui->use_docked_mode->setChecked(Settings::values.use_docked_mode);
  29. ui->enable_nfc->setChecked(Settings::values.enable_nfc);
  30. }
  31. void ConfigureGeneral::PopulateHotkeyList(const HotkeyRegistry& registry) {
  32. ui->widget->Populate(registry);
  33. }
  34. void ConfigureGeneral::OnDockedModeChanged(bool last_state, bool new_state) {
  35. if (last_state == new_state) {
  36. return;
  37. }
  38. Core::System& system{Core::System::GetInstance()};
  39. if (!system.IsPoweredOn()) {
  40. return;
  41. }
  42. Service::SM::ServiceManager& sm = system.ServiceManager();
  43. // Message queue is shared between these services, we just need to signal an operation
  44. // change to one and it will handle both automatically
  45. auto applet_oe = sm.GetService<Service::AM::AppletOE>("appletOE");
  46. auto applet_ae = sm.GetService<Service::AM::AppletAE>("appletAE");
  47. bool has_signalled = false;
  48. if (applet_oe != nullptr) {
  49. applet_oe->GetMessageQueue()->OperationModeChanged();
  50. has_signalled = true;
  51. }
  52. if (applet_ae != nullptr && !has_signalled) {
  53. applet_ae->GetMessageQueue()->OperationModeChanged();
  54. }
  55. }
  56. void ConfigureGeneral::applyConfiguration() {
  57. UISettings::values.gamedir_deepscan = ui->toggle_deepscan->isChecked();
  58. UISettings::values.confirm_before_closing = ui->toggle_check_exit->isChecked();
  59. UISettings::values.theme =
  60. ui->theme_combobox->itemData(ui->theme_combobox->currentIndex()).toString();
  61. Settings::values.use_cpu_jit = ui->use_cpu_jit->isChecked();
  62. const bool pre_docked_mode = Settings::values.use_docked_mode;
  63. Settings::values.use_docked_mode = ui->use_docked_mode->isChecked();
  64. OnDockedModeChanged(pre_docked_mode, Settings::values.use_docked_mode);
  65. Settings::values.enable_nfc = ui->enable_nfc->isChecked();
  66. }