2022-05-15 02:06:02 +02:00
|
|
|
// SPDX-FileCopyrightText: 2016 Citra Emulator Project
|
|
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2016-01-24 18:34:05 +01:00
|
|
|
|
2021-09-02 21:40:55 -04:00
|
|
|
#include <memory>
|
|
|
|
|
#include "common/logging/log.h"
|
2021-04-14 16:07:40 -07:00
|
|
|
#include "common/settings.h"
|
2023-08-16 16:12:42 -04:00
|
|
|
#include "common/settings_enums.h"
|
2020-11-27 10:50:48 -05:00
|
|
|
#include "core/core.h"
|
2016-09-21 00:21:23 +09:00
|
|
|
#include "ui_configure.h"
|
2023-05-28 21:46:02 +00:00
|
|
|
#include "vk_device_info.h"
|
2024-01-26 23:28:24 -05:00
|
|
|
#include "yuzu/configuration/configure_applets.h"
|
2021-09-02 21:40:55 -04:00
|
|
|
#include "yuzu/configuration/configure_audio.h"
|
|
|
|
|
#include "yuzu/configuration/configure_cpu.h"
|
|
|
|
|
#include "yuzu/configuration/configure_debug_tab.h"
|
2018-01-11 20:33:56 -07:00
|
|
|
#include "yuzu/configuration/configure_dialog.h"
|
2021-09-02 21:40:55 -04:00
|
|
|
#include "yuzu/configuration/configure_filesystem.h"
|
|
|
|
|
#include "yuzu/configuration/configure_general.h"
|
|
|
|
|
#include "yuzu/configuration/configure_graphics.h"
|
|
|
|
|
#include "yuzu/configuration/configure_graphics_advanced.h"
|
2025-04-23 20:57:53 -04:00
|
|
|
#include "yuzu/configuration/configure_graphics_extensions.h"
|
2021-09-02 21:40:55 -04:00
|
|
|
#include "yuzu/configuration/configure_hotkeys.h"
|
|
|
|
|
#include "yuzu/configuration/configure_input.h"
|
2019-02-16 16:19:29 +01:00
|
|
|
#include "yuzu/configuration/configure_input_player.h"
|
2021-09-02 21:40:55 -04:00
|
|
|
#include "yuzu/configuration/configure_network.h"
|
|
|
|
|
#include "yuzu/configuration/configure_profile_manager.h"
|
|
|
|
|
#include "yuzu/configuration/configure_system.h"
|
|
|
|
|
#include "yuzu/configuration/configure_ui.h"
|
|
|
|
|
#include "yuzu/configuration/configure_web.h"
|
2018-08-07 00:43:07 -04:00
|
|
|
#include "yuzu/hotkeys.h"
|
2022-04-13 13:29:59 -07:00
|
|
|
#include "yuzu/uisettings.h"
|
2018-01-11 20:33:56 -07:00
|
|
|
|
2022-06-13 18:19:04 -04:00
|
|
|
ConfigureDialog::ConfigureDialog(QWidget* parent, HotkeyRegistry& registry_,
|
2021-09-02 21:40:55 -04:00
|
|
|
InputCommon::InputSubsystem* input_subsystem,
|
2023-05-28 21:46:02 +00:00
|
|
|
std::vector<VkDeviceInfo::Record>& vk_device_records,
|
2021-12-25 20:27:52 +01:00
|
|
|
Core::System& system_, bool enable_web_config)
|
|
|
|
|
: QDialog(parent), ui{std::make_unique<Ui::ConfigureDialog>()},
|
2023-06-21 01:42:42 -04:00
|
|
|
registry(registry_), system{system_}, builder{std::make_unique<ConfigurationShared::Builder>(
|
|
|
|
|
this, !system_.IsPoweredOn())},
|
2024-01-26 23:28:24 -05:00
|
|
|
applets_tab{std::make_unique<ConfigureApplets>(system_, nullptr, *builder, this)},
|
2023-06-21 01:42:42 -04:00
|
|
|
audio_tab{std::make_unique<ConfigureAudio>(system_, nullptr, *builder, this)},
|
|
|
|
|
cpu_tab{std::make_unique<ConfigureCpu>(system_, nullptr, *builder, this)},
|
2021-09-02 21:40:55 -04:00
|
|
|
debug_tab_tab{std::make_unique<ConfigureDebugTab>(system_, this)},
|
|
|
|
|
filesystem_tab{std::make_unique<ConfigureFilesystem>(this)},
|
2023-06-21 01:42:42 -04:00
|
|
|
general_tab{std::make_unique<ConfigureGeneral>(system_, nullptr, *builder, this)},
|
|
|
|
|
graphics_advanced_tab{
|
2025-04-23 20:57:53 -04:00
|
|
|
std::make_unique<ConfigureGraphicsAdvanced>(system_, nullptr, *builder, this)},
|
|
|
|
|
graphics_extensions_tab{
|
|
|
|
|
std::make_unique<ConfigureGraphicsExtensions>(system_, nullptr, *builder, this)},
|
2023-08-16 16:12:42 -04:00
|
|
|
ui_tab{std::make_unique<ConfigureUi>(system_, this)},
|
2023-05-02 16:48:45 -07:00
|
|
|
graphics_tab{std::make_unique<ConfigureGraphics>(
|
2023-05-28 21:46:02 +00:00
|
|
|
system_, vk_device_records, [&]() { graphics_advanced_tab->ExposeComputeOption(); },
|
2023-08-16 16:12:42 -04:00
|
|
|
[this](Settings::AspectRatio ratio, Settings::ResolutionSetup setup) {
|
|
|
|
|
ui_tab->UpdateScreenshotInfo(ratio, setup);
|
|
|
|
|
},
|
2023-06-21 01:42:42 -04:00
|
|
|
nullptr, *builder, this)},
|
2021-11-15 17:57:41 -06:00
|
|
|
hotkeys_tab{std::make_unique<ConfigureHotkeys>(system_.HIDCore(), this)},
|
2021-09-02 21:40:55 -04:00
|
|
|
input_tab{std::make_unique<ConfigureInput>(system_, this)},
|
|
|
|
|
network_tab{std::make_unique<ConfigureNetwork>(system_, this)},
|
|
|
|
|
profile_tab{std::make_unique<ConfigureProfileManager>(system_, this)},
|
2023-06-21 01:42:42 -04:00
|
|
|
system_tab{std::make_unique<ConfigureSystem>(system_, nullptr, *builder, this)},
|
2023-08-16 16:12:42 -04:00
|
|
|
web_tab{std::make_unique<ConfigureWeb>(this)} {
|
2020-11-04 04:16:34 -05:00
|
|
|
Settings::SetConfiguringGlobal(true);
|
2020-07-09 22:42:09 -04:00
|
|
|
|
2016-01-24 18:34:05 +01:00
|
|
|
ui->setupUi(this);
|
2021-09-02 21:40:55 -04:00
|
|
|
|
2024-01-26 23:28:24 -05:00
|
|
|
ui->tabWidget->addTab(applets_tab.get(), tr("Applets"));
|
2021-09-02 21:40:55 -04:00
|
|
|
ui->tabWidget->addTab(audio_tab.get(), tr("Audio"));
|
|
|
|
|
ui->tabWidget->addTab(cpu_tab.get(), tr("CPU"));
|
|
|
|
|
ui->tabWidget->addTab(debug_tab_tab.get(), tr("Debug"));
|
|
|
|
|
ui->tabWidget->addTab(filesystem_tab.get(), tr("Filesystem"));
|
|
|
|
|
ui->tabWidget->addTab(general_tab.get(), tr("General"));
|
|
|
|
|
ui->tabWidget->addTab(graphics_tab.get(), tr("Graphics"));
|
|
|
|
|
ui->tabWidget->addTab(graphics_advanced_tab.get(), tr("GraphicsAdvanced"));
|
2025-04-23 20:57:53 -04:00
|
|
|
ui->tabWidget->addTab(graphics_extensions_tab.get(), tr("GraphicsExtensions"));
|
2021-09-02 21:40:55 -04:00
|
|
|
ui->tabWidget->addTab(hotkeys_tab.get(), tr("Hotkeys"));
|
|
|
|
|
ui->tabWidget->addTab(input_tab.get(), tr("Controls"));
|
|
|
|
|
ui->tabWidget->addTab(profile_tab.get(), tr("Profiles"));
|
|
|
|
|
ui->tabWidget->addTab(network_tab.get(), tr("Network"));
|
|
|
|
|
ui->tabWidget->addTab(system_tab.get(), tr("System"));
|
|
|
|
|
ui->tabWidget->addTab(ui_tab.get(), tr("Game List"));
|
|
|
|
|
ui->tabWidget->addTab(web_tab.get(), tr("Web"));
|
|
|
|
|
|
2021-12-25 20:27:52 +01:00
|
|
|
web_tab->SetWebServiceConfigEnabled(enable_web_config);
|
2021-09-02 21:40:55 -04:00
|
|
|
hotkeys_tab->Populate(registry);
|
2019-05-09 03:20:13 -04:00
|
|
|
|
2021-09-02 21:40:55 -04:00
|
|
|
input_tab->Initialize(input_subsystem);
|
2020-08-27 15:16:47 -04:00
|
|
|
|
2021-09-02 21:40:55 -04:00
|
|
|
general_tab->SetResetCallback([&] { this->close(); });
|
2021-05-25 20:49:42 -04:00
|
|
|
|
2019-05-26 00:39:23 -04:00
|
|
|
SetConfiguration();
|
|
|
|
|
PopulateSelectionList();
|
|
|
|
|
|
2021-10-15 16:41:29 -04:00
|
|
|
connect(ui->tabWidget, &QTabWidget::currentChanged, this, [this](int index) {
|
|
|
|
|
if (index != -1) {
|
|
|
|
|
debug_tab_tab->SetCurrentIndex(0);
|
|
|
|
|
}
|
|
|
|
|
});
|
2021-09-02 21:40:55 -04:00
|
|
|
connect(ui_tab.get(), &ConfigureUi::LanguageChanged, this, &ConfigureDialog::OnLanguageChanged);
|
2018-09-06 19:59:25 +02:00
|
|
|
connect(ui->selectorList, &QListWidget::itemSelectionChanged, this,
|
|
|
|
|
&ConfigureDialog::UpdateVisibleTabs);
|
2019-05-09 03:20:13 -04:00
|
|
|
|
2021-09-02 21:40:55 -04:00
|
|
|
if (system.IsPoweredOn()) {
|
2021-05-17 16:13:39 -04:00
|
|
|
QPushButton* apply_button = ui->buttonBox->addButton(QDialogButtonBox::Apply);
|
|
|
|
|
connect(apply_button, &QAbstractButton::clicked, this,
|
|
|
|
|
&ConfigureDialog::HandleApplyButtonClicked);
|
|
|
|
|
}
|
|
|
|
|
|
2018-09-06 19:59:25 +02:00
|
|
|
adjustSize();
|
|
|
|
|
ui->selectorList->setCurrentRow(0);
|
2023-07-21 23:56:01 -04:00
|
|
|
|
2025-04-23 20:57:53 -04:00
|
|
|
// Selects the leftmost button on the bottom bar (Cancel as of writing)
|
2023-07-21 23:56:01 -04:00
|
|
|
ui->buttonBox->setFocus();
|
2016-01-24 18:34:05 +01:00
|
|
|
}
|
|
|
|
|
|
2018-08-06 12:58:46 -04:00
|
|
|
ConfigureDialog::~ConfigureDialog() = default;
|
2016-01-24 18:34:05 +01:00
|
|
|
|
2019-05-26 00:39:23 -04:00
|
|
|
void ConfigureDialog::SetConfiguration() {}
|
2016-01-24 18:34:05 +01:00
|
|
|
|
2019-05-26 00:39:23 -04:00
|
|
|
void ConfigureDialog::ApplyConfiguration() {
|
2021-09-02 21:40:55 -04:00
|
|
|
general_tab->ApplyConfiguration();
|
|
|
|
|
ui_tab->ApplyConfiguration();
|
|
|
|
|
system_tab->ApplyConfiguration();
|
|
|
|
|
profile_tab->ApplyConfiguration();
|
2022-02-01 21:59:29 -05:00
|
|
|
filesystem_tab->ApplyConfiguration();
|
2021-09-02 21:40:55 -04:00
|
|
|
input_tab->ApplyConfiguration();
|
|
|
|
|
hotkeys_tab->ApplyConfiguration(registry);
|
|
|
|
|
cpu_tab->ApplyConfiguration();
|
|
|
|
|
graphics_tab->ApplyConfiguration();
|
|
|
|
|
graphics_advanced_tab->ApplyConfiguration();
|
2025-04-23 20:57:53 -04:00
|
|
|
graphics_extensions_tab->ApplyConfiguration();
|
2021-09-02 21:40:55 -04:00
|
|
|
audio_tab->ApplyConfiguration();
|
|
|
|
|
debug_tab_tab->ApplyConfiguration();
|
|
|
|
|
web_tab->ApplyConfiguration();
|
|
|
|
|
network_tab->ApplyConfiguration();
|
2024-01-26 23:28:24 -05:00
|
|
|
applets_tab->ApplyConfiguration();
|
2021-09-02 21:40:55 -04:00
|
|
|
system.ApplySettings();
|
2018-07-10 18:02:14 +08:00
|
|
|
Settings::LogSettings();
|
2016-01-24 18:34:05 +01:00
|
|
|
}
|
2018-09-06 19:59:25 +02:00
|
|
|
|
2019-06-05 18:39:46 -04:00
|
|
|
void ConfigureDialog::changeEvent(QEvent* event) {
|
|
|
|
|
if (event->type() == QEvent::LanguageChange) {
|
|
|
|
|
RetranslateUI();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QDialog::changeEvent(event);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ConfigureDialog::RetranslateUI() {
|
|
|
|
|
const int old_row = ui->selectorList->currentRow();
|
|
|
|
|
const int old_index = ui->tabWidget->currentIndex();
|
|
|
|
|
|
|
|
|
|
ui->retranslateUi(this);
|
|
|
|
|
|
|
|
|
|
PopulateSelectionList();
|
|
|
|
|
ui->selectorList->setCurrentRow(old_row);
|
|
|
|
|
|
|
|
|
|
UpdateVisibleTabs();
|
|
|
|
|
ui->tabWidget->setCurrentIndex(old_index);
|
|
|
|
|
}
|
|
|
|
|
|
2021-05-17 16:13:39 -04:00
|
|
|
void ConfigureDialog::HandleApplyButtonClicked() {
|
|
|
|
|
UISettings::values.configuration_applied = true;
|
|
|
|
|
ApplyConfiguration();
|
|
|
|
|
}
|
|
|
|
|
|
2019-08-26 19:11:27 +02:00
|
|
|
Q_DECLARE_METATYPE(QList<QWidget*>);
|
|
|
|
|
|
2018-09-06 19:59:25 +02:00
|
|
|
void ConfigureDialog::PopulateSelectionList() {
|
2020-07-11 14:26:36 +01:00
|
|
|
const std::array<std::pair<QString, QList<QWidget*>>, 6> items{
|
2025-04-23 20:57:53 -04:00
|
|
|
{{tr("General"),
|
|
|
|
|
{general_tab.get(), hotkeys_tab.get(), ui_tab.get(), web_tab.get(), debug_tab_tab.get()}},
|
|
|
|
|
{tr("System"),
|
|
|
|
|
{system_tab.get(), profile_tab.get(), network_tab.get(), filesystem_tab.get(),
|
|
|
|
|
applets_tab.get()}},
|
|
|
|
|
{tr("CPU"), {cpu_tab.get()}},
|
|
|
|
|
{tr("Graphics"), {graphics_tab.get(), graphics_advanced_tab.get(), graphics_extensions_tab.get()}},
|
|
|
|
|
{tr("Audio"), {audio_tab.get()}},
|
|
|
|
|
{tr("Controls"), input_tab->GetSubTabs()}},
|
|
|
|
|
};
|
2018-09-06 19:59:25 +02:00
|
|
|
|
2019-06-05 18:39:46 -04:00
|
|
|
[[maybe_unused]] const QSignalBlocker blocker(ui->selectorList);
|
|
|
|
|
|
|
|
|
|
ui->selectorList->clear();
|
2018-09-06 19:59:25 +02:00
|
|
|
for (const auto& entry : items) {
|
|
|
|
|
auto* const item = new QListWidgetItem(entry.first);
|
2019-08-26 19:11:27 +02:00
|
|
|
item->setData(Qt::UserRole, QVariant::fromValue(entry.second));
|
2018-09-06 19:59:25 +02:00
|
|
|
|
|
|
|
|
ui->selectorList->addItem(item);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-01-26 00:26:07 +01:00
|
|
|
void ConfigureDialog::OnLanguageChanged(const QString& locale) {
|
|
|
|
|
emit LanguageChanged(locale);
|
2022-04-13 13:29:59 -07:00
|
|
|
// Reloading the game list is needed to force retranslation.
|
|
|
|
|
UISettings::values.is_game_list_reload_pending = true;
|
2020-01-26 00:26:07 +01:00
|
|
|
// first apply the configuration, and then restore the display
|
|
|
|
|
ApplyConfiguration();
|
|
|
|
|
RetranslateUI();
|
|
|
|
|
SetConfiguration();
|
|
|
|
|
}
|
|
|
|
|
|
2018-09-06 19:59:25 +02:00
|
|
|
void ConfigureDialog::UpdateVisibleTabs() {
|
|
|
|
|
const auto items = ui->selectorList->selectedItems();
|
2019-06-05 18:39:46 -04:00
|
|
|
if (items.isEmpty()) {
|
2018-09-06 19:59:25 +02:00
|
|
|
return;
|
2019-06-05 18:39:46 -04:00
|
|
|
}
|
2018-09-06 19:59:25 +02:00
|
|
|
|
2019-06-05 18:39:46 -04:00
|
|
|
[[maybe_unused]] const QSignalBlocker blocker(ui->tabWidget);
|
2018-09-06 19:59:25 +02:00
|
|
|
|
|
|
|
|
ui->tabWidget->clear();
|
2019-08-26 19:11:27 +02:00
|
|
|
|
2021-01-14 03:04:20 -05:00
|
|
|
const auto tabs = qvariant_cast<QList<QWidget*>>(items[0]->data(Qt::UserRole));
|
2019-08-26 19:11:27 +02:00
|
|
|
|
2021-01-14 03:04:20 -05:00
|
|
|
for (auto* const tab : tabs) {
|
2021-09-02 21:40:55 -04:00
|
|
|
LOG_DEBUG(Frontend, "{}", tab->accessibleName().toStdString());
|
2020-07-22 10:39:53 -04:00
|
|
|
ui->tabWidget->addTab(tab, tab->accessibleName());
|
2019-06-05 18:39:46 -04:00
|
|
|
}
|
2018-09-06 19:59:25 +02:00
|
|
|
}
|