API Documentation
Loading...
Searching...
No Matches
LanguageEditor.h
Go to the documentation of this file.
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{
13 /**--------------------------------------------------------------------------------------------------
14 \brief Syntactically highlights translations.
15 **/
16 class LanguageHighlighter : public QSyntaxHighlighter
17 {
18 Q_OBJECT
19 public:
20 LanguageHighlighter(QTextDocument* parent = 0);
21 void setSearchString(const QString& search_string);
22 protected:
23 void highlightBlock(const QString& text) override;
24
25 private:
26 struct HighlightingRule
27 {
28 QRegularExpression pattern;
29 QTextCharFormat format;
30 };
31 QVector<HighlightingRule> m_highlighting_rules;
32 };
33 /**--------------------------------------------------------------------------------------------------
34 \brief Allows the user to adjust translation values for a given language.
35 **/
36 class LanguageEditor : public QWidget
37 {
38 public:
39 LanguageEditor(QWidget* parent = nullptr);
40 virtual ~LanguageEditor();
41
42 void setEditingTranslation(const Translator& translator);
43 void setReferenceTranslation(const Translator& translator);
44#if SUPPORTS_GOOGLE_TRANSLATE
45 QString googleTranslate(const QString& keyword, const QString& from, const QString& to) const;
46#endif
47 protected:
49 void updateUI();
52 bool canSave();
53 protected:
54 bool m_has_change = false;
55 Ui::LanguageEditorUI* ui;
59 };
60}
Allows the user to adjust translation values for a given language.
Definition LanguageEditor.h:37
void setReferenceTranslation(const Translator &translator)
Translator m_translator
Definition LanguageEditor.h:56
void setEditingTranslation(const Translator &translator)
Translator m_reference_translator
Definition LanguageEditor.h:57
LanguageEditor(QWidget *parent=nullptr)
bool m_has_change
Definition LanguageEditor.h:54
Ui::LanguageEditorUI * ui
Definition LanguageEditor.h:55
Translator m_original_translator
Definition LanguageEditor.h:58
Syntactically highlights translations.
Definition LanguageEditor.h:17
void highlightBlock(const QString &text) override
void setSearchString(const QString &search_string)
LanguageHighlighter(QTextDocument *parent=0)
Contains logic for translating a string into a defined language.
Definition Translator.h:45
Definition ACIColor.h:37
Definition FontEditor.h:6