git: cd55d84b6a6f - main - net-im/kaidan: prepare for textproc/zxing-cpp 2.0.0

From: Tobias C. Berner <tcberner_at_FreeBSD.org>
Date: Tue, 10 Jan 2023 16:42:40 UTC
The branch main has been updated by tcberner:

URL: https://cgit.FreeBSD.org/ports/commit/?id=cd55d84b6a6fa671682a8f2cf8caedb5e785e916

commit cd55d84b6a6fa671682a8f2cf8caedb5e785e916
Author:     Tobias C. Berner <tcberner@FreeBSD.org>
AuthorDate: 2023-01-10 10:37:52 +0000
Commit:     Tobias C. Berner <tcberner@FreeBSD.org>
CommitDate: 2023-01-10 16:41:14 +0000

    net-im/kaidan: prepare for textproc/zxing-cpp 2.0.0
    
    Backported from upstream.
---
 net-im/kaidan/files/patch-src_QrCodeDecoder.cpp   | 26 +++++++++++++++++++++++
 net-im/kaidan/files/patch-src_QrCodeGenerator.cpp | 25 ++++++++++++++++++++++
 2 files changed, 51 insertions(+)

diff --git a/net-im/kaidan/files/patch-src_QrCodeDecoder.cpp b/net-im/kaidan/files/patch-src_QrCodeDecoder.cpp
new file mode 100644
index 000000000000..5223f26e47c6
--- /dev/null
+++ b/net-im/kaidan/files/patch-src_QrCodeDecoder.cpp
@@ -0,0 +1,26 @@
+--- src/QrCodeDecoder.cpp.orig	2023-01-10 10:30:39 UTC
++++ src/QrCodeDecoder.cpp
+@@ -60,7 +60,11 @@ void QrCodeDecoder::decodeImage(const QImage &image)
+ {
+ 	// Advise the decoder to check for QR codes and to try decoding rotated versions of the image.
+ #if ZXING_VERSION >= QT_VERSION_CHECK(1, 1, 0)
++# if ZXING_VERSION >= QT_VERSION_CHECK(1, 1, 1)
++	const auto decodeHints = DecodeHints().setFormats(BarcodeFormat::QRCode);
++# else
+ 	const auto decodeHints = DecodeHints().setFormats(BarcodeFormat::QR_CODE);
++# endif
+ 	const auto result = ReadBarcode({image.bits(), image.width(), image.height(), ZXing::ImageFormat::Lum, image.bytesPerLine()}, decodeHints);
+ #else
+ 	const auto decodeHints =
+@@ -77,7 +81,11 @@ void QrCodeDecoder::decodeImage(const QImage &image)
+ 	// If a QR code could be found and decoded, emit a signal with the decoded string.
+ 	// Otherwise, emit a signal for failed decoding.
+ 	if (result.isValid())
++#if ZXING_VERSION < QT_VERSION_CHECK(2, 0, 0)
+ 		emit decodingSucceeded(QString::fromStdString(TextUtfEncoding::ToUtf8(result.text())));
++#else
++		emit decodingSucceeded(QString::fromStdString(result.text()));
++#endif
+ 	else
+ 		emit decodingFailed();
+ }
diff --git a/net-im/kaidan/files/patch-src_QrCodeGenerator.cpp b/net-im/kaidan/files/patch-src_QrCodeGenerator.cpp
new file mode 100644
index 000000000000..f72eba0b2bdb
--- /dev/null
+++ b/net-im/kaidan/files/patch-src_QrCodeGenerator.cpp
@@ -0,0 +1,25 @@
+--- src/QrCodeGenerator.cpp.orig	2023-01-10 10:34:19 UTC
++++ src/QrCodeGenerator.cpp
+@@ -33,6 +33,10 @@
+ #include <QImage>
+ #include <QRgb>
+ 
++#include <ZXing/ZXVersion.h>
++#define ZXING_VERSION \
++	QT_VERSION_CHECK(ZXING_VERSION_MAJOR, ZXING_VERSION_MINOR, ZXING_VERSION_PATCH)
++
+ #include <ZXing/BarcodeFormat.h>
+ #include <ZXing/MultiFormatWriter.h>
+ 
+@@ -74,7 +78,11 @@ QImage QrCodeGenerator::generateQrCode(int edgePixelCo
+ QImage QrCodeGenerator::generateQrCode(int edgePixelCount, const QString &text)
+ {
+ 	try {
++#if ZXING_VERSION >= QT_VERSION_CHECK(1, 1, 1)
++		ZXing::MultiFormatWriter writer(ZXing::BarcodeFormat::QRCode);
++#else
+ 		ZXing::MultiFormatWriter writer(ZXing::BarcodeFormat::QR_CODE);
++#endif
+ 		const ZXing::BitMatrix &bitMatrix = writer.encode(text.toStdWString(), edgePixelCount, edgePixelCount);
+ 		return toImage(bitMatrix);
+ 	} catch (const std::invalid_argument &e) {