-
Notifications
You must be signed in to change notification settings - Fork 343
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add QMLPlugin class for registring as a qml plugin
- Loading branch information
Showing
4 changed files
with
61 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#include "QZXingPlugin.h" | ||
#include "QZXing.h" | ||
#include <QtQml/qqml.h> | ||
#ifdef QZXING_MULTIMEDIA | ||
#include <QZXingFilter.h> | ||
#endif | ||
#include "QZXingImageProvider.h" | ||
|
||
void QZXingPlugin::registerTypes(const char *uri) | ||
{ | ||
Q_ASSERT(uri == QLatin1String("QZXing")); | ||
qmlRegisterType<QZXing>("QZXing", 2, 3, "QZXing"); | ||
|
||
#ifdef QZXING_MULTIMEDIA | ||
qmlRegisterType<QZXingFilter>("QZXing", 2, 3, "QZXingFilter"); | ||
#endif //QZXING_MULTIMEDIA | ||
qmlProtectModule(uri, 2); | ||
} | ||
|
||
void QZXingPlugin::initializeEngine(QQmlEngine *engine, const char *uri) | ||
{ | ||
Q_UNUSED(uri) | ||
engine->addImageProvider(QLatin1String("QZXing"), new QZXingImageProvider()); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#ifndef QXZINGPLUGIN_H | ||
#define QXZINGPLUGIN_H | ||
#include <QtQml/QQmlExtensionPlugin> | ||
#include <QQmlEngine> | ||
|
||
class QZXingPlugin : public QQmlExtensionPlugin | ||
{ | ||
Q_OBJECT | ||
Q_PLUGIN_METADATA(IID QQmlExtensionInterface_iid) | ||
public: | ||
void registerTypes(const char *uri) override; | ||
void initializeEngine(QQmlEngine *engine, const char *uri) override; | ||
}; | ||
|
||
#endif // QXZINGPLUGIN_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
module QZXing | ||
plugin QZXing | ||
classname QZXingPlugin | ||
depends QtMultimedia 5.5 |