Hello community,

here is the log from the commit of package prison-qt5 for openSUSE:Factory 
checked in at 2020-04-15 20:03:22
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/prison-qt5 (Old)
 and      /work/SRC/openSUSE:Factory/.prison-qt5.new.2738 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "prison-qt5"

Wed Apr 15 20:03:22 2020 rev:42 rq:793196 version:5.69.0

Changes:
--------
--- /work/SRC/openSUSE:Factory/prison-qt5/prison-qt5.changes    2020-03-19 
19:47:51.104101338 +0100
+++ /work/SRC/openSUSE:Factory/.prison-qt5.new.2738/prison-qt5.changes  
2020-04-15 20:05:30.826065073 +0200
@@ -1,0 +2,14 @@
+Sun Apr  5 19:45:58 UTC 2020 - Christophe Giboudeaux <[email protected]>
+
+- Update to 5.69.0
+  * New feature release
+  * For more details please see:
+  * https://kde.org/announcements/kde-frameworks-5.69.0
+- Changes since 5.68.0:
+  * Also expose the true minimum size to QML
+  * Add a new set of barcode size functions
+  * Simplify minimum size handling
+  * Move barcode image scaling logic to AbstractBarcode
+  * Add API to check whether a barcode is one- or two-dimensional
+
+-------------------------------------------------------------------

Old:
----
  prison-5.68.0.tar.xz
  prison-5.68.0.tar.xz.sig

New:
----
  prison-5.69.0.tar.xz
  prison-5.69.0.tar.xz.sig

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ prison-qt5.spec ++++++
--- /var/tmp/diff_new_pack.1EMuh8/_old  2020-04-15 20:05:31.430065484 +0200
+++ /var/tmp/diff_new_pack.1EMuh8/_new  2020-04-15 20:05:31.434065487 +0200
@@ -19,7 +19,7 @@
 %define sonum   5
 %define rname prison
 %define _libname KF5Prison
-%define _tar_path 5.68
+%define _tar_path 5.69
 # 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.68.0
+Version:        5.69.0
 Release:        0
 Summary:        Barcode abstraction layer library
 License:        MIT


++++++ prison-5.68.0.tar.xz -> prison-5.69.0.tar.xz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/prison-5.68.0/CMakeLists.txt 
new/prison-5.69.0/CMakeLists.txt
--- old/prison-5.68.0/CMakeLists.txt    2020-03-07 09:55:41.000000000 +0100
+++ new/prison-5.69.0/CMakeLists.txt    2020-04-05 00:38:55.000000000 +0200
@@ -1,11 +1,11 @@
 cmake_minimum_required(VERSION 3.5)
 
-set(KF5_VERSION "5.68.0") # handled by release scripts
+set(KF5_VERSION "5.69.0") # handled by release scripts
 project(prison VERSION ${KF5_VERSION})
 
 # ECM setup
 include(FeatureSummary)
-find_package(ECM 5.68.0 NO_MODULE)
+find_package(ECM 5.69.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}")
@@ -17,6 +17,7 @@
 
 include(GenerateExportHeader)
 include(ECMGenerateHeaders)
+include(ECMGenerateExportHeader)
 include(ECMGeneratePriFile)
 include(ECMAddQch)
 include(ECMAddTests)
@@ -24,6 +25,8 @@
 include(ECMSetupVersion)
 include(ECMQtDeclareLoggingCategory)
 
+set(EXCLUDE_DEPRECATED_BEFORE_AND_AT 0 CACHE STRING "Control the range of 
deprecated API excluded from the build [default=0].")
+
 option(BUILD_QCH "Build API documentation in QCH format (for e.g. Qt 
Assistant, Qt Creator & KDevelop)" OFF)
 add_feature_info(QCH ${BUILD_QCH} "API documentation in QCH format (for e.g. 
Qt Assistant, Qt Creator & KDevelop)")
 
Binary files old/prison-5.68.0/autotests/aztec/encoding/aztec-complete-big.png 
and new/prison-5.69.0/autotests/aztec/encoding/aztec-complete-big.png differ
Binary files 
old/prison-5.68.0/autotests/aztec/encoding/aztec-complete-compact1.png and 
new/prison-5.69.0/autotests/aztec/encoding/aztec-complete-compact1.png differ
Binary files 
old/prison-5.68.0/autotests/aztec/encoding/aztec-complete-compact3.png and 
new/prison-5.69.0/autotests/aztec/encoding/aztec-complete-compact3.png differ
Binary files 
old/prison-5.68.0/autotests/aztec/encoding/aztec-complete-compact4.png and 
new/prison-5.69.0/autotests/aztec/encoding/aztec-complete-compact4.png differ
Binary files 
old/prison-5.68.0/autotests/aztec/encoding/aztec-complete-full5.png and 
new/prison-5.69.0/autotests/aztec/encoding/aztec-complete-full5.png differ
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/prison-5.68.0/autotests/aztecbarcodetest.cpp 
new/prison-5.69.0/autotests/aztecbarcodetest.cpp
--- old/prison-5.68.0/autotests/aztecbarcodetest.cpp    2020-03-07 
09:55:41.000000000 +0100
+++ new/prison-5.69.0/autotests/aztecbarcodetest.cpp    2020-04-05 
00:38:55.000000000 +0200
@@ -7,10 +7,14 @@
 #include "../src/lib/aztecbarcode.h"
 #include "../src/lib/bitvector_p.h"
 
+#include <prison.h>
+
 #include <QImage>
 #include <QObject>
 #include <qtest.h>
 
+#include <memory>
+
 Q_DECLARE_METATYPE(Prison::BitVector)
 
 using namespace Prison;
@@ -365,13 +369,34 @@
 
         AztecBarcode code;
         code.setData(input);
-        const auto img = code.paintImage({200, 200});
+        const auto img = code.paintImage({});
         img.save(refName);
 
         QImage ref(QStringLiteral(":/encoding/") + refName);
         ref = ref.convertToFormat(img.format());
         QCOMPARE(img, ref);
     }
