Messagelib

messagepartrenderermanager.h
1 /*
2  SPDX-FileCopyrightText: 2016-2023 Laurent Montel <[email protected]>
3 
4  SPDX-License-Identifier: LGPL-2.0-or-later
5 */
6 
7 #pragma once
8 #include "messageviewer_export.h"
9 #include <QObject>
10 
11 #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
12 #include <grantlee/template.h>
13 #else
14 #include <KTextTemplate/Template>
15 #endif
16 
17 #include <QMetaType>
18 
19 #include <functional>
20 
21 namespace GrantleeTheme
22 {
23 class Engine;
24 }
25 
26 namespace MessageViewer
27 {
28 class GlobalContext;
29 
30 #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
31 using GrantleeCallback = std::function<void(Grantlee::OutputStream *)>;
32 #else
33 using GrantleeCallback = std::function<void(KTextTemplate::OutputStream *)>;
34 #endif
35 /**
36  * @brief The MessagePartRendererManager class
37  */
38 class MESSAGEVIEWER_EXPORT MessagePartRendererManager : public QObject
39 {
40  Q_OBJECT
41 public:
42  explicit MessagePartRendererManager(QObject *parent = nullptr);
43  ~MessagePartRendererManager() override;
44  static MessagePartRendererManager *self();
45 #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
46  Q_REQUIRED_RESULT Grantlee::Template loadByName(const QString &name);
47  Q_REQUIRED_RESULT Grantlee::Context createContext();
48 #else
49  Q_REQUIRED_RESULT KTextTemplate::Template loadByName(const QString &name);
50  Q_REQUIRED_RESULT KTextTemplate::Context createContext();
51 #endif
52 
53 private:
54  void initializeRenderer();
55  GrantleeTheme::Engine *m_engine = nullptr;
56  GlobalContext *const m_globalContext;
57 };
58 }
59 
60 Q_DECLARE_METATYPE(MessageViewer::GrantleeCallback)
The MessagePartRendererManager class.
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Sun Mar 26 2023 04:08:11 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.