Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add QMLPlugin class for registring as a qml plugin #102

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

Thaodan
Copy link
Contributor

@Thaodan Thaodan commented Apr 11, 2019

This makes QZXing a qml plugin lib to be used as shared qml plugin when qml is enabled.
Still wip but ready to use.

Copy link
Owner

@ftylitak ftylitak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello @Thaodan

thank you again for contributing! I have made a comment for the code, as soon as it gets resolved, I will merge it.

src/QZXing.pri Outdated
DEFINES += QZXING_QML

HEADERS += \
$$PWD/QZXingImageProvider.h

SOURCES += \
$$PWD/QZXingImageProvider.cpp

HEADERS += \
qxzingplugin.h
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would propose three enhancements.

a) merge the same tags (HEADERS, SOURCES)
b) Use the same notation as the above definitions of headers and sources:
c) rename qxzingplugin.h and qxzingplugin.cpp to QZXingPlugin.h and QZXingPlugin.cpp correspondingly. Even though what you did is correct, lets stick with camel case just for the sake of consistency.

 HEADERS +=  \
        $$PWD/QZXingImageProvider.h \
        $$PWD/QZXingPlugin.h

 SOURCES +=  \
        $$PWD/QZXingImageProvider.cpp \
        $$PWD/QZXingPlugin.cpp

@Thaodan
Copy link
Contributor Author

Thaodan commented Apr 15, 2019 via email

@Thaodan
Copy link
Contributor Author

Thaodan commented Apr 15, 2019

What do yo mean by:

a) merge the same tags (HEADERS, SOURCES)
?

@Thaodan
Copy link
Contributor Author

Thaodan commented Apr 15, 2019

Applied the requested changes

@ftylitak
Copy link
Owner

What do yo mean by:

a) merge the same tags (HEADERS, SOURCES)
?

May be i was not clear so i will explain with an example.

Instead of doing this:

HEADERS +=  \
        $$PWD/QZXingImageProvider.h

HEADERS +=  \
        $$PWD/QZXingPlugin.h

you could do this:

HEADERS +=  \
        $$PWD/QZXingImageProvider.h \
        $$PWD/QZXingPlugin.h

@Thaodan
Copy link
Contributor Author

Thaodan commented Apr 16, 2019

should be fixed now.

@Thaodan
Copy link
Contributor Author

Thaodan commented May 1, 2019

Anything missing here?

@@ -79,6 +79,8 @@ QZXing::QZXing(QZXing::DecoderFormat decodeHints, QObject *parent) : QObject(par

#ifdef QZXING_QML

#ifndef DISABLE_LIBRARY_FEATURES
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be removed as this macro refers to the integration method of the library, not to the functionality itself.

Thus the same comment applies to the closing of the ifdef.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But its needed on static builds and not on dynamic builds.
I thought that macro was to check if no dynamic build was built.

@Thaodan
Copy link
Contributor Author

Thaodan commented Jun 14, 2019

Do you have time to review the PR again?

@Thaodan
Copy link
Contributor Author

Thaodan commented Sep 26, 2019

Ping?

@ftylitak
Copy link
Owner

You will have a reply withing this weakend, sorry for the delay.

Copy link
Owner

@ftylitak ftylitak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here are my comments:

a) In QZXing.pri, The "CONFIG += plugin" (line 285) and all the directives that set the deployment paths (Lines 297-302) must be moved to the QZXing.pro file. This is because the creation and deployment of the QML plugin happens only when compiling the project defined by QZXing.pro. The QZXing.pri is used by the projects that directly include the source files of QZXing.

b) In QZXing.cpp you need to remove lines 82 and 103 regarding the preprocessor directives to deactive the code with the DISABLE_LIBRARY_FEATURES. THose lines match with the implementation of the QZXingPlugin, so it would be better to do a refactoring but keeping in mind the backward compatibility. Make QZXing::registerQMLTypes call QZXingPlugin to do the same thinga and also make QZXing::registerQMLImageProvider call QZXingPlugin as well.

c) There is an catch in the qmldir file. The dependency to the QtMultimedia is only applicable when qzxing_multimedia configuration is activated. If the library is used with qzxing_qml configuration, it adds an unwanted dependency. I have not yet figured any workaround to this issue, so i would remove the dependency and request from a user to add the "import QtMultimedia 5.5" explicitly.

d) Finally, i must admit I have no experience on using C++ QML plugins thus I can not yet provide proper suggestions. I do know that years ago, the library has been used as a QML plugin here: https://github.com/dplanella/qzxing . Did your solution worked fine for your case? What OS are you targeting?

For all the above, I would first like to see some enhancements to the implementation and then we can work our way towards the merge.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants