zbar: switch to qt5

This commit is contained in:
maxice8 2018-09-18 18:36:08 -03:00 committed by maxice8
parent 5ba82d222e
commit ff47867113
3 changed files with 171 additions and 6 deletions

View File

@ -0,0 +1,70 @@
From aab155cde51e44334022bcaddb694c014f800ae8 Mon Sep 17 00:00:00 2001
From: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Date: Sun, 26 Mar 2017 08:35:16 -0300
Subject: [PATCH] configure.ac: check for Qt5 version first
Despite zbar can be compiled with either Qt4 or Qt5, the
current logic seeks only Qt4. Change it to try first Qt5.
Yet, as people may have both but want to build it with
Qt4, add a --without-qt5 configuration option that will
make it to check only for Qt4, just like before.
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
---
configure.ac | 24 ++++++++++++++++--------
1 file changed, 16 insertions(+), 8 deletions(-)
diff --git a/configure.ac b/configure.ac
index d49094c..70b759d 100644
--- configure.ac
+++ configure.ac
@@ -364,18 +364,26 @@ AM_CONDITIONAL([HAVE_PYTHON], [test "x$with_python" = "xyes"])
dnl Qt
AC_ARG_WITH([qt],
[AS_HELP_STRING([--without-qt],
- [disable support for Qt4 widget])],
+ [disable support for Qt widget])],
[],
[with_qt="yes"])
AC_ARG_VAR([MOC], [full path to Qt moc program])
AS_IF([test "x$with_qt" != "xno"],
- [PKG_CHECK_MODULES([QT], [QtCore >= 4 QtGui >= 4])
- MOC=`$PKG_CONFIG QtGui --variable=moc_location`
- AC_MSG_NOTICE([using moc from $MOC])
- QT_VERSION=`$PKG_CONFIG QtGui --modversion`
- AC_MSG_NOTICE([using Qt version $QT_VERSION])])
+ AS_IF([test "x$with_qt5" != "xno"],
+ [PKG_CHECK_MODULES([QT], [Qt5Core >= 5 Qt5Gui >= 5 Qt5Widgets >= 5.0 Qt5X11Extras >= 5.0])
+ AC_CHECK_PROGS(MOC, [moc-qt5 moc])
+ AC_MSG_NOTICE([using moc from $MOC])
+ QT_VERSION=`$PKG_CONFIG Qt5Gui --modversion`
+ CPPFLAGS="$CPPFLAGS $QT_CPPFLAGS -fPIC"
+ AC_MSG_NOTICE([using Qt version $QT_VERSION])],
+
+ [PKG_CHECK_MODULES([QT], [QtCore >= 4 QtGui >= 4])
+ MOC=`$PKG_CONFIG QtGui --variable=moc_location`
+ AC_MSG_NOTICE([using moc from $MOC])
+ QT_VERSION=`$PKG_CONFIG QtGui --modversion`
+ AC_MSG_NOTICE([using Qt version $QT_VERSION])]))
AM_CONDITIONAL([HAVE_QT], [test "x$with_qt" = "xyes"])
@@ -453,9 +461,9 @@ AS_IF([test "x$with_gtk" != "xyes"],
[echo " => the GTK+ widget will *NOT* be built"],
[AS_IF([test "x$with_python" != "xyes"],
[echo " => the PyGTK widget wrapper will *NOT* be built"])])
-echo "Qt4 --with-qt=$with_qt"
+echo "Qt${QT_VERSION} --with-qt=$with_qt"
AS_IF([test "x$with_qt" != "xyes"],
- [echo " => the Qt4 widget will *NOT* be built"])
+ [echo " => the Qt widget will *NOT* be built"])
#echo "NPAPI Plugin --with-npapi=$with_npapi"
#AS_IF([test "x$with_mozilla" != "xyes"],
# [echo " => the Mozilla/Firefox/OpenOffice plugin will *NOT* be built"])
--
2.19.0

View File

