Qt: make cheat_type combobox translateable

This commit is contained in:
Megamouse 2020-04-06 20:22:33 +02:00
parent 96086d57fa
commit 2bd4485082
3 changed files with 26 additions and 4 deletions

View File

@ -552,9 +552,8 @@ cheat_manager_dialog::cheat_manager_dialog(QWidget* parent)
for (u64 i = 0; i < cheat_type_max; i++)
{
std::string type_formatted;
fmt::append(type_formatted, "%s", static_cast<cheat_type>(i));
cbx_cheat_search_type->insertItem(i, QString::fromStdString(type_formatted));
const QString item_text = get_localized_cheat_type(static_cast<cheat_type>(i));
cbx_cheat_search_type->addItem(item_text);
}
cbx_cheat_search_type->setCurrentIndex(static_cast<u8>(cheat_type::signed_32_cheat));
grp_add_cheat_sub_layout->addWidget(btn_new_search);
@ -1012,3 +1011,24 @@ void cheat_manager_dialog::update_cheat_list()
g_cheat.save();
}
QString cheat_manager_dialog::get_localized_cheat_type(cheat_type type)
{
switch (type)
{
case cheat_type::unsigned_8_cheat: return tr("Unsigned 8 bits");
case cheat_type::unsigned_16_cheat: return tr("Unsigned 16 bits");
case cheat_type::unsigned_32_cheat: return tr("Unsigned 32 bits");
case cheat_type::unsigned_64_cheat: return tr("Unsigned 64 bits");
case cheat_type::signed_8_cheat: return tr("Signed 8 bits");
case cheat_type::signed_16_cheat: return tr("Signed 16 bits");
case cheat_type::signed_32_cheat: return tr("Signed 32 bits");
case cheat_type::signed_64_cheat: return tr("Signed 64 bits");
case cheat_type::max:
default:
break;
}
std::string type_formatted;
fmt::append(type_formatted, "%s", type);
return QString::fromStdString(type_formatted);
}

View File

@ -112,4 +112,6 @@ protected:
private:
static cheat_manager_dialog* inst;
QString get_localized_cheat_type(cheat_type type);
};

View File

@ -45,7 +45,7 @@ vfs_dialog_tab::vfs_dialog_tab(vfs_settings_info settingsInfo, std::shared_ptr<g
QHBoxLayout* selectedConfigLayout = new QHBoxLayout;
m_selectedConfigLabel = new QLabel(current_dir.isEmpty() ? EmptyPath : current_dir);
selectedConfigLayout->addWidget(new QLabel(m_info.name + tr(" directory:")));
selectedConfigLayout->addWidget(new QLabel(tr("%0 directory:").arg(m_info.name)));
selectedConfigLayout->addWidget(m_selectedConfigLabel);
selectedConfigLayout->addStretch();
selectedConfigLayout->addWidget(addDir);