Skip to content

Commit

Permalink
Translator: Fixed an inability to see dialogues
Browse files Browse the repository at this point in the history
When other than "original" language is seleted
  • Loading branch information
Wohlstand committed Oct 6, 2024
1 parent 826b6b2 commit cf647c5
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 3 deletions.
6 changes: 5 additions & 1 deletion Translator/textdata/dialogues_list_model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include <QColor>
#include <QPalette>
#include <QApplication>
#include <QtDebug>

#include "dialogues_list_model.h"

Expand All @@ -32,11 +33,14 @@ DialoguesListModel::DialoguesListModel(TranslateProject *project, QObject *paren
void DialoguesListModel::setData(const QString &lang, const QString &level)
{
beginResetModel();
m_recentLang = lang;
m_levelKey = level;
m_level = &(*m_project)[lang].levels[level];
m_level = &(*m_project)[TRANSLATE_METADATA].levels[level];
m_dialogues = &m_level->dialogues;
m_view.clear();

qDebug() << "Dialogues view: adding" << m_dialogues->size() << "dialogue(s) to the list...";

for(int i = 0; i < m_dialogues->size(); ++i)
{
auto &d = (*m_dialogues)[i];
Expand Down
1 change: 1 addition & 0 deletions Translator/textdata/dialogues_list_model.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ class DialoguesListModel : public QAbstractTableModel
TranslateProject *m_project = nullptr;
TranslationData_Level *m_level = nullptr;
QString m_levelKey;
QString m_recentLang;
QVector<TranslationData_Dialogue> *m_dialogues = nullptr;

struct TrView
Expand Down
4 changes: 2 additions & 2 deletions Translator/textdata/text_data_processor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -955,14 +955,14 @@ void TextDataProcessor::recountStats(TranslateProject &proj, TranslationData &tr
bool TextDataProcessor::saveJSONs(const QString &directory, const TranslateProject &proj)
{
bool ret = true;
const auto &origin = proj["metadata"];
const auto &origin = proj[TRANSLATE_METADATA];
bool useTrId = origin.useTrId;

for(auto it = proj.begin(); it != proj.end(); ++it)
{
QJsonObject o;

bool isOrigin = (it.key() == "metadata");
bool isOrigin = (it.key() == TRANSLATE_METADATA);

if(isOrigin)
o["use-tr-id"] = it->useTrId;
Expand Down
2 changes: 2 additions & 0 deletions Translator/textdata/textdata.h
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,8 @@ struct TranslationData
QMap<QString, int> trId_map_script_lines;
};

#define TRANSLATE_METADATA "metadata"

typedef QMap<QString, TranslationData> TranslateProject;

#endif // TEXTDATA_H

0 comments on commit cf647c5

Please sign in to comment.