From 452ccf02a6ddc7a810e90e3d8c04222a7b74f8b4 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Wed, 24 Oct 2018 08:20:32 -0400 Subject: [PATCH 1/8] game_list: Make game list column headers translatable These are user-facing strings, so they should be marked as translatable --- src/citra_qt/game_list.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/citra_qt/game_list.cpp b/src/citra_qt/game_list.cpp index c28878b88..eab2fba15 100644 --- a/src/citra_qt/game_list.cpp +++ b/src/citra_qt/game_list.cpp @@ -289,11 +289,11 @@ GameList::GameList(GMainWindow* parent) : QWidget{parent} { tree_view->setContextMenuPolicy(Qt::CustomContextMenu); item_model->insertColumns(0, COLUMN_COUNT); - item_model->setHeaderData(COLUMN_NAME, Qt::Horizontal, "Name"); - item_model->setHeaderData(COLUMN_COMPATIBILITY, Qt::Horizontal, "Compatibility"); - item_model->setHeaderData(COLUMN_REGION, Qt::Horizontal, "Region"); - item_model->setHeaderData(COLUMN_FILE_TYPE, Qt::Horizontal, "File type"); - item_model->setHeaderData(COLUMN_SIZE, Qt::Horizontal, "Size"); + item_model->setHeaderData(COLUMN_NAME, Qt::Horizontal, tr("Name")); + item_model->setHeaderData(COLUMN_COMPATIBILITY, Qt::Horizontal, tr("Compatibility")); + item_model->setHeaderData(COLUMN_REGION, Qt::Horizontal, tr("Region")); + item_model->setHeaderData(COLUMN_FILE_TYPE, Qt::Horizontal, tr("File type")); + item_model->setHeaderData(COLUMN_SIZE, Qt::Horizontal, tr("Size")); item_model->setSortRole(GameListItemPath::TitleRole); connect(main_window, &GMainWindow::UpdateThemedIcons, this, &GameList::onUpdateThemedIcons); From f4bd5c3559771dd99aadfbe56cf88d316e603ed4 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Tue, 23 Oct 2018 21:46:33 -0400 Subject: [PATCH 2/8] yuzu/configuration/config: Reorganize member variable and function layout Makes the class layout consistent with the others. --- src/citra_qt/configuration/config.h | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/src/citra_qt/configuration/config.h b/src/citra_qt/configuration/config.h index 502b1a8c0..1108926c5 100644 --- a/src/citra_qt/configuration/config.h +++ b/src/citra_qt/configuration/config.h @@ -12,16 +12,6 @@ class QSettings; class Config { - QSettings* qt_config; - std::string qt_config_loc; - - void ReadValues(); - void SaveValues(); - QVariant ReadSetting(const QString& name); - QVariant ReadSetting(const QString& name, const QVariant& default_value); - void WriteSetting(const QString& name, const QVariant& value); - void WriteSetting(const QString& name, const QVariant& value, const QVariant& default_value); - public: Config(); ~Config(); @@ -31,4 +21,15 @@ public: static const std::array default_buttons; static const std::array, Settings::NativeAnalog::NumAnalogs> default_analogs; + +private: + void ReadValues(); + void SaveValues(); + QVariant ReadSetting(const QString& name); + QVariant ReadSetting(const QString& name, const QVariant& default_value); + void WriteSetting(const QString& name, const QVariant& value); + void WriteSetting(const QString& name, const QVariant& value, const QVariant& default_value); + + QSettings* qt_config; + std::string qt_config_loc; }; From bf6dd783247b60e7e372d76e5095e7476223b98e Mon Sep 17 00:00:00 2001 From: Lioncash Date: Tue, 23 Oct 2018 21:49:50 -0400 Subject: [PATCH 3/8] yuzu/configuration/config: Use a std::unique_ptr for qt_config instead of a raw pointer Same behavior, less code. --- src/citra_qt/configuration/config.cpp | 13 ++++++------- src/citra_qt/configuration/config.h | 3 ++- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/citra_qt/configuration/config.cpp b/src/citra_qt/configuration/config.cpp index a7c284471..3004fa936 100644 --- a/src/citra_qt/configuration/config.cpp +++ b/src/citra_qt/configuration/config.cpp @@ -16,11 +16,16 @@ Config::Config() { // TODO: Don't hardcode the path; let the frontend decide where to put the config files. qt_config_loc = FileUtil::GetUserPath(FileUtil::UserPath::ConfigDir) + "qt-config.ini"; FileUtil::CreateFullPath(qt_config_loc); - qt_config = new QSettings(QString::fromStdString(qt_config_loc), QSettings::IniFormat); + qt_config = + std::make_unique(QString::fromStdString(qt_config_loc), QSettings::IniFormat); Reload(); } +Config::~Config() { + Save(); +} + const std::array Config::default_buttons = { Qt::Key_A, Qt::Key_S, Qt::Key_Z, Qt::Key_X, Qt::Key_T, Qt::Key_G, Qt::Key_F, Qt::Key_H, Qt::Key_Q, Qt::Key_W, Qt::Key_M, Qt::Key_N, Qt::Key_1, Qt::Key_2, Qt::Key_B, @@ -561,9 +566,3 @@ void Config::Reload() { void Config::Save() { SaveValues(); } - -Config::~Config() { - Save(); - - delete qt_config; -} diff --git a/src/citra_qt/configuration/config.h b/src/citra_qt/configuration/config.h index 1108926c5..fdb161c23 100644 --- a/src/citra_qt/configuration/config.h +++ b/src/citra_qt/configuration/config.h @@ -5,6 +5,7 @@ #pragma once #include +#include #include #include #include "core/settings.h" @@ -30,6 +31,6 @@ private: void WriteSetting(const QString& name, const QVariant& value); void WriteSetting(const QString& name, const QVariant& value, const QVariant& default_value); - QSettings* qt_config; + std::unique_ptr qt_config; std::string qt_config_loc; }; From 027197cf1f0e9b0651a25fa962caf94ca79ade58 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Wed, 24 Oct 2018 08:10:56 -0400 Subject: [PATCH 4/8] bootmanager: Use QStringLiteral instead of std::string to represent the window title This gets rid of an unnecessary type conversion. We can just use the regular QStringLiteral to already format the string as the type setWindowTitle accepts instead of converting from a std::string instance. --- src/citra_qt/bootmanager.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/citra_qt/bootmanager.cpp b/src/citra_qt/bootmanager.cpp index 9dd2b338e..39115f31e 100644 --- a/src/citra_qt/bootmanager.cpp +++ b/src/citra_qt/bootmanager.cpp @@ -109,9 +109,8 @@ private: GRenderWindow::GRenderWindow(QWidget* parent, EmuThread* emu_thread) : QWidget(parent), child(nullptr), emu_thread(emu_thread) { - std::string window_title = fmt::format("Citra {} | {}-{}", Common::g_build_name, - Common::g_scm_branch, Common::g_scm_desc); - setWindowTitle(QString::fromStdString(window_title)); + setWindowTitle(QStringLiteral("Citra %1 | %2-%3") + .arg(Common::g_build_name, Common::g_scm_branch, Common::g_scm_desc)); setAttribute(Qt::WA_AcceptTouchEvents); InputCommon::Init(); From 452cfb46a92f05b3c1fd685dfda22284d22568f0 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Thu, 25 Oct 2018 16:43:42 -0400 Subject: [PATCH 5/8] configure_system: Make public slots private These are only used within this class, so we can make them private to keep their use contained. This also gets rid of the pre-Qt5 'slot' identifier, since Qt 5's connection syntax doesn't require a function to be declared a slot anymore. --- src/citra_qt/configuration/configure_system.h | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/citra_qt/configuration/configure_system.h b/src/citra_qt/configuration/configure_system.h index 36c7d2e94..bef7793f4 100644 --- a/src/citra_qt/configuration/configure_system.h +++ b/src/citra_qt/configuration/configure_system.h @@ -29,15 +29,14 @@ public: void setConfiguration(); void retranslateUi(); -public slots: - void updateBirthdayComboBox(int birthmonth_index); - void updateInitTime(int init_clock); - void refreshConsoleID(); - private: void ReadSystemSettings(); void ConfigureTime(); + void updateBirthdayComboBox(int birthmonth_index); + void updateInitTime(int init_clock); + void refreshConsoleID(); + std::unique_ptr ui; bool enabled; From 97cdf44ddddecc81f6a4a5897fdb4ebc9a23e4f9 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Thu, 25 Oct 2018 16:45:13 -0400 Subject: [PATCH 6/8] configure_system: Add missing override specifier on the destructor --- src/citra_qt/configuration/configure_system.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/citra_qt/configuration/configure_system.h b/src/citra_qt/configuration/configure_system.h index bef7793f4..db32b290e 100644 --- a/src/citra_qt/configuration/configure_system.h +++ b/src/citra_qt/configuration/configure_system.h @@ -23,7 +23,7 @@ class ConfigureSystem : public QWidget { public: explicit ConfigureSystem(QWidget* parent = nullptr); - ~ConfigureSystem(); + ~ConfigureSystem() override; void applyConfiguration(); void setConfiguration(); From 470cc660493b31dbde2ab0e48f859d2796360abb Mon Sep 17 00:00:00 2001 From: Lioncash Date: Thu, 25 Oct 2018 16:47:09 -0400 Subject: [PATCH 7/8] configure_system: Amend function casing --- src/citra_qt/configuration/configure_system.cpp | 16 ++++++++-------- src/citra_qt/configuration/configure_system.h | 6 +++--- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/citra_qt/configuration/configure_system.cpp b/src/citra_qt/configuration/configure_system.cpp index 475699b86..4239aea76 100644 --- a/src/citra_qt/configuration/configure_system.cpp +++ b/src/citra_qt/configuration/configure_system.cpp @@ -220,12 +220,12 @@ ConfigureSystem::ConfigureSystem(QWidget* parent) : QWidget(parent), ui(new Ui:: ui->setupUi(this); connect(ui->combo_birthmonth, static_cast(&QComboBox::currentIndexChanged), this, - &ConfigureSystem::updateBirthdayComboBox); + &ConfigureSystem::UpdateBirthdayComboBox); connect(ui->combo_init_clock, static_cast(&QComboBox::currentIndexChanged), this, - &ConfigureSystem::updateInitTime); + &ConfigureSystem::UpdateInitTime); connect(ui->button_regenerate_console_id, &QPushButton::clicked, this, - &ConfigureSystem::refreshConsoleID); + &ConfigureSystem::RefreshConsoleID); for (u8 i = 0; i < country_names.size(); i++) { if (country_names.at(i) != "") { ui->combo_country->addItem(tr(country_names.at(i)), i); @@ -270,7 +270,7 @@ void ConfigureSystem::ReadSystemSettings() { // set birthday std::tie(birthmonth, birthday) = cfg->GetBirthday(); ui->combo_birthmonth->setCurrentIndex(birthmonth - 1); - updateBirthdayComboBox( + UpdateBirthdayComboBox( birthmonth - 1); // explicitly update it because the signal from setCurrentIndex is not reliable ui->combo_birthday->setCurrentIndex(birthday - 1); @@ -358,7 +358,7 @@ void ConfigureSystem::applyConfiguration() { Settings::Apply(); } -void ConfigureSystem::updateBirthdayComboBox(int birthmonth_index) { +void ConfigureSystem::UpdateBirthdayComboBox(int birthmonth_index) { if (birthmonth_index < 0 || birthmonth_index >= 12) return; @@ -391,17 +391,17 @@ void ConfigureSystem::ConfigureTime() { this->setConfiguration(); - updateInitTime(ui->combo_init_clock->currentIndex()); + UpdateInitTime(ui->combo_init_clock->currentIndex()); } -void ConfigureSystem::updateInitTime(int init_clock) { +void ConfigureSystem::UpdateInitTime(int init_clock) { const bool is_fixed_time = static_cast(init_clock) == Settings::InitClock::FixedTime; ui->label_init_time->setVisible(is_fixed_time); ui->edit_init_time->setVisible(is_fixed_time); } -void ConfigureSystem::refreshConsoleID() { +void ConfigureSystem::RefreshConsoleID() { QMessageBox::StandardButton reply; QString warning_text = tr("This will replace your current virtual 3DS with a new one. " "Your current virtual 3DS will not be recoverable. " diff --git a/src/citra_qt/configuration/configure_system.h b/src/citra_qt/configuration/configure_system.h index db32b290e..b9936f494 100644 --- a/src/citra_qt/configuration/configure_system.h +++ b/src/citra_qt/configuration/configure_system.h @@ -33,9 +33,9 @@ private: void ReadSystemSettings(); void ConfigureTime(); - void updateBirthdayComboBox(int birthmonth_index); - void updateInitTime(int init_clock); - void refreshConsoleID(); + void UpdateBirthdayComboBox(int birthmonth_index); + void UpdateInitTime(int init_clock); + void RefreshConsoleID(); std::unique_ptr ui; bool enabled; From a74d97b15faf2c5f190fa745fbc66bb5366c8a91 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Thu, 25 Oct 2018 16:52:21 -0400 Subject: [PATCH 8/8] configure_system: Default initialize member variables These should be initialized to deterministic values so it's easier to catch improper behavior, as it'll always be reproducable, instead of performing uninitialized reads. --- src/citra_qt/configuration/configure_system.h | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/citra_qt/configuration/configure_system.h b/src/citra_qt/configuration/configure_system.h index b9936f494..f84457bd6 100644 --- a/src/citra_qt/configuration/configure_system.h +++ b/src/citra_qt/configuration/configure_system.h @@ -38,13 +38,14 @@ private: void RefreshConsoleID(); std::unique_ptr ui; - bool enabled; + bool enabled = false; std::shared_ptr cfg; std::u16string username; - int birthmonth, birthday; - int language_index; - int sound_index; + int birthmonth = 0; + int birthday = 0; + int language_index = 0; + int sound_index = 0; u8 country_code; u16 play_coin; };