-
Notifications
You must be signed in to change notification settings - Fork 743
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
net-im/kaidan: prepare for textproc/zxing-cpp 2.0.0
Backported from upstream.
- Loading branch information
Showing
2 changed files
with
51 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) { |