mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-04-21 03:55:32 +00:00
Qt: localize default pad names
This commit is contained in:
parent
7abc5f3ead
commit
183380fe57
4 changed files with 36 additions and 7 deletions
|
@ -6,6 +6,7 @@
|
|||
struct pad_device_info
|
||||
{
|
||||
std::string name;
|
||||
QString localized_name;
|
||||
bool is_connected{false};
|
||||
};
|
||||
|
||||
|
|
|
@ -52,7 +52,7 @@ pad_motion_settings_dialog::pad_motion_settings_dialog(QDialog* parent, std::sha
|
|||
if (device.is_buddy_only)
|
||||
{
|
||||
const QString device_name = QString::fromStdString(device.name);
|
||||
const QVariant user_data = QVariant::fromValue(pad_device_info{ device.name, true });
|
||||
const QVariant user_data = QVariant::fromValue(pad_device_info{ device.name, device_name, true });
|
||||
|
||||
ui->cb_choose_device->addItem(device_name, user_data);
|
||||
}
|
||||
|
|
|
@ -648,7 +648,7 @@ void pad_settings_dialog::switch_pad_info(int index, pad_device_info info, bool
|
|||
info.is_connected = is_connected;
|
||||
|
||||
ui->chooseDevice->setItemData(index, QVariant::fromValue(info));
|
||||
ui->chooseDevice->setItemText(index, is_connected ? qstr(info.name) : (qstr(info.name) + Disconnected_suffix));
|
||||
ui->chooseDevice->setItemText(index, is_connected ? info.localized_name : (info.localized_name + Disconnected_suffix));
|
||||
}
|
||||
|
||||
if (!is_connected && m_remap_timer.isActive() && ui->chooseDevice->currentIndex() == index)
|
||||
|
@ -1456,7 +1456,8 @@ void pad_settings_dialog::ChangeHandler()
|
|||
for (usz i = 1; i <= m_handler->max_devices(); i++) // Controllers 1-n in GUI
|
||||
{
|
||||
const QString device_name = name_string + QString::number(i);
|
||||
ui->chooseDevice->addItem(device_name, QVariant::fromValue(pad_device_info{ sstr(device_name), true }));
|
||||
const QString device_name_localized = GetLocalizedPadName(m_handler->m_type, device_name, i);
|
||||
ui->chooseDevice->addItem(device_name_localized, QVariant::fromValue(pad_device_info{ sstr(device_name), device_name_localized, true }));
|
||||
}
|
||||
force_enable = true;
|
||||
break;
|
||||
|
@ -1472,14 +1473,16 @@ void pad_settings_dialog::ChangeHandler()
|
|||
}
|
||||
default:
|
||||
{
|
||||
for (const pad_list_entry& device : device_list)
|
||||
for (usz i = 0; i < device_list.size(); i++)
|
||||
{
|
||||
const pad_list_entry& device = ::at32(device_list, i);
|
||||
|
||||
if (!device.is_buddy_only)
|
||||
{
|
||||
const QString device_name = QString::fromStdString(device.name);
|
||||
const QVariant user_data = QVariant::fromValue(pad_device_info{ device.name, true });
|
||||
const QString device_name_localized = GetLocalizedPadName(m_handler->m_type, QString::fromStdString(device.name), i);
|
||||
const QVariant user_data = QVariant::fromValue(pad_device_info{ device.name, device_name_localized, true });
|
||||
|
||||
ui->chooseDevice->addItem(device_name, user_data);
|
||||
ui->chooseDevice->addItem(device_name_localized, user_data);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -1914,6 +1917,30 @@ QString pad_settings_dialog::GetLocalizedPadHandler(const QString& original, pad
|
|||
return original;
|
||||
}
|
||||
|
||||
QString pad_settings_dialog::GetLocalizedPadName(pad_handler handler, const QString& original, usz index)
|
||||
{
|
||||
switch (handler)
|
||||
{
|
||||
case pad_handler::null: return tr("Default Null Device");
|
||||
case pad_handler::keyboard: return tr("Keyboard");
|
||||
case pad_handler::ds3: return tr("DS3 Pad #%0").arg(index);
|
||||
case pad_handler::ds4: return tr("DS4 Pad #%0").arg(index);
|
||||
case pad_handler::dualsense: return tr("DualSense Pad #%0").arg(index);
|
||||
case pad_handler::skateboard: return tr("Skateboard #%0").arg(index);
|
||||
#ifdef _WIN32
|
||||
case pad_handler::xinput: return tr("XInput Pad #%0").arg(index);
|
||||
case pad_handler::mm: return tr("Joystick #%0").arg(index);
|
||||
#endif
|
||||
#ifdef HAVE_SDL2
|
||||
case pad_handler::sdl: break; // Localization not feasible. Names differ for each device.
|
||||
#endif
|
||||
#ifdef HAVE_LIBEVDEV
|
||||
case pad_handler::evdev: break; // Localization not feasible. Names differ for each device.
|
||||
#endif
|
||||
}
|
||||
return original;
|
||||
}
|
||||
|
||||
bool pad_settings_dialog::GetIsLddPad(u32 index) const
|
||||
{
|
||||
// We only check for ldd pads if the current dialog may affect the running application.
|
||||
|
|
|
@ -208,6 +208,7 @@ private:
|
|||
void RepaintPreviewLabel(QLabel* l, int deadzone, int desired_width, int x, int y, int squircle, double multiplier) const;
|
||||
|
||||
QString GetLocalizedPadHandler(const QString& original, pad_handler handler);
|
||||
QString GetLocalizedPadName(pad_handler handler, const QString& original, usz index);
|
||||
|
||||
/** Checks if the port at the given index is already reserved by the application as custom controller (ldd pad) */
|
||||
bool GetIsLddPad(u32 index) const;
|
||||
|
|
Loading…
Add table
Reference in a new issue