+
+    void testDimension()
+    {
+        std::unique_ptr<Prison::AbstractBarcode> 
barcode(Prison::createBarcode(Prison::Aztec));
+        QVERIFY(barcode);
+        QCOMPARE(barcode->dimensions(), 
Prison::AbstractBarcode::TwoDimensions);
+    }
+
+    void testSize()
+    {
+        std::unique_ptr<Prison::AbstractBarcode> 
barcode(Prison::createBarcode(Prison::Aztec));
+        QVERIFY(barcode);
+        QVERIFY(!barcode->minimumSize().isValid());
+        barcode->setData(QStringLiteral("UNIT TEST"));
+        QCOMPARE(barcode->minimumSize(), QSize(60, 60));
+        QCOMPARE(barcode->trueMinimumSize(), QSize(15, 15));
+        QCOMPARE(barcode->preferredSize(1), QSize(60, 60));
+        QCOMPARE(barcode->preferredSize(2), QSize(30, 30));
+        QCOMPARE(barcode->toImage(barcode->minimumSize()).size(), QSize(60, 
60));
+        QCOMPARE(barcode->toImage({1, 1}).isNull(), true);
+    }
 };
 
 QTEST_APPLESS_MAIN(AztecBarcodeTest)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/prison-5.68.0/autotests/code128barcodetest.cpp 
new/prison-5.69.0/autotests/code128barcodetest.cpp
--- old/prison-5.68.0/autotests/code128barcodetest.cpp  2020-03-07 
09:55:41.000000000 +0100
+++ new/prison-5.69.0/autotests/code128barcodetest.cpp  2020-04-05 
00:38:55.000000000 +0200
@@ -7,6 +7,8 @@
 #include "../src/lib/code128barcode.h"
 #include "../src/lib/bitvector_p.h"
 
+#include <prison.h>
+
 #include <QImage>
 #include <QObject>
 #include <qtest.h>
@@ -91,6 +93,27 @@
         }
         QCOMPARE(v, output);
     }
+
+    void testDimension()
+    {
+        std::unique_ptr<Prison::AbstractBarcode> 
barcode(Prison::createBarcode(Prison::Code128));
+        QVERIFY(barcode);
+        QCOMPARE(barcode->dimensions(), Prison::AbstractBarcode::OneDimension);
+    }
+
+    void testSize()
+    {
+        std::unique_ptr<Prison::AbstractBarcode> 
barcode(Prison::createBarcode(Prison::Code128));
+        QVERIFY(barcode);
+        QVERIFY(!barcode->minimumSize().isValid());
+        barcode->setData(QStringLiteral("UNIT TEST"));
+        QCOMPARE(barcode->minimumSize(), QSize(154, 10));
+        QCOMPARE(barcode->trueMinimumSize(), QSize(154, 1));
+        QCOMPARE(barcode->preferredSize(1), QSize(308, 50));
+        QCOMPARE(barcode->preferredSize(2), QSize(154, 50));
+        QCOMPARE(barcode->toImage(barcode->minimumSize()).size(), QSize(154, 
10));
+        QCOMPARE(barcode->toImage({1, 1}).isNull(), true);
+    }
 };
 
 QTEST_APPLESS_MAIN(Code128BarcodeTest)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/prison-5.68.0/src/lib/CMakeLists.txt 
new/prison-5.69.0/src/lib/CMakeLists.txt
--- old/prison-5.68.0/src/lib/CMakeLists.txt    2020-03-07 09:55:41.000000000 
+0100
+++ new/prison-5.69.0/src/lib/CMakeLists.txt    2020-04-05 00:38:55.000000000 
+0200
@@ -28,8 +28,14 @@
 )
 add_library(KF5Prison ${prison_SRCS})
 
