NDEVR
API Documentation
LanguageEditor.h
1#pragma once
2#include <NDEVR/Translator.h>
3#include <QWidget>
4#include <QSyntaxHighlighter>
5#include <QRegularExpression>
6namespace Ui
7{
8 class LanguageEditorUI;
9}
10class QPlainTextEdit;
11namespace NDEVR
12{
16 class LanguageHighlighter : public QSyntaxHighlighter
17 {
18 Q_OBJECT
19 public:
24 LanguageHighlighter(QTextDocument* parent = 0);
29 void setSearchString(const QString& search_string);
30 protected:
35 void highlightBlock(const QString& text) override;
36
37 private:
41 struct HighlightingRule
42 {
43 QRegularExpression pattern;
44 QTextCharFormat format;
45 };
46 QVector<HighlightingRule> m_highlighting_rules;
47 };
48
51 class LanguageEditor : public QWidget
52 {
53 public:
58 LanguageEditor(QWidget* parent = nullptr);
59 virtual ~LanguageEditor();
60
65 void setEditingTranslation(const Translator& translator);
70 void setReferenceTranslation(const Translator& translator);
71#if SUPPORTS_GOOGLE_TRANSLATE
79 QString googleTranslate(const QString& keyword, const QString& from, const QString& to) const;
80#endif
81 protected:
89 void updateUI();
102 bool canSave();
103 protected:
104 bool m_has_change = false;
105 Ui::LanguageEditorUI* ui;
109 };
110}
Translator m_reference_translator
The reference translator for comparison.
Translator m_original_translator
The original translator state before edits.
void copyReference()
Copies the reference translation values into the editing translator.
void updateTranslationView()
Updates the translation view panel with the current entries.
void setEditingTranslation(const Translator &translator)
Sets the translator currently being edited.
bool m_has_change
Whether unsaved changes exist.
void setReferenceTranslation(const Translator &translator)
Sets the reference translator to compare against while editing.
void saveLanguage()
Saves the current translation edits to disk.
void updateUI()
Refreshes the editor UI to reflect the current state.
Translator m_translator
The translator currently being edited.
LanguageEditor(QWidget *parent=nullptr)
Constructs a LanguageEditor widget.
Ui::LanguageEditorUI * ui
The auto-generated UI form for the editor.
bool canSave()
Returns whether the current edits can be saved.
LanguageHighlighter(QTextDocument *parent=0)
Constructs a LanguageHighlighter for the given text document.
void highlightBlock(const QString &text) override
Applies highlighting rules to the given block of text.
void setSearchString(const QString &search_string)
Sets the search string to highlight in the translation text.
Provides language translation services for the application.
Definition Translator.h:61
The primary namespace for the NDEVR SDK.