Differential D8110 Diff 21394 messageviewer/src/messagepartthemes/default/messagepartrenderermanager.cpp
Changeset View
Changeset View
Standalone View
Standalone View
messageviewer/src/messagepartthemes/default/messagepartrenderermanager.cpp
| Show All 21 Lines | |||||
| 22 | #include <KIconLoader> | 22 | #include <KIconLoader> | ||
| 23 | #include <QStandardPaths> | 23 | #include <QStandardPaths> | ||
| 24 | #include <GrantleeTheme/GrantleeKi18nLocalizer> | 24 | #include <GrantleeTheme/GrantleeKi18nLocalizer> | ||
| 25 | #include <GrantleeTheme/QtResourceTemplateLoader> | 25 | #include <GrantleeTheme/QtResourceTemplateLoader> | ||
| 26 | #include <GrantleeTheme/GrantleeThemeEngine> | 26 | #include <GrantleeTheme/GrantleeThemeEngine> | ||
| 27 | 27 | | |||
| 28 | #include <gpgme++/verificationresult.h> | 28 | #include <gpgme++/verificationresult.h> | ||
| 29 | #include <gpgme++/decryptionresult.h> | 29 | #include <gpgme++/decryptionresult.h> | ||
| 30 | #include <gpgme++/key.h> | ||||
| 30 | 31 | | |||
| 31 | #include <QGpgME/Protocol> | 32 | #include <QGpgME/Protocol> | ||
| 32 | 33 | | |||
| 33 | #include <grantlee/context.h> | 34 | #include <grantlee/context.h> | ||
| 34 | #include <grantlee/engine.h> | 35 | #include <grantlee/engine.h> | ||
| 35 | #include <grantlee/metatype.h> | 36 | #include <grantlee/metatype.h> | ||
| 36 | #include <grantlee/templateloader.h> | 37 | #include <grantlee/templateloader.h> | ||
| 37 | 38 | | |||
| 38 | #include <QGuiApplication> | 39 | #include <QGuiApplication> | ||
| 39 | 40 | | |||
| 40 | Q_DECLARE_METATYPE(GpgME::DecryptionResult::Recipient) | 41 | Q_DECLARE_METATYPE(GpgME::DecryptionResult::Recipient) | ||
| 41 | Q_DECLARE_METATYPE(const QGpgME::Protocol *) | 42 | Q_DECLARE_METATYPE(const QGpgME::Protocol *) | ||
| 43 | Q_DECLARE_METATYPE(GpgME::Key) | ||||
| 44 | | ||||
| 42 | // Read-only introspection of GpgME::DecryptionResult::Recipient object. | 45 | // Read-only introspection of GpgME::DecryptionResult::Recipient object. | ||
| 43 | GRANTLEE_BEGIN_LOOKUP(GpgME::DecryptionResult::Recipient) | 46 | GRANTLEE_BEGIN_LOOKUP(GpgME::DecryptionResult::Recipient) | ||
| 44 | if (property == QStringLiteral("keyID")) { | 47 | if (property == QStringLiteral("keyID")) { | ||
| 45 | return QString::fromLatin1(object.keyID()); | 48 | return QString::fromLatin1(object.keyID()); | ||
| 46 | } | 49 | } | ||
| 47 | GRANTLEE_END_LOOKUP | 50 | GRANTLEE_END_LOOKUP | ||
| 48 | // Read-only introspection of QGpgME::Protocol object. | 51 | // Read-only introspection of QGpgME::Protocol object. | ||
| 49 | namespace Grantlee { | 52 | namespace Grantlee { | ||
| 50 | template<> | 53 | template<> | ||
| 51 | inline QVariant TypeAccessor<const QGpgME::Protocol *>::lookUp(const QGpgME::Protocol *const object, const QString &property) | 54 | inline QVariant TypeAccessor<const QGpgME::Protocol *>::lookUp(const QGpgME::Protocol *const object, const QString &property) | ||
| 52 | { | 55 | { | ||
| 53 | if (property == QStringLiteral("name")) { | 56 | if (property == QStringLiteral("name")) { | ||
| 54 | return object->name(); | 57 | return object->name(); | ||
| 55 | } else if (property == QStringLiteral("displayName")) { | 58 | } else if (property == QStringLiteral("displayName")) { | ||
| 56 | return object->displayName(); | 59 | return object->displayName(); | ||
| 57 | } | 60 | } | ||
| 58 | return QVariant(); | 61 | return QVariant(); | ||
| 59 | } | 62 | } | ||
| 60 | } | 63 | } | ||
| 61 | 64 | | |||
| 65 | // Read-only introspection of std::pair<GpgME::DecryptionResult::Recipient, GpgME::Key> object. | ||||
| 66 | namespace Grantlee { | ||||
| 67 | template<> | ||||
| 68 | inline QVariant TypeAccessor<std::pair<GpgME::DecryptionResult::Recipient, GpgME::Key>&>::lookUp(std::pair<GpgME::DecryptionResult::Recipient, GpgME::Key> const &object, const QString &property) | ||||
| 69 | { | ||||
| 70 | if (property == QStringLiteral("keyID")) { | ||||
| 71 | return QString::fromLatin1(object.first.keyID()); | ||||
| 72 | } | ||||
| 73 | if (property == QStringLiteral("id")) { | ||||
| 74 | return QString::fromLatin1(object.second.userID(0).id()); | ||||
| 75 | } | ||||
| 76 | if (property == QStringLiteral("mainID")) { | ||||
| 77 | return QString::fromLatin1(object.second.keyID()); | ||||
| 78 | } | ||||
| 79 | return QVariant(); | ||||
| 80 | } | ||||
| 81 | } | ||||
| 82 | | ||||
| 62 | namespace MessageViewer { | 83 | namespace MessageViewer { | ||
| 63 | class GlobalContext : public QObject | 84 | class GlobalContext : public QObject | ||
| 64 | { | 85 | { | ||
| 65 | Q_OBJECT | 86 | Q_OBJECT | ||
| 66 | Q_PROPERTY(QString dir READ layoutDirection CONSTANT) | 87 | Q_PROPERTY(QString dir READ layoutDirection CONSTANT) | ||
| 67 | Q_PROPERTY(int iconSize READ iconSize CONSTANT) | 88 | Q_PROPERTY(int iconSize READ iconSize CONSTANT) | ||
| 68 | public: | 89 | public: | ||
| 69 | explicit GlobalContext(QObject *parent) : QObject(parent) | 90 | explicit GlobalContext(QObject *parent) : QObject(parent) | ||
| Show All 32 Lines | 122 | { | |||
| 102 | static MessagePartRendererManager s_self; | 123 | static MessagePartRendererManager s_self; | ||
| 103 | return &s_self; | 124 | return &s_self; | ||
| 104 | } | 125 | } | ||
| 105 | 126 | | |||
| 106 | void MessagePartRendererManager::initializeRenderer() | 127 | void MessagePartRendererManager::initializeRenderer() | ||
| 107 | { | 128 | { | ||
| 108 | Grantlee::registerMetaType<GpgME::DecryptionResult::Recipient>(); | 129 | Grantlee::registerMetaType<GpgME::DecryptionResult::Recipient>(); | ||
| 109 | Grantlee::registerMetaType<const QGpgME::Protocol *>(); | 130 | Grantlee::registerMetaType<const QGpgME::Protocol *>(); | ||
| 131 | Grantlee::registerMetaType<std::pair<GpgME::DecryptionResult::Recipient, GpgME::Key>>(); | ||||
| 110 | m_engine = new GrantleeTheme::Engine; | 132 | m_engine = new GrantleeTheme::Engine; | ||
| 111 | foreach (const auto &p, QCoreApplication::libraryPaths()) { | 133 | foreach (const auto &p, QCoreApplication::libraryPaths()) { | ||
| 112 | m_engine->addPluginPath(p + QStringLiteral("/messageviewer")); | 134 | m_engine->addPluginPath(p + QStringLiteral("/messageviewer")); | ||
| 113 | } | 135 | } | ||
| 114 | m_engine->addDefaultLibrary(QStringLiteral("messageviewer_grantlee_extension")); | 136 | m_engine->addDefaultLibrary(QStringLiteral("messageviewer_grantlee_extension")); | ||
| 115 | m_engine->localizer()->setApplicationDomain(QByteArrayLiteral("libmessageviewer")); | 137 | m_engine->localizer()->setApplicationDomain(QByteArrayLiteral("libmessageviewer")); | ||
| 116 | 138 | | |||
| 117 | auto loader = QSharedPointer<Grantlee::FileSystemTemplateLoader>( | 139 | auto loader = QSharedPointer<Grantlee::FileSystemTemplateLoader>( | ||
| Show All 28 Lines | |||||