-generate_export_header(KF5Prison BASE_NAME Prison)
-
+ecm_generate_export_header(KF5Prison
+    BASE_NAME Prison
+    GROUP_BASE_NAME KF
+    VERSION ${KF5_VERSION}
+    DEPRECATED_BASE_VERSION 0
+    DEPRECATION_VERSIONS 5.69
+    EXCLUDE_DEPRECATED_BEFORE_AND_AT ${EXCLUDE_DEPRECATED_BEFORE_AND_AT}
+)
 add_library(KF5::Prison ALIAS KF5Prison)
 
 target_include_directories(KF5Prison INTERFACE 
"$<INSTALL_INTERFACE:${KDE_INSTALL_INCLUDEDIR_KF5}/prison/>")
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/prison-5.68.0/src/lib/abstractbarcode.cpp 
new/prison-5.69.0/src/lib/abstractbarcode.cpp
--- old/prison-5.68.0/src/lib/abstractbarcode.cpp       2020-03-07 
09:55:41.000000000 +0100
+++ new/prison-5.69.0/src/lib/abstractbarcode.cpp       2020-04-05 
00:38:55.000000000 +0200
@@ -5,6 +5,8 @@
 */
 
 #include "abstractbarcode.h"
+
+#include <QDebug>
 #include <QImage>
 #include <QPainter>
 #include <QColor>
