| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
#ifndef PLUGINLOADER_H |
| 19 |
#define PLUGINLOADER_H |
| 20 |
|
| 21 |
#include <QLoggingCategory> |
| 22 |
#include <QObject> |
| 23 |
#include <QtPlugin> |
| 24 |
#include "PluginInfo.h" |
| 25 |
#include <QTranslator> |
| 26 |
|
| 27 |
Q_DECLARE_LOGGING_CATEGORY(PLUGIN_LOADER) |
| 28 |
|
| 29 |
class PluginInterface |
| 30 |
{ |
| 31 |
public: |
| 32 |
virtual QString name() const = 0; |
| 33 |
virtual QString description() const = 0; |
| 34 |
virtual PluginInfo *create(QObject *parent) const = 0; |
| 35 |
}; |
| 36 |
|
| 37 |
Q_DECLARE_INTERFACE(PluginInterface, "PluginInterface") |
| 38 |
|
| 39 |
class PluginLoader |
| 40 |
{ |
| 41 |
public: |
| 42 |
explicit PluginLoader(); |
| 43 |
~PluginLoader(); |
| 44 |
|
| 45 |
void loadPlugins(QMultiMap<QString, PluginInfo *> ®istry, const QString &pluginType = QString()); |
| 46 |
void setPluginPaths(const QStringList &paths); |
| 47 |
|
| 48 |
protected: |
| 49 |
PluginInfo *parsePluginSpec(const QString &path); |
| 50 |
void initSettings(const QVariantMap &map); |
| 51 |
void loadTranslations(const QString &i18nDir); |
| 52 |
|
| 53 |
private: |
| 54 |
QStringList m_pluginPaths; |
| 55 |
QList<QPointer<QTranslator> > m_translators; |
| 56 |
}; |
| 57 |
|
| 58 |
#endif |