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
|
/*
SPDX-FileCopyrightText: 2018 Eike Hein <hein@kde.org>
SPDX-FileCopyrightText: 2021 Volker Krause <vkrause@kde.org>
SPDX-License-Identifier: MIT
*/
#include "kquicksyntaxhighlightingplugin.h"
#include "kquicksyntaxhighlighter.h"
#include "repositorywrapper.h"
#include <definition.h>
#include <repository.h>
#include <theme.h>
#include <memory>
using namespace KSyntaxHighlighting;
Repository *defaultRepository()
{
static std::unique_ptr<Repository> s_instance;
if (!s_instance) {
s_instance = std::make_unique<Repository>();
}
return s_instance.get();
}
void KQuickSyntaxHighlightingPlugin::registerTypes(const char *uri)
{
Q_ASSERT(QLatin1String(uri) == QLatin1String("org.kde.syntaxhighlighting"));
qRegisterMetaType<Definition>();
qRegisterMetaType<QVector<Definition>>();
qRegisterMetaType<Theme>();
qRegisterMetaType<QVector<Theme>>();
qmlRegisterType<KQuickSyntaxHighlighter>(uri, 1, 0, "SyntaxHighlighter");
qmlRegisterUncreatableType<Definition>(uri, 1, 0, "Definition", {});
qmlRegisterUncreatableType<Theme>(uri, 1, 0, "Theme", {});
qmlRegisterSingletonType<RepositoryWrapper>(uri, 1, 0, "Repository", [](auto engine, auto scriptEngine) {
(void)engine;
(void)scriptEngine;
auto repo = new RepositoryWrapper;
repo->m_repository = defaultRepository();
return repo;
});
}
|