@@ -16,64 +18,117 @@
 class AbstractBarcode::Private {
   public:
     QString m_data;
-    QSizeF m_size;
     QImage m_cache;
-    QColor m_foreground;
-    QColor m_background;
-    QSizeF m_minimum_size;
+    QColor m_foreground = Qt::black;
+    QColor m_background = Qt::white;
+    AbstractBarcode::Dimensions m_dimension = AbstractBarcode::NoDimensions;
     AbstractBarcode* q;
-    bool sizeTooSmall(const QSizeF& size) {
-        if(m_minimum_size.width() > size.width()) {
-            return true;
-        } else if(m_minimum_size.height() > size.height()) {
-            return true;
+
+    bool sizeTooSmall(const QSizeF& size) const
+    {
+        return m_cache.width() > size.width() || m_cache.height() > 
size.height();
+    }
+
+    void recompute()
+    {
+        if (m_cache.isNull() && !m_data.isEmpty()) {
+            m_cache = q->paintImage({});
         }
-        return false;
     }
-    Private(AbstractBarcode* barcode) : m_foreground(Qt::black), 
m_background(Qt::white), m_minimum_size(10,10), q(barcode) { }
+
+    Private(AbstractBarcode* barcode) : q(barcode) { }
 };
 /**
  * @endcond
  */
 
+#if PRISON_BUILD_DEPRECATED_SINCE(5, 69)
 AbstractBarcode::AbstractBarcode() : d(new AbstractBarcode::Private(this)) {
 
 }
+#endif
+
+AbstractBarcode::AbstractBarcode(AbstractBarcode::Dimensions dim) :
+    d(new AbstractBarcode::Private(this))
+{
+    d->m_dimension = dim;
+}
 
 QString AbstractBarcode::data() const {
   return d->m_data;
 }
 
 
-QImage AbstractBarcode::toImage(const QSizeF& size) {
-    if(d->sizeTooSmall(size)) {
-        d->m_cache = QImage();
+QImage AbstractBarcode::toImage(const QSizeF& size)
+{
+    d->recompute();
+    if (d->m_cache.isNull() || d->sizeTooSmall(size)) {
         return QImage();
     }
-    if(d->m_cache.isNull() || size != d->m_size) {
-        d->m_size = size;
-        d->m_cache = paintImage(size);
-        return d->m_cache;
+
+    // scale to the requested size, using only full integer factors to keep 
the code readable
+    int scaleX = std::max<int>(1, size.width() / d->m_cache.width());
+    int scaleY = std::max<int>(1, size.height() / d->m_cache.height());
+    if (dimensions() == TwoDimensions) {
+        scaleX = scaleY = std::min(scaleX, scaleY);
     }
-    return d->m_cache;
+
+    QImage out(d->m_cache.width() * scaleX, d->m_cache.height() * scaleY, 
d->m_cache.format());
+    QPainter p(&out);
+    p.setRenderHint(QPainter::SmoothPixmapTransform, false);
+    p.drawImage(out.rect(), d->m_cache, d->m_cache.rect());
+    return out;
 }
 
 void AbstractBarcode::setData(const QString& data) {
   d->m_data=data;
   d->m_cache=QImage();
-  d->m_size=QSize();
-  d->m_minimum_size=QSizeF(10,10);
 }
 
-QSizeF AbstractBarcode::minimumSize() const {
-  return d->m_minimum_size;
+QSizeF AbstractBarcode::minimumSize() const
+{
+    d->recompute();
+
+    // ### backward compatibility: this is applying minimum size behavior that 
the specific
+    // implementations were doing prior to 5.69. This is eventually to be 
dropped.
+    if (d->m_cache.isNull()) {
+        return {};
+    }
+    switch (d->m_dimension) {
+        case NoDimensions:
+            return {};
+        case OneDimension:
+            return QSizeF(d->m_cache.width(), std::max(d->m_cache.height(), 
10));
+        case TwoDimensions:
+            return d->m_cache.size() * 4;
+    }
+
+    return d->m_cache.size();
 }
 
-void AbstractBarcode::setMinimumSize(const QSizeF& minimumSize) {
-    d->m_minimum_size = minimumSize;
-    if(minimumSize.width() > d->m_size.width() || minimumSize.height() > 
d->m_size.height()) {
-        d->m_cache = QImage();
+QSizeF AbstractBarcode::trueMinimumSize() const
+{
+    d->recompute();
+    return d->m_cache.size();
+}
+
+QSizeF AbstractBarcode::preferredSize(qreal devicePixelRatio) const
+{
+    d->recompute();
+    switch (d->m_dimension) {
+        case NoDimensions:
+            return {};
+        case OneDimension:
+            return QSizeF(d->m_cache.width() * (devicePixelRatio < 2 ? 2 : 1), 
std::max(d->m_cache.height(), 50));
+        case TwoDimensions:
+            return d->m_cache.size() * (devicePixelRatio < 2 ? 4 : 2);
     }
+    return {};
+}
+
+void AbstractBarcode::setMinimumSize(const QSizeF& minimumSize)
+{
+    Q_UNUSED(minimumSize);
 }
 
 const QColor& AbstractBarcode::backgroundColor() const {
@@ -98,6 +153,11 @@
     }
 }
 
+AbstractBarcode::Dimensions AbstractBarcode::dimensions() const
+{
+    return d->m_dimension;
+}
+
 AbstractBarcode::~AbstractBarcode() {
     delete d;
 }
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/prison-5.68.0/src/lib/abstractbarcode.h 
new/prison-5.69.0/src/lib/abstractbarcode.h
--- old/prison-5.68.0/src/lib/abstractbarcode.h 2020-03-07 09:55:41.000000000 
+0100
+++ new/prison-5.69.0/src/lib/abstractbarcode.h 2020-04-05 00:38:55.000000000 
+0200
@@ -29,10 +29,15 @@
    */
 class PRISON_EXPORT AbstractBarcode {
   public:
+#if PRISON_ENABLE_DEPRECATED_SINCE(5, 69)
     /**
      * creates a barcode generator without any data
+     * @deprecated since 5.69 Use Prison::createBarcode instead.
      */
+    PRISON_DEPRECATED_VERSION(5, 69, "Use Prison::createBarcode()")
     AbstractBarcode();
+#endif
+
     virtual ~AbstractBarcode();
     /**
      * @return the QString encoded in this barcode.
@@ -50,17 +55,40 @@
      * Creates a image with a barcode on
      * @return QImage with a barcode on, trying to match the requested \param 
size
      *
-     * The image function is cached and painted on demand.
-     *
-     * if one of the dimensions of @param size is smaller than the matching 
dimension in \ref minimumSize,
+     * If one of the dimensions of @param size is smaller than the matching 
dimension in \ref minimumSize,
      * a null QImage will be returned
      */
     QImage toImage(const QSizeF& size) ;
     /**
-     * Note! minimalSize() doesn't work as expected if this is not painting on 
something.
+     * The minimal size of this barcode.
+     * @note This isn't the absolute minimum, but closer to the result of 
preferredSize(1).
      * @return the minimal size for this barcode.
+     * @deprecated since 5.69 Prefer preferredSize() or trueMinimumSize().
      */
     QSizeF minimumSize() const;
+
+    /**
+     * The minimal amount of pixels needed to represent this barcode without 
loss of information.
+     * That is, the size of the barcode image if each line or dot is just one 
pixel wide.
+     * On normal screens that is not enough for barcode scanners to reliably 
detect the barcode
+     * though.
+     * @see preferredSize
+     * @since 5.69
+     */
+    QSizeF trueMinimumSize() const; // TODO KF6: rename to minimumSize
+
+    /**
+     * The recommended size for this barcode when shown on a screen.
+     * This is typically significantly larger than trueMinimumSize() so that
+     * barcode scanners tend to reliably detect the code. As this depends
+     * on the physical resolution of the output, you have to pass the device
+     * pixel ration of the output screen here.
+     * @param devicePixelRatio The device pixel ratio of the screen this is 
shown on.
+     * @see trueMinimumSize
+     * @since 5.69
+     */
+    QSizeF preferredSize(qreal devicePixelRatio) const;
+
     /**
      * @return the foreground color (by default black) to be used for the 
barcode.
      */
@@ -80,18 +108,42 @@
      */
     void setBackgroundColor(const QColor& backgroundcolor);
 
+    /** Dimensions of the barcode.
+     *  @since 5.69
+     */
+    enum Dimensions : uint8_t {
+        NoDimensions, ///< Null barcode.
+        OneDimension, ///< One-dimensional barcode.
+        TwoDimensions ///< 2D matrix code.
+    };
+
+    /** Returns the amount of dimensions of the barcode.
+     *  @since 5.69
+     */
+    Dimensions dimensions() const;
+
   protected:
+    ///@cond internal
+    explicit AbstractBarcode(Dimensions dim);
+    ///@endcond
+
+#if PRISON_ENABLE_DEPRECATED_SINCE(5, 69)
     /**
      * Sets the minimum size for this barcode.
      * Some barcodes have minimum sizes for when they are readable and such
      * @param minimumSize QSizeF holding the minimum size for this barcode
+     * @deprecated since 5.69, function is a no-op, no need to call this 
anymore.
      */
+    PRISON_DEPRECATED_VERSION(5, 69, "no need to call this anymore")
     void setMinimumSize(const QSizeF& minimumSize);
+#endif
+
     /**
      * Doing the actual painting of the image
-     * @param size requested size of the miage
+     * @param size unused - will be removed in KF6
      * @return image with barcode, or null image
      */
+    // TODO KF6: remove the size argument
     virtual QImage paintImage(const QSizeF& size) = 0;
   private:
    class Private;
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/prison-5.68.0/src/lib/aztecbarcode.cpp 
new/prison-5.69.0/src/lib/aztecbarcode.cpp
--- old/prison-5.68.0/src/lib/aztecbarcode.cpp  2020-03-07 09:55:41.000000000 
+0100
+++ new/prison-5.69.0/src/lib/aztecbarcode.cpp  2020-04-05 00:38:55.000000000 
+0200
@@ -33,7 +33,7 @@
     CompactLayerCount = 4
 };
 
-AztecBarcode::AztecBarcode() = default;
+AztecBarcode::AztecBarcode() : AbstractBarcode(AbstractBarcode::TwoDimensions) 
{}
 AztecBarcode::~AztecBarcode() = default;
 
 // encoding properties depending on layer count
@@ -63,6 +63,7 @@
 
 QImage AztecBarcode::paintImage(const QSizeF& size)
 {
+    Q_UNUSED(size);
     const auto inputData = aztecEncode(data().toLatin1());
 
     int layerCount = 0;
@@ -142,14 +143,14 @@
         paintCompactGrid(&img);
         paintCompactData(&img, encodedData, layerCount);
         paintCompactModeMessage(&img, modeMsg);
-        return cropAndScaleCompact(&img, layerCount, std::min(size.width(), 
size.height()));
+        return cropAndScaleCompact(&img, layerCount);
     } else {
         QImage img(FullMaxSize, FullMaxSize, QImage::Format_RGB32);
         img.fill(backgroundColor());
         paintFullGrid(&img);
         paintFullData(&img, encodedData, layerCount);
         paintFullModeMessage(&img, modeMsg);
-        return cropAndScaleFull(&img, layerCount, std::min(size.width(), 
size.height()));
+        return cropAndScaleFull(&img, layerCount);
     }
 }
 
@@ -679,14 +680,12 @@
     }
 }
 
-QImage AztecBarcode::cropAndScaleFull(QImage *img, int layerCount, int size)
+QImage AztecBarcode::cropAndScaleFull(QImage *img, int layerCount)
 {
     const auto offset = aztecFullLayerOffset[layerCount - 1];
     const auto minSize = FullMaxSize - 2 * offset;
-    setMinimumSize(QSizeF(minSize, minSize) * 4); // *4 taken from what QR does
-    const int scale = std::max(1, size / minSize);
 
-    QImage out(minSize * scale, minSize * scale, img->format());
+    QImage out(minSize, minSize, img->format());
     QPainter p(&out);
     p.setRenderHint(QPainter::SmoothPixmapTransform, false);
     const auto srcRect = img->rect().adjusted(offset, offset, -offset, 
-offset);
@@ -769,14 +768,12 @@
     }
 }
 
-QImage AztecBarcode::cropAndScaleCompact(QImage *img, int layerCount, int size)
+QImage AztecBarcode::cropAndScaleCompact(QImage *img, int layerCount)
 {
     const auto offset = aztecCompactLayerOffset[layerCount - 1];
     const auto minSize = CompactMaxSize - 2 * offset;
-    setMinimumSize(QSizeF(minSize, minSize) * 4); // *4 taken from what QR does
-    const int scale = std::max(1, size / minSize);
 
-    QImage out(minSize * scale, minSize * scale, img->format());
+    QImage out(minSize, minSize, img->format());
     QPainter p(&out);
     p.setRenderHint(QPainter::SmoothPixmapTransform, false);
     const auto srcRect = img->rect().adjusted(offset, offset, -offset, 
-offset);
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/prison-5.68.0/src/lib/aztecbarcode.h 
new/prison-5.69.0/src/lib/aztecbarcode.h
--- old/prison-5.68.0/src/lib/aztecbarcode.h    2020-03-07 09:55:41.000000000 
+0100
+++ new/prison-5.69.0/src/lib/aztecbarcode.h    2020-04-05 00:38:55.000000000 
+0200
@@ -34,12 +34,12 @@
     void paintFullGrid(QImage *img) const;
     void paintFullData(QImage *img, const BitVector &data, int layerCount) 
const;
     void paintFullModeMessage(QImage *img, const BitVector &modeData) const;
-    QImage cropAndScaleFull(QImage *img, int layerCount, int size);
+    QImage cropAndScaleFull(QImage *img, int layerCount);
 
     void paintCompactGrid(QImage *img) const;
     void paintCompactData(QImage *img, const BitVector &data, int layerCount) 
const;
     void paintCompactModeMessage(QImage *img, const BitVector &modeData) const;
-    QImage cropAndScaleCompact(QImage *img, int layerCount, int size);
+    QImage cropAndScaleCompact(QImage *img, int layerCount);
 };
 
 }
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/prison-5.68.0/src/lib/code128barcode.cpp 
new/prison-5.69.0/src/lib/code128barcode.cpp
--- old/prison-5.68.0/src/lib/code128barcode.cpp        2020-03-07 
09:55:41.000000000 +0100
+++ new/prison-5.69.0/src/lib/code128barcode.cpp        2020-04-05 
00:38:55.000000000 +0200
@@ -38,28 +38,23 @@
     LatchC = 99
 };
 
-Code128Barcode::Code128Barcode() = default;
+Code128Barcode::Code128Barcode() : 
AbstractBarcode(AbstractBarcode::OneDimension) {}
 Code128Barcode::~Code128Barcode() = default;
 
 QImage Code128Barcode::paintImage(const QSizeF& size)
 {
-    if (size.height() < 1)
-        return {};
+    Q_UNUSED(size);
 
     const auto bits = encode(data().toLatin1());
     const auto width = bits.size() + 2 * QuietZone;
-    setMinimumSize(QSizeF(width, 10));
 
-    const auto moduleSize = size.width() / width;
-    if (moduleSize < 1) // too small for this
-        return {};
-
-    QImage img(moduleSize * width, size.height(), QImage::Format_ARGB32);
+    QImage img(width, 1, QImage::Format_ARGB32);
     img.fill(backgroundColor());
     QPainter p(&img);
     for (int i = 0; i < bits.size(); ++i) {
-        if (bits.at(i))
-            p.fillRect(QRectF((QuietZone + i) * moduleSize, 0, moduleSize, 
img.height()), foregroundColor());
+        if (bits.at(i)) {
+            img.setPixel(QuietZone + i, 0, foregroundColor().rgb());
+        }
     }
 
     return img;
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/prison-5.68.0/src/lib/code39barcode.cpp 
new/prison-5.69.0/src/lib/code39barcode.cpp
--- old/prison-5.68.0/src/lib/code39barcode.cpp 2020-03-07 09:55:41.000000000 
+0100
+++ new/prison-5.69.0/src/lib/code39barcode.cpp 2020-04-05 00:38:55.000000000 
+0200
@@ -69,11 +69,12 @@
     }
 }
 
