|
71 | 71 | #include <sys/wait.h> |
72 | 72 |
|
73 | 73 | #include "gui/agent_panel.hpp" |
| 74 | +#include <QCoreApplication> |
74 | 75 | #include <QTimer> |
75 | 76 | #include <cerrno> |
76 | 77 | #include <QColor> |
|
94 | 95 | namespace ce::gui { |
95 | 96 | using namespace mainwindow_detail; |
96 | 97 |
|
| 98 | +// Defined with the Type-column helpers near the end of the file; data() needs it. |
| 99 | +static QString valueTypeLabel(ce::ValueType t); |
| 100 | + |
97 | 101 | // ═══════════════════════════════════════════════════════════════ |
98 | 102 | // AddressListModel |
99 | 103 | // ═══════════════════════════════════════════════════════════════ |
@@ -303,7 +307,7 @@ static std::expected<size_t, std::string> writeValueToProcess( |
303 | 307 | options.codec = codec; options.bigEndian = bigEndian; options.hex = showHex; |
304 | 308 | if (order != ByteOrder::Unknown) options.byteOrder = order; |
305 | 309 | if (pointerWidth) options.pointerWidthOverride = pointerWidth; |
306 | | - if (!proc) return std::unexpected("No process attached"); |
| 310 | + if (!proc) return std::unexpected(QCoreApplication::translate("ce::gui::AddressListModel", "No process attached").toStdString()); |
307 | 311 | auto resolved = ce::valueOptionsForTarget(*proc, addr, type, options); |
308 | 312 | if (!resolved) return std::unexpected(resolved.error()); |
309 | 313 | options = *resolved; |
@@ -1174,7 +1178,7 @@ QVariant AddressListModel::data(const QModelIndex& index, int role) const { |
1174 | 1178 | ? QString("0x%1").arg(e.address, 0, 16) : e.addressExpr; |
1175 | 1179 | // The type editor starts from the record's type: an empty editor |
1176 | 1180 | // committed by clicking away changed every record to 4 Bytes. |
1177 | | - if (index.column() == 3) return QString(ce::valueTypeName(e.type)); |
| 1181 | + if (index.column() == 3) return valueTypeLabel(e.type); |
1178 | 1182 | if (index.column() == 4) return e.currentValue; |
1179 | 1183 | return {}; |
1180 | 1184 | } |
@@ -1204,7 +1208,7 @@ QVariant AddressListModel::data(const QModelIndex& index, int role) const { |
1204 | 1208 | if (e.isGroup) return ""; |
1205 | 1209 | // CE-canonical name; String/Array records also show their element length |
1206 | 1210 | // in brackets (e.g. "String[10]", "Array of byte[8]"), like Cheat Engine. |
1207 | | - QString name = ce::valueTypeName(e.type); |
| 1211 | + QString name = valueTypeLabel(e.type); |
1208 | 1212 | if ((e.type == ValueType::String || e.type == ValueType::UnicodeString || |
1209 | 1213 | e.type == ValueType::ByteArray) && e.byteCount > 0) |
1210 | 1214 | name += QString("[%1]").arg(e.byteCount); |
@@ -1368,18 +1372,42 @@ void AddressListModel::groupSelectedRows(const QList<int>& rows, const QString& |
1368 | 1372 | endResetModel(); |
1369 | 1373 | } |
1370 | 1374 |
|
| 1375 | +// Localized name of the Type column. The canonical English ce::valueTypeName() stays |
| 1376 | +// the format used by cheat tables, Lua and the CLI; only the table and its editor |
| 1377 | +// show this translation. |
| 1378 | +static QString valueTypeLabel(ce::ValueType t) { |
| 1379 | + switch (t) { |
| 1380 | + case ValueType::Byte: return QCoreApplication::translate("ce::gui::AddressListModel", "Byte"); |
| 1381 | + case ValueType::Int16: return QCoreApplication::translate("ce::gui::AddressListModel", "2 Bytes"); |
| 1382 | + case ValueType::Int32: return QCoreApplication::translate("ce::gui::AddressListModel", "4 Bytes"); |
| 1383 | + case ValueType::Int64: return QCoreApplication::translate("ce::gui::AddressListModel", "8 Bytes"); |
| 1384 | + case ValueType::Float: return QCoreApplication::translate("ce::gui::AddressListModel", "Float"); |
| 1385 | + case ValueType::Double: return QCoreApplication::translate("ce::gui::AddressListModel", "Double"); |
| 1386 | + case ValueType::String: return QCoreApplication::translate("ce::gui::AddressListModel", "String"); |
| 1387 | + case ValueType::UnicodeString: return QCoreApplication::translate("ce::gui::AddressListModel", "Unicode String"); |
| 1388 | + case ValueType::ByteArray: return QCoreApplication::translate("ce::gui::AddressListModel", "Array of byte"); |
| 1389 | + case ValueType::Binary: return QCoreApplication::translate("ce::gui::AddressListModel", "Binary"); |
| 1390 | + case ValueType::All: return QCoreApplication::translate("ce::gui::AddressListModel", "All"); |
| 1391 | + case ValueType::Grouped: return QCoreApplication::translate("ce::gui::AddressListModel", "Grouped"); |
| 1392 | + case ValueType::Custom: return QCoreApplication::translate("ce::gui::AddressListModel", "Custom"); |
| 1393 | + case ValueType::Pointer: return QCoreApplication::translate("ce::gui::AddressListModel", "Pointer"); |
| 1394 | + } |
| 1395 | + return QCoreApplication::translate("ce::gui::AddressListModel", "4 Bytes"); |
| 1396 | +} |
| 1397 | + |
1371 | 1398 | // Parse a Type-column display name back to a ValueType. First matches the canonical |
1372 | | -// name (ce::valueTypeName), so every name the column can show round-trips ("String", |
1373 | | -// "Unicode String", "Array of byte", "All", ...); then a few common synonyms. Int32 fallback. |
1374 | | -// A record's type from its name; nothing for an unknown name or a scan-only |
1375 | | -// type (All, Grouped), which a record cannot hold. |
| 1399 | +// name (ce::valueTypeName) and its translation, so every name the column can show |
| 1400 | +// round-trips ("String", "Unicode String", "Array of byte", "All", ...); then a few |
| 1401 | +// common synonyms. Int32 fallback. A record's type from its name; nothing for an |
| 1402 | +// unknown name or a scan-only type (All, Grouped), which a record cannot hold. |
1376 | 1403 | static std::optional<ValueType> valueTypeFromDisplayName(const QString& s) { |
1377 | 1404 | QString n = s.trimmed().toLower(); |
1378 | 1405 | if (const auto bracket = n.indexOf('['); bracket > 0) n = n.left(bracket).trimmed(); // "string[10]" |
1379 | 1406 | for (auto t : {ValueType::Byte, ValueType::Int16, ValueType::Int32, ValueType::Int64, |
1380 | 1407 | ValueType::Float, ValueType::Double, ValueType::String, ValueType::UnicodeString, |
1381 | 1408 | ValueType::ByteArray, ValueType::Binary, ValueType::Custom, ValueType::Pointer}) |
1382 | | - if (n == QString(ce::valueTypeName(t)).toLower()) return t; |
| 1409 | + if (n == QString(ce::valueTypeName(t)).toLower() || |
| 1410 | + n == valueTypeLabel(t).toLower()) return t; |
1383 | 1411 | if (n == "word" || n == "short") return ValueType::Int16; |
1384 | 1412 | if (n == "dword" || n == "int") return ValueType::Int32; |
1385 | 1413 | if (n == "qword" || n == "long" || n == "int64") return ValueType::Int64; |
|
0 commit comments