KSyntaxHighlighting

kquicksyntaxhighlightingplugin.cpp
1 /*
2  SPDX-FileCopyrightText: 2018 Eike Hein <[email protected]>
3  SPDX-FileCopyrightText: 2021 Volker Krause <[email protected]>
4 
5  SPDX-License-Identifier: MIT
6 */
7 
8 #include "kquicksyntaxhighlightingplugin.h"
9 #include "kquicksyntaxhighlighter.h"
10 #include "repositorywrapper.h"
11 
12 #include <KSyntaxHighlighting/Definition>
13 #include <KSyntaxHighlighting/Repository>
14 #include <KSyntaxHighlighting/Theme>
15 
16 #include <memory>
17 
18 using namespace KSyntaxHighlighting;
19 
20 Repository *defaultRepository()
21 {
22  static std::unique_ptr<Repository> s_instance;
23  if (!s_instance) {
24  s_instance = std::make_unique<Repository>();
25  }
26  return s_instance.get();
27 }
28 
29 void KQuickSyntaxHighlightingPlugin::registerTypes(const char *uri)
30 {
31  Q_ASSERT(QLatin1String(uri) == QLatin1String("org.kde.syntaxhighlighting"));
32  qRegisterMetaType<Definition>();
33  qRegisterMetaType<QVector<Definition>>();
34  qRegisterMetaType<Theme>();
35  qRegisterMetaType<QVector<Theme>>();
36  qmlRegisterType<KQuickSyntaxHighlighter>(uri, 1, 0, "SyntaxHighlighter");
37  qmlRegisterUncreatableType<Definition>(uri, 1, 0, "Definition", {});
38  qmlRegisterUncreatableType<Theme>(uri, 1, 0, "Theme", {});
39  qmlRegisterSingletonType<RepositoryWrapper>(uri, 1, 0, "Repository", [](auto engine, auto scriptEngine) {
40  (void)engine;
41  (void)scriptEngine;
42  auto repo = new RepositoryWrapper;
43  repo->m_repository = defaultRepository();
44  return repo;
45  });
46 }
Syntax highlighting repository.
Definition: repository.h:127
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Sun Mar 26 2023 04:09:17 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.