-Code39Barcode::Code39Barcode() = default;
+Code39Barcode::Code39Barcode() : 
AbstractBarcode(AbstractBarcode::OneDimension) {}
 Code39Barcode::~Code39Barcode() = default;
 
-QImage Code39Barcode::paintImage(const QSizeF& size) {
-  if(size.height() == 0.0) return QImage();
+QImage Code39Barcode::paintImage(const QSizeF& size)
+{
+  Q_UNUSED(size);
   QList<bool> barcode;
   // convert text into sequences of wide/narrow bars
   {
@@ -103,21 +104,12 @@
      *) wide * largeWidth + narrow * smallWidth <= size.width()
         - the barcode has to fit within the given size
    */
-  const int w = size.width();
   const int wide = barcode.count(true);
   const int narrow = barcode.count(false);
-  // maximize wide bar width
-  int largeWidth = 2*w / (2*wide + narrow);
-  // then maximize narrow bar width
-  int smallWidth = (w - largeWidth*wide) / narrow;
-  // if the requested size was too small return a null image
-  setMinimumSize(QSize(2* wide + narrow, 10));
-  if(largeWidth<2) {
-      return QImage();
-  }
-  if(smallWidth<1) {
-        return QImage();
-  }
+  // wide bar width
+  const int largeWidth = 2;
+  // narrow bar width
+  const int smallWidth = 1;
   Q_ASSERT(largeWidth > smallWidth);
 
   // one line of the result image
@@ -132,11 +124,8 @@
   }
 
   // build the complete barcode
-  QImage ret(line.size(), size.height(), QImage::Format_ARGB32);
-  // just repeat the line to make the image
-  for(int y = 0 ; y < ret.height() ; y++) {
-    memcpy(ret.scanLine(y), line.data(), line.size() * sizeof(QRgb));
-  }
+  QImage ret(line.size(), 1, QImage::Format_ARGB32);
+  memcpy(ret.scanLine(0), line.data(), line.size() * sizeof(QRgb));
   return ret;
 }
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/prison-5.68.0/src/lib/code93barcode.cpp 
new/prison-5.69.0/src/lib/code93barcode.cpp
--- old/prison-5.68.0/src/lib/code93barcode.cpp 2020-03-07 09:55:41.000000000 
+0100
+++ new/prison-5.69.0/src/lib/code93barcode.cpp 2020-04-05 00:38:55.000000000 
+0200
@@ -225,13 +225,11 @@
     return check % 47;
 }
 
