From 27f62723c7ab7ff5c792ba1f5ee24a9b3a98edf9 Mon Sep 17 00:00:00 2001 From: Connor McLaughlin Date: Tue, 28 Jul 2020 19:24:10 +1000 Subject: [PATCH] Qt: Make gmae list headings translatable --- src/duckstation-qt/gamelistwidget.cpp | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/duckstation-qt/gamelistwidget.cpp b/src/duckstation-qt/gamelistwidget.cpp index d498a7cc4..381673b14 100644 --- a/src/duckstation-qt/gamelistwidget.cpp +++ b/src/duckstation-qt/gamelistwidget.cpp @@ -42,6 +42,7 @@ public: GameListModel(GameList* game_list, QObject* parent = nullptr) : QAbstractTableModel(parent), m_game_list(game_list) { loadCommonImages(); + setColumnDisplayNames(); } ~GameListModel() = default; @@ -183,9 +184,11 @@ public: if (orientation != Qt::Horizontal || role != Qt::DisplayRole || section < 0 || section >= Column_Count) return {}; - return tr(s_column_names[section]); + return m_column_display_names[section]; } + ALWAYS_INLINE const QString& getColumnDisplayName(int column) { return m_column_display_names[column]; } + void refresh() { beginResetModel(); @@ -220,8 +223,21 @@ private: m_compatibiliy_pixmaps[i].load(QStringLiteral(":/icons/star-%1.png").arg(i)); } + void setColumnDisplayNames() + { + m_column_display_names[Column_Type] = tr("Type"); + m_column_display_names[Column_Code] = tr("Code"); + m_column_display_names[Column_Title] = tr("Title"); + m_column_display_names[Column_FileTitle] = tr("File Title"); + m_column_display_names[Column_Size] = tr("Size"); + m_column_display_names[Column_Region] = tr("Region"); + m_column_display_names[Column_Compatibility] = tr("Compatibility"); + } + GameList* m_game_list; + std::array m_column_display_names; + QPixmap m_type_disc_pixmap; QPixmap m_type_exe_pixmap; @@ -349,7 +365,7 @@ void GameListWidget::onTableViewHeaderContextMenuRequested(const QPoint& point) for (int column = 0; column < GameListModel::Column_Count; column++) { - QAction* action = menu.addAction(tr(GameListModel::s_column_names[column])); + QAction* action = menu.addAction(m_table_model->getColumnDisplayName(column)); action->setCheckable(true); action->setChecked(!m_table_view->isColumnHidden(column)); connect(action, &QAction::toggled, [this, column](bool enabled) {