Changeset View
Changeset View
Standalone View
Standalone View
templateparser/src/templatestexteditor.cpp
Show All 11 Lines | 1 | /* | |||
---|---|---|---|---|---|
12 | 12 | | |||
13 | You should have received a copy of the GNU General Public License along | 13 | You should have received a copy of the GNU General Public License along | ||
14 | with this program; if not, write to the Free Software Foundation, Inc., | 14 | with this program; if not, write to the Free Software Foundation, Inc., | ||
15 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | 15 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
16 | */ | 16 | */ | ||
17 | 17 | | |||
18 | #include "templatestexteditor.h" | 18 | #include "templatestexteditor.h" | ||
19 | #include "templatesutil_p.h" | 19 | #include "templatesutil_p.h" | ||
20 | #include "templatessyntaxhighlighterrules.h" | 20 | | ||
21 | #include <KPIMTextEdit/TextEditorCompleter> | 21 | #include <KPIMTextEdit/TextEditorCompleter> | ||
22 | #include <KPIMTextEdit/SyntaxHighlighterBase> | 22 | #include <KPIMTextEdit/PlainTextSyntaxSpellCheckingHighlighter> | ||
23 | | ||||
24 | #include <KSyntaxHighlighting/Definition> | ||||
25 | #include <KSyntaxHighlighting/Theme> | ||||
23 | 26 | | |||
24 | #include <QCompleter> | 27 | #include <QCompleter> | ||
25 | #include <QKeyEvent> | 28 | #include <QKeyEvent> | ||
26 | #include <QScrollBar> | 29 | #include <QScrollBar> | ||
27 | #include <QStringListModel> | 30 | #include <QStringListModel> | ||
28 | #include <QAbstractItemView> | 31 | #include <QAbstractItemView> | ||
29 | #include <QFontDatabase> | 32 | #include <QFontDatabase> | ||
30 | 33 | | |||
31 | #include <kpimtextedit/plaintextsyntaxspellcheckinghighlighter.h> | | |||
32 | | ||||
33 | using namespace TemplateParser; | 34 | using namespace TemplateParser; | ||
34 | 35 | | |||
35 | TemplatesTextEditor::TemplatesTextEditor(QWidget *parent) | 36 | TemplatesTextEditor::TemplatesTextEditor(QWidget *parent) | ||
36 | : KPIMTextEdit::PlainTextEditor(parent) | 37 | : KPIMTextEdit::PlainTextEditor(parent) | ||
37 | { | 38 | { | ||
38 | setFocus(); | 39 | setFocus(); | ||
39 | const QFont f = QFontDatabase::systemFont(QFontDatabase::FixedFont); | 40 | const QFont f = QFontDatabase::systemFont(QFontDatabase::FixedFont); | ||
40 | setFont(f); | 41 | setFont(f); | ||
Show All 27 Lines | 68 | { | |||
68 | //Nothing | 69 | //Nothing | ||
69 | } | 70 | } | ||
70 | 71 | | |||
71 | void TemplatesTextEditor::createHighlighter() | 72 | void TemplatesTextEditor::createHighlighter() | ||
72 | { | 73 | { | ||
73 | KPIMTextEdit::PlainTextSyntaxSpellCheckingHighlighter *highlighter = new KPIMTextEdit::PlainTextSyntaxSpellCheckingHighlighter(this); | 74 | KPIMTextEdit::PlainTextSyntaxSpellCheckingHighlighter *highlighter = new KPIMTextEdit::PlainTextSyntaxSpellCheckingHighlighter(this); | ||
74 | highlighter->toggleSpellHighlighting(checkSpellingEnabled()); | 75 | highlighter->toggleSpellHighlighting(checkSpellingEnabled()); | ||
75 | highlighter->setCurrentLanguage(spellCheckingLanguage()); | 76 | highlighter->setCurrentLanguage(spellCheckingLanguage()); | ||
76 | TemplatesSyntaxHighlighterRules rules; | 77 | highlighter->setDefinition(mSyntaxRepo.definitionForName(QStringLiteral("KMail Template"))); | ||
77 | highlighter->setSyntaxHighlighterRules(rules.rules()); | 78 | highlighter->setTheme((palette().color(QPalette::Base).lightness() < 128) | ||
79 | ? mSyntaxRepo.defaultTheme(KSyntaxHighlighting::Repository::DarkTheme) | ||||
80 | : mSyntaxRepo.defaultTheme(KSyntaxHighlighting::Repository::LightTheme)); | ||||
78 | setHighlighter(highlighter); | 81 | setHighlighter(highlighter); | ||
79 | } | 82 | } | ||
80 | 83 | | |||
81 | void TemplatesTextEditor::initCompleter() | 84 | void TemplatesTextEditor::initCompleter() | ||
82 | { | 85 | { | ||
83 | QStringList listWord; | 86 | QStringList listWord; | ||
84 | QStringList excludeKeyWord; | 87 | QStringList excludeKeyWord; | ||
85 | const QStringList lst = TemplateParser::Util::keywords(); | 88 | const QStringList lst = TemplateParser::Util::keywords(); | ||
Show All 30 Lines |