void-packages/srcpkgs/zbar/patches/compile-with-qt5.patch

95 lines
2.6 KiB
Diff
Raw Normal View History

2018-09-18 23:36:08 +02:00
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();