Merge pull request #2499 from lioncash/translate

yuzu/configuration: Specify string conversions explicitly
This commit is contained in:
bunnei 2019-05-20 11:13:25 -04:00 committed by GitHub
commit 0adb54abc1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 206 additions and 133 deletions

View File

@ -16,21 +16,21 @@ ConfigureAudio::ConfigureAudio(QWidget* parent)
ui->setupUi(this); ui->setupUi(this);
ui->output_sink_combo_box->clear(); 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()) { 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, connect(ui->volume_slider, &QSlider::valueChanged, this,
&ConfigureAudio::setVolumeIndicatorText); &ConfigureAudio::setVolumeIndicatorText);
this->setConfiguration(); this->setConfiguration();
connect(ui->output_sink_combo_box, connect(ui->output_sink_combo_box, qOverload<int>(&QComboBox::currentIndexChanged), this,
static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this,
&ConfigureAudio::updateAudioDevices); &ConfigureAudio::updateAudioDevices);
ui->output_sink_combo_box->setEnabled(!Core::System::GetInstance().IsPoweredOn()); const bool is_powered_on = Core::System::GetInstance().IsPoweredOn();
ui->audio_device_combo_box->setEnabled(!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; ConfigureAudio::~ConfigureAudio() = default;
@ -94,7 +94,7 @@ void ConfigureAudio::applyConfiguration() {
void ConfigureAudio::updateAudioDevices(int sink_index) { void ConfigureAudio::updateAudioDevices(int sink_index) {
ui->audio_device_combo_box->clear(); 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(); const std::string sink_id = ui->output_sink_combo_box->itemText(sink_index).toStdString();
for (const auto& device : AudioCore::GetDeviceListForSink(sink_id)) { for (const auto& device : AudioCore::GetDeviceListForSink(sink_id)) {

View File

@ -100,13 +100,15 @@ void ConfigureGameList::RetranslateUI() {
void ConfigureGameList::InitializeIconSizeComboBox() { void ConfigureGameList::InitializeIconSizeComboBox() {
for (const auto& size : default_icon_sizes) { 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() { void ConfigureGameList::InitializeRowComboBoxes() {
for (std::size_t i = 0; i < row_text_names.size(); ++i) { 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)); const QString row_text_name = QString::fromUtf8(row_text_names[i]);
ui->row_2_text_combobox->addItem(row_text_names[i], QVariant::fromValue(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));
} }
} }

View File

@ -14,7 +14,8 @@ ConfigureGeneral::ConfigureGeneral(QWidget* parent)
ui->setupUi(this); ui->setupUi(this);
for (const auto& theme : UISettings::themes) { 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(); this->setConfiguration();

View File

@ -75,8 +75,8 @@ ConfigureInput::ConfigureInput(QWidget* parent)
}; };
for (auto* controller_box : players_controller) { for (auto* controller_box : players_controller) {
controller_box->addItems({"None", "Pro Controller", "Dual Joycons", "Single Right Joycon", controller_box->addItems({tr("None"), tr("Pro Controller"), tr("Dual Joycons"),
"Single Left Joycon"}); tr("Single Right Joycon"), tr("Single Left Joycon")});
} }
this->loadConfiguration(); this->loadConfiguration();
@ -85,9 +85,10 @@ ConfigureInput::ConfigureInput(QWidget* parent)
connect(ui->restore_defaults_button, &QPushButton::pressed, this, connect(ui->restore_defaults_button, &QPushButton::pressed, this,
&ConfigureInput::restoreDefaults); &ConfigureInput::restoreDefaults);
for (auto* enabled : players_controller) for (auto* enabled : players_controller) {
connect(enabled, QOverload<int>::of(&QComboBox::currentIndexChanged), this, connect(enabled, QOverload<int>::of(&QComboBox::currentIndexChanged), this,
&ConfigureInput::updateUIEnabled); &ConfigureInput::updateUIEnabled);
}
connect(ui->use_docked_mode, &QCheckBox::stateChanged, this, &ConfigureInput::updateUIEnabled); connect(ui->use_docked_mode, &QCheckBox::stateChanged, this, &ConfigureInput::updateUIEnabled);
connect(ui->handheld_connected, &QCheckBox::stateChanged, this, connect(ui->handheld_connected, &QCheckBox::stateChanged, this,
&ConfigureInput::updateUIEnabled); &ConfigureInput::updateUIEnabled);
@ -147,11 +148,13 @@ void ConfigureInput::updateUIEnabled() {
bool hit_disabled = false; bool hit_disabled = false;
for (auto* player : players_controller) { for (auto* player : players_controller) {
player->setDisabled(hit_disabled); player->setDisabled(hit_disabled);
if (hit_disabled) if (hit_disabled) {
player->setCurrentIndex(0); player->setCurrentIndex(0);
if (!hit_disabled && player->currentIndex() == 0) }
if (!hit_disabled && player->currentIndex() == 0) {
hit_disabled = true; hit_disabled = true;
} }
}
for (std::size_t i = 0; i < players_controller.size(); ++i) { for (std::size_t i = 0; i < players_controller.size(); ++i) {
players_configure[i]->setEnabled(players_controller[i]->currentIndex() != 0); players_configure[i]->setEnabled(players_controller[i]->currentIndex() != 0);

View File

@ -45,7 +45,7 @@ static QString GetKeyName(int key_code) {
case Qt::Key_Alt: case Qt::Key_Alt:
return QObject::tr("Alt"); return QObject::tr("Alt");
case Qt::Key_Meta: case Qt::Key_Meta:
return ""; return {};
default: default:
return QKeySequence(key_code).toString(); return QKeySequence(key_code).toString();
} }
@ -65,46 +65,70 @@ static void SetAnalogButton(const Common::ParamPackage& input_param,
static QString ButtonToText(const Common::ParamPackage& param) { static QString ButtonToText(const Common::ParamPackage& param) {
if (!param.Has("engine")) { if (!param.Has("engine")) {
return QObject::tr("[not set]"); return QObject::tr("[not set]");
} else if (param.Get("engine", "") == "keyboard") { }
if (param.Get("engine", "") == "keyboard") {
return GetKeyName(param.Get("code", 0)); return GetKeyName(param.Get("code", 0));
} else if (param.Get("engine", "") == "sdl") { }
if (param.Get("engine", "") == "sdl") {
if (param.Has("hat")) { if (param.Has("hat")) {
return QString(QObject::tr("Hat %1 %2")) const QString hat_str = QString::fromStdString(param.Get("hat", ""));
.arg(param.Get("hat", "").c_str(), param.Get("direction", "").c_str()); const QString direction_str = QString::fromStdString(param.Get("direction", ""));
return QObject::tr("Hat %1 %2").arg(hat_str, direction_str);
} }
if (param.Has("axis")) { if (param.Has("axis")) {
return QString(QObject::tr("Axis %1%2")) const QString axis_str = QString::fromStdString(param.Get("axis", ""));
.arg(param.Get("axis", "").c_str(), param.Get("direction", "").c_str()); const QString direction_str = QString::fromStdString(param.Get("direction", ""));
return QObject::tr("Axis %1%2").arg(axis_str, direction_str);
} }
if (param.Has("button")) { 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 {};
}
return QObject::tr("[unknown]"); return QObject::tr("[unknown]");
} }
};
static QString AnalogToText(const Common::ParamPackage& param, const std::string& dir) { static QString AnalogToText(const Common::ParamPackage& param, const std::string& dir) {
if (!param.Has("engine")) { if (!param.Has("engine")) {
return QObject::tr("[not set]"); 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, "")}); return ButtonToText(Common::ParamPackage{param.Get(dir, "")});
} else if (param.Get("engine", "") == "sdl") { }
if (param.Get("engine", "") == "sdl") {
if (dir == "modifier") { if (dir == "modifier") {
return QString(QObject::tr("[unused]")); return QObject::tr("[unused]");
} }
if (dir == "left" || dir == "right") { if (dir == "left" || dir == "right") {
return QString(QObject::tr("Axis %1")).arg(param.Get("axis_x", "").c_str()); const QString axis_x_str = QString::fromStdString(param.Get("axis_x", ""));
} else if (dir == "up" || dir == "down") {
return QString(QObject::tr("Axis %1")).arg(param.Get("axis_y", "").c_str()); return QObject::tr("Axis %1").arg(axis_x_str);
} }
return QString();
} else { 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]"); return QObject::tr("[unknown]");
} }
};
ConfigureInputPlayer::ConfigureInputPlayer(QWidget* parent, std::size_t player_index, bool debug) ConfigureInputPlayer::ConfigureInputPlayer(QWidget* parent, std::size_t player_index, bool debug)
: QDialog(parent), ui(std::make_unique<Ui::ConfigureInputPlayer>()), player_index(player_index), : QDialog(parent), ui(std::make_unique<Ui::ConfigureInputPlayer>()), player_index(player_index),
@ -214,17 +238,19 @@ ConfigureInputPlayer::ConfigureInputPlayer(QWidget* parent, std::size_t player_i
analog_map_stick = {ui->buttonLStickAnalog, ui->buttonRStickAnalog}; analog_map_stick = {ui->buttonLStickAnalog, ui->buttonRStickAnalog};
for (int button_id = 0; button_id < Settings::NativeButton::NumButtons; button_id++) { 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; continue;
button_map[button_id]->setContextMenuPolicy(Qt::CustomContextMenu); }
connect(button_map[button_id], &QPushButton::released, [=]() {
button->setContextMenuPolicy(Qt::CustomContextMenu);
connect(button, &QPushButton::released, [=] {
handleClick( handleClick(
button_map[button_id], button_map[button_id],
[=](const Common::ParamPackage& params) { buttons_param[button_id] = params; }, [=](const Common::ParamPackage& params) { buttons_param[button_id] = params; },
InputCommon::Polling::DeviceType::Button); InputCommon::Polling::DeviceType::Button);
}); });
connect(button_map[button_id], &QPushButton::customContextMenuRequested, connect(button, &QPushButton::customContextMenuRequested, [=](const QPoint& menu_location) {
[=](const QPoint& menu_location) {
QMenu context_menu; QMenu context_menu;
context_menu.addAction(tr("Clear"), [&] { context_menu.addAction(tr("Clear"), [&] {
buttons_param[button_id].Clear(); buttons_param[button_id].Clear();
@ -241,11 +267,13 @@ ConfigureInputPlayer::ConfigureInputPlayer(QWidget* parent, std::size_t player_i
for (int analog_id = 0; analog_id < Settings::NativeAnalog::NumAnalogs; analog_id++) { 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++) { 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; 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], handleClick(analog_map_buttons[analog_id][sub_button_id],
[=](const Common::ParamPackage& params) { [=](const Common::ParamPackage& params) {
SetAnalogButton(params, analogs_param[analog_id], SetAnalogButton(params, analogs_param[analog_id],
@ -253,8 +281,8 @@ ConfigureInputPlayer::ConfigureInputPlayer(QWidget* parent, std::size_t player_i
}, },
InputCommon::Polling::DeviceType::Button); InputCommon::Polling::DeviceType::Button);
}); });
connect(analog_map_buttons[analog_id][sub_button_id], connect(analog_button, &QPushButton::customContextMenuRequested,
&QPushButton::customContextMenuRequested, [=](const QPoint& menu_location) { [=](const QPoint& menu_location) {
QMenu context_menu; QMenu context_menu;
context_menu.addAction(tr("Clear"), [&] { context_menu.addAction(tr("Clear"), [&] {
analogs_param[analog_id].Erase(analog_sub_buttons[sub_button_id]); analogs_param[analog_id].Erase(analog_sub_buttons[sub_button_id]);
@ -272,7 +300,7 @@ ConfigureInputPlayer::ConfigureInputPlayer(QWidget* parent, std::size_t player_i
menu_location)); menu_location));
}); });
} }
connect(analog_map_stick[analog_id], &QPushButton::released, [=]() { connect(analog_map_stick[analog_id], &QPushButton::released, [=] {
QMessageBox::information(this, tr("Information"), QMessageBox::information(this, tr("Information"),
tr("After pressing OK, first move your joystick horizontally, " tr("After pressing OK, first move your joystick horizontally, "
"and then vertically.")); "and then vertically."));
@ -351,7 +379,7 @@ void ConfigureInputPlayer::OnControllerButtonClick(int i) {
return; return;
controller_colors[i] = new_bg_color; controller_colors[i] = new_bg_color;
controller_color_buttons[i]->setStyleSheet( 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() { void ConfigureInputPlayer::loadConfiguration() {
@ -388,7 +416,8 @@ void ConfigureInputPlayer::loadConfiguration() {
for (std::size_t i = 0; i < colors.size(); ++i) { for (std::size_t i = 0; i < colors.size(); ++i) {
controller_color_buttons[i]->setStyleSheet( 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()));
} }
} }
@ -410,13 +439,21 @@ void ConfigureInputPlayer::restoreDefaults() {
void ConfigureInputPlayer::ClearAll() { void ConfigureInputPlayer::ClearAll() {
for (int button_id = 0; button_id < Settings::NativeButton::NumButtons; button_id++) { for (int button_id = 0; button_id < Settings::NativeButton::NumButtons; button_id++) {
if (button_map[button_id] && button_map[button_id]->isEnabled()) const auto* const button = button_map[button_id];
if (button == nullptr || !button->isEnabled()) {
continue;
}
buttons_param[button_id].Clear(); buttons_param[button_id].Clear();
} }
for (int analog_id = 0; analog_id < Settings::NativeAnalog::NumAnalogs; analog_id++) { 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++) { 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] && const auto* const analog_button = analog_map_buttons[analog_id][sub_button_id];
analog_map_buttons[analog_id][sub_button_id]->isEnabled()) if (analog_button == nullptr || !analog_button->isEnabled()) {
continue;
}
analogs_param[analog_id].Erase(analog_sub_buttons[sub_button_id]); analogs_param[analog_id].Erase(analog_sub_buttons[sub_button_id]);
} }
} }
@ -431,10 +468,14 @@ void ConfigureInputPlayer::updateButtonLabels() {
for (int analog_id = 0; analog_id < Settings::NativeAnalog::NumAnalogs; analog_id++) { 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++) { 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];
analog_map_buttons[analog_id][sub_button_id]->setText(
AnalogToText(analogs_param[analog_id], analog_sub_buttons[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")); analog_map_stick[analog_id]->setText(tr("Set Analog Stick"));
} }

View File

@ -25,7 +25,7 @@ static QString GetKeyName(int key_code) {
case Qt::Key_Alt: case Qt::Key_Alt:
return QObject::tr("Alt"); return QObject::tr("Alt");
case Qt::Key_Meta: case Qt::Key_Meta:
return ""; return {};
default: default:
return QKeySequence(key_code).toString(); return QKeySequence(key_code).toString();
} }
@ -34,25 +34,37 @@ static QString GetKeyName(int key_code) {
static QString ButtonToText(const Common::ParamPackage& param) { static QString ButtonToText(const Common::ParamPackage& param) {
if (!param.Has("engine")) { if (!param.Has("engine")) {
return QObject::tr("[not set]"); return QObject::tr("[not set]");
} else if (param.Get("engine", "") == "keyboard") { }
if (param.Get("engine", "") == "keyboard") {
return GetKeyName(param.Get("code", 0)); return GetKeyName(param.Get("code", 0));
} else if (param.Get("engine", "") == "sdl") { }
if (param.Get("engine", "") == "sdl") {
if (param.Has("hat")) { if (param.Has("hat")) {
return QString(QObject::tr("Hat %1 %2")) const QString hat_str = QString::fromStdString(param.Get("hat", ""));
.arg(param.Get("hat", "").c_str(), param.Get("direction", "").c_str()); const QString direction_str = QString::fromStdString(param.Get("direction", ""));
return QObject::tr("Hat %1 %2").arg(hat_str, direction_str);
} }
if (param.Has("axis")) { if (param.Has("axis")) {
return QString(QObject::tr("Axis %1%2")) const QString axis_str = QString::fromStdString(param.Get("axis", ""));
.arg(param.Get("axis", "").c_str(), param.Get("direction", "").c_str()); const QString direction_str = QString::fromStdString(param.Get("direction", ""));
return QObject::tr("Axis %1%2").arg(axis_str, direction_str);
} }
if (param.Has("button")) { 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(); return {};
} else { }
return QObject::tr("[unknown]"); return QObject::tr("[unknown]");
} }
}
ConfigureMouseAdvanced::ConfigureMouseAdvanced(QWidget* parent) ConfigureMouseAdvanced::ConfigureMouseAdvanced(QWidget* parent)
: QDialog(parent), ui(std::make_unique<Ui::ConfigureMouseAdvanced>()), : QDialog(parent), ui(std::make_unique<Ui::ConfigureMouseAdvanced>()),
@ -65,26 +77,27 @@ ConfigureMouseAdvanced::ConfigureMouseAdvanced(QWidget* parent)
}; };
for (int button_id = 0; button_id < Settings::NativeMouseButton::NumMouseButtons; button_id++) { 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; continue;
button_map[button_id]->setContextMenuPolicy(Qt::CustomContextMenu); }
connect(button_map[button_id], &QPushButton::released, [=]() {
button->setContextMenuPolicy(Qt::CustomContextMenu);
connect(button, &QPushButton::released, [=] {
handleClick( handleClick(
button_map[button_id], button_map[button_id],
[=](const Common::ParamPackage& params) { buttons_param[button_id] = params; }, [=](const Common::ParamPackage& params) { buttons_param[button_id] = params; },
InputCommon::Polling::DeviceType::Button); InputCommon::Polling::DeviceType::Button);
}); });
connect(button_map[button_id], &QPushButton::customContextMenuRequested, connect(button, &QPushButton::customContextMenuRequested, [=](const QPoint& menu_location) {
[=](const QPoint& menu_location) {
QMenu context_menu; QMenu context_menu;
context_menu.addAction(tr("Clear"), [&] { context_menu.addAction(tr("Clear"), [&] {
buttons_param[button_id].Clear(); buttons_param[button_id].Clear();
button_map[button_id]->setText(tr("[not set]")); button_map[button_id]->setText(tr("[not set]"));
}); });
context_menu.addAction(tr("Restore Default"), [&] { context_menu.addAction(tr("Restore Default"), [&] {
buttons_param[button_id] = buttons_param[button_id] = Common::ParamPackage{
Common::ParamPackage{InputCommon::GenerateKeyboardParam( InputCommon::GenerateKeyboardParam(Config::default_mouse_buttons[button_id])};
Config::default_mouse_buttons[button_id])};
button_map[button_id]->setText(ButtonToText(buttons_param[button_id])); button_map[button_id]->setText(ButtonToText(buttons_param[button_id]));
}); });
context_menu.exec(button_map[button_id]->mapToGlobal(menu_location)); context_menu.exec(button_map[button_id]->mapToGlobal(menu_location));
@ -138,9 +151,11 @@ void ConfigureMouseAdvanced::restoreDefaults() {
void ConfigureMouseAdvanced::ClearAll() { void ConfigureMouseAdvanced::ClearAll() {
for (int i = 0; i < Settings::NativeMouseButton::NumMouseButtons; ++i) { 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(); buttons_param[i].Clear();
} }
}
updateButtonLabels(); updateButtonLabels();
} }

View File

@ -88,15 +88,15 @@ void ConfigurePerGameGeneral::loadFromFile(FileSys::VirtualFile file) {
} }
void ConfigurePerGameGeneral::loadConfiguration() { void ConfigurePerGameGeneral::loadConfiguration() {
if (file == nullptr) if (file == nullptr) {
return; return;
}
const auto loader = Loader::GetLoader(file); ui->display_title_id->setText(QString::fromStdString(fmt::format("{:016X}", title_id)));
ui->display_title_id->setText(fmt::format("{:016X}", title_id).c_str());
FileSys::PatchManager pm{title_id}; FileSys::PatchManager pm{title_id};
const auto control = pm.GetControlMetadata(); const auto control = pm.GetControlMetadata();
const auto loader = Loader::GetLoader(file);
if (control.first != nullptr) { if (control.first != nullptr) {
ui->display_version->setText(QString::fromStdString(control.first->GetVersionString())); 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]; const auto& disabled = Settings::values.disabled_addons[title_id];
for (const auto& patch : pm.GetPatchVersionNames(update_raw)) { for (const auto& patch : pm.GetPatchVersionNames(update_raw)) {
QStandardItem* first_item = new QStandardItem; const auto name =
const auto name = QString::fromStdString(patch.first).replace("[D] ", ""); QString::fromStdString(patch.first).replace(QStringLiteral("[D] "), QString{});
auto* const first_item = new QStandardItem;
first_item->setText(name); first_item->setText(name);
first_item->setCheckable(true); first_item->setCheckable(true);

View File

@ -98,7 +98,7 @@ ConfigureProfileManager ::ConfigureProfileManager(QWidget* parent)
tree_view->setContextMenuPolicy(Qt::NoContextMenu); tree_view->setContextMenuPolicy(Qt::NoContextMenu);
item_model->insertColumns(0, 1); 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 // 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. // with signals/slots. In this case, QList falls under the umbrells of custom types.

View File

@ -66,8 +66,9 @@ void ConfigureSystem::setConfiguration() {
ui->rng_seed_checkbox->setChecked(Settings::values.rng_seed.has_value()); ui->rng_seed_checkbox->setChecked(Settings::values.rng_seed.has_value());
ui->rng_seed_edit->setEnabled(Settings::values.rng_seed.has_value()); ui->rng_seed_edit->setEnabled(Settings::values.rng_seed.has_value());
const auto rng_seed = const auto rng_seed = QStringLiteral("%1")
QString("%1").arg(Settings::values.rng_seed.value_or(0), 8, 16, QLatin1Char{'0'}).toUpper(); .arg(Settings::values.rng_seed.value_or(0), 8, 16, QLatin1Char{'0'})
.toUpper();
ui->rng_seed_edit->setText(rng_seed); ui->rng_seed_edit->setText(rng_seed);
ui->custom_rtc_checkbox->setChecked(Settings::values.custom_rtc.has_value()); ui->custom_rtc_checkbox->setChecked(Settings::values.custom_rtc.has_value());

View File

@ -78,12 +78,16 @@ void ConfigureWeb::RefreshTelemetryID() {
void ConfigureWeb::OnLoginChanged() { void ConfigureWeb::OnLoginChanged() {
if (ui->edit_username->text().isEmpty() && ui->edit_token->text().isEmpty()) { if (ui->edit_username->text().isEmpty() && ui->edit_token->text().isEmpty()) {
user_verified = true; 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 { } else {
user_verified = false; 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")); ui->button_verify_login->setText(tr("Verify"));
if (verify_watcher.result()) { if (verify_watcher.result()) {
user_verified = true; 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 { } else {
ui->label_username_verified->setPixmap(QIcon::fromTheme("failed").pixmap(16)); const QPixmap pixmap = QIcon::fromTheme(QStringLiteral("failed")).pixmap(16);
ui->label_token_verified->setPixmap(QIcon::fromTheme("failed").pixmap(16)); ui->label_username_verified->setPixmap(pixmap);
ui->label_token_verified->setPixmap(pixmap);
QMessageBox::critical( QMessageBox::critical(
this, tr("Verification failed"), this, tr("Verification failed"),
tr("Verification failed. Check that you have entered your username and token " tr("Verification failed. Check that you have entered your username and token "