2016-01-24 17:34:05 +00:00
|
|
|
// Copyright 2016 Citra Emulator Project
|
|
|
|
// Licensed under GPLv2 or any later version
|
|
|
|
// Refer to the license.txt file included.
|
|
|
|
|
2019-02-05 21:07:03 +00:00
|
|
|
#include <map>
|
2018-09-06 18:59:25 +01:00
|
|
|
#include <QListWidgetItem>
|
2023-08-01 23:40:39 +01:00
|
|
|
#include "citra_qt/configuration/configure_audio.h"
|
|
|
|
#include "citra_qt/configuration/configure_camera.h"
|
|
|
|
#include "citra_qt/configuration/configure_debug.h"
|
2016-12-22 04:49:36 +00:00
|
|
|
#include "citra_qt/configuration/configure_dialog.h"
|
2023-08-01 23:40:39 +01:00
|
|
|
#include "citra_qt/configuration/configure_enhancements.h"
|
|
|
|
#include "citra_qt/configuration/configure_general.h"
|
|
|
|
#include "citra_qt/configuration/configure_graphics.h"
|
|
|
|
#include "citra_qt/configuration/configure_hotkeys.h"
|
|
|
|
#include "citra_qt/configuration/configure_input.h"
|
|
|
|
#include "citra_qt/configuration/configure_storage.h"
|
|
|
|
#include "citra_qt/configuration/configure_system.h"
|
|
|
|
#include "citra_qt/configuration/configure_ui.h"
|
|
|
|
#include "citra_qt/configuration/configure_web.h"
|
2018-08-07 05:43:07 +01:00
|
|
|
#include "citra_qt/hotkeys.h"
|
2022-12-08 11:27:25 +00:00
|
|
|
#include "common/settings.h"
|
2023-06-30 11:39:38 +01:00
|
|
|
#include "core/core.h"
|
2016-09-20 16:21:23 +01:00
|
|
|
#include "ui_configure.h"
|
2016-01-24 17:34:05 +00:00
|
|
|
|
2023-06-30 11:39:38 +01:00
|
|
|
ConfigureDialog::ConfigureDialog(QWidget* parent, HotkeyRegistry& registry_, Core::System& system_,
|
2023-09-12 23:28:50 +01:00
|
|
|
std::span<const QString> physical_devices, bool enable_web_config)
|
2023-06-30 11:39:38 +01:00
|
|
|
: QDialog(parent), ui{std::make_unique<Ui::ConfigureDialog>()}, registry{registry_},
|
2023-08-01 23:40:39 +01:00
|
|
|
system{system_}, is_powered_on{system.IsPoweredOn()},
|
|
|
|
general_tab{std::make_unique<ConfigureGeneral>(this)},
|
|
|
|
system_tab{std::make_unique<ConfigureSystem>(system, this)},
|
|
|
|
input_tab{std::make_unique<ConfigureInput>(this)},
|
|
|
|
hotkeys_tab{std::make_unique<ConfigureHotkeys>(this)},
|
2023-09-12 23:28:50 +01:00
|
|
|
graphics_tab{std::make_unique<ConfigureGraphics>(physical_devices, is_powered_on, this)},
|
2023-08-01 23:40:39 +01:00
|
|
|
enhancements_tab{std::make_unique<ConfigureEnhancements>(this)},
|
|
|
|
audio_tab{std::make_unique<ConfigureAudio>(is_powered_on, this)},
|
|
|
|
camera_tab{std::make_unique<ConfigureCamera>(this)},
|
|
|
|
debug_tab{std::make_unique<ConfigureDebug>(is_powered_on, this)},
|
|
|
|
storage_tab{std::make_unique<ConfigureStorage>(is_powered_on, this)},
|
|
|
|
web_tab{std::make_unique<ConfigureWeb>(this)}, ui_tab{std::make_unique<ConfigureUi>(this)} {
|
2022-12-08 11:27:25 +00:00
|
|
|
Settings::SetConfiguringGlobal(true);
|
|
|
|
|
2016-01-24 17:34:05 +00:00
|
|
|
ui->setupUi(this);
|
2023-08-01 23:40:39 +01:00
|
|
|
|
|
|
|
ui->tabWidget->addTab(general_tab.get(), tr("General"));
|
|
|
|
ui->tabWidget->addTab(system_tab.get(), tr("System"));
|
|
|
|
ui->tabWidget->addTab(input_tab.get(), tr("Input"));
|
|
|
|
ui->tabWidget->addTab(hotkeys_tab.get(), tr("Hotkeys"));
|
|
|
|
ui->tabWidget->addTab(graphics_tab.get(), tr("Graphics"));
|
|
|
|
ui->tabWidget->addTab(enhancements_tab.get(), tr("Enhancements"));
|
|
|
|
ui->tabWidget->addTab(audio_tab.get(), tr("Audio"));
|
|
|
|
ui->tabWidget->addTab(camera_tab.get(), tr("Camera"));
|
|
|
|
ui->tabWidget->addTab(debug_tab.get(), tr("Debug"));
|
|
|
|
ui->tabWidget->addTab(storage_tab.get(), tr("Storage"));
|
|
|
|
ui->tabWidget->addTab(web_tab.get(), tr("Web"));
|
|
|
|
ui->tabWidget->addTab(ui_tab.get(), tr("UI"));
|
|
|
|
|
|
|
|
hotkeys_tab->Populate(registry);
|
|
|
|
web_tab->SetWebServiceConfigEnabled(enable_web_config);
|
2018-05-22 20:30:36 +01:00
|
|
|
|
2019-05-26 05:39:23 +01:00
|
|
|
PopulateSelectionList();
|
2019-05-09 08:20:13 +01:00
|
|
|
|
2023-08-01 23:40:39 +01:00
|
|
|
connect(ui_tab.get(), &ConfigureUi::LanguageChanged, this, &ConfigureDialog::OnLanguageChanged);
|
2018-09-06 18:59:25 +01:00
|
|
|
connect(ui->selectorList, &QListWidget::itemSelectionChanged, this,
|
|
|
|
&ConfigureDialog::UpdateVisibleTabs);
|
2019-05-09 08:20:13 +01:00
|
|
|
|
2018-09-06 18:59:25 +01:00
|
|
|
adjustSize();
|
|
|
|
ui->selectorList->setCurrentRow(0);
|
2018-05-22 20:30:36 +01:00
|
|
|
|
2018-11-16 16:34:00 +00:00
|
|
|
// Set up used key list synchronisation
|
2023-08-01 23:40:39 +01:00
|
|
|
connect(input_tab.get(), &ConfigureInput::InputKeysChanged, hotkeys_tab.get(),
|
2018-05-22 20:30:36 +01:00
|
|
|
&ConfigureHotkeys::OnInputKeysChanged);
|
2023-08-01 23:40:39 +01:00
|
|
|
connect(hotkeys_tab.get(), &ConfigureHotkeys::HotkeysChanged, input_tab.get(),
|
2018-05-22 20:30:36 +01:00
|
|
|
&ConfigureInput::OnHotkeysChanged);
|
|
|
|
|
|
|
|
// Synchronise lists upon initialisation
|
2023-08-01 23:40:39 +01:00
|
|
|
input_tab->EmitInputKeysChanged();
|
|
|
|
hotkeys_tab->EmitHotkeysChanged();
|
2016-01-24 17:34:05 +00:00
|
|
|
}
|
|
|
|
|
2018-08-24 16:14:09 +01:00
|
|
|
ConfigureDialog::~ConfigureDialog() = default;
|
2016-01-24 17:34:05 +00:00
|
|
|
|
2019-05-26 05:39:23 +01:00
|
|
|
void ConfigureDialog::SetConfiguration() {
|
2023-08-01 23:40:39 +01:00
|
|
|
general_tab->SetConfiguration();
|
|
|
|
system_tab->SetConfiguration();
|
|
|
|
input_tab->LoadConfiguration();
|
|
|
|
graphics_tab->SetConfiguration();
|
|
|
|
enhancements_tab->SetConfiguration();
|
|
|
|
audio_tab->SetConfiguration();
|
|
|
|
camera_tab->SetConfiguration();
|
|
|
|
debug_tab->SetConfiguration();
|
|
|
|
web_tab->SetConfiguration();
|
|
|
|
ui_tab->SetConfiguration();
|
|
|
|
storage_tab->SetConfiguration();
|
2018-11-02 14:40:58 +00:00
|
|
|
}
|
2016-01-24 17:34:05 +00:00
|
|
|
|
2019-05-26 05:39:23 +01:00
|
|
|
void ConfigureDialog::ApplyConfiguration() {
|
2023-08-01 23:40:39 +01:00
|
|
|
general_tab->ApplyConfiguration();
|
|
|
|
system_tab->ApplyConfiguration();
|
|
|
|
input_tab->ApplyConfiguration();
|
|
|
|
input_tab->ApplyProfile();
|
|
|
|
hotkeys_tab->ApplyConfiguration(registry);
|
|
|
|
graphics_tab->ApplyConfiguration();
|
|
|
|
enhancements_tab->ApplyConfiguration();
|
|
|
|
audio_tab->ApplyConfiguration();
|
|
|
|
camera_tab->ApplyConfiguration();
|
|
|
|
debug_tab->ApplyConfiguration();
|
|
|
|
web_tab->ApplyConfiguration();
|
|
|
|
ui_tab->ApplyConfiguration();
|
|
|
|
storage_tab->ApplyConfiguration();
|
2023-06-30 11:39:38 +01:00
|
|
|
system.ApplySettings();
|
2018-07-18 00:39:41 +01:00
|
|
|
Settings::LogSettings();
|
2016-01-24 17:34:05 +00:00
|
|
|
}
|
2017-09-23 14:13:59 +01:00
|
|
|
|
2019-08-10 08:00:56 +01:00
|
|
|
Q_DECLARE_METATYPE(QList<QWidget*>);
|
|
|
|
|
2018-09-06 18:59:25 +01:00
|
|
|
void ConfigureDialog::PopulateSelectionList() {
|
2018-11-02 14:40:58 +00:00
|
|
|
ui->selectorList->clear();
|
2018-09-06 18:59:25 +01:00
|
|
|
|
2020-02-01 15:04:48 +00:00
|
|
|
const std::array<std::pair<QString, QList<QWidget*>>, 5> items{
|
2023-08-01 23:40:39 +01:00
|
|
|
{{tr("General"), {general_tab.get(), web_tab.get(), debug_tab.get(), ui_tab.get()}},
|
|
|
|
{tr("System"), {system_tab.get(), camera_tab.get(), storage_tab.get()}},
|
|
|
|
{tr("Graphics"), {enhancements_tab.get(), graphics_tab.get()}},
|
|
|
|
{tr("Audio"), {audio_tab.get()}},
|
|
|
|
{tr("Controls"), {input_tab.get(), hotkeys_tab.get()}}}};
|
2018-09-06 18:59:25 +01:00
|
|
|
|
|
|
|
for (const auto& entry : items) {
|
2019-02-05 21:07:03 +00:00
|
|
|
auto* const item = new QListWidgetItem(entry.first);
|
2019-08-10 08:00:56 +01:00
|
|
|
item->setData(Qt::UserRole, QVariant::fromValue(entry.second));
|
2018-09-06 18:59:25 +01:00
|
|
|
|
|
|
|
ui->selectorList->addItem(item);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-05-26 05:39:23 +01:00
|
|
|
void ConfigureDialog::OnLanguageChanged(const QString& locale) {
|
|
|
|
emit LanguageChanged(locale);
|
2018-11-02 14:40:58 +00:00
|
|
|
// first apply the configuration, and then restore the display
|
2019-05-26 05:39:23 +01:00
|
|
|
ApplyConfiguration();
|
|
|
|
RetranslateUI();
|
|
|
|
SetConfiguration();
|
2018-11-02 14:40:58 +00:00
|
|
|
}
|
|
|
|
|
2019-05-26 05:39:23 +01:00
|
|
|
void ConfigureDialog::RetranslateUI() {
|
2018-11-02 14:40:58 +00:00
|
|
|
int old_row = ui->selectorList->currentRow();
|
|
|
|
int old_index = ui->tabWidget->currentIndex();
|
2017-09-23 14:13:59 +01:00
|
|
|
ui->retranslateUi(this);
|
2018-11-02 14:40:58 +00:00
|
|
|
PopulateSelectionList();
|
|
|
|
// restore selection after repopulating
|
|
|
|
ui->selectorList->setCurrentRow(old_row);
|
|
|
|
ui->tabWidget->setCurrentIndex(old_index);
|
|
|
|
|
2023-08-01 23:40:39 +01:00
|
|
|
general_tab->RetranslateUI();
|
|
|
|
system_tab->RetranslateUI();
|
|
|
|
input_tab->RetranslateUI();
|
|
|
|
hotkeys_tab->RetranslateUI();
|
|
|
|
graphics_tab->RetranslateUI();
|
|
|
|
enhancements_tab->RetranslateUI();
|
|
|
|
audio_tab->RetranslateUI();
|
|
|
|
camera_tab->RetranslateUI();
|
|
|
|
debug_tab->RetranslateUI();
|
|
|
|
web_tab->RetranslateUI();
|
|
|
|
ui_tab->RetranslateUI();
|
|
|
|
storage_tab->RetranslateUI();
|
2017-09-23 14:13:59 +01:00
|
|
|
}
|
2018-09-06 18:59:25 +01:00
|
|
|
|
|
|
|
void ConfigureDialog::UpdateVisibleTabs() {
|
2019-02-05 21:07:03 +00:00
|
|
|
const auto items = ui->selectorList->selectedItems();
|
2018-09-06 18:59:25 +01:00
|
|
|
if (items.isEmpty())
|
|
|
|
return;
|
|
|
|
|
2023-08-01 23:40:39 +01:00
|
|
|
const std::map<QWidget*, QString> widgets = {{general_tab.get(), tr("General")},
|
|
|
|
{system_tab.get(), tr("System")},
|
|
|
|
{input_tab.get(), tr("Input")},
|
|
|
|
{hotkeys_tab.get(), tr("Hotkeys")},
|
|
|
|
{enhancements_tab.get(), tr("Enhancements")},
|
|
|
|
{graphics_tab.get(), tr("Advanced")},
|
|
|
|
{audio_tab.get(), tr("Audio")},
|
|
|
|
{camera_tab.get(), tr("Camera")},
|
|
|
|
{debug_tab.get(), tr("Debug")},
|
|
|
|
{storage_tab.get(), tr("Storage")},
|
|
|
|
{web_tab.get(), tr("Web")},
|
|
|
|
{ui_tab.get(), tr("UI")}};
|
2018-09-06 18:59:25 +01:00
|
|
|
|
|
|
|
ui->tabWidget->clear();
|
|
|
|
|
2019-08-10 08:00:56 +01:00
|
|
|
const QList<QWidget*> tabs = qvariant_cast<QList<QWidget*>>(items[0]->data(Qt::UserRole));
|
2018-09-06 18:59:25 +01:00
|
|
|
|
2019-08-10 08:00:56 +01:00
|
|
|
for (const auto tab : tabs)
|
|
|
|
ui->tabWidget->addTab(tab, widgets.at(tab));
|
2018-09-06 18:59:25 +01:00
|
|
|
}
|