From d184224e8fceee33ac4ab188b8acb75d1a5208b4 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sun, 19 May 2019 11:08:54 -0400 Subject: yuzu/configuration/configure_audio: Specify string conversions explicitly Allows the audio configuration code to build with implicit string conversions disabled. --- src/yuzu/configuration/configure_audio.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/yuzu/configuration/configure_audio.cpp b/src/yuzu/configuration/configure_audio.cpp index 5d9ccc6e8..a407011f0 100644 --- a/src/yuzu/configuration/configure_audio.cpp +++ b/src/yuzu/configuration/configure_audio.cpp @@ -16,9 +16,9 @@ ConfigureAudio::ConfigureAudio(QWidget* parent) ui->setupUi(this); ui->output_sink_combo_box->clear(); - ui->output_sink_combo_box->addItem("auto"); + ui->output_sink_combo_box->addItem(QString::fromUtf8(AudioCore::auto_device_name)); for (const char* id : AudioCore::GetSinkIDs()) { - ui->output_sink_combo_box->addItem(id); + ui->output_sink_combo_box->addItem(QString::fromUtf8(id)); } connect(ui->volume_slider, &QSlider::valueChanged, this, @@ -94,7 +94,7 @@ void ConfigureAudio::applyConfiguration() { void ConfigureAudio::updateAudioDevices(int sink_index) { ui->audio_device_combo_box->clear(); - ui->audio_device_combo_box->addItem(AudioCore::auto_device_name); + ui->audio_device_combo_box->addItem(QString::fromUtf8(AudioCore::auto_device_name)); const std::string sink_id = ui->output_sink_combo_box->itemText(sink_index).toStdString(); for (const auto& device : AudioCore::GetDeviceListForSink(sink_id)) { -- cgit v1.2.3 From d00ca5c6c80ce6a418c0aa654350532f6d28fabc Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sun, 19 May 2019 11:10:55 -0400 Subject: yuzu/configuration/configure_audio: Tidy up function cast We can just use qOverload here to tidy up the function cast. --- src/yuzu/configuration/configure_audio.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src') diff --git a/src/yuzu/configuration/configure_audio.cpp b/src/yuzu/configuration/configure_audio.cpp index a407011f0..e68309bb2 100644 --- a/src/yuzu/configuration/configure_audio.cpp +++ b/src/yuzu/configuration/configure_audio.cpp @@ -25,8 +25,7 @@ ConfigureAudio::ConfigureAudio(QWidget* parent) &ConfigureAudio::setVolumeIndicatorText); this->setConfiguration(); - connect(ui->output_sink_combo_box, - static_cast(&QComboBox::currentIndexChanged), this, + connect(ui->output_sink_combo_box, qOverload(&QComboBox::currentIndexChanged), this, &ConfigureAudio::updateAudioDevices); ui->output_sink_combo_box->setEnabled(!Core::System::GetInstance().IsPoweredOn()); -- cgit v1.2.3 From 5f01ec338e5b3935dd54e2145a3ff1d0c15d7a7f Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sun, 19 May 2019 11:12:29 -0400 Subject: yuzu/configuration/configure_audio: Store power on query into a variable Avoids using the system accessor more than necessary, and ensures that both dialog boxes see the same power on state. --- src/yuzu/configuration/configure_audio.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/yuzu/configuration/configure_audio.cpp b/src/yuzu/configuration/configure_audio.cpp index e68309bb2..b0f9b814d 100644 --- a/src/yuzu/configuration/configure_audio.cpp +++ b/src/yuzu/configuration/configure_audio.cpp @@ -28,8 +28,9 @@ ConfigureAudio::ConfigureAudio(QWidget* parent) connect(ui->output_sink_combo_box, qOverload(&QComboBox::currentIndexChanged), this, &ConfigureAudio::updateAudioDevices); - ui->output_sink_combo_box->setEnabled(!Core::System::GetInstance().IsPoweredOn()); - ui->audio_device_combo_box->setEnabled(!Core::System::GetInstance().IsPoweredOn()); + const bool is_powered_on = Core::System::GetInstance().IsPoweredOn(); + ui->output_sink_combo_box->setEnabled(!is_powered_on); + ui->audio_device_combo_box->setEnabled(!is_powered_on); } ConfigureAudio::~ConfigureAudio() = default; -- cgit v1.2.3 From 05235ccaa96c26a56a4a3c3af70ec446e785dba7 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sun, 19 May 2019 11:16:21 -0400 Subject: yuzu/configuration/configure_gamelist: Specify string conversions explicitly Allows the gamelist configuration code to compile with implicit string conversions disabled. --- src/yuzu/configuration/configure_gamelist.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/yuzu/configuration/configure_gamelist.cpp b/src/yuzu/configuration/configure_gamelist.cpp index ae8cac243..6f0d75605 100644 --- a/src/yuzu/configuration/configure_gamelist.cpp +++ b/src/yuzu/configuration/configure_gamelist.cpp @@ -100,13 +100,15 @@ void ConfigureGameList::RetranslateUI() { void ConfigureGameList::InitializeIconSizeComboBox() { for (const auto& size : default_icon_sizes) { - ui->icon_size_combobox->addItem(size.second, size.first); + ui->icon_size_combobox->addItem(QString::fromUtf8(size.second), size.first); } } void ConfigureGameList::InitializeRowComboBoxes() { for (std::size_t i = 0; i < row_text_names.size(); ++i) { - ui->row_1_text_combobox->addItem(row_text_names[i], QVariant::fromValue(i)); - ui->row_2_text_combobox->addItem(row_text_names[i], QVariant::fromValue(i)); + const QString row_text_name = QString::fromUtf8(row_text_names[i]); + + ui->row_1_text_combobox->addItem(row_text_name, QVariant::fromValue(i)); + ui->row_2_text_combobox->addItem(row_text_name, QVariant::fromValue(i)); } } -- cgit v1.2.3 From 7e650088ddd574c7f500eb902a0b80378a1b9b46 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sun, 19 May 2019 11:18:13 -0400 Subject: yuzu/configuration/configure_general: Specify string conversions explicitly Allows the general configuration code to successfully compile with implicit string conversions disabled. --- src/yuzu/configuration/configure_general.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/yuzu/configuration/configure_general.cpp b/src/yuzu/configuration/configure_general.cpp index e48f4f5a3..dd25dc6e1 100644 --- a/src/yuzu/configuration/configure_general.cpp +++ b/src/yuzu/configuration/configure_general.cpp @@ -14,7 +14,8 @@ ConfigureGeneral::ConfigureGeneral(QWidget* parent) ui->setupUi(this); for (const auto& theme : UISettings::themes) { - ui->theme_combobox->addItem(theme.first, theme.second); + ui->theme_combobox->addItem(QString::fromUtf8(theme.first), + QString::fromUtf8(theme.second)); } this->setConfiguration(); -- cgit v1.2.3 From d81d4a0f68852082403971d874cf64c96fe7550e Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sun, 19 May 2019 11:23:21 -0400 Subject: yuzu/configuration/configure_input: Mark controller type names as translateable These are user-facing strings, so they should be localizable. --- src/yuzu/configuration/configure_input.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/yuzu/configuration/configure_input.cpp b/src/yuzu/configuration/configure_input.cpp index f39d57998..87e459714 100644 --- a/src/yuzu/configuration/configure_input.cpp +++ b/src/yuzu/configuration/configure_input.cpp @@ -75,8 +75,8 @@ ConfigureInput::ConfigureInput(QWidget* parent) }; for (auto* controller_box : players_controller) { - controller_box->addItems({"None", "Pro Controller", "Dual Joycons", "Single Right Joycon", - "Single Left Joycon"}); + controller_box->addItems({tr("None"), tr("Pro Controller"), tr("Dual Joycons"), + tr("Single Right Joycon"), tr("Single Left Joycon")}); } this->loadConfiguration(); @@ -85,9 +85,10 @@ ConfigureInput::ConfigureInput(QWidget* parent) connect(ui->restore_defaults_button, &QPushButton::pressed, this, &ConfigureInput::restoreDefaults); - for (auto* enabled : players_controller) + for (auto* enabled : players_controller) { connect(enabled, QOverload::of(&QComboBox::currentIndexChanged), this, &ConfigureInput::updateUIEnabled); + } connect(ui->use_docked_mode, &QCheckBox::stateChanged, this, &ConfigureInput::updateUIEnabled); connect(ui->handheld_connected, &QCheckBox::stateChanged, this, &ConfigureInput::updateUIEnabled); @@ -147,10 +148,12 @@ void ConfigureInput::updateUIEnabled() { bool hit_disabled = false; for (auto* player : players_controller) { player->setDisabled(hit_disabled); - if (hit_disabled) + if (hit_disabled) { player->setCurrentIndex(0); - if (!hit_disabled && player->currentIndex() == 0) + } + if (!hit_disabled && player->currentIndex() == 0) { hit_disabled = true; + } } for (std::size_t i = 0; i < players_controller.size(); ++i) { -- cgit v1.2.3 From 4d2da5a40aff840ad3c5d2ef6fc60d0005a81aac Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sun, 19 May 2019 11:38:28 -0400 Subject: yuzu/configuration/configure_input_player: Specify string conversions explicitly Allows the player input configuration code to compile with implicit string conversions disabled. --- src/yuzu/configuration/configure_input_player.cpp | 73 +++++++++++++++-------- 1 file changed, 49 insertions(+), 24 deletions(-) (limited to 'src') diff --git a/src/yuzu/configuration/configure_input_player.cpp b/src/yuzu/configuration/configure_input_player.cpp index c5a245ebe..62a68d912 100644 --- a/src/yuzu/configuration/configure_input_player.cpp +++ b/src/yuzu/configuration/configure_input_player.cpp @@ -45,7 +45,7 @@ static QString GetKeyName(int key_code) { case Qt::Key_Alt: return QObject::tr("Alt"); case Qt::Key_Meta: - return ""; + return {}; default: return QKeySequence(key_code).toString(); } @@ -65,46 +65,70 @@ static void SetAnalogButton(const Common::ParamPackage& input_param, static QString ButtonToText(const Common::ParamPackage& param) { if (!param.Has("engine")) { return QObject::tr("[not set]"); - } else if (param.Get("engine", "") == "keyboard") { + } + + if (param.Get("engine", "") == "keyboard") { return GetKeyName(param.Get("code", 0)); - } else if (param.Get("engine", "") == "sdl") { + } + + if (param.Get("engine", "") == "sdl") { if (param.Has("hat")) { - return QString(QObject::tr("Hat %1 %2")) - .arg(param.Get("hat", "").c_str(), param.Get("direction", "").c_str()); + const QString hat_str = QString::fromStdString(param.Get("hat", "")); + const QString direction_str = QString::fromStdString(param.Get("direction", "")); + + return QObject::tr("Hat %1 %2").arg(hat_str, direction_str); } + if (param.Has("axis")) { - return QString(QObject::tr("Axis %1%2")) - .arg(param.Get("axis", "").c_str(), param.Get("direction", "").c_str()); + const QString axis_str = QString::fromStdString(param.Get("axis", "")); + const QString direction_str = QString::fromStdString(param.Get("direction", "")); + + return QObject::tr("Axis %1%2").arg(axis_str, direction_str); } + if (param.Has("button")) { - return QString(QObject::tr("Button %1")).arg(param.Get("button", "").c_str()); + const QString button_str = QString::fromStdString(param.Get("button", "")); + + return QObject::tr("Button %1").arg(button_str); } - return QString(); - } else { - return QObject::tr("[unknown]"); + + return {}; } -}; + + return QObject::tr("[unknown]"); +} static QString AnalogToText(const Common::ParamPackage& param, const std::string& dir) { if (!param.Has("engine")) { return QObject::tr("[not set]"); - } else if (param.Get("engine", "") == "analog_from_button") { + } + + if (param.Get("engine", "") == "analog_from_button") { return ButtonToText(Common::ParamPackage{param.Get(dir, "")}); - } else if (param.Get("engine", "") == "sdl") { + } + + if (param.Get("engine", "") == "sdl") { if (dir == "modifier") { - return QString(QObject::tr("[unused]")); + return QObject::tr("[unused]"); } if (dir == "left" || dir == "right") { - return QString(QObject::tr("Axis %1")).arg(param.Get("axis_x", "").c_str()); - } else if (dir == "up" || dir == "down") { - return QString(QObject::tr("Axis %1")).arg(param.Get("axis_y", "").c_str()); + const QString axis_x_str = QString::fromStdString(param.Get("axis_x", "")); + + return QObject::tr("Axis %1").arg(axis_x_str); } - return QString(); - } else { - return QObject::tr("[unknown]"); + + if (dir == "up" || dir == "down") { + const QString axis_y_str = QString::fromStdString(param.Get("axis_y", "")); + + return QObject::tr("Axis %1").arg(axis_y_str); + } + + return {}; } -}; + + return QObject::tr("[unknown]"); +} ConfigureInputPlayer::ConfigureInputPlayer(QWidget* parent, std::size_t player_index, bool debug) : QDialog(parent), ui(std::make_unique()), player_index(player_index), @@ -351,7 +375,7 @@ void ConfigureInputPlayer::OnControllerButtonClick(int i) { return; controller_colors[i] = new_bg_color; controller_color_buttons[i]->setStyleSheet( - QString("QPushButton { background-color: %1 }").arg(controller_colors[i].name())); + QStringLiteral("QPushButton { background-color: %1 }").arg(controller_colors[i].name())); } void ConfigureInputPlayer::loadConfiguration() { @@ -388,7 +412,8 @@ void ConfigureInputPlayer::loadConfiguration() { for (std::size_t i = 0; i < colors.size(); ++i) { controller_color_buttons[i]->setStyleSheet( - QString("QPushButton { background-color: %1 }").arg(controller_colors[i].name())); + QStringLiteral("QPushButton { background-color: %1 }") + .arg(controller_colors[i].name())); } } -- cgit v1.2.3 From aa83639b783145b35e4f8f3abcf6a568c85b4fa9 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sun, 19 May 2019 12:08:48 -0400 Subject: yuzu/configuration/configure_input_player: Clean up array accesses Rather than repeatedly index arrays that have quite a large array index, we can just use a named variable instead. --- src/yuzu/configuration/configure_input_player.cpp | 80 ++++++++++++++--------- 1 file changed, 48 insertions(+), 32 deletions(-) (limited to 'src') diff --git a/src/yuzu/configuration/configure_input_player.cpp b/src/yuzu/configuration/configure_input_player.cpp index 62a68d912..95b0a656a 100644 --- a/src/yuzu/configuration/configure_input_player.cpp +++ b/src/yuzu/configuration/configure_input_player.cpp @@ -238,38 +238,42 @@ ConfigureInputPlayer::ConfigureInputPlayer(QWidget* parent, std::size_t player_i analog_map_stick = {ui->buttonLStickAnalog, ui->buttonRStickAnalog}; for (int button_id = 0; button_id < Settings::NativeButton::NumButtons; button_id++) { - if (!button_map[button_id]) + auto* const button = button_map[button_id]; + if (button == nullptr) { continue; - button_map[button_id]->setContextMenuPolicy(Qt::CustomContextMenu); - connect(button_map[button_id], &QPushButton::released, [=]() { + } + + button->setContextMenuPolicy(Qt::CustomContextMenu); + connect(button, &QPushButton::released, [=] { handleClick( button_map[button_id], [=](const Common::ParamPackage& params) { buttons_param[button_id] = params; }, InputCommon::Polling::DeviceType::Button); }); - connect(button_map[button_id], &QPushButton::customContextMenuRequested, - [=](const QPoint& menu_location) { - QMenu context_menu; - context_menu.addAction(tr("Clear"), [&] { - buttons_param[button_id].Clear(); - button_map[button_id]->setText(tr("[not set]")); - }); - context_menu.addAction(tr("Restore Default"), [&] { - buttons_param[button_id] = Common::ParamPackage{ - InputCommon::GenerateKeyboardParam(Config::default_buttons[button_id])}; - button_map[button_id]->setText(ButtonToText(buttons_param[button_id])); - }); - context_menu.exec(button_map[button_id]->mapToGlobal(menu_location)); - }); + connect(button, &QPushButton::customContextMenuRequested, [=](const QPoint& menu_location) { + QMenu context_menu; + context_menu.addAction(tr("Clear"), [&] { + buttons_param[button_id].Clear(); + button_map[button_id]->setText(tr("[not set]")); + }); + context_menu.addAction(tr("Restore Default"), [&] { + buttons_param[button_id] = Common::ParamPackage{ + InputCommon::GenerateKeyboardParam(Config::default_buttons[button_id])}; + button_map[button_id]->setText(ButtonToText(buttons_param[button_id])); + }); + context_menu.exec(button_map[button_id]->mapToGlobal(menu_location)); + }); } for (int analog_id = 0; analog_id < Settings::NativeAnalog::NumAnalogs; analog_id++) { for (int sub_button_id = 0; sub_button_id < ANALOG_SUB_BUTTONS_NUM; sub_button_id++) { - if (!analog_map_buttons[analog_id][sub_button_id]) + auto* const analog_button = analog_map_buttons[analog_id][sub_button_id]; + if (analog_button == nullptr) { continue; - analog_map_buttons[analog_id][sub_button_id]->setContextMenuPolicy( - Qt::CustomContextMenu); - connect(analog_map_buttons[analog_id][sub_button_id], &QPushButton::released, [=]() { + } + + analog_button->setContextMenuPolicy(Qt::CustomContextMenu); + connect(analog_button, &QPushButton::released, [=]() { handleClick(analog_map_buttons[analog_id][sub_button_id], [=](const Common::ParamPackage& params) { SetAnalogButton(params, analogs_param[analog_id], @@ -277,8 +281,8 @@ ConfigureInputPlayer::ConfigureInputPlayer(QWidget* parent, std::size_t player_i }, InputCommon::Polling::DeviceType::Button); }); - connect(analog_map_buttons[analog_id][sub_button_id], - &QPushButton::customContextMenuRequested, [=](const QPoint& menu_location) { + connect(analog_button, &QPushButton::customContextMenuRequested, + [=](const QPoint& menu_location) { QMenu context_menu; context_menu.addAction(tr("Clear"), [&] { analogs_param[analog_id].Erase(analog_sub_buttons[sub_button_id]); @@ -296,7 +300,7 @@ ConfigureInputPlayer::ConfigureInputPlayer(QWidget* parent, std::size_t player_i menu_location)); }); } - connect(analog_map_stick[analog_id], &QPushButton::released, [=]() { + connect(analog_map_stick[analog_id], &QPushButton::released, [=] { QMessageBox::information(this, tr("Information"), tr("After pressing OK, first move your joystick horizontally, " "and then vertically.")); @@ -435,14 +439,22 @@ void ConfigureInputPlayer::restoreDefaults() { void ConfigureInputPlayer::ClearAll() { for (int button_id = 0; button_id < Settings::NativeButton::NumButtons; button_id++) { - if (button_map[button_id] && button_map[button_id]->isEnabled()) - buttons_param[button_id].Clear(); + const auto* const button = button_map[button_id]; + if (button == nullptr || !button->isEnabled()) { + continue; + } + + buttons_param[button_id].Clear(); } + for (int analog_id = 0; analog_id < Settings::NativeAnalog::NumAnalogs; analog_id++) { for (int sub_button_id = 0; sub_button_id < ANALOG_SUB_BUTTONS_NUM; sub_button_id++) { - if (analog_map_buttons[analog_id][sub_button_id] && - analog_map_buttons[analog_id][sub_button_id]->isEnabled()) - analogs_param[analog_id].Erase(analog_sub_buttons[sub_button_id]); + const auto* const analog_button = analog_map_buttons[analog_id][sub_button_id]; + if (analog_button == nullptr || !analog_button->isEnabled()) { + continue; + } + + analogs_param[analog_id].Erase(analog_sub_buttons[sub_button_id]); } } @@ -456,10 +468,14 @@ void ConfigureInputPlayer::updateButtonLabels() { for (int analog_id = 0; analog_id < Settings::NativeAnalog::NumAnalogs; analog_id++) { for (int sub_button_id = 0; sub_button_id < ANALOG_SUB_BUTTONS_NUM; sub_button_id++) { - if (analog_map_buttons[analog_id][sub_button_id]) { - analog_map_buttons[analog_id][sub_button_id]->setText( - AnalogToText(analogs_param[analog_id], analog_sub_buttons[sub_button_id])); + auto* const analog_button = analog_map_buttons[analog_id][sub_button_id]; + + if (analog_button == nullptr) { + continue; } + + analog_button->setText( + AnalogToText(analogs_param[analog_id], analog_sub_buttons[sub_button_id])); } analog_map_stick[analog_id]->setText(tr("Set Analog Stick")); } -- cgit v1.2.3 From c9c4208c4a0196780446f1773ffcb87895b41d8f Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sun, 19 May 2019 12:24:13 -0400 Subject: yuzu/configuration/configure_mouse_advanced: Specify string conversions explicitly Allows the advanced mouse configuration code to build with implicit string conversions disabled. --- .../configuration/configure_mouse_advanced.cpp | 34 +++++++++++++++------- 1 file changed, 23 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/yuzu/configuration/configure_mouse_advanced.cpp b/src/yuzu/configuration/configure_mouse_advanced.cpp index ef857035e..ba5992f9f 100644 --- a/src/yuzu/configuration/configure_mouse_advanced.cpp +++ b/src/yuzu/configuration/configure_mouse_advanced.cpp @@ -25,7 +25,7 @@ static QString GetKeyName(int key_code) { case Qt::Key_Alt: return QObject::tr("Alt"); case Qt::Key_Meta: - return ""; + return {}; default: return QKeySequence(key_code).toString(); } @@ -34,24 +34,36 @@ static QString GetKeyName(int key_code) { static QString ButtonToText(const Common::ParamPackage& param) { if (!param.Has("engine")) { return QObject::tr("[not set]"); - } else if (param.Get("engine", "") == "keyboard") { + } + + if (param.Get("engine", "") == "keyboard") { return GetKeyName(param.Get("code", 0)); - } else if (param.Get("engine", "") == "sdl") { + } + + if (param.Get("engine", "") == "sdl") { if (param.Has("hat")) { - return QString(QObject::tr("Hat %1 %2")) - .arg(param.Get("hat", "").c_str(), param.Get("direction", "").c_str()); + const QString hat_str = QString::fromStdString(param.Get("hat", "")); + const QString direction_str = QString::fromStdString(param.Get("direction", "")); + + return QObject::tr("Hat %1 %2").arg(hat_str, direction_str); } + if (param.Has("axis")) { - return QString(QObject::tr("Axis %1%2")) - .arg(param.Get("axis", "").c_str(), param.Get("direction", "").c_str()); + const QString axis_str = QString::fromStdString(param.Get("axis", "")); + const QString direction_str = QString::fromStdString(param.Get("direction", "")); + + return QObject::tr("Axis %1%2").arg(axis_str, direction_str); } + if (param.Has("button")) { - return QString(QObject::tr("Button %1")).arg(param.Get("button", "").c_str()); + const QString button_str = QString::fromStdString(param.Get("button", "")); + + return QObject::tr("Button %1").arg(button_str); } - return QString(); - } else { - return QObject::tr("[unknown]"); + return {}; } + + return QObject::tr("[unknown]"); } ConfigureMouseAdvanced::ConfigureMouseAdvanced(QWidget* parent) -- cgit v1.2.3 From 3039211c205e8d065695f7bc681cc3a44933de2f Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sun, 19 May 2019 12:31:47 -0400 Subject: yuzu/configuration/configure_mouse_advanced: Clean up array accesses Deduplicates array accesses and uses a named variable where appropriate. --- .../configuration/configure_mouse_advanced.cpp | 41 ++++++++++++---------- 1 file changed, 22 insertions(+), 19 deletions(-) (limited to 'src') diff --git a/src/yuzu/configuration/configure_mouse_advanced.cpp b/src/yuzu/configuration/configure_mouse_advanced.cpp index ba5992f9f..a14bb1475 100644 --- a/src/yuzu/configuration/configure_mouse_advanced.cpp +++ b/src/yuzu/configuration/configure_mouse_advanced.cpp @@ -77,30 +77,31 @@ ConfigureMouseAdvanced::ConfigureMouseAdvanced(QWidget* parent) }; for (int button_id = 0; button_id < Settings::NativeMouseButton::NumMouseButtons; button_id++) { - if (!button_map[button_id]) + auto* const button = button_map[button_id]; + if (button == nullptr) { continue; - button_map[button_id]->setContextMenuPolicy(Qt::CustomContextMenu); - connect(button_map[button_id], &QPushButton::released, [=]() { + } + + button->setContextMenuPolicy(Qt::CustomContextMenu); + connect(button, &QPushButton::released, [=] { handleClick( button_map[button_id], [=](const Common::ParamPackage& params) { buttons_param[button_id] = params; }, InputCommon::Polling::DeviceType::Button); }); - connect(button_map[button_id], &QPushButton::customContextMenuRequested, - [=](const QPoint& menu_location) { - QMenu context_menu; - context_menu.addAction(tr("Clear"), [&] { - buttons_param[button_id].Clear(); - button_map[button_id]->setText(tr("[not set]")); - }); - context_menu.addAction(tr("Restore Default"), [&] { - buttons_param[button_id] = - Common::ParamPackage{InputCommon::GenerateKeyboardParam( - Config::default_mouse_buttons[button_id])}; - button_map[button_id]->setText(ButtonToText(buttons_param[button_id])); - }); - context_menu.exec(button_map[button_id]->mapToGlobal(menu_location)); - }); + connect(button, &QPushButton::customContextMenuRequested, [=](const QPoint& menu_location) { + QMenu context_menu; + context_menu.addAction(tr("Clear"), [&] { + buttons_param[button_id].Clear(); + button_map[button_id]->setText(tr("[not set]")); + }); + context_menu.addAction(tr("Restore Default"), [&] { + buttons_param[button_id] = Common::ParamPackage{ + InputCommon::GenerateKeyboardParam(Config::default_mouse_buttons[button_id])}; + button_map[button_id]->setText(ButtonToText(buttons_param[button_id])); + }); + context_menu.exec(button_map[button_id]->mapToGlobal(menu_location)); + }); } connect(ui->buttonClearAll, &QPushButton::released, [this] { ClearAll(); }); @@ -150,8 +151,10 @@ void ConfigureMouseAdvanced::restoreDefaults() { void ConfigureMouseAdvanced::ClearAll() { for (int i = 0; i < Settings::NativeMouseButton::NumMouseButtons; ++i) { - if (button_map[i] && button_map[i]->isEnabled()) + const auto* const button = button_map[i]; + if (button != nullptr && button->isEnabled()) { buttons_param[i].Clear(); + } } updateButtonLabels(); -- cgit v1.2.3 From 17255cd835a4727ab83fd2bfa1b4d21a98a19f61 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sun, 19 May 2019 12:47:30 -0400 Subject: yuzu/configuration/configure_per_general: Specify string conversions explicitly Allows the per-game configuration to be successfully built with implicit string conversions disabled. --- src/yuzu/configuration/configure_per_general.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/yuzu/configuration/configure_per_general.cpp b/src/yuzu/configuration/configure_per_general.cpp index 022b94609..2bdfc8e5a 100644 --- a/src/yuzu/configuration/configure_per_general.cpp +++ b/src/yuzu/configuration/configure_per_general.cpp @@ -88,15 +88,15 @@ void ConfigurePerGameGeneral::loadFromFile(FileSys::VirtualFile file) { } void ConfigurePerGameGeneral::loadConfiguration() { - if (file == nullptr) + if (file == nullptr) { return; + } - const auto loader = Loader::GetLoader(file); - - ui->display_title_id->setText(fmt::format("{:016X}", title_id).c_str()); + ui->display_title_id->setText(QString::fromStdString(fmt::format("{:016X}", title_id))); FileSys::PatchManager pm{title_id}; const auto control = pm.GetControlMetadata(); + const auto loader = Loader::GetLoader(file); if (control.first != nullptr) { ui->display_version->setText(QString::fromStdString(control.first->GetVersionString())); @@ -142,8 +142,10 @@ void ConfigurePerGameGeneral::loadConfiguration() { const auto& disabled = Settings::values.disabled_addons[title_id]; for (const auto& patch : pm.GetPatchVersionNames(update_raw)) { - QStandardItem* first_item = new QStandardItem; - const auto name = QString::fromStdString(patch.first).replace("[D] ", ""); + const auto name = + QString::fromStdString(patch.first).replace(QStringLiteral("[D] "), QString{}); + + auto* const first_item = new QStandardItem; first_item->setText(name); first_item->setCheckable(true); -- cgit v1.2.3 From 428d8098a76e3bf065c8e7666e1fdd175bd51d12 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sun, 19 May 2019 12:54:01 -0400 Subject: yuzu/configuration/configure_profile_manager: Mark UI string as translatable This is a user-facing string, so it should be marked as translatable. --- src/yuzu/configuration/configure_profile_manager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/yuzu/configuration/configure_profile_manager.cpp b/src/yuzu/configuration/configure_profile_manager.cpp index 41663e39a..002a51780 100644 --- a/src/yuzu/configuration/configure_profile_manager.cpp +++ b/src/yuzu/configuration/configure_profile_manager.cpp @@ -98,7 +98,7 @@ ConfigureProfileManager ::ConfigureProfileManager(QWidget* parent) tree_view->setContextMenuPolicy(Qt::NoContextMenu); item_model->insertColumns(0, 1); - item_model->setHeaderData(0, Qt::Horizontal, "Users"); + item_model->setHeaderData(0, Qt::Horizontal, tr("Users")); // We must register all custom types with the Qt Automoc system so that we are able to use it // with signals/slots. In this case, QList falls under the umbrells of custom types. -- cgit v1.2.3 From d9c4d64ed548f2234bb583b147e6a2089a13a538 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sun, 19 May 2019 12:56:39 -0400 Subject: yuzu/configuration/configure_system: Specify string conversions explicitly Allows the system config code to build successfully with implicit string conversions disabled. --- src/yuzu/configuration/configure_system.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/yuzu/configuration/configure_system.cpp b/src/yuzu/configuration/configure_system.cpp index 10645a2b3..ff18ace40 100644 --- a/src/yuzu/configuration/configure_system.cpp +++ b/src/yuzu/configuration/configure_system.cpp @@ -66,8 +66,9 @@ void ConfigureSystem::setConfiguration() { ui->rng_seed_checkbox->setChecked(Settings::values.rng_seed.has_value()); ui->rng_seed_edit->setEnabled(Settings::values.rng_seed.has_value()); - const auto rng_seed = - QString("%1").arg(Settings::values.rng_seed.value_or(0), 8, 16, QLatin1Char{'0'}).toUpper(); + const auto rng_seed = QStringLiteral("%1") + .arg(Settings::values.rng_seed.value_or(0), 8, 16, QLatin1Char{'0'}) + .toUpper(); ui->rng_seed_edit->setText(rng_seed); ui->custom_rtc_checkbox->setChecked(Settings::values.custom_rtc.has_value()); -- cgit v1.2.3 From 2318c394a805cbd58e6087a144456d3980e1de36 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sun, 19 May 2019 13:05:06 -0400 Subject: yuzu/configuration/configure_web: Specify string conversions explicitly Allows the web config code to compile with implicit string conversions disabled. We can also deduplicate the calls to create the pixmap. --- src/yuzu/configuration/configure_web.cpp | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/yuzu/configuration/configure_web.cpp b/src/yuzu/configuration/configure_web.cpp index 18566d028..9dc34412d 100644 --- a/src/yuzu/configuration/configure_web.cpp +++ b/src/yuzu/configuration/configure_web.cpp @@ -78,12 +78,16 @@ void ConfigureWeb::RefreshTelemetryID() { void ConfigureWeb::OnLoginChanged() { if (ui->edit_username->text().isEmpty() && ui->edit_token->text().isEmpty()) { user_verified = true; - ui->label_username_verified->setPixmap(QIcon::fromTheme("checked").pixmap(16)); - ui->label_token_verified->setPixmap(QIcon::fromTheme("checked").pixmap(16)); + + const QPixmap pixmap = QIcon::fromTheme(QStringLiteral("checked")).pixmap(16); + ui->label_username_verified->setPixmap(pixmap); + ui->label_token_verified->setPixmap(pixmap); } else { user_verified = false; - ui->label_username_verified->setPixmap(QIcon::fromTheme("failed").pixmap(16)); - ui->label_token_verified->setPixmap(QIcon::fromTheme("failed").pixmap(16)); + + const QPixmap pixmap = QIcon::fromTheme(QStringLiteral("failed")).pixmap(16); + ui->label_username_verified->setPixmap(pixmap); + ui->label_token_verified->setPixmap(pixmap); } } @@ -101,11 +105,15 @@ void ConfigureWeb::OnLoginVerified() { ui->button_verify_login->setText(tr("Verify")); if (verify_watcher.result()) { user_verified = true; - ui->label_username_verified->setPixmap(QIcon::fromTheme("checked").pixmap(16)); - ui->label_token_verified->setPixmap(QIcon::fromTheme("checked").pixmap(16)); + + const QPixmap pixmap = QIcon::fromTheme(QStringLiteral("checked")).pixmap(16); + ui->label_username_verified->setPixmap(pixmap); + ui->label_token_verified->setPixmap(pixmap); } else { - ui->label_username_verified->setPixmap(QIcon::fromTheme("failed").pixmap(16)); - ui->label_token_verified->setPixmap(QIcon::fromTheme("failed").pixmap(16)); + const QPixmap pixmap = QIcon::fromTheme(QStringLiteral("failed")).pixmap(16); + ui->label_username_verified->setPixmap(pixmap); + ui->label_token_verified->setPixmap(pixmap); + QMessageBox::critical( this, tr("Verification failed"), tr("Verification failed. Check that you have entered your username and token " -- cgit v1.2.3