Move the conversion of Barcode Encode data from the QZXing:encodeData to QZXingImageProvider. The URL-formatted input is provided by the QML code so the conversion must be executed only then. If a user executes QZXing::encodeData directly, it must encode the data as is.

This commit is contained in:
Nikos Ftylitakis 2020-01-13 11:32:58 +02:00
parent c1f4379ec7
commit 2a58c5032b
2 changed files with 4 additions and 4 deletions

View File

@ -595,15 +595,13 @@ QImage QZXing::encodeData(const QString &data, const QZXingEncoderConfig &encode
{
QImage image;
QString dataTemp(QUrl::fromPercentEncoding(data.toUtf8()));
try {
switch (encoderConfig.format) {
#ifdef ENABLE_ENCODER_QR_CODE
case EncoderFormat_QR_CODE:
{
Ref<qrcode::QRCode> barcode = qrcode::Encoder::encode(
dataTemp.toStdWString(),
data.toStdWString(),
encoderConfig.errorCorrectionLevel == EncodeErrorCorrectionLevel_H ?
qrcode::ErrorCorrectionLevel::H :
(encoderConfig.errorCorrectionLevel == EncodeErrorCorrectionLevel_Q ?

View File

@ -72,7 +72,9 @@ QImage QZXingImageProvider::requestImage(const QString &id, QSize *size, const Q
QZXingEncoderConfig encoderConfig(format, requestedSize, correctionLevel, border, transparent);
QImage result = QZXing::encodeData(data, encoderConfig);
QString dataTemp(QUrl::fromPercentEncoding(data.toUtf8()));
QImage result = QZXing::encodeData(dataTemp, encoderConfig);
*size = result.size();
return result;
}