60 lines
2.1 KiB
C++
60 lines
2.1 KiB
C++
#ifndef MAINWINDOW_H
|
|
#define MAINWINDOW_H
|
|
|
|
#include <QMainWindow>
|
|
|
|
QT_BEGIN_NAMESPACE
|
|
namespace Ui { class MainWindow; }
|
|
QT_END_NAMESPACE
|
|
|
|
class QTreeWidgetItem;
|
|
class QFile;
|
|
class QNetworkReply;
|
|
|
|
class MainWindow : public QMainWindow
|
|
{
|
|
Q_OBJECT
|
|
|
|
public:
|
|
MainWindow(QWidget *parent = nullptr);
|
|
~MainWindow();
|
|
|
|
private slots:
|
|
void on_selectProjectDirButton_clicked();
|
|
void on_reloadButton_clicked();
|
|
void on_languageCombo_currentTextChanged(const QString &selectedLanguage);
|
|
void on_reloadTranslationsButton_clicked();
|
|
void on_reloadFilesButton_clicked();
|
|
void on_nextUntranslatedButton_clicked();
|
|
void on_treeWidget_itemSelectionChanged();
|
|
void on_setTranslationButton_clicked();
|
|
void on_setTranslationAndJumpNextButton_clicked();
|
|
void on_setAndNextAndAutoTranslate_clicked();
|
|
void on_translationEdit_returnPressed();
|
|
void on_saveButton_clicked();
|
|
void on_cleanupButton_clicked();
|
|
void on_cleanupAndSaveButton_clicked();
|
|
void onDeeplTranslationPossibilitiesLoaded(QNetworkReply *reply);
|
|
void on_deeplTranslateFrom_currentTextChanged(const QString &sourceLanguage);
|
|
void on_autoTranslateButton_clicked();
|
|
|
|
private:
|
|
Ui::MainWindow *ui;
|
|
std::map<QString, QString> fileContentsMap;
|
|
std::map<QString, std::vector<QString> > translationsMap;
|
|
const QString deeplAuthKey = "5f6bc5cc-1e5d-4c69-9ef0-eb3cc2c1ece5:fx";
|
|
void crawlProject();
|
|
void populateTreeWidgetFromMap();
|
|
void saveFiles(QStringList &failedFiles);
|
|
bool createBackup(const QString &filePath, const QString &backupFileName);
|
|
bool editAndSaveFile(QTreeWidgetItem *fileItem, const QString &backupFileName, const QString &fileName);
|
|
bool saveToFile(const QString &backupFileName, const QStringList &lines);
|
|
bool parseAndEditFile(QFile &backupFile, QTreeWidgetItem *fileItem, QStringList &lines, bool &changed);
|
|
QString findNewText(QTreeWidgetItem *fileItem, const QString &lineNumber, const QString &originalText);
|
|
void loadDeeplTranslationPossibilities();
|
|
void renderDeeplSources();
|
|
void translationRequestFinished(QNetworkReply *reply);
|
|
void countAndShowUntranslated();
|
|
};
|
|
#endif // MAINWINDOW_H
|