yuzu/configuration: create UI tab and move gamelist settings there

This commit is contained in:
FearlessTobi 2020-01-24 00:15:51 +01:00
parent a167da4278
commit d0e4f1c6f4
8 changed files with 76 additions and 104 deletions

View file

@ -36,9 +36,6 @@ add_executable(yuzu
configuration/configure_filesystem.cpp configuration/configure_filesystem.cpp
configuration/configure_filesystem.h configuration/configure_filesystem.h
configuration/configure_filesystem.ui configuration/configure_filesystem.ui
configuration/configure_gamelist.cpp
configuration/configure_gamelist.h
configuration/configure_gamelist.ui
configuration/configure_general.cpp configuration/configure_general.cpp
configuration/configure_general.h configuration/configure_general.h
configuration/configure_general.ui configuration/configure_general.ui
@ -75,6 +72,9 @@ add_executable(yuzu
configuration/configure_touchscreen_advanced.cpp configuration/configure_touchscreen_advanced.cpp
configuration/configure_touchscreen_advanced.h configuration/configure_touchscreen_advanced.h
configuration/configure_touchscreen_advanced.ui configuration/configure_touchscreen_advanced.ui
configuration/configure_ui.cpp
configuration/configure_ui.h
configuration/configure_ui.ui
configuration/configure_web.cpp configuration/configure_web.cpp
configuration/configure_web.h configuration/configure_web.h
configuration/configure_web.ui configuration/configure_web.ui

View file

@ -48,7 +48,7 @@
<string>General</string> <string>General</string>
</attribute> </attribute>
</widget> </widget>
<widget class="ConfigureGameList" name="gameListTab"> <widget class="ConfigureUi" name="uiTab">
<attribute name="title"> <attribute name="title">
<string>Game List</string> <string>Game List</string>
</attribute> </attribute>
@ -166,9 +166,9 @@
<container>1</container> <container>1</container>
</customwidget> </customwidget>
<customwidget> <customwidget>
<class>ConfigureGameList</class> <class>ConfigureUi</class>
<extends>QWidget</extends> <extends>QWidget</extends>
<header>configuration/configure_gamelist.h</header> <header>configuration/configure_ui.h</header>
<container>1</container> <container>1</container>
</customwidget> </customwidget>
<customwidget> <customwidget>

View file

@ -34,7 +34,7 @@ void ConfigureDialog::SetConfiguration() {}
void ConfigureDialog::ApplyConfiguration() { void ConfigureDialog::ApplyConfiguration() {
ui->generalTab->ApplyConfiguration(); ui->generalTab->ApplyConfiguration();
ui->gameListTab->ApplyConfiguration(); ui->uiTab->ApplyConfiguration();
ui->systemTab->ApplyConfiguration(); ui->systemTab->ApplyConfiguration();
ui->profileManagerTab->ApplyConfiguration(); ui->profileManagerTab->ApplyConfiguration();
ui->filesystemTab->applyConfiguration(); ui->filesystemTab->applyConfiguration();
@ -74,7 +74,7 @@ Q_DECLARE_METATYPE(QList<QWidget*>);
void ConfigureDialog::PopulateSelectionList() { void ConfigureDialog::PopulateSelectionList() {
const std::array<std::pair<QString, QList<QWidget*>>, 5> items{ const std::array<std::pair<QString, QList<QWidget*>>, 5> items{
{{tr("General"), {ui->generalTab, ui->webTab, ui->debugTab, ui->gameListTab}}, {{tr("General"), {ui->generalTab, ui->webTab, ui->debugTab, ui->uiTab}},
{tr("System"), {ui->systemTab, ui->profileManagerTab, ui->serviceTab, ui->filesystemTab}}, {tr("System"), {ui->systemTab, ui->profileManagerTab, ui->serviceTab, ui->filesystemTab}},
{tr("Graphics"), {ui->graphicsTab}}, {tr("Graphics"), {ui->graphicsTab}},
{tr("Audio"), {ui->audioTab}}, {tr("Audio"), {ui->audioTab}},
@ -108,7 +108,7 @@ void ConfigureDialog::UpdateVisibleTabs() {
{ui->audioTab, tr("Audio")}, {ui->audioTab, tr("Audio")},
{ui->debugTab, tr("Debug")}, {ui->debugTab, tr("Debug")},
{ui->webTab, tr("Web")}, {ui->webTab, tr("Web")},
{ui->gameListTab, tr("Game List")}, {ui->uiTab, tr("UI")},
{ui->filesystemTab, tr("Filesystem")}, {ui->filesystemTab, tr("Filesystem")},
{ui->serviceTab, tr("Services")}, {ui->serviceTab, tr("Services")},
}; };

View file

@ -15,11 +15,6 @@ ConfigureGeneral::ConfigureGeneral(QWidget* parent)
ui->setupUi(this); ui->setupUi(this);
for (const auto& theme : UISettings::themes) {
ui->theme_combobox->addItem(QString::fromUtf8(theme.first),
QString::fromUtf8(theme.second));
}
SetConfiguration(); SetConfiguration();
connect(ui->toggle_frame_limit, &QCheckBox::toggled, ui->frame_limit, &QSpinBox::setEnabled); connect(ui->toggle_frame_limit, &QCheckBox::toggled, ui->frame_limit, &QSpinBox::setEnabled);
@ -30,7 +25,6 @@ ConfigureGeneral::~ConfigureGeneral() = default;
void ConfigureGeneral::SetConfiguration() { void ConfigureGeneral::SetConfiguration() {
ui->toggle_check_exit->setChecked(UISettings::values.confirm_before_closing); ui->toggle_check_exit->setChecked(UISettings::values.confirm_before_closing);
ui->toggle_user_on_boot->setChecked(UISettings::values.select_user_on_boot); ui->toggle_user_on_boot->setChecked(UISettings::values.select_user_on_boot);
ui->theme_combobox->setCurrentIndex(ui->theme_combobox->findData(UISettings::values.theme));
ui->toggle_background_pause->setChecked(UISettings::values.pause_when_in_background); ui->toggle_background_pause->setChecked(UISettings::values.pause_when_in_background);
ui->toggle_frame_limit->setChecked(Settings::values.use_frame_limit); ui->toggle_frame_limit->setChecked(Settings::values.use_frame_limit);
@ -41,8 +35,6 @@ void ConfigureGeneral::SetConfiguration() {
void ConfigureGeneral::ApplyConfiguration() { void ConfigureGeneral::ApplyConfiguration() {
UISettings::values.confirm_before_closing = ui->toggle_check_exit->isChecked(); UISettings::values.confirm_before_closing = ui->toggle_check_exit->isChecked();
UISettings::values.select_user_on_boot = ui->toggle_user_on_boot->isChecked(); UISettings::values.select_user_on_boot = ui->toggle_user_on_boot->isChecked();
UISettings::values.theme =
ui->theme_combobox->itemData(ui->theme_combobox->currentIndex()).toString();
UISettings::values.pause_when_in_background = ui->toggle_background_pause->isChecked(); UISettings::values.pause_when_in_background = ui->toggle_background_pause->isChecked();
Settings::values.use_frame_limit = ui->toggle_frame_limit->isChecked(); Settings::values.use_frame_limit = ui->toggle_frame_limit->isChecked();

View file

@ -65,39 +65,12 @@
</property> </property>
</widget> </widget>
</item> </item>
<item>
<widget class="QCheckBox" name="toggle_background_pause">
<property name="text">
<string>Pause emulation when in background</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="theme_group_box">
<property name="title">
<string>Theme</string>
</property>
<layout class="QHBoxLayout" name="theme_qhbox_layout">
<item>
<layout class="QVBoxLayout" name="theme_qvbox_layout">
<item> <item>
<layout class="QHBoxLayout" name="theme_qhbox_layout_2"> <widget class="QCheckBox" name="toggle_background_pause">
<item> <property name="text">
<widget class="QLabel" name="theme_label"> <string>Pause emulation when in background</string>
<property name="text"> </property>
<string>Theme:</string> </widget>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="theme_combobox"/>
</item>
</layout>
</item> </item>
</layout> </layout>
</item> </item>

View file

@ -7,8 +7,8 @@
#include "common/common_types.h" #include "common/common_types.h"
#include "core/settings.h" #include "core/settings.h"
#include "ui_configure_gamelist.h" #include "ui_configure_ui.h"
#include "yuzu/configuration/configure_gamelist.h" #include "yuzu/configuration/configure_ui.h"
#include "yuzu/uisettings.h" #include "yuzu/uisettings.h"
namespace { namespace {
@ -26,35 +26,40 @@ constexpr std::array row_text_names{
}; };
} // Anonymous namespace } // Anonymous namespace
ConfigureGameList::ConfigureGameList(QWidget* parent) ConfigureUi::ConfigureUi(QWidget* parent) : QWidget(parent), ui(new Ui::ConfigureUi) {
: QWidget(parent), ui(new Ui::ConfigureGameList) {
ui->setupUi(this); ui->setupUi(this);
for (const auto& theme : UISettings::themes) {
ui->theme_combobox->addItem(QString::fromUtf8(theme.first),
QString::fromUtf8(theme.second));
}
InitializeIconSizeComboBox(); InitializeIconSizeComboBox();
InitializeRowComboBoxes(); InitializeRowComboBoxes();
SetConfiguration(); SetConfiguration();
// Force game list reload if any of the relevant settings are changed. // Force game list reload if any of the relevant settings are changed.
connect(ui->show_unknown, &QCheckBox::stateChanged, this, connect(ui->show_unknown, &QCheckBox::stateChanged, this, &ConfigureUi::RequestGameListUpdate);
&ConfigureGameList::RequestGameListUpdate);
connect(ui->icon_size_combobox, QOverload<int>::of(&QComboBox::currentIndexChanged), this, connect(ui->icon_size_combobox, QOverload<int>::of(&QComboBox::currentIndexChanged), this,
&ConfigureGameList::RequestGameListUpdate); &ConfigureUi::RequestGameListUpdate);
connect(ui->row_1_text_combobox, QOverload<int>::of(&QComboBox::currentIndexChanged), this, connect(ui->row_1_text_combobox, QOverload<int>::of(&QComboBox::currentIndexChanged), this,
&ConfigureGameList::RequestGameListUpdate); &ConfigureUi::RequestGameListUpdate);
connect(ui->row_2_text_combobox, QOverload<int>::of(&QComboBox::currentIndexChanged), this, connect(ui->row_2_text_combobox, QOverload<int>::of(&QComboBox::currentIndexChanged), this,
&ConfigureGameList::RequestGameListUpdate); &ConfigureUi::RequestGameListUpdate);
// Update text ComboBoxes after user interaction. // Update text ComboBoxes after user interaction.
connect(ui->row_1_text_combobox, QOverload<int>::of(&QComboBox::activated), connect(ui->row_1_text_combobox, QOverload<int>::of(&QComboBox::activated),
[=]() { ConfigureGameList::UpdateSecondRowComboBox(); }); [=]() { ConfigureUi::UpdateSecondRowComboBox(); });
connect(ui->row_2_text_combobox, QOverload<int>::of(&QComboBox::activated), connect(ui->row_2_text_combobox, QOverload<int>::of(&QComboBox::activated),
[=]() { ConfigureGameList::UpdateFirstRowComboBox(); }); [=]() { ConfigureUi::UpdateFirstRowComboBox(); });
} }
ConfigureGameList::~ConfigureGameList() = default; ConfigureUi::~ConfigureUi() = default;
void ConfigureGameList::ApplyConfiguration() { void ConfigureUi::ApplyConfiguration() {
UISettings::values.theme =
ui->theme_combobox->itemData(ui->theme_combobox->currentIndex()).toString();
UISettings::values.show_unknown = ui->show_unknown->isChecked(); UISettings::values.show_unknown = ui->show_unknown->isChecked();
UISettings::values.show_add_ons = ui->show_add_ons->isChecked(); UISettings::values.show_add_ons = ui->show_add_ons->isChecked();
UISettings::values.icon_size = ui->icon_size_combobox->currentData().toUInt(); UISettings::values.icon_size = ui->icon_size_combobox->currentData().toUInt();
@ -63,18 +68,19 @@ void ConfigureGameList::ApplyConfiguration() {
Settings::Apply(); Settings::Apply();
} }
void ConfigureGameList::RequestGameListUpdate() { void ConfigureUi::RequestGameListUpdate() {
UISettings::values.is_game_list_reload_pending.exchange(true); UISettings::values.is_game_list_reload_pending.exchange(true);
} }
void ConfigureGameList::SetConfiguration() { void ConfigureUi::SetConfiguration() {
ui->theme_combobox->setCurrentIndex(ui->theme_combobox->findData(UISettings::values.theme));
ui->show_unknown->setChecked(UISettings::values.show_unknown); ui->show_unknown->setChecked(UISettings::values.show_unknown);
ui->show_add_ons->setChecked(UISettings::values.show_add_ons); ui->show_add_ons->setChecked(UISettings::values.show_add_ons);
ui->icon_size_combobox->setCurrentIndex( ui->icon_size_combobox->setCurrentIndex(
ui->icon_size_combobox->findData(UISettings::values.icon_size)); ui->icon_size_combobox->findData(UISettings::values.icon_size));
} }
void ConfigureGameList::changeEvent(QEvent* event) { void ConfigureUi::changeEvent(QEvent* event) {
if (event->type() == QEvent::LanguageChange) { if (event->type() == QEvent::LanguageChange) {
RetranslateUI(); RetranslateUI();
} }
@ -82,7 +88,7 @@ void ConfigureGameList::changeEvent(QEvent* event) {
QWidget::changeEvent(event); QWidget::changeEvent(event);
} }
void ConfigureGameList::RetranslateUI() { void ConfigureUi::RetranslateUI() {
ui->retranslateUi(this); ui->retranslateUi(this);
for (int i = 0; i < ui->icon_size_combobox->count(); i++) { for (int i = 0; i < ui->icon_size_combobox->count(); i++) {
@ -97,18 +103,18 @@ void ConfigureGameList::RetranslateUI() {
} }
} }
void ConfigureGameList::InitializeIconSizeComboBox() { void ConfigureUi::InitializeIconSizeComboBox() {
for (const auto& size : default_icon_sizes) { for (const auto& size : default_icon_sizes) {
ui->icon_size_combobox->addItem(QString::fromUtf8(size.second), size.first); ui->icon_size_combobox->addItem(QString::fromUtf8(size.second), size.first);
} }
} }
void ConfigureGameList::InitializeRowComboBoxes() { void ConfigureUi::InitializeRowComboBoxes() {
UpdateFirstRowComboBox(true); UpdateFirstRowComboBox(true);
UpdateSecondRowComboBox(true); UpdateSecondRowComboBox(true);
} }
void ConfigureGameList::UpdateFirstRowComboBox(bool init) { void ConfigureUi::UpdateFirstRowComboBox(bool init) {
const int currentIndex = const int currentIndex =
init ? UISettings::values.row_1_text_id init ? UISettings::values.row_1_text_id
: ui->row_1_text_combobox->findData(ui->row_1_text_combobox->currentData()); : ui->row_1_text_combobox->findData(ui->row_1_text_combobox->currentData());
@ -127,7 +133,7 @@ void ConfigureGameList::UpdateFirstRowComboBox(bool init) {
ui->row_1_text_combobox->findData(ui->row_2_text_combobox->currentData())); ui->row_1_text_combobox->findData(ui->row_2_text_combobox->currentData()));
} }
void ConfigureGameList::UpdateSecondRowComboBox(bool init) { void ConfigureUi::UpdateSecondRowComboBox(bool init) {
const int currentIndex = const int currentIndex =
init ? UISettings::values.row_2_text_id init ? UISettings::values.row_2_text_id
: ui->row_2_text_combobox->findData(ui->row_2_text_combobox->currentData()); : ui->row_2_text_combobox->findData(ui->row_2_text_combobox->currentData());

View file

@ -8,15 +8,15 @@
#include <QWidget> #include <QWidget>
namespace Ui { namespace Ui {
class ConfigureGameList; class ConfigureUi;
} }
class ConfigureGameList : public QWidget { class ConfigureUi : public QWidget {
Q_OBJECT Q_OBJECT
public: public:
explicit ConfigureGameList(QWidget* parent = nullptr); explicit ConfigureUi(QWidget* parent = nullptr);
~ConfigureGameList() override; ~ConfigureUi() override;
void ApplyConfiguration(); void ApplyConfiguration();
@ -34,5 +34,5 @@ private:
void UpdateFirstRowComboBox(bool init = false); void UpdateFirstRowComboBox(bool init = false);
void UpdateSecondRowComboBox(bool init = false); void UpdateSecondRowComboBox(bool init = false);
std::unique_ptr<Ui::ConfigureGameList> ui; std::unique_ptr<Ui::ConfigureUi> ui;
}; };

View file

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0"> <ui version="4.0">
<class>ConfigureGameList</class> <class>ConfigureUi</class>
<widget class="QWidget" name="ConfigureGameList"> <widget class="QWidget" name="ConfigureUi">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>0</x> <x>0</x>
@ -21,7 +21,34 @@
<property name="title"> <property name="title">
<string>General</string> <string>General</string>
</property> </property>
<layout class="QHBoxLayout" name="GeneralHorizontalLayout"> <layout class="QHBoxLayout" name="horizontalLayout">
<item>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QLabel" name="theme_label">
<property name="text">
<string>Theme:</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="theme_combobox"/>
</item>
</layout>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="GameListGroupBox">
<property name="title">
<string>Game List</string>
</property>
<layout class="QHBoxLayout" name="GameListHorizontalLayout">
<item> <item>
<layout class="QVBoxLayout" name="GeneralVerticalLayout"> <layout class="QVBoxLayout" name="GeneralVerticalLayout">
<item> <item>
@ -38,19 +65,6 @@
</property> </property>
</widget> </widget>
</item> </item>
</layout>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="IconSizeGroupBox">
<property name="title">
<string>Icon Size</string>
</property>
<layout class="QHBoxLayout" name="icon_size_qhbox_layout">
<item>
<layout class="QVBoxLayout" name="icon_size_qvbox_layout">
<item> <item>
<layout class="QHBoxLayout" name="icon_size_qhbox_layout_2"> <layout class="QHBoxLayout" name="icon_size_qhbox_layout_2">
<item> <item>
@ -65,19 +79,6 @@
</item> </item>
</layout> </layout>
</item> </item>
</layout>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="RowGroupBox">
<property name="title">
<string>Row Text</string>
</property>
<layout class="QHBoxLayout" name="RowHorizontalLayout">
<item>
<layout class="QVBoxLayout" name="RowVerticalLayout">
<item> <item>
<layout class="QHBoxLayout" name="row_1_qhbox_layout"> <layout class="QHBoxLayout" name="row_1_qhbox_layout">
<item> <item>