-Code93Barcode::Code93Barcode() = default;
+Code93Barcode::Code93Barcode() : 
AbstractBarcode(AbstractBarcode::OneDimension) {}
 Code93Barcode::~Code93Barcode() = default;
 
 QImage Code93Barcode::paintImage(const QSizeF& size) {
-  if(size.height() == 0.0) {
-    return QImage();
-  }
+  Q_UNUSED(size);
   QList<bool> barcode;
   // convert text into sequences of fg/bg bars
   {
@@ -260,12 +258,7 @@
     barcode += true;
   }
 
-  // try to fill the requested size
-  const int barWidth = int(size.width() / barcode.size());
-  setMinimumSize(QSize(barcode.size(), 10));
-  if(barWidth < 1 ) { // can't go below 1 pixel
-      return QImage();
-  }
+  const int barWidth = 1;
 
   // build one line of the result image
   QVector<QRgb> line;
@@ -278,10 +271,7 @@
   }
 
   // build the complete barcode
-  QImage ret(line.size(), size.height(), QImage::Format_ARGB32);
-  // just repeat the line to make the image
-  for(int y = 0 ; y < ret.height() ; y++) {
-    memcpy(ret.scanLine(y), line.data(), line.size() * sizeof(QRgb));
-  }
+  QImage ret(line.size(), 1, QImage::Format_ARGB32);
+  memcpy(ret.scanLine(0), line.data(), line.size() * sizeof(QRgb));
   return ret;
 }
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/prison-5.68.0/src/lib/datamatrixbarcode.cpp 
new/prison-5.69.0/src/lib/datamatrixbarcode.cpp
--- old/prison-5.68.0/src/lib/datamatrixbarcode.cpp     2020-03-07 
09:55:41.000000000 +0100
+++ new/prison-5.69.0/src/lib/datamatrixbarcode.cpp     2020-04-05 
00:38:55.000000000 +0200
@@ -9,19 +9,20 @@
 #include <QColor>
 using namespace Prison;
 
