2018-07-28 18:32:16 +02:00
|
|
|
// Copyright 2016 Citra Emulator Project
|
|
|
|
// Licensed under GPLv2 or any later version
|
|
|
|
// Refer to the license.txt file included.
|
|
|
|
|
2018-09-12 07:09:25 +02:00
|
|
|
#include <array>
|
|
|
|
#include <utility>
|
|
|
|
|
|
|
|
#include "common/common_types.h"
|
2018-07-28 18:32:16 +02:00
|
|
|
#include "core/settings.h"
|
|
|
|
#include "ui_configure_gamelist.h"
|
|
|
|
#include "yuzu/configuration/configure_gamelist.h"
|
2019-07-29 22:06:33 +02:00
|
|
|
#include "yuzu/uisettings.h"
|
2018-07-28 18:32:16 +02:00
|
|
|
|
2018-09-12 07:11:25 +02:00
|
|
|
namespace {
|
2019-05-26 06:39:23 +02:00
|
|
|
constexpr std::array default_icon_sizes{
|
2018-09-12 07:11:25 +02:00
|
|
|
std::make_pair(0, QT_TR_NOOP("None")),
|
|
|
|
std::make_pair(32, QT_TR_NOOP("Small (32x32)")),
|
|
|
|
std::make_pair(64, QT_TR_NOOP("Standard (64x64)")),
|
|
|
|
std::make_pair(128, QT_TR_NOOP("Large (128x128)")),
|
|
|
|
std::make_pair(256, QT_TR_NOOP("Full Size (256x256)")),
|
2019-05-26 06:39:23 +02:00
|
|
|
};
|
2018-09-12 07:11:25 +02:00
|
|
|
|
2019-05-26 06:39:23 +02:00
|
|
|
constexpr std::array row_text_names{
|
2020-01-19 21:56:49 +01:00
|
|
|
QT_TR_NOOP("Filename"), QT_TR_NOOP("Filetype"), QT_TR_NOOP("Title ID"),
|
|
|
|
QT_TR_NOOP("Title Name"), QT_TR_NOOP("None"),
|
2019-05-26 06:39:23 +02:00
|
|
|
};
|
2018-09-12 07:11:25 +02:00
|
|
|
} // Anonymous namespace
|
|
|
|
|
2018-07-28 18:32:16 +02:00
|
|
|
ConfigureGameList::ConfigureGameList(QWidget* parent)
|
|
|
|
: QWidget(parent), ui(new Ui::ConfigureGameList) {
|
|
|
|
ui->setupUi(this);
|
|
|
|
|
2018-09-12 07:06:50 +02:00
|
|
|
InitializeIconSizeComboBox();
|
|
|
|
InitializeRowComboBoxes();
|
|
|
|
|
2019-05-26 06:39:23 +02:00
|
|
|
SetConfiguration();
|
2018-11-04 01:38:39 +01:00
|
|
|
|
|
|
|
// Force game list reload if any of the relevant settings are changed.
|
|
|
|
connect(ui->show_unknown, &QCheckBox::stateChanged, this,
|
|
|
|
&ConfigureGameList::RequestGameListUpdate);
|
|
|
|
connect(ui->icon_size_combobox, QOverload<int>::of(&QComboBox::currentIndexChanged), this,
|
|
|
|
&ConfigureGameList::RequestGameListUpdate);
|
|
|
|
connect(ui->row_1_text_combobox, QOverload<int>::of(&QComboBox::currentIndexChanged), this,
|
|
|
|
&ConfigureGameList::RequestGameListUpdate);
|
|
|
|
connect(ui->row_2_text_combobox, QOverload<int>::of(&QComboBox::currentIndexChanged), this,
|
|
|
|
&ConfigureGameList::RequestGameListUpdate);
|
2020-01-19 21:56:49 +01:00
|
|
|
|
|
|
|
// Update text ComboBoxes after user interaction.
|
|
|
|
connect(ui->row_1_text_combobox, QOverload<int>::of(&QComboBox::activated),
|
|
|
|
[=]() { ConfigureGameList::UpdateSecondRowComboBox(); });
|
|
|
|
connect(ui->row_2_text_combobox, QOverload<int>::of(&QComboBox::activated),
|
|
|
|
[=]() { ConfigureGameList::UpdateFirstRowComboBox(); });
|
2018-09-12 07:06:50 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
ConfigureGameList::~ConfigureGameList() = default;
|
|
|
|
|
2019-05-26 06:39:23 +02:00
|
|
|
void ConfigureGameList::ApplyConfiguration() {
|
2018-09-12 07:06:50 +02:00
|
|
|
UISettings::values.show_unknown = ui->show_unknown->isChecked();
|
2018-11-02 01:27:12 +01:00
|
|
|
UISettings::values.show_add_ons = ui->show_add_ons->isChecked();
|
2018-09-12 07:06:50 +02:00
|
|
|
UISettings::values.icon_size = ui->icon_size_combobox->currentData().toUInt();
|
|
|
|
UISettings::values.row_1_text_id = ui->row_1_text_combobox->currentData().toUInt();
|
|
|
|
UISettings::values.row_2_text_id = ui->row_2_text_combobox->currentData().toUInt();
|
|
|
|
Settings::Apply();
|
|
|
|
}
|
|
|
|
|
2018-11-04 01:38:39 +01:00
|
|
|
void ConfigureGameList::RequestGameListUpdate() {
|
|
|
|
UISettings::values.is_game_list_reload_pending.exchange(true);
|
|
|
|
}
|
|
|
|
|
2019-05-26 06:39:23 +02:00
|
|
|
void ConfigureGameList::SetConfiguration() {
|
2018-09-12 07:06:50 +02:00
|
|
|
ui->show_unknown->setChecked(UISettings::values.show_unknown);
|
2018-11-02 01:27:12 +01:00
|
|
|
ui->show_add_ons->setChecked(UISettings::values.show_add_ons);
|
2018-09-12 07:06:50 +02:00
|
|
|
ui->icon_size_combobox->setCurrentIndex(
|
|
|
|
ui->icon_size_combobox->findData(UISettings::values.icon_size));
|
|
|
|
}
|
|
|
|
|
2018-09-12 07:11:25 +02:00
|
|
|
void ConfigureGameList::changeEvent(QEvent* event) {
|
|
|
|
if (event->type() == QEvent::LanguageChange) {
|
|
|
|
RetranslateUI();
|
|
|
|
}
|
2018-07-28 18:32:16 +02:00
|
|
|
|
2018-09-12 07:11:25 +02:00
|
|
|
QWidget::changeEvent(event);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ConfigureGameList::RetranslateUI() {
|
|
|
|
ui->retranslateUi(this);
|
|
|
|
|
|
|
|
for (int i = 0; i < ui->icon_size_combobox->count(); i++) {
|
|
|
|
ui->icon_size_combobox->setItemText(i, tr(default_icon_sizes[i].second));
|
|
|
|
}
|
|
|
|
|
|
|
|
for (int i = 0; i < ui->row_1_text_combobox->count(); i++) {
|
|
|
|
const QString name = tr(row_text_names[i]);
|
|
|
|
|
|
|
|
ui->row_1_text_combobox->setItemText(i, name);
|
|
|
|
ui->row_2_text_combobox->setItemText(i, name);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void ConfigureGameList::InitializeIconSizeComboBox() {
|
2018-07-28 18:32:16 +02:00
|
|
|
for (const auto& size : default_icon_sizes) {
|
2019-05-19 17:16:21 +02:00
|
|
|
ui->icon_size_combobox->addItem(QString::fromUtf8(size.second), size.first);
|
2018-07-28 18:32:16 +02:00
|
|
|
}
|
2018-09-12 07:06:50 +02:00
|
|
|
}
|
2018-07-28 18:32:16 +02:00
|
|
|
|
2018-09-12 07:06:50 +02:00
|
|
|
void ConfigureGameList::InitializeRowComboBoxes() {
|
2020-01-19 21:56:49 +01:00
|
|
|
UpdateFirstRowComboBox(true);
|
|
|
|
UpdateSecondRowComboBox(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ConfigureGameList::UpdateFirstRowComboBox(bool init) {
|
|
|
|
const int currentIndex =
|
|
|
|
init ? UISettings::values.row_1_text_id
|
|
|
|
: ui->row_1_text_combobox->findData(ui->row_1_text_combobox->currentData());
|
2019-05-19 17:16:21 +02:00
|
|
|
|
2020-01-19 21:56:49 +01:00
|
|
|
ui->row_1_text_combobox->clear();
|
|
|
|
|
|
|
|
for (std::size_t i = 0; i < row_text_names.size(); i++) {
|
|
|
|
const QString row_text_name = QString::fromUtf8(row_text_names[i]);
|
2019-05-19 17:16:21 +02:00
|
|
|
ui->row_1_text_combobox->addItem(row_text_name, QVariant::fromValue(i));
|
2020-01-19 21:56:49 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
ui->row_1_text_combobox->setCurrentIndex(ui->row_1_text_combobox->findData(currentIndex));
|
|
|
|
|
|
|
|
ui->row_1_text_combobox->removeItem(4); // None
|
|
|
|
ui->row_1_text_combobox->removeItem(
|
|
|
|
ui->row_1_text_combobox->findData(ui->row_2_text_combobox->currentData()));
|
|
|
|
}
|
|
|
|
|
|
|
|
void ConfigureGameList::UpdateSecondRowComboBox(bool init) {
|
|
|
|
const int currentIndex =
|
|
|
|
init ? UISettings::values.row_2_text_id
|
|
|
|
: ui->row_2_text_combobox->findData(ui->row_2_text_combobox->currentData());
|
|
|
|
|
|
|
|
ui->row_2_text_combobox->clear();
|
|
|
|
|
|
|
|
for (std::size_t i = 0; i < row_text_names.size(); ++i) {
|
|
|
|
const QString row_text_name = QString::fromUtf8(row_text_names[i]);
|
2019-05-19 17:16:21 +02:00
|
|
|
ui->row_2_text_combobox->addItem(row_text_name, QVariant::fromValue(i));
|
2018-07-28 18:32:16 +02:00
|
|
|
}
|
2020-01-19 21:56:49 +01:00
|
|
|
|
|
|
|
ui->row_2_text_combobox->setCurrentIndex(ui->row_2_text_combobox->findData(currentIndex));
|
|
|
|
|
|
|
|
ui->row_2_text_combobox->removeItem(
|
|
|
|
ui->row_2_text_combobox->findData(ui->row_1_text_combobox->currentData()));
|
2018-07-28 18:32:16 +02:00
|
|
|
}
|