From 7715ab8df28ecfcd49e2492519ed6e0240e7fd93 Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Mar 26 2017 11:42:45 +0000 Subject: make zbar-qt to use Qt5 Signed-off-by: Mauro Carvalho Chehab --- diff --git a/zbar.spec b/zbar.spec index 4f7ff68..a15663e 100644 --- a/zbar.spec +++ b/zbar.spec @@ -15,6 +15,7 @@ Patch1: zbar_use_libv4l.patch Patch2: zbar_choose_supported_format_first.patch Patch3: zbar_use_REQBUFS_properly.patch Patch4: zbar_configure_ac_use_m4_pattern_allow.patch +Patch5: zbar_add_support_for_qt5.patch BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) BuildRequires: autoconf automake libtool python-devel gettext-devel @@ -90,6 +91,7 @@ scanning widget. %patch2 -p1 %patch3 -p1 %patch4 -p1 +%patch5 -p1 %build autoreconf -vfi @@ -183,6 +185,9 @@ rm -rf $RPM_BUILD_ROOT %{_includedir}/zbar/QZBar*.h %changelog +* Sun Mar 26 2017 Mauro Carvalho Chehab - 0.10-29 +- Make zbar-qt to use Qt5 + * Sat Feb 11 2017 Fedora Release Engineering - 0.10-28 - Rebuilt for https://fedoraproject.org/wiki/Fedora_26_Mass_Rebuild diff --git a/zbar_add_support_for_qt5.patch b/zbar_add_support_for_qt5.patch new file mode 100644 index 0000000..519645f --- /dev/null +++ b/zbar_add_support_for_qt5.patch @@ -0,0 +1,140 @@ +diff --git a/configure.ac b/configure.ac +index dbd7153fb13b..7bcb18219853 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -476,18 +476,33 @@ 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"]) + ++dnl Qt5 ++AC_ARG_WITH([qt5], ++ [AS_HELP_STRING([--without-qt5], ++ [disable support for Qt5 widget. if --with-qt, it will seek only for Qt4])], ++ [], ++ [with_qt5="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"]) + +@@ -596,9 +611,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 "Java --with-java=$with_java" + AS_IF([test "x$with_java" != "xyes"], + [echo " => the Java interface will *NOT* be built"]) +diff --git a/include/zbar/QZBar.h b/include/zbar/QZBar.h +index 104449928e2d..1a4716565047 100644 +--- a/include/zbar/QZBar.h ++++ b/include/zbar/QZBar.h +@@ -26,7 +26,12 @@ + /// @file + /// Barcode Reader Qt4 Widget + +-#include ++#include ++#if QT_VERSION >= 0x050000 ++# include ++#else ++# include ++#endif + + namespace zbar { + +diff --git a/include/zbar/QZBarImage.h b/include/zbar/QZBarImage.h +index 1505177e07a9..b862c8085576 100644 +--- a/include/zbar/QZBarImage.h ++++ b/include/zbar/QZBarImage.h +@@ -54,7 +54,11 @@ public: + unsigned height = qimg.height(); + set_size(width, height); + set_format(zbar_fourcc('B','G','R','4')); ++#if QT_VERSION >= 0x050000 ++ unsigned long datalen = qimg.byteCount(); ++#else + unsigned long datalen = qimg.numBytes(); ++#endif + set_data(qimg.bits(), datalen); + + if((width * 4 != bpl) || +diff --git a/qt/QZBar.cpp b/qt/QZBar.cpp +index e1001b09cff5..a5b956b342ad 100644 +--- a/qt/QZBar.cpp ++++ b/qt/QZBar.cpp +@@ -23,7 +23,7 @@ + + #include + #include +-#include ++#include + #include + #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();