-
Notifications
You must be signed in to change notification settings - Fork 0
/
translator.h
106 lines (89 loc) · 2.89 KB
/
translator.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
#ifndef TRANSLATOR_H
#define TRANSLATOR_H
#include <QMainWindow>
#include <QTimer>
#include <QTableWidgetItem>
#include <QListWidgetItem>
#include "json/writer.h"
namespace Ui
{
class Translator;
}
extern Json::Value JsonData;
extern Json::Value JsonConfig;
extern bool ReplaceStringInPlace(std::string& subject, const std::string& search, const std::string& replace);
class Translator : public QMainWindow
{
Q_OBJECT
public:
explicit Translator(QWidget *parent = nullptr);
~Translator();
void AddItem( std::string strItem, bool bLang );
void AddItem( std::string strItem, std::string strValue, bool bLang );
void AddItem( std::string strItem, std::string strValue, std::string strLang );
void RemoveItem( std::string strItem, bool bLang );
void SaveTableValue(int tableid, std::string lang, std::string key, QString value);
void closeEvent(QCloseEvent *event);
void SaveOptions( std::string strMain, std::string strExport, int iTimer, std::string strBackup, int iTimer_Backup );
bool MinimizeSave();
void OnNewTranslationCreated( QString strFile );
void OnItemModified( QString OldString, QString NewString, bool IsLang );
public slots:
void ClearFile();
void OpenKeyValueImport();
void OpenExport();
void OpenOptions();
void ShowAbout();
void ShowQTAbout();
void NewFile();
void OpenFile();
void SaveFile();
void BackupFile();
void AutoSave();
void AutoBackup();
void ToggleMode(bool state);
void SetModified(bool state);
void UpdateTimer();
void ShutDown();
void KeySet(QTableWidgetItem *item);
void KeyModify(QTableWidgetItem *item);
void TabSwitch(QListWidgetItem *item);
void Export();
void Import();
void LangAdd();
void LangRemove();
void KeyAdd();
void KeyRemove();
void ModifyItem();
void ModifyLang();
protected:
void OpenSpecificFile(std::string strLocation, std::string strFile, bool bConfigClear = true);
void SaveConfig(bool bSaveWindowSize = false, bool bSaveOptions = false);
void LoadConfig();
void LoadTranslation();
void LoadTranslationKeys(Json::Value jdata);
void AddKey(std::string strKey, std::string strValue, QColor color);
private:
Ui::Translator *ui;
QTimer *timer;
QTimer *timer_bk;
int iMinSaveTimer;
int iMinBackupTimer;
int iMaxKeys;
bool bFileLoaded;
bool bConfigLoaded;
bool bHasModifiedFile;
bool bIgnoreAddItemError;
// START: AS API Docs Support
/// If enabled, we will check the latest data.json
/// provided by the SDK AppID, the same exact one used by the API docs website.
bool bIsAngelscript;
// END: AS API Docs Support
std::string strCurrentLang = "lang_english";
std::string strFileLocation;
std::string strFileLoaded;
std::string strBackupLocation;
std::string strMainPath;
std::string strExportPath;
};
#endif // TRANSLATOR_H