From f581e879de783b84c22d0179935dad8bedb5105c Mon Sep 17 00:00:00 2001 From: favoritas37 Date: Thu, 16 Mar 2017 16:26:48 +0200 Subject: [PATCH] fixed compilation of QZXingLive for platforms other than Android --- .gitignore | 1 + examples/QZXingLive/QZXingLive.pro | 12 ++++-------- examples/QZXingLive/native.cpp | 8 +++++++- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/.gitignore b/.gitignore index 80f7c85..3ee4964 100644 --- a/.gitignore +++ b/.gitignore @@ -25,3 +25,4 @@ debug/ .gradle .idea .build +.obj diff --git a/examples/QZXingLive/QZXingLive.pro b/examples/QZXingLive/QZXingLive.pro index 3827c9a..6101d4a 100644 --- a/examples/QZXingLive/QZXingLive.pro +++ b/examples/QZXingLive/QZXingLive.pro @@ -12,10 +12,12 @@ CONFIG(debug, debug|release) { } HEADERS += \ - application.h + application.h \ + native.h SOURCES += main.cpp \ - application.cpp + application.cpp \ + native.cpp RESOURCES += qml.qrc @@ -30,12 +32,6 @@ include(deployment.pri) android { QT += androidextras - HEADERS += \ - native.h - - SOURCES += \ - native.cpp - DISTFILES += \ android/AndroidManifest.xml \ android/gradle/wrapper/gradle-wrapper.jar \ diff --git a/examples/QZXingLive/native.cpp b/examples/QZXingLive/native.cpp index 7e456ea..cea7ee0 100644 --- a/examples/QZXingLive/native.cpp +++ b/examples/QZXingLive/native.cpp @@ -1,9 +1,13 @@ -#include +#if defined(Q_OS_ANDROID) + #include +#endif //Q_OS_ANDROID #include "native.h" #include QObject *NativeHelpers::application_p_ = 0; +#if defined(Q_OS_ANDROID) + // define our native static functions // these are the functions that Java part will call directly from Android UI thread static void onPermissionsGranted(JNIEnv * /*env*/, jobject /*obj*/) @@ -45,3 +49,5 @@ JNIEXPORT jint JNI_OnLoad(JavaVM* vm, void* /*reserved*/) return JNI_VERSION_1_6; } + +#endif // Q_OS_ANDROID