mirror of
https://git.citron-emu.org/citron/emulator
synced 2025-12-21 03:23:34 +00:00
Edit configure_ui.cpp
This commit is contained in:
@@ -12,6 +12,7 @@
|
|||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
#include <QCheckBox>
|
#include <QCheckBox>
|
||||||
|
#include <QColorDialog>
|
||||||
#include <QComboBox>
|
#include <QComboBox>
|
||||||
#include <QCoreApplication>
|
#include <QCoreApplication>
|
||||||
#include <QDirIterator>
|
#include <QDirIterator>
|
||||||
@@ -33,42 +34,42 @@
|
|||||||
#include "citron/uisettings.h"
|
#include "citron/uisettings.h"
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
constexpr std::array default_game_icon_sizes{
|
constexpr std::array default_game_icon_sizes{
|
||||||
std::make_pair(0, QT_TRANSLATE_NOOP("ConfigureUI", "None")),
|
std::make_pair(0, QT_TRANSLATE_NOOP("ConfigureUI", "None")),
|
||||||
std::make_pair(32, QT_TRANSLATE_NOOP("ConfigureUI", "Small (32x32)")),
|
std::make_pair(32, QT_TRANSLATE_NOOP("ConfigureUI", "Small (32x32)")),
|
||||||
std::make_pair(64, QT_TRANSLATE_NOOP("ConfigureUI", "Standard (64x64)")),
|
std::make_pair(64, QT_TRANSLATE_NOOP("ConfigureUI", "Standard (64x64)")),
|
||||||
std::make_pair(128, QT_TRANSLATE_NOOP("ConfigureUI", "Large (128x128)")),
|
std::make_pair(128, QT_TRANSLATE_NOOP("ConfigureUI", "Large (128x128)")),
|
||||||
std::make_pair(256, QT_TRANSLATE_NOOP("ConfigureUI", "Full Size (256x256)")),
|
std::make_pair(256, QT_TRANSLATE_NOOP("ConfigureUI", "Full Size (256x256)")),
|
||||||
};
|
};
|
||||||
|
|
||||||
constexpr std::array default_folder_icon_sizes{
|
constexpr std::array default_folder_icon_sizes{
|
||||||
std::make_pair(0, QT_TRANSLATE_NOOP("ConfigureUI", "None")),
|
std::make_pair(0, QT_TRANSLATE_NOOP("ConfigureUI", "None")),
|
||||||
std::make_pair(24, QT_TRANSLATE_NOOP("ConfigureUI", "Small (24x24)")),
|
std::make_pair(24, QT_TRANSLATE_NOOP("ConfigureUI", "Small (24x24)")),
|
||||||
std::make_pair(48, QT_TRANSLATE_NOOP("ConfigureUI", "Standard (48x48)")),
|
std::make_pair(48, QT_TRANSLATE_NOOP("ConfigureUI", "Standard (48x48)")),
|
||||||
std::make_pair(72, QT_TRANSLATE_NOOP("ConfigureUI", "Large (72x72)")),
|
std::make_pair(72, QT_TRANSLATE_NOOP("ConfigureUI", "Large (72x72)")),
|
||||||
};
|
};
|
||||||
|
|
||||||
// clang-format off
|
// clang-format off
|
||||||
constexpr std::array row_text_names{
|
constexpr std::array row_text_names{
|
||||||
QT_TRANSLATE_NOOP("ConfigureUI", "Filename"),
|
QT_TRANSLATE_NOOP("ConfigureUI", "Filename"),
|
||||||
QT_TRANSLATE_NOOP("ConfigureUI", "Filetype"),
|
QT_TRANSLATE_NOOP("ConfigureUI", "Filetype"),
|
||||||
QT_TRANSLATE_NOOP("ConfigureUI", "Title ID"),
|
QT_TRANSLATE_NOOP("ConfigureUI", "Title ID"),
|
||||||
QT_TRANSLATE_NOOP("ConfigureUI", "Title Name"),
|
QT_TRANSLATE_NOOP("ConfigureUI", "Title Name"),
|
||||||
QT_TRANSLATE_NOOP("ConfigureUI", "None"),
|
QT_TRANSLATE_NOOP("ConfigureUI", "None"),
|
||||||
};
|
};
|
||||||
// clang-format on
|
// clang-format on
|
||||||
|
|
||||||
QString GetTranslatedGameIconSize(size_t index) {
|
QString GetTranslatedGameIconSize(size_t index) {
|
||||||
return QCoreApplication::translate("ConfigureUI", default_game_icon_sizes[index].second);
|
return QCoreApplication::translate("ConfigureUI", default_game_icon_sizes[index].second);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString GetTranslatedFolderIconSize(size_t index) {
|
QString GetTranslatedFolderIconSize(size_t index) {
|
||||||
return QCoreApplication::translate("ConfigureUI", default_folder_icon_sizes[index].second);
|
return QCoreApplication::translate("ConfigureUI", default_folder_icon_sizes[index].second);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString GetTranslatedRowTextName(size_t index) {
|
QString GetTranslatedRowTextName(size_t index) {
|
||||||
return QCoreApplication::translate("ConfigureUI", row_text_names[index]);
|
return QCoreApplication::translate("ConfigureUI", row_text_names[index]);
|
||||||
}
|
}
|
||||||
} // Anonymous namespace
|
} // Anonymous namespace
|
||||||
|
|
||||||
static float GetUpFactor(Settings::ResolutionSetup res_setup) {
|
static float GetUpFactor(Settings::ResolutionSetup res_setup) {
|
||||||
@@ -102,9 +103,9 @@ static u32 ScreenshotDimensionToInt(const QString& height) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ConfigureUi::ConfigureUi(Core::System& system_, QWidget* parent)
|
ConfigureUi::ConfigureUi(Core::System& system_, QWidget* parent)
|
||||||
: QWidget(parent), ui{std::make_unique<Ui::ConfigureUi>()},
|
: QWidget(parent), ui{std::make_unique<Ui::ConfigureUi>()},
|
||||||
ratio{Settings::values.aspect_ratio.GetValue()},
|
ratio{Settings::values.aspect_ratio.GetValue()},
|
||||||
resolution_setting{Settings::values.resolution_setup.GetValue()}, system{system_} {
|
resolution_setting{Settings::values.resolution_setup.GetValue()}, system{system_} {
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
|
||||||
InitializeLanguageComboBox();
|
InitializeLanguageComboBox();
|
||||||
@@ -121,26 +122,31 @@ ConfigureUi::ConfigureUi(Core::System& system_, QWidget* parent)
|
|||||||
|
|
||||||
SetConfiguration();
|
SetConfiguration();
|
||||||
|
|
||||||
|
connect(ui->accentColorButton, &QPushButton::clicked, this, &ConfigureUi::OnAccentColorButtonPressed);
|
||||||
|
connect(ui->rainbowModeCheckBox, &QCheckBox::checkStateChanged, this, [this](int state) {
|
||||||
|
emit themeChanged();
|
||||||
|
});
|
||||||
|
|
||||||
// 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_add_ons, &QCheckBox::stateChanged, this, &ConfigureUi::RequestGameListUpdate);
|
connect(ui->show_add_ons, &QCheckBox::checkStateChanged, this, &ConfigureUi::RequestGameListUpdate);
|
||||||
connect(ui->show_compat, &QCheckBox::stateChanged, this, &ConfigureUi::RequestGameListUpdate);
|
connect(ui->show_compat, &QCheckBox::checkStateChanged, this, &ConfigureUi::RequestGameListUpdate);
|
||||||
connect(ui->show_size, &QCheckBox::stateChanged, this, &ConfigureUi::RequestGameListUpdate);
|
connect(ui->show_size, &QCheckBox::checkStateChanged, this, &ConfigureUi::RequestGameListUpdate);
|
||||||
connect(ui->show_types, &QCheckBox::stateChanged, this, &ConfigureUi::RequestGameListUpdate);
|
connect(ui->show_types, &QCheckBox::checkStateChanged, this, &ConfigureUi::RequestGameListUpdate);
|
||||||
connect(ui->show_play_time, &QCheckBox::stateChanged, this,
|
connect(ui->show_play_time, &QCheckBox::checkStateChanged, this,
|
||||||
&ConfigureUi::RequestGameListUpdate);
|
&ConfigureUi::RequestGameListUpdate);
|
||||||
connect(ui->game_icon_size_combobox, QOverload<int>::of(&QComboBox::currentIndexChanged), this,
|
connect(ui->game_icon_size_combobox, &QComboBox::currentIndexChanged, this,
|
||||||
&ConfigureUi::RequestGameListUpdate);
|
&ConfigureUi::RequestGameListUpdate);
|
||||||
connect(ui->folder_icon_size_combobox, QOverload<int>::of(&QComboBox::currentIndexChanged),
|
connect(ui->folder_icon_size_combobox, &QComboBox::currentIndexChanged,
|
||||||
this, &ConfigureUi::RequestGameListUpdate);
|
this, &ConfigureUi::RequestGameListUpdate);
|
||||||
connect(ui->row_1_text_combobox, QOverload<int>::of(&QComboBox::currentIndexChanged), this,
|
connect(ui->row_1_text_combobox, &QComboBox::currentIndexChanged, this,
|
||||||
&ConfigureUi::RequestGameListUpdate);
|
&ConfigureUi::RequestGameListUpdate);
|
||||||
connect(ui->row_2_text_combobox, QOverload<int>::of(&QComboBox::currentIndexChanged), this,
|
connect(ui->row_2_text_combobox, &QComboBox::currentIndexChanged, this,
|
||||||
&ConfigureUi::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, &QComboBox::activated,
|
||||||
[this] { ConfigureUi::UpdateSecondRowComboBox(); });
|
[this] { ConfigureUi::UpdateSecondRowComboBox(); });
|
||||||
connect(ui->row_2_text_combobox, QOverload<int>::of(&QComboBox::activated),
|
connect(ui->row_2_text_combobox, &QComboBox::activated,
|
||||||
[this] { ConfigureUi::UpdateFirstRowComboBox(); });
|
[this] { ConfigureUi::UpdateFirstRowComboBox(); });
|
||||||
|
|
||||||
// Set screenshot path to user specification.
|
// Set screenshot path to user specification.
|
||||||
@@ -168,6 +174,7 @@ ConfigureUi::~ConfigureUi() = default;
|
|||||||
void ConfigureUi::ApplyConfiguration() {
|
void ConfigureUi::ApplyConfiguration() {
|
||||||
UISettings::values.theme =
|
UISettings::values.theme =
|
||||||
ui->theme_combobox->itemData(ui->theme_combobox->currentIndex()).toString().toStdString();
|
ui->theme_combobox->itemData(ui->theme_combobox->currentIndex()).toString().toStdString();
|
||||||
|
UISettings::values.enable_rainbow_mode = ui->rainbowModeCheckBox->isChecked();
|
||||||
UISettings::values.show_add_ons = ui->show_add_ons->isChecked();
|
UISettings::values.show_add_ons = ui->show_add_ons->isChecked();
|
||||||
UISettings::values.show_compat = ui->show_compat->isChecked();
|
UISettings::values.show_compat = ui->show_compat->isChecked();
|
||||||
UISettings::values.show_size = ui->show_size->isChecked();
|
UISettings::values.show_size = ui->show_size->isChecked();
|
||||||
@@ -198,6 +205,7 @@ void ConfigureUi::SetConfiguration() {
|
|||||||
ui->theme_combobox->findData(QString::fromStdString(UISettings::values.theme)));
|
ui->theme_combobox->findData(QString::fromStdString(UISettings::values.theme)));
|
||||||
ui->language_combobox->setCurrentIndex(ui->language_combobox->findData(
|
ui->language_combobox->setCurrentIndex(ui->language_combobox->findData(
|
||||||
QString::fromStdString(UISettings::values.language.GetValue())));
|
QString::fromStdString(UISettings::values.language.GetValue())));
|
||||||
|
ui->rainbowModeCheckBox->setChecked(UISettings::values.enable_rainbow_mode.GetValue());
|
||||||
ui->show_add_ons->setChecked(UISettings::values.show_add_ons.GetValue());
|
ui->show_add_ons->setChecked(UISettings::values.show_add_ons.GetValue());
|
||||||
ui->show_compat->setChecked(UISettings::values.show_compat.GetValue());
|
ui->show_compat->setChecked(UISettings::values.show_compat.GetValue());
|
||||||
ui->show_size->setChecked(UISettings::values.show_size.GetValue());
|
ui->show_size->setChecked(UISettings::values.show_size.GetValue());
|
||||||
@@ -221,6 +229,18 @@ void ConfigureUi::SetConfiguration() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ConfigureUi::OnAccentColorButtonPressed() {
|
||||||
|
const QColor current_color(QString::fromStdString(UISettings::values.accent_color.GetValue()));
|
||||||
|
QColorDialog dialog(current_color, this);
|
||||||
|
if (dialog.exec() == QDialog::Accepted) {
|
||||||
|
const QColor color = dialog.selectedColor();
|
||||||
|
if (color.isValid()) {
|
||||||
|
UISettings::values.accent_color.SetValue(color.name().toStdString());
|
||||||
|
emit themeChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void ConfigureUi::changeEvent(QEvent* event) {
|
void ConfigureUi::changeEvent(QEvent* event) {
|
||||||
if (event->type() == QEvent::LanguageChange) {
|
if (event->type() == QEvent::LanguageChange) {
|
||||||
RetranslateUI();
|
RetranslateUI();
|
||||||
@@ -263,10 +283,7 @@ void ConfigureUi::InitializeLanguageComboBox() {
|
|||||||
ui->language_combobox->addItem(QStringLiteral("%1 (%2)").arg(lang, country), locale);
|
ui->language_combobox->addItem(QStringLiteral("%1 (%2)").arg(lang, country), locale);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Unlike other configuration changes, interface language changes need to be reflected on the
|
connect(ui->language_combobox, &QComboBox::currentIndexChanged, this,
|
||||||
// interface immediately. This is done by passing a signal to the main window, and then
|
|
||||||
// retranslating when passing back.
|
|
||||||
connect(ui->language_combobox, qOverload<int>(&QComboBox::currentIndexChanged), this,
|
|
||||||
&ConfigureUi::OnLanguageChanged);
|
&ConfigureUi::OnLanguageChanged);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user