-DataMatrixBarcode::DataMatrixBarcode() = default;
+DataMatrixBarcode::DataMatrixBarcode() : 
AbstractBarcode(AbstractBarcode::TwoDimensions) {}
 DataMatrixBarcode::~DataMatrixBarcode() = default;
 
-QImage DataMatrixBarcode::paintImage(const QSizeF& size) {
-  const int width = qRound(qMin(size.width(),size.height()));
-  if(data().size()==0 || width == 0 || data().size() > 1200) {
+QImage DataMatrixBarcode::paintImage(const QSizeF& size)
+{
+  Q_UNUSED(size);
+  if (data().size() > 1200) {
     return QImage();
   }
 
   DmtxEncode * enc = dmtxEncodeCreate();
   dmtxEncodeSetProp( enc, DmtxPropPixelPacking, DmtxPack32bppRGBX );
-  dmtxEncodeSetProp( enc, DmtxPropWidth, width );
-  dmtxEncodeSetProp( enc, DmtxPropHeight, width );
+  dmtxEncodeSetProp( enc, DmtxPropModuleSize, 1);
+  dmtxEncodeSetProp( enc, DmtxPropMarginSize, 2);
 
   QByteArray trimmedData(data().trimmed().toUtf8());
   DmtxPassFail result =  dmtxEncodeDataMatrix(enc, trimmedData.length(),
@@ -32,7 +33,6 @@
   }
   Q_ASSERT(enc->image->width == enc->image->height);
 
-  setMinimumSize(QSizeF(enc->image->width,enc->image->height));
   QImage ret;
 
   if(foregroundColor()==Qt::black && backgroundColor() == Qt::white) {
@@ -72,9 +72,6 @@
       delete[] img;
     }
   }
-  if(!ret.isNull() && ret.width() < width) {
-    ret = ret.scaled(width,width);
-  }
   dmtxEncodeDestroy(&enc);
   return ret;
 }
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/prison-5.68.0/src/lib/qrcodebarcode.cpp 
new/prison-5.69.0/src/lib/qrcodebarcode.cpp
--- old/prison-5.68.0/src/lib/qrcodebarcode.cpp 2020-03-07 09:55:41.000000000 
+0100
+++ new/prison-5.69.0/src/lib/qrcodebarcode.cpp 2020-04-05 00:38:55.000000000 
+0200
@@ -10,14 +10,11 @@
 
 using namespace Prison;
 
-QRCodeBarcode::QRCodeBarcode() = default;
+QRCodeBarcode::QRCodeBarcode() : 
AbstractBarcode(AbstractBarcode::TwoDimensions) {}
 QRCodeBarcode::~QRCodeBarcode() = default;
 
 QImage QRCodeBarcode::paintImage(const QSizeF& size) {
-  const int width = qRound(qMin(size.width(),size.height()));
-  if(data().size()==0 || width==0) {
-    return QImage();
-  }
+  Q_UNUSED(size);
   const QByteArray trimmedData(data().trimmed().toUtf8());
   QRcode* code = QRcode_encodeString8bit(trimmedData.constData(), 0, 
QR_ECLEVEL_Q);
   if(!code) {
@@ -64,10 +61,9 @@
       }
     }
   }
-  QImage 
tmp(img,code->width+2*margin,code->width+2*margin,QImage::Format_ARGB32);
-  setMinimumSize(QSizeF(tmp.width()*4,tmp.height()*4));
-  QImage ret = 
tmp.convertToFormat(QImage::Format_ARGB32).scaled(qMax(tmp.width()*4,width),qMax(tmp.height()*4,width));
 //4 is determined by trial and error.