@ -0,0 +1,94 @@
From 3e81367fa16773b0e4cb89baf269ed9bd464c220 Mon Sep 17 00:00:00 2001
From: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Date: Sun, 26 Mar 2017 08:25:16 -0300
Subject: [PATCH] Add support to compile zbar with qt5
There aren't many changes for it to support both qt4 and qt5.
Add the needed stuff for qt5, without breaking backard compatible.
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
---
include/zbar/QZBar.h | 7 ++++++-
include/zbar/QZBarImage.h | 4 ++++
qt/QZBar.cpp | 15 ++++++++++++++-
3 files changed, 24 insertions(+), 2 deletions(-)
--- include/zbar/QZBar.h
+++ include/zbar/QZBar.h
@@ -26,7 +26,12 @@
/// @file
/// Barcode Reader Qt4 Widget
-#include <qwidget.h>
+#include <QtGui>
+#if QT_VERSION >= 0x050000
+# include <QtWidgets>
+#else
+# include <qwidget.h>
+#endif
namespace zbar {
diff --git a/include/zbar/QZBarImage.h b/include/zbar/QZBarImage.h
index ce98401..775f2e0 100644
--- include/zbar/QZBarImage.h
+++ include/zbar/QZBarImage.h
@@ -54,7 +54,7 @@ public:
unsigned height = qimg.height();
set_size(width, height);
set_format('B' | ('G' << 8) | ('R' << 16) | ('4' << 24));
- unsigned long datalen = qimg.numBytes();
+ unsigned long datalen = qimg.byteCount();
set_data(qimg.bits(), datalen);
if((width * 4 != bpl) ||
--- qt/QZBar.cpp
+++ qt/QZBar.cpp
@@ -23,7 +23,7 @@
#include <qevent.h>
#include <qurl.h>
-#include <qx11info_x11.h>
+#include <QX11Info>
#include <zbar/QZBar.h>
#include "QZBarThread.h"
@@ -49,7 +49,11 @@ QZBar::QZBar (QWidget *parent)
thread = new QZBarThread;
if(testAttribute(Qt::WA_WState_Created)) {
+#if QT_VERSION >= 0x050000
+ thread->window.attach(QX11Info::display(), winId());
+#else
thread->window.attach(x11Info().display(), winId());
+#endif
_attached = 1;
}
connect(thread, SIGNAL(videoOpened(bool)),
@@ -204,7 +208,12 @@ void QZBar::changeEvent(QEvent *event)
try {
QMutexLocker locker(&thread->mutex);
if(event->type() == QEvent::ParentChange)
+#if QT_VERSION >= 0x050000
+ thread->window.attach(QX11Info::display(), winId());
+#else
thread->window.attach(x11Info().display(), winId());
+#endif
+
}
catch(Exception) { /* ignore (FIXME do something w/error) */ }
}
@@ -215,7 +224,11 @@ void QZBar::attach ()
return;
try {
+#if QT_VERSION >= 0x050000
+ thread->window.attach(QX11Info::display(), winId());
+#else
thread->window.attach(x11Info().display(), winId());
+#endif
_attached = 1;
_videoEnabled = !_videoDevice.isEmpty();

View File

@ -1,17 +1,18 @@
# Template file for 'zbar'
pkgname=zbar
version=0.10
revision=6
revision=7
build_style=gnu-configure
configure_args="ac_cv_header_wand_MagickWand_h=yes $(vopt_with qt) --with-gtk"
configure_args="ac_cv_header_wand_MagickWand_h=yes $(vopt_with qt qt5) --with-gtk"
hostmakedepends="automake pkg-config libtool gettext-devel python
$(vopt_if qt 'qt-qmake qt-host-tools') glib-devel"
makedepends="libmagick-devel libXv-devel pygtk-devel $(vopt_if qt qt-devel) v4l-utils-devel"
$(vopt_if qt 'qt5-qmake qt5-host-tools') glib-devel"
makedepends="libmagick-devel libXv-devel pygtk-devel v4l-utils-devel
$(vopt_if qt qt5-x11extras-devel)"
short_desc="A barcode reading library and application"
maintainer="Jürgen Buchmüller <pullmoll@t-online.de>"
license="LGPL-2"
license="LGPL-2.1-or-later"
homepage="https://zbar.sourceforge.net/"
distfiles="$SOURCEFORGE_SITE/zbar/${version}/${pkgname}-${version}.tar.bz2"
distfiles="${SOURCEFORGE_SITE}/zbar/${version}/${pkgname}-${version}.tar.bz2"
checksum=234efb39dbbe5cef4189cc76f37afbe3cfcfb45ae52493bfe8e191318bdbadc6
depends="libzbar-${version}_${revision}"