Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package prison-qt5 for openSUSE:Factory checked in at 2021-08-16 10:08:19 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/prison-qt5 (Old) and /work/SRC/openSUSE:Factory/.prison-qt5.new.1899 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "prison-qt5" Mon Aug 16 10:08:19 2021 rev:58 rq:912175 version:5.85.0 Changes: -------- --- /work/SRC/openSUSE:Factory/prison-qt5/prison-qt5.changes 2021-07-16 00:02:07.548761934 +0200 +++ /work/SRC/openSUSE:Factory/.prison-qt5.new.1899/prison-qt5.changes 2021-08-16 10:12:39.575022926 +0200 @@ -1,0 +2,11 @@ +Fri Aug 6 12:13:34 UTC 2021 - Christophe Giboudeaux <[email protected]> + +- Update to 5.85.0 + * New feature release + * For more details please see: + * https://kde.org/announcements/frameworks/5/5.85.0 +- Changes since 5.84.0: + * Support binary content in QR codes + * Constrain rendering by the minimum size, not the preferred size + +------------------------------------------------------------------- Old: ---- prison-5.84.0.tar.xz prison-5.84.0.tar.xz.sig New: ---- prison-5.85.0.tar.xz prison-5.85.0.tar.xz.sig ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ prison-qt5.spec ++++++ --- /var/tmp/diff_new_pack.nkEFlO/_old 2021-08-16 10:12:40.087022322 +0200 +++ /var/tmp/diff_new_pack.nkEFlO/_new 2021-08-16 10:12:40.091022319 +0200 @@ -19,7 +19,7 @@ %define sonum 5 %define rname prison %define _libname KF5Prison -%define _tar_path 5.84 +%define _tar_path 5.85 # Full KF5 version (e.g. 5.33.0) %{!?_kf5_version: %global _kf5_version %{version}} # Last major and minor KF5 version (e.g. 5.33) @@ -27,7 +27,7 @@ # Only needed for the package signature condition %bcond_without lang Name: prison-qt5 -Version: 5.84.0 +Version: 5.85.0 Release: 0 Summary: Barcode abstraction layer library License: MIT ++++++ prison-5.84.0.tar.xz -> prison-5.85.0.tar.xz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/prison-5.84.0/.reuse/dep5 new/prison-5.85.0/.reuse/dep5 --- old/prison-5.84.0/.reuse/dep5 1970-01-01 01:00:00.000000000 +0100 +++ new/prison-5.85.0/.reuse/dep5 2021-07-16 21:17:03.000000000 +0200 @@ -0,0 +1,7 @@ +Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ +Upstream-Name: KF5::Prison +Source: https://invent.kde.org/frameworks/prison + +Files: autotests/aztec/encoding/*.png autotests/aztec/rendering/*.png autotests/code128/*.png autotests/datamatrix/*.png autotests/qr/*.png +Copyright: none +License: CC0-1.0 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/prison-5.84.0/CMakeLists.txt new/prison-5.85.0/CMakeLists.txt --- old/prison-5.84.0/CMakeLists.txt 2021-06-19 18:04:24.000000000 +0200 +++ new/prison-5.85.0/CMakeLists.txt 2021-07-16 21:17:03.000000000 +0200 @@ -1,11 +1,11 @@ cmake_minimum_required(VERSION 3.16) -set(KF_VERSION "5.84.0") # handled by release scripts +set(KF_VERSION "5.85.0") # handled by release scripts project(prison VERSION ${KF_VERSION}) # ECM setup include(FeatureSummary) -find_package(ECM 5.84.0 NO_MODULE) +find_package(ECM 5.85.0 NO_MODULE) set_package_properties(ECM PROPERTIES TYPE REQUIRED DESCRIPTION "Extra CMake Modules." URL "https://commits.kde.org/extra-cmake-modules") feature_summary(WHAT REQUIRED_PACKAGES_NOT_FOUND FATAL_ON_MISSING_REQUIRED_PACKAGES) set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake" "${ECM_MODULE_PATH}") diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/prison-5.84.0/LICENSES/CC0-1.0.txt new/prison-5.85.0/LICENSES/CC0-1.0.txt --- old/prison-5.84.0/LICENSES/CC0-1.0.txt 1970-01-01 01:00:00.000000000 +0100 +++ new/prison-5.85.0/LICENSES/CC0-1.0.txt 2021-07-16 21:17:03.000000000 +0200 @@ -0,0 +1,121 @@ +Creative Commons Legal Code + +CC0 1.0 Universal + + CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE + LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN + ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS + INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES + REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS + PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM + THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED + HEREUNDER. + +Statement of Purpose + +The laws of most jurisdictions throughout the world automatically confer +exclusive Copyright and Related Rights (defined below) upon the creator +and subsequent owner(s) (each and all, an "owner") of an original work of +authorship and/or a database (each, a "Work"). + +Certain owners wish to permanently relinquish those rights to a Work for +the purpose of contributing to a commons of creative, cultural and +scientific works ("Commons") that the public can reliably and without fear +of later claims of infringement build upon, modify, incorporate in other +works, reuse and redistribute as freely as possible in any form whatsoever +and for any purposes, including without limitation commercial purposes. +These owners may contribute to the Commons to promote the ideal of a free +culture and the further production of creative, cultural and scientific +works, or to gain reputation or greater distribution for their Work in +part through the use and efforts of others. + +For these and/or other purposes and motivations, and without any +expectation of additional consideration or compensation, the person +associating CC0 with a Work (the "Affirmer"), to the extent that he or she +is an owner of Copyright and Related Rights in the Work, voluntarily +elects to apply CC0 to the Work and publicly distribute the Work under its +terms, with knowledge of his or her Copyright and Related Rights in the +Work and the meaning and intended legal effect of CC0 on those rights. + +1. Copyright and Related Rights. A Work made available under CC0 may be +protected by copyright and related or neighboring rights ("Copyright and +Related Rights"). Copyright and Related Rights include, but are not +limited to, the following: + + i. the right to reproduce, adapt, distribute, perform, display, + communicate, and translate a Work; + ii. moral rights retained by the original author(s) and/or performer(s); +iii. publicity and privacy rights pertaining to a person's image or + likeness depicted in a Work; + iv. rights protecting against unfair competition in regards to a Work, + subject to the limitations in paragraph 4(a), below; + v. rights protecting the extraction, dissemination, use and reuse of data + in a Work; + vi. database rights (such as those arising under Directive 96/9/EC of the + European Parliament and of the Council of 11 March 1996 on the legal + protection of databases, and under any national implementation + thereof, including any amended or successor version of such + directive); and +vii. other similar, equivalent or corresponding rights throughout the + world based on applicable law or treaty, and any national + implementations thereof. + +2. Waiver. To the greatest extent permitted by, but not in contravention +of, applicable law, Affirmer hereby overtly, fully, permanently, +irrevocably and unconditionally waives, abandons, and surrenders all of +Affirmer's Copyright and Related Rights and associated claims and causes +of action, whether now known or unknown (including existing as well as +future claims and causes of action), in the Work (i) in all territories +worldwide, (ii) for the maximum duration provided by applicable law or +treaty (including future time extensions), (iii) in any current or future +medium and for any number of copies, and (iv) for any purpose whatsoever, +including without limitation commercial, advertising or promotional +purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each +member of the public at large and to the detriment of Affirmer's heirs and +successors, fully intending that such Waiver shall not be subject to +revocation, rescission, cancellation, termination, or any other legal or +equitable action to disrupt the quiet enjoyment of the Work by the public +as contemplated by Affirmer's express Statement of Purpose. + +3. Public License Fallback. Should any part of the Waiver for any reason +be judged legally invalid or ineffective under applicable law, then the +Waiver shall be preserved to the maximum extent permitted taking into +account Affirmer's express Statement of Purpose. In addition, to the +extent the Waiver is so judged Affirmer hereby grants to each affected +person a royalty-free, non transferable, non sublicensable, non exclusive, +irrevocable and unconditional license to exercise Affirmer's Copyright and +Related Rights in the Work (i) in all territories worldwide, (ii) for the +maximum duration provided by applicable law or treaty (including future +time extensions), (iii) in any current or future medium and for any number +of copies, and (iv) for any purpose whatsoever, including without +limitation commercial, advertising or promotional purposes (the +"License"). The License shall be deemed effective as of the date CC0 was +applied by Affirmer to the Work. Should any part of the License for any +reason be judged legally invalid or ineffective under applicable law, such +partial invalidity or ineffectiveness shall not invalidate the remainder +of the License, and in such case Affirmer hereby affirms that he or she +will not (i) exercise any of his or her remaining Copyright and Related +Rights in the Work or (ii) assert any associated claims and causes of +action with respect to the Work, in either case contrary to Affirmer's +express Statement of Purpose. + +4. Limitations and Disclaimers. + + a. No trademark or patent rights held by Affirmer are waived, abandoned, + surrendered, licensed or otherwise affected by this document. + b. Affirmer offers the Work as-is and makes no representations or + warranties of any kind concerning the Work, express, implied, + statutory or otherwise, including without limitation warranties of + title, merchantability, fitness for a particular purpose, non + infringement, or the absence of latent or other defects, accuracy, or + the present or absence of errors, whether or not discoverable, all to + the greatest extent permissible under applicable law. + c. Affirmer disclaims responsibility for clearing rights of other persons + that may apply to the Work or any use thereof, including without + limitation any person's Copyright and Related Rights in the Work. + Further, Affirmer disclaims responsibility for obtaining any necessary + consents, permissions or other rights required for any use of the + Work. + d. Affirmer understands and acknowledges that Creative Commons is not a + party to this document and has no duty or obligation with respect to + this CC0 or use of the Work. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/prison-5.84.0/autotests/CMakeLists.txt new/prison-5.85.0/autotests/CMakeLists.txt --- old/prison-5.84.0/autotests/CMakeLists.txt 2021-06-19 18:04:24.000000000 +0200 +++ new/prison-5.85.0/autotests/CMakeLists.txt 2021-07-16 21:17:03.000000000 +0200 @@ -1,11 +1,14 @@ +# SPDX-FileCopyrightText: 2017-2018 Volker Krause <[email protected]> +# SPDX-License-Identifier: BSD-3-Clause + set(aztecbarcodetest_srcs aztecbarcodetest.cpp + aztec/aztec.qrc ../src/lib/aztecbarcode.cpp ../src/lib/bitvector.cpp ../src/lib/reedsolomon.cpp ${CMAKE_CURRENT_BINARY_DIR}/../src/lib/prison_debug.cpp ) -qt_add_resources(aztecbarcodetest_srcs aztec/aztec.qrc) ecm_add_test(${aztecbarcodetest_srcs} TEST_NAME prison-aztecbarcodetest LINK_LIBRARIES Qt5::Test KF5::Prison) @@ -19,9 +22,13 @@ set(code128barcodetest_srcs code128barcodetest.cpp + code128/code128.qrc ../src/lib/code128barcode.cpp ../src/lib/bitvector.cpp ${CMAKE_CURRENT_BINARY_DIR}/../src/lib/prison_debug.cpp ) ecm_add_test(${code128barcodetest_srcs} TEST_NAME prison-code128barcodetest LINK_LIBRARIES Qt5::Test KF5::Prison) + +ecm_add_test(datamatrixtest.cpp datamatrix/datamatrix.qrc TEST_NAME prison-datamatrixtest LINK_LIBRARIES Qt5::Test KF5::Prison) +ecm_add_test(qrtest.cpp qr/qr.qrc TEST_NAME prison-qrtest LINK_LIBRARIES Qt5::Test KF5::Prison) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/prison-5.84.0/autotests/aztec/aztec.qrc new/prison-5.85.0/autotests/aztec/aztec.qrc --- old/prison-5.84.0/autotests/aztec/aztec.qrc 2021-06-19 18:04:24.000000000 +0200 +++ new/prison-5.85.0/autotests/aztec/aztec.qrc 2021-07-16 21:17:03.000000000 +0200 @@ -1,5 +1,9 @@ +<!-- + SPDX-FileCopyrightText: none + SPDX-License-Identifier: CC0-1.0 +--> <RCC> - <qresource prefix="/"> + <qresource prefix="/aztec/"> <file>rendering/aztec-full-grid.png</file> <file>rendering/aztec-full-data-0011.png</file> <file>rendering/aztec-full-data-0101.png</file> @@ -25,5 +29,6 @@ <file>encoding/aztec-complete-compact4.png</file> <file>encoding/aztec-complete-full5.png</file> <file>encoding/aztec-complete-big.png</file> + <file>encoding/aztec-binary.png</file> </qresource> </RCC> Binary files old/prison-5.84.0/autotests/aztec/encoding/aztec-binary.png and new/prison-5.85.0/autotests/aztec/encoding/aztec-binary.png differ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/prison-5.84.0/autotests/aztecbarcodetest.cpp new/prison-5.85.0/autotests/aztecbarcodetest.cpp --- old/prison-5.84.0/autotests/aztecbarcodetest.cpp 2021-06-19 18:04:24.000000000 +0200 +++ new/prison-5.85.0/autotests/aztecbarcodetest.cpp 2021-07-16 21:17:03.000000000 +0200 @@ -135,12 +135,12 @@ v.appendMSB(0, 5); v.appendMSB(17, 5); v.appendMSB(18, 5); - QTest::newRow("upper ambigious punct shift") << QByteArray("P,Q") << v; + QTest::newRow("upper ambiguous punct shift") << QByteArray("P,Q") << v; v.clear(); v.appendMSB(30, 5); v.appendMSB(13, 4); v.appendMSB(7, 4); - QTest::newRow("digit ambigious punct latch") << QByteArray(".5") << v; + QTest::newRow("digit ambiguous punct latch") << QByteArray(".5") << v; v.clear(); v.appendMSB(29, 5); v.appendMSB(30, 5); @@ -175,7 +175,7 @@ QTest::addColumn<int>("codeWordSize"); BitVector in, out; - QTest::newRow("emtpy") << in << out << 4; + QTest::newRow("empty") << in << out << 4; in.appendMSB(0x2, 2); out.appendMSB(0xB, 4); QTest::newRow("pad only") << in << out << 4; @@ -218,7 +218,7 @@ img.fill(code.backgroundColor()); code.paintFullGrid(&img); - QImage ref(QStringLiteral(":/rendering/aztec-full-grid.png")); + QImage ref(QStringLiteral(":/aztec/rendering/aztec-full-grid.png")); ref = ref.convertToFormat(img.format()); QCOMPARE(img, ref); } @@ -231,7 +231,7 @@ code.paintCompactGrid(&img); img.save(QStringLiteral("aztec-compact-grid.png")); - QImage ref(QStringLiteral(":/rendering/aztec-compact-grid.png")); + QImage ref(QStringLiteral(":/aztec/rendering/aztec-compact-grid.png")); ref = ref.convertToFormat(img.format()); QCOMPARE(img, ref); } @@ -280,7 +280,7 @@ code.paintFullData(&img, data, layer); img.save(refName); - QImage ref(QStringLiteral(":/rendering/") + refName); + QImage ref(QStringLiteral(":/aztec/rendering/") + refName); ref = ref.convertToFormat(img.format()); QCOMPARE(img, ref); } @@ -317,7 +317,7 @@ code.paintFullModeMessage(&img, data); img.save(refName); - QImage ref(QStringLiteral(":/rendering/") + refName); + QImage ref(QStringLiteral(":/aztec/rendering/") + refName); ref = ref.convertToFormat(img.format()); QCOMPARE(img, ref); } @@ -366,7 +366,7 @@ code.paintCompactData(&img, data, layer); img.save(refName); - QImage ref(QStringLiteral(":/rendering/") + refName); + QImage ref(QStringLiteral(":/aztec/rendering/") + refName); ref = ref.convertToFormat(img.format()); QCOMPARE(img, ref); } @@ -403,22 +403,22 @@ code.paintCompactModeMessage(&img, data); img.save(refName); - QImage ref(QStringLiteral(":/rendering/") + refName); + QImage ref(QStringLiteral(":/aztec/rendering/") + refName); ref = ref.convertToFormat(img.format()); QCOMPARE(img, ref); } void testCodeGen_data() { - QTest::addColumn<QString>("input"); + QTest::addColumn<QByteArray>("input"); QTest::addColumn<QString>("refName"); - QTest::newRow("short compact") << QStringLiteral("KF5::Prison") << "aztec-complete-compact1.png"; - QTest::newRow("compact 3 layer") << QStringLiteral("M1KRAUSE/VOLKER ABCDEFG TXLRIXBT 0212 309Y014E0063 100") << "aztec-complete-compact3.png"; - QTest::newRow("long compact") << QStringLiteral("KF5::Prison - the barcode generation library of KDE Frameworks 5!") << "aztec-complete-compact4.png"; - QTest::newRow("short full") << QStringLiteral("KF5::Prison - the MIT licensed free software barcode generation library of KDE Frameworks 5!") + QTest::newRow("short compact") << QByteArray("KF5::Prison") << "aztec-complete-compact1.png"; + QTest::newRow("compact 3 layer") << QByteArray("M1KRAUSE/VOLKER ABCDEFG TXLRIXBT 0212 309Y014E0063 100") << "aztec-complete-compact3.png"; + QTest::newRow("long compact") << QByteArray("KF5::Prison - the barcode generation library of KDE Frameworks 5!") << "aztec-complete-compact4.png"; + QTest::newRow("short full") << QByteArray("KF5::Prison - the MIT licensed free software barcode generation library of KDE Frameworks 5!") << "aztec-complete-full5.png"; - QTest::newRow("long full") << QString::fromLatin1( + QTest::newRow("long full") << QByteArray( "Permission is hereby granted, free of charge, to any person\n" "obtaining a copy of this software and associated documentation\n" "files (the \"Software\"), to deal in the Software without\n" @@ -438,21 +438,35 @@ "FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR\n" "OTHER DEALINGS IN THE SOFTWARE.") << "aztec-complete-big.png"; + QTest::newRow("binary") << QByteArray("KDE\x0\x1\x2\x3\x4\x5\x6\x7\x8\x9kde", 16) << "aztec-binary.png"; } void testCodeGen() { - QFETCH(QString, input); + QFETCH(QByteArray, input); QFETCH(QString, refName); - AztecBarcode code; - code.setData(input); - const auto img = code.paintImage({}); - img.save(refName); + { + AztecBarcode code; + code.setData(QString::fromLatin1(input.constData(), input.size())); + const auto img = code.paintImage({}); + img.save(refName); + + QImage ref(QStringLiteral(":/aztec/encoding/") + refName); + ref = ref.convertToFormat(img.format()); + QCOMPARE(img, ref); + } - QImage ref(QStringLiteral(":/encoding/") + refName); - ref = ref.convertToFormat(img.format()); - QCOMPARE(img, ref); + { + AztecBarcode code; + code.setData(input); + const auto img = code.paintImage({}); + img.save(refName); + + QImage ref(QStringLiteral(":/aztec/encoding/") + refName); + ref = ref.convertToFormat(img.format()); + QCOMPARE(img, ref); + } } void testDimension() Binary files old/prison-5.84.0/autotests/code128/code128-binary.png and new/prison-5.85.0/autotests/code128/code128-binary.png differ Binary files old/prison-5.84.0/autotests/code128/code128-text.png and new/prison-5.85.0/autotests/code128/code128-text.png differ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/prison-5.84.0/autotests/code128/code128.qrc new/prison-5.85.0/autotests/code128/code128.qrc --- old/prison-5.84.0/autotests/code128/code128.qrc 1970-01-01 01:00:00.000000000 +0100 +++ new/prison-5.85.0/autotests/code128/code128.qrc 2021-07-16 21:17:03.000000000 +0200 @@ -0,0 +1,10 @@ +<!-- + SPDX-FileCopyrightText: none + SPDX-License-Identifier: CC0-1.0 +--> +<RCC> + <qresource prefix="/code128/"> + <file>code128-text.png</file> + <file>code128-binary.png</file> + </qresource> +</RCC> diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/prison-5.84.0/autotests/code128barcodetest.cpp new/prison-5.85.0/autotests/code128barcodetest.cpp --- old/prison-5.84.0/autotests/code128barcodetest.cpp 2021-06-19 18:04:24.000000000 +0200 +++ new/prison-5.85.0/autotests/code128barcodetest.cpp 2021-07-16 21:17:03.000000000 +0200 @@ -201,6 +201,43 @@ QCOMPARE(barcode->toImage(barcode->preferredSize(1)).size(), QSize(308, 50)); QCOMPARE(barcode->toImage({1, 1}).isNull(), true); } + + void testRender_data() + { + QTest::addColumn<QByteArray>("input"); + QTest::addColumn<QString>("refName"); + + QTest::newRow("text") << QByteArray("KF5::Prison") << "code128-text.png"; + QTest::newRow("binary") << QByteArray("KDE\x0\x1\x2\x3\x4\x5\x6\x7\x8\x9kde", 16) << "code128-binary.png"; + } + + void testRender() + { + QFETCH(QByteArray, input); + QFETCH(QString, refName); + + { + Code128Barcode code; + code.setData(QString::fromLatin1(input.constData(), input.size())); + const auto img = code.paintImage({}); + img.save(refName); + + QImage ref(QStringLiteral(":/code128/") + refName); + ref = ref.convertToFormat(img.format()); + QCOMPARE(img, ref); + } + + { + Code128Barcode code; + code.setData(input); + const auto img = code.paintImage({}); + img.save(refName); + + QImage ref(QStringLiteral(":/code128/") + refName); + ref = ref.convertToFormat(img.format()); + QCOMPARE(img, ref); + } + } }; QTEST_APPLESS_MAIN(Code128BarcodeTest) Binary files old/prison-5.84.0/autotests/datamatrix/datamatrix-binary.png and new/prison-5.85.0/autotests/datamatrix/datamatrix-binary.png differ Binary files old/prison-5.84.0/autotests/datamatrix/datamatrix-text.png and new/prison-5.85.0/autotests/datamatrix/datamatrix-text.png differ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/prison-5.84.0/autotests/datamatrix/datamatrix.qrc new/prison-5.85.0/autotests/datamatrix/datamatrix.qrc --- old/prison-5.84.0/autotests/datamatrix/datamatrix.qrc 1970-01-01 01:00:00.000000000 +0100 +++ new/prison-5.85.0/autotests/datamatrix/datamatrix.qrc 2021-07-16 21:17:03.000000000 +0200 @@ -0,0 +1,10 @@ +<!-- + SPDX-FileCopyrightText: none + SPDX-License-Identifier: CC0-1.0 +--> +<RCC> + <qresource prefix="/datamatrix/"> + <file>datamatrix-text.png</file> + <file>datamatrix-binary.png</file> + </qresource> +</RCC> diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/prison-5.84.0/autotests/datamatrixtest.cpp new/prison-5.85.0/autotests/datamatrixtest.cpp --- old/prison-5.84.0/autotests/datamatrixtest.cpp 1970-01-01 01:00:00.000000000 +0100 +++ new/prison-5.85.0/autotests/datamatrixtest.cpp 2021-07-16 21:17:03.000000000 +0200 @@ -0,0 +1,57 @@ +/* + SPDX-FileCopyrightText: 2021 Volker Krause <[email protected]> + + SPDX-License-Identifier: MIT +*/ + +#include <prison.h> + +#include <QObject> +#include <QTest> + +using namespace Prison; + +class DataMatrixTest : public QObject +{ + Q_OBJECT +private Q_SLOTS: + void testRender_data() + { + QTest::addColumn<QByteArray>("input"); + QTest::addColumn<QString>("refName"); + + QTest::newRow("text") << QByteArray("KF5::Prison") << "datamatrix-text.png"; + QTest::newRow("binary") << QByteArray("KDE\x0\x1\x2\x3\x4\x5\x6\x7\x8\x9kde", 16) << "datamatrix-binary.png"; + } + + void testRender() + { + QFETCH(QByteArray, input); + QFETCH(QString, refName); + + { + std::unique_ptr<Prison::AbstractBarcode> code(Prison::createBarcode(Prison::DataMatrix)); + code->setData(QString::fromLatin1(input.constData(), input.size())); + const auto img = code->toImage(code->minimumSize()); + img.save(refName); + + QImage ref(QStringLiteral(":/datamatrix/") + refName); + ref = ref.convertToFormat(img.format()); + QCOMPARE(img, ref); + } + { + std::unique_ptr<Prison::AbstractBarcode> code(Prison::createBarcode(Prison::DataMatrix)); + code->setData(input); + const auto img = code->toImage(code->minimumSize()); + img.save(refName); + + QImage ref(QStringLiteral(":/datamatrix/") + refName); + ref = ref.convertToFormat(img.format()); + QCOMPARE(img, ref); + } + } +}; + +QTEST_APPLESS_MAIN(DataMatrixTest) + +#include "datamatrixtest.moc" Binary files old/prison-5.84.0/autotests/qr/qr-binary.png and new/prison-5.85.0/autotests/qr/qr-binary.png differ Binary files old/prison-5.84.0/autotests/qr/qr-text.png and new/prison-5.85.0/autotests/qr/qr-text.png differ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/prison-5.84.0/autotests/qr/qr.qrc new/prison-5.85.0/autotests/qr/qr.qrc --- old/prison-5.84.0/autotests/qr/qr.qrc 1970-01-01 01:00:00.000000000 +0100 +++ new/prison-5.85.0/autotests/qr/qr.qrc 2021-07-16 21:17:03.000000000 +0200 @@ -0,0 +1,11 @@ +<!-- + SPDX-FileCopyrightText: none + SPDX-License-Identifier: CC0-1.0 +--> +<RCC> + <qresource prefix="/qr/"> + <file>qr-text.png</file> + <file>qr-binary.png</file> + </qresource> +</RCC> + diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/prison-5.84.0/autotests/qrtest.cpp new/prison-5.85.0/autotests/qrtest.cpp --- old/prison-5.84.0/autotests/qrtest.cpp 1970-01-01 01:00:00.000000000 +0100 +++ new/prison-5.85.0/autotests/qrtest.cpp 2021-07-16 21:17:03.000000000 +0200 @@ -0,0 +1,68 @@ +/* + SPDX-FileCopyrightText: 2021 Volker Krause <[email protected]> + + SPDX-License-Identifier: MIT +*/ + +#include <prison.h> + +#include <QObject> +#include <QTest> + +using namespace Prison; + +class QrTest : public QObject +{ + Q_OBJECT +private Q_SLOTS: + void testRenderText_data() + { + QTest::addColumn<QString>("input"); + QTest::addColumn<QString>("refName"); + + QTest::newRow("text") << QStringLiteral("KF5::Prison") << "qr-text.png"; + } + + void testRenderText() + { + QFETCH(QString, input); + QFETCH(QString, refName); + + std::unique_ptr<Prison::AbstractBarcode> code(Prison::createBarcode(Prison::QRCode)); + code->setData(input); + const auto img = code->toImage(code->minimumSize()); + img.save(refName); + + QImage ref(QStringLiteral(":/qr/") + refName); + ref = ref.convertToFormat(img.format()); + QCOMPARE(img, ref); + } + + void testRenderBinary_data() + { + QTest::addColumn<QByteArray>("input"); + QTest::addColumn<QString>("refName"); + + QTest::newRow("text") << QByteArray("KF5::Prison") << "qr-text.png"; + QTest::newRow("binary") << QByteArray("KDE\x0\x1\x2\x3\x4\x5\x6\x7\x8\x9kde", 16) << "qr-binary.png"; + } + + void testRenderBinary() + { + QFETCH(QByteArray, input); + QFETCH(QString, refName); + + std::unique_ptr<Prison::AbstractBarcode> code(Prison::createBarcode(Prison::QRCode)); + code->setData(input); + const auto img = code->toImage(code->minimumSize()); + img.save(refName); + + QImage ref(QStringLiteral(":/qr/") + refName); + ref = ref.convertToFormat(img.format()); + QCOMPARE(img, ref); + } +}; + +QTEST_APPLESS_MAIN(QrTest) + +#include "qrtest.moc" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/prison-5.84.0/src/lib/abstractbarcode.cpp new/prison-5.85.0/src/lib/abstractbarcode.cpp --- old/prison-5.84.0/src/lib/abstractbarcode.cpp 2021-06-19 18:04:24.000000000 +0200 +++ new/prison-5.85.0/src/lib/abstractbarcode.cpp 2021-07-16 21:17:03.000000000 +0200 @@ -8,6 +8,7 @@ #include <QColor> #include <QPainter> +#include <QVariant> using namespace Prison; /** @@ -16,7 +17,7 @@ class Prison::AbstractBarcodePrivate { public: - QString m_data; + QVariant m_data; QImage m_cache; QColor m_foreground = Qt::black; QColor m_background = Qt::white; @@ -28,9 +29,22 @@ return m_cache.width() > size.width() || m_cache.height() > size.height(); } + bool isEmpty() const + { + switch (m_data.type()) { + case QVariant::String: + return m_data.toString().isEmpty(); + case QVariant::ByteArray: + return m_data.toByteArray().isEmpty(); + default: + break; + } + return true; + } + void recompute() { - if (m_cache.isNull() && !m_data.isEmpty()) { + if (m_cache.isNull() && !isEmpty()) { m_cache = q->paintImage({}); } } @@ -59,7 +73,12 @@ QString AbstractBarcode::data() const { - return d->m_data; + return d->m_data.type() == QVariant::String ? d->m_data.toString() : QString(); +} + +QByteArray AbstractBarcode::byteArrayData() const +{ + return d->m_data.type() == QVariant::ByteArray ? d->m_data.toByteArray() : QByteArray(); } QImage AbstractBarcode::toImage(const QSizeF &size) @@ -87,6 +106,12 @@ { d->m_data = data; d->m_cache = QImage(); +} + +void AbstractBarcode::setData(const QByteArray &data) +{ + d->m_data = data; + d->m_cache = QImage(); } #if PRISON_BUILD_DEPRECATED_SINCE(5, 72) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/prison-5.84.0/src/lib/abstractbarcode.h new/prison-5.85.0/src/lib/abstractbarcode.h --- old/prison-5.84.0/src/lib/abstractbarcode.h 2021-06-19 18:04:24.000000000 +0200 +++ new/prison-5.85.0/src/lib/abstractbarcode.h 2021-07-16 21:17:03.000000000 +0200 @@ -43,18 +43,38 @@ virtual ~AbstractBarcode(); /** - * @return the QString encoded in this barcode. + * Textual content encoded in this barcode. + * This returns an empty QString if binary content is set. + * @see byteArrayData() */ QString data() const; /** - * sets the data to be drawn by this function - * calling this function does not do any repaints of anything, they are - * your own responsibility. If you are using the barcodes thru BarcodeWidget or BarcodeItem, you - * should rather use their setData function, as they handle the relevant updates. - * @param data QString containing the data + * Binary data encoded in this barcode. + * This returns an empty QByteArray if textual content is set. + * @see data() + * @since 5.85 + */ + QByteArray byteArrayData() const; + /** + * Sets textual data to be drawn as a barcode. + * Only use this function if your content is textual, use the QByteArray overload + * when your content contains non-textual binary content. + * Calling this function does not do any repaints of anything, they are + * your own responsibility. + * @param data textual barcode content */ void setData(const QString &data); /** + * Sets binary data to be drawn as a barcode. + * Prefer the QString overload if your content is purely textual, to reduce + * the risk of encoding issues for non-ASCII content. + * Calling this function does not do any repaints of anything, they are + * your own responsibility. + * @param data binary barcode content + * @since 5.85 + */ + void setData(const QByteArray &data); + /** * Creates a image with a barcode on * @return QImage with a barcode on, trying to match the requested \param size * diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/prison-5.84.0/src/lib/aztecbarcode.cpp new/prison-5.85.0/src/lib/aztecbarcode.cpp --- old/prison-5.84.0/src/lib/aztecbarcode.cpp 2021-06-19 18:04:24.000000000 +0200 +++ new/prison-5.85.0/src/lib/aztecbarcode.cpp 2021-07-16 21:17:03.000000000 +0200 @@ -64,12 +64,12 @@ QImage AztecBarcode::paintImage(const QSizeF &size) { Q_UNUSED(size); - const auto inputData = aztecEncode(data().toLatin1()); + const auto inputData = aztecEncode(data().isEmpty() ? byteArrayData() : data().toLatin1()); int layerCount = 0; int codewordCount = 0; int availableBits = 0; - int stuffSize = 0; // extra bits added during bit stuffing, which might make us overun the available size + int stuffSize = 0; // extra bits added during bit stuffing, which might make us overrun the available size bool compactMode = false; BitVector encodedData; @@ -261,7 +261,7 @@ static const int aztec_code_size[] = {0, 5, 5, 5, 5, 4, 8}; Q_STATIC_ASSERT(sizeof(aztec_code_size) / sizeof(int) == MODE_COUNT); -// codes for ambigious characters, ie. those that can be encoded in multiple modes +// codes for ambiguous characters, ie. those that can be encoded in multiple modes static const aztec_code_t aztec_special_chars[SPECIAL_CHAR_COUNT][MODE_COUNT - 1] = { /* NoMode Upper Lower Mixed Punct Digit */ {{0, NoMode}, {1, Upper}, {1, Lower}, {1, Mixed}, {1, Upper}, {1, Digit}}, /* SP */ @@ -355,7 +355,7 @@ } } - // pick one if we still have an ambigious symbol + // pick one if we still have an ambiguous symbol if ((*begin).mode != Special) { return; } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/prison-5.84.0/src/lib/code128barcode.cpp new/prison-5.85.0/src/lib/code128barcode.cpp --- old/prison-5.84.0/src/lib/code128barcode.cpp 2021-06-19 18:04:24.000000000 +0200 +++ new/prison-5.85.0/src/lib/code128barcode.cpp 2021-07-16 21:17:03.000000000 +0200 @@ -48,7 +48,7 @@ { Q_UNUSED(size); - const auto bits = encode(data().toLatin1()); + const auto bits = encode(data().isEmpty() ? byteArrayData() : data().toLatin1()); const auto width = bits.size() + 2 * QuietZone; QImage img(width, 1, QImage::Format_ARGB32); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/prison-5.84.0/src/lib/code39barcode.cpp new/prison-5.85.0/src/lib/code39barcode.cpp --- old/prison-5.84.0/src/lib/code39barcode.cpp 2021-06-19 18:04:24.000000000 +0200 +++ new/prison-5.85.0/src/lib/code39barcode.cpp 2021-07-16 21:17:03.000000000 +0200 @@ -121,7 +121,7 @@ barcode += endSequence; barcode += false; // translate the string - const QString str = data(); + const QString str = data().isEmpty() ? QString::fromLatin1(byteArrayData().constData(), byteArrayData().size()) : data(); for (int i = 0; i < str.size(); i++) { QList<bool> b = sequenceForChar(str.at(i).unicode()); if (!b.empty()) { diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/prison-5.84.0/src/lib/code93barcode.cpp new/prison-5.85.0/src/lib/code93barcode.cpp --- old/prison-5.84.0/src/lib/code93barcode.cpp 2021-06-19 18:04:24.000000000 +0200 +++ new/prison-5.85.0/src/lib/code93barcode.cpp 2021-07-16 21:17:03.000000000 +0200 @@ -621,7 +621,7 @@ { // translate the string into a code sequence QList<int> codes; - const QString str = data(); + const QString str = data().isEmpty() ? QString::fromLatin1(byteArrayData().constData(), byteArrayData().size()) : data(); for (int i = 0; i < str.size(); i++) { codes += codesForChar(str.at(i).unicode()); } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/prison-5.84.0/src/lib/qrcodebarcode.cpp new/prison-5.85.0/src/lib/qrcodebarcode.cpp --- old/prison-5.84.0/src/lib/qrcodebarcode.cpp 2021-06-19 18:04:24.000000000 +0200 +++ new/prison-5.85.0/src/lib/qrcodebarcode.cpp 2021-07-16 21:17:03.000000000 +0200 @@ -7,8 +7,13 @@ #include "qrcodebarcode.h" #include <qrencode.h> +#include <memory> + using namespace Prison; +using QRcode_ptr = std::unique_ptr<QRcode, decltype(&QRcode_free)>; +using QRinput_ptr = std::unique_ptr<QRinput, decltype(&QRinput_free)>; + QRCodeBarcode::QRCodeBarcode() : AbstractBarcode(AbstractBarcode::TwoDimensions) { @@ -18,8 +23,28 @@ QImage QRCodeBarcode::paintImage(const QSizeF &size) { Q_UNUSED(size); - const QByteArray trimmedData(data().trimmed().toUtf8()); - QRcode *code = QRcode_encodeString8bit(trimmedData.constData(), 0, QR_ECLEVEL_Q); + + QRcode_ptr code(nullptr, &QRcode_free); + QRinput_ptr input(nullptr, &QRinput_free); + if (!data().isEmpty()) { + const QByteArray trimmedData(data().trimmed().toUtf8()); + code.reset(QRcode_encodeString8bit(trimmedData.constData(), 0, QR_ECLEVEL_Q)); + } else { + const auto b = byteArrayData(); + const auto isReallyBinary = std::any_of(b.begin(), b.end(), [](unsigned char c) { + return std::iscntrl(c) && !std::isspace(c); + }); + // prefer encodeString whenever possible, as that selects the more efficient encoding + // automatically, otherwise we end up needlessly in the binary encoding unconditionally + if (isReallyBinary) { + input.reset(QRinput_new()); + QRinput_append(input.get(), QR_MODE_8, byteArrayData().size(), reinterpret_cast<const uint8_t *>(byteArrayData().constData())); + code.reset(QRcode_encodeInput(input.get())); + } else { + code.reset(QRcode_encodeString8bit(b.constData(), 0, QR_ECLEVEL_Q)); + } + } + if (!code) { return QImage(); } @@ -70,6 +95,5 @@ const auto result = QImage(img, code->width + 2 * margin, code->width + 2 * margin, QImage::Format_ARGB32).copy(); // deep copy as we are going to delete img delete[] img; - QRcode_free(code); return result; } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/prison-5.84.0/src/quick/barcodequickitem.cpp new/prison-5.85.0/src/quick/barcodequickitem.cpp --- old/prison-5.84.0/src/quick/barcodequickitem.cpp 2021-06-19 18:04:24.000000000 +0200 +++ new/prison-5.85.0/src/quick/barcodequickitem.cpp 2021-07-16 21:17:03.000000000 +0200 @@ -19,12 +19,12 @@ BarcodeQuickItem::~BarcodeQuickItem() = default; -QString BarcodeQuickItem::content() const +QVariant BarcodeQuickItem::content() const { return m_content; } -void BarcodeQuickItem::setContent(const QString &content) +void BarcodeQuickItem::setContent(const QVariant &content) { if (m_content == content) return; @@ -86,8 +86,8 @@ if (!m_barcode) return; - const auto w_max = std::max(implicitWidth(), width()); - const auto h_max = std::max(implicitHeight(), height()); + const auto w_max = std::max(minimumWidth(), width()); + const auto h_max = std::max(minimumHeight(), height()); const auto img = m_barcode->toImage(QSizeF(w_max, h_max)); const auto x = (w_max - img.width()) / 2; const auto y = (h_max - img.height()) / 2; @@ -111,12 +111,34 @@ return m_barcode ? m_barcode->trueMinimumSize().width() : 0.0; } +bool BarcodeQuickItem::isEmpty() const +{ + switch (m_content.type()) { + case QVariant::String: + return m_content.toString().isEmpty(); + case QVariant::ByteArray: + return m_content.toByteArray().isEmpty(); + default: + break; + } + return true; +} + void BarcodeQuickItem::updateBarcode() { if (!isComponentComplete()) return; - if (m_type == Prison::Null || m_content.isEmpty()) { + QString content; + if (m_content.type() == QVariant::String) { + content = m_content.toString(); + } + if (m_content.type() == QVariant::ByteArray) { + const auto b = m_content.toByteArray(); + content = QString::fromLatin1(b.constData(), b.size()); // ### fix this once Prison::Barcode can consume QByteArrays + } + + if (m_type == Prison::Null || isEmpty()) { m_barcode.reset(); update(); Q_EMIT dimensionsChanged(); @@ -126,7 +148,11 @@ if (!m_barcode) m_barcode.reset(Prison::createBarcode(m_type)); if (m_barcode) { - m_barcode->setData(m_content); + if (m_content.type() == QVariant::String) { + m_barcode->setData(m_content.toString()); + } else { + m_barcode->setData(m_content.toByteArray()); + } m_barcode->setForegroundColor(m_fgColor); m_barcode->setBackgroundColor(m_bgColor); const auto size = m_barcode->preferredSize(QGuiApplication::primaryScreen()->devicePixelRatio()); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/prison-5.84.0/src/quick/barcodequickitem.h new/prison-5.85.0/src/quick/barcodequickitem.h --- old/prison-5.84.0/src/quick/barcodequickitem.h 2021-06-19 18:04:24.000000000 +0200 +++ new/prison-5.85.0/src/quick/barcodequickitem.h 2021-07-16 21:17:03.000000000 +0200 @@ -21,7 +21,7 @@ class BarcodeQuickItem : public QQuickPaintedItem { Q_OBJECT - Q_PROPERTY(QString content READ content WRITE setContent NOTIFY contentChanged) + Q_PROPERTY(QVariant content READ content WRITE setContent NOTIFY contentChanged) Q_PROPERTY(BarcodeType barcodeType READ barcodeType WRITE setBarcodeType NOTIFY barcodeTypeChanged) Q_PROPERTY(QColor foregroundColor READ foregroundColor WRITE setForegroundColor NOTIFY foregroundColorChanged) Q_PROPERTY(QColor backgroundColor READ backgroundColor WRITE setBackgroundColor NOTIFY backgroundColorChanged) @@ -51,8 +51,8 @@ explicit BarcodeQuickItem(QQuickItem *parent = nullptr); ~BarcodeQuickItem(); - QString content() const; - void setContent(const QString &data); + QVariant content() const; + void setContent(const QVariant &data); Prison::BarcodeQuickItem::BarcodeType barcodeType() const; void setBarcodeType(Prison::BarcodeQuickItem::BarcodeType type); @@ -84,9 +84,10 @@ void dimensionsChanged(); private: + bool isEmpty() const; void updateBarcode(); - QString m_content; + QVariant m_content; std::unique_ptr<AbstractBarcode> m_barcode; QColor m_fgColor = Qt::black; QColor m_bgColor = Qt::white; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/prison-5.84.0/tests/barcodeexamplewidget.h new/prison-5.85.0/tests/barcodeexamplewidget.h --- old/prison-5.84.0/tests/barcodeexamplewidget.h 2021-06-19 18:04:24.000000000 +0200 +++ new/prison-5.85.0/tests/barcodeexamplewidget.h 2021-07-16 21:17:03.000000000 +0200 @@ -22,7 +22,7 @@ /** * Creates a barcode widget with 'barcode' as barcode generator * @param barcode The barcode generator for this widget. Takes ownership over the barcode generator - * @param parent the parent in QWidget hierachy + * @param parent the parent in QWidget hierarchy */ BarcodeExampleWidget(Prison::AbstractBarcode *barcode, QWidget *parent = nullptr); virtual ~BarcodeExampleWidget();