+
+  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 ret;
+  return result;
 }
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/prison-5.68.0/src/quick/barcodequickitem.cpp 
new/prison-5.69.0/src/quick/barcodequickitem.cpp
--- old/prison-5.68.0/src/quick/barcodequickitem.cpp    2020-03-07 
09:55:41.000000000 +0100
+++ new/prison-5.69.0/src/quick/barcodequickitem.cpp    2020-04-05 
00:38:55.000000000 +0200
@@ -9,7 +9,9 @@
 #include <prison/prison.h>
 
 #include <QDebug>
+#include <QGuiApplication>
 #include <QPainter>
+#include <QScreen>
 
 using namespace Prison;
 
@@ -77,6 +79,11 @@
     updateBarcode();
 }
 
+BarcodeQuickItem::Dimensions Prison::BarcodeQuickItem::dimensions() const
+{
+    return m_barcode ? 
static_cast<BarcodeQuickItem::Dimensions>(m_barcode->dimensions()) : 
NoDimensions;
+}
+
 void BarcodeQuickItem::paint(QPainter* painter)
 {
     if (!m_barcode)
@@ -97,6 +104,16 @@
     updateBarcode();
 }
 
+qreal BarcodeQuickItem::minimumHeight() const
+{
+    return m_barcode ? m_barcode->trueMinimumSize().height() : 0.0;
+}
+
+qreal BarcodeQuickItem::minimumWidth() const
+{
+    return m_barcode ? m_barcode->trueMinimumSize().width() : 0.0;
+}
+
 void BarcodeQuickItem::updateBarcode()
 {
     if (!isComponentComplete())
@@ -105,6 +122,7 @@
     if (m_type == Prison::Null || m_content.isEmpty()) {
         m_barcode.reset();
         update();
+        emit dimensionsChanged();
         return;
     }
 
@@ -114,10 +132,10 @@
         m_barcode->setData(m_content);
         m_barcode->setForegroundColor(m_fgColor);
         m_barcode->setBackgroundColor(m_bgColor);
-        // minimumSize() is only providing valid results after the first call 
to toImage()...
-        m_barcode->toImage(m_barcode->minimumSize());
-        setImplicitSize(m_barcode->minimumSize().width(), 
m_barcode->minimumSize().height());
+        const auto size = 
m_barcode->preferredSize(QGuiApplication::primaryScreen()->devicePixelRatio());
+        setImplicitSize(size.width(), size.height());
     }
 
     update();
+    emit dimensionsChanged();
 }
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/prison-5.68.0/src/quick/barcodequickitem.h 
new/prison-5.69.0/src/quick/barcodequickitem.h
--- old/prison-5.68.0/src/quick/barcodequickitem.h      2020-03-07 
09:55:41.000000000 +0100
+++ new/prison-5.69.0/src/quick/barcodequickitem.h      2020-04-05 
00:38:55.000000000 +0200
@@ -25,6 +25,17 @@
     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)
+    Q_PROPERTY(Dimensions dimensions READ dimensions NOTIFY dimensionsChanged)
+    /**
+     * @see Prison::AbstractBarcode::trueMinimumSize()
+     * @since 5.69
+     */
+    Q_PROPERTY(qreal minimumHeight READ minimumHeight NOTIFY 
implicitHeightChanged)
+    /**
+     * @see Prison::AbstractBarcode::trueMinimumSize()
+     * @since 5.69
+     */
+    Q_PROPERTY(qreal minimumWidth READ minimumWidth NOTIFY 
implicitWidthChanged)
 
 public:
     enum BarcodeType {
@@ -51,14 +62,26 @@
     QColor backgroundColor() const;
     void setBackgroundColor(const QColor &color);
 
+    enum Dimensions {
+        NoDimensions,
+        OneDimension,
+        TwoDimensions
+    };
+    Q_ENUM(Dimensions);
+    Dimensions dimensions() const;
+
     void paint(QPainter *painter) override;
     void componentComplete() override;
 
+    qreal minimumHeight() const;
+    qreal minimumWidth() const;
+
 Q_SIGNALS:
     void contentChanged();
     void barcodeTypeChanged();
     void foregroundColorChanged();
     void backgroundColorChanged();
+    void dimensionsChanged();
 
 private:
     void updateBarcode();
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/prison-5.68.0/tests/barcode.qml 
new/prison-5.69.0/tests/barcode.qml
--- old/prison-5.68.0/tests/barcode.qml 2020-03-07 09:55:41.000000000 +0100
+++ new/prison-5.69.0/tests/barcode.qml 2020-04-05 00:38:55.000000000 +0200
@@ -30,6 +30,7 @@
         }
 
         Prison.Barcode {
+            id: barcode
             Layout.fillWidth: true
             Layout.fillHeight: true
             content: contentEdit.text
@@ -37,5 +38,17 @@
 //             foregroundColor: "red"
 //             backgroundColor: "green"
         }
+
+        RowLayout {
+            Label {
+                text: "1D: " + (barcode.dimensions == 
Prison.Barcode.OneDimension)
+            }
+            Label {
+                text: "2D: " + (barcode.dimensions == 2)
+            }
+            Label {
+                text: "Min size: " + barcode.minimumWidth + "x" + 
barcode.minimumHeight
+            }
+        }
     }
 }


Reply via email to