From 98a4e59f528c8116ca1dc19b3d50b97c350ffc05 Mon Sep 17 00:00:00 2001 From: Connor McLaughlin Date: Tue, 5 Jan 2021 19:34:20 +1000 Subject: [PATCH] Qt: Fix some strings not being translatable --- src/core/playstation_mouse.cpp | 4 +- src/duckstation-qt/debuggermodels.cpp | 56 +++++++++++++++++---------- 2 files changed, 38 insertions(+), 22 deletions(-) diff --git a/src/core/playstation_mouse.cpp b/src/core/playstation_mouse.cpp index d2dafc147..57c4eeb2b 100644 --- a/src/core/playstation_mouse.cpp +++ b/src/core/playstation_mouse.cpp @@ -212,8 +212,8 @@ u32 PlayStationMouse::StaticGetVibrationMotorCount() Controller::SettingList PlayStationMouse::StaticGetSettings() { static constexpr std::array settings = {{ - {SettingInfo::Type::Boolean, "RelativeMouseMode", TRANSLATABLE("PlaystationMouse", "Relative Mouse Mode"), - TRANSLATABLE("PlaystationMouse", "Locks the mouse cursor to the window, use for FPS games.")}, + {SettingInfo::Type::Boolean, "RelativeMouseMode", TRANSLATABLE("PlayStationMouse", "Relative Mouse Mode"), + TRANSLATABLE("PlayStationMouse", "Locks the mouse cursor to the window, use for FPS games.")}, }}; return SettingList(settings.begin(), settings.end()); diff --git a/src/duckstation-qt/debuggermodels.cpp b/src/duckstation-qt/debuggermodels.cpp index 651e200cc..8113cace1 100644 --- a/src/duckstation-qt/debuggermodels.cpp +++ b/src/duckstation-qt/debuggermodels.cpp @@ -77,7 +77,7 @@ QVariant DebuggerCodeModel::data(const QModelIndex& index, int role /*= Qt::Disp // Bytes u32 instruction_bits; if (!CPU::SafeReadInstruction(address, &instruction_bits)) - return QStringLiteral(""); + return tr(""); return QString::asprintf("%08X", instruction_bits); } @@ -87,9 +87,8 @@ QVariant DebuggerCodeModel::data(const QModelIndex& index, int role /*= Qt::Disp // Instruction u32 instruction_bits; if (!CPU::SafeReadInstruction(address, &instruction_bits)) - return QStringLiteral(""); + return tr(""); - Log_DevPrintf("Disassemble %08X", address); SmallString str; CPU::DisassembleInstruction(&str, address, instruction_bits); return QString::fromUtf8(str.GetCharArray(), static_cast(str.GetLength())); @@ -103,7 +102,7 @@ QVariant DebuggerCodeModel::data(const QModelIndex& index, int role /*= Qt::Disp u32 instruction_bits; if (!CPU::SafeReadInstruction(address, &instruction_bits)) - return QStringLiteral(""); + return tr(""); TinyString str; CPU::DisassembleInstructionComment(&str, address, instruction_bits, &CPU::g_state.regs); @@ -168,11 +167,20 @@ QVariant DebuggerCodeModel::headerData(int section, Qt::Orientation orientation, if (role != Qt::DisplayRole) return QVariant(); - static const char* header_names[] = {"", "Address", "Bytes", "Instruction", "Comment"}; - if (section < 0 || section >= countof(header_names)) - return QVariant(); - - return header_names[section]; + switch (section) + { + case 1: + return tr("Address"); + case 2: + return tr("Bytes"); + case 3: + return tr("Instruction"); + case 4: + return tr("Comment"); + case 0: + default: + return QVariant(); + } } bool DebuggerCodeModel::updateRegion(VirtualMemoryAddress address) @@ -340,11 +348,15 @@ QVariant DebuggerRegistersModel::headerData(int section, Qt::Orientation orienta if (role != Qt::DisplayRole) return QVariant(); - static const char* header_names[] = {"Register", "Value"}; - if (section < 0 || section >= countof(header_names)) - return QVariant(); - - return header_names[section]; + switch (section) + { + case 0: + return tr("Register"); + case 1: + return tr("Value"); + default: + return QVariant(); + } } void DebuggerRegistersModel::invalidateView() @@ -390,7 +402,7 @@ QVariant DebuggerStackModel::data(const QModelIndex& index, int role /*= Qt::Dis u32 value; if (!CPU::SafeReadMemoryWord(address, &value)) - return QStringLiteral(""); + return tr(""); return QString::asprintf("0x%08X", ZeroExtend32(value)); } @@ -403,11 +415,15 @@ QVariant DebuggerStackModel::headerData(int section, Qt::Orientation orientation if (role != Qt::DisplayRole) return QVariant(); - static const char* header_names[] = {"Address", "Value"}; - if (section < 0 || section >= countof(header_names)) - return QVariant(); - - return header_names[section]; + switch (section) + { + case 0: + return tr("Address"); + case 1: + return tr("Value"); + default: + return QVariant(); + } } void DebuggerStackModel::invalidateView()