GUI: remove refs to AspectRatioMode and mark as legacy (#243)

This commit is contained in:
gitlost 2021-09-05 21:52:00 +01:00
parent c4b7921819
commit 492d9a41c5
5 changed files with 33 additions and 36 deletions

View File

@ -27,8 +27,8 @@
#include <stdio.h>
#include <math.h>
#include <QFontMetrics>
/* the following include was necessary to compile with QT 5.18 on Windows */
/* QT 8.7 did not require it. */
/* the following include was necessary to compile with Qt 5.15 on Windows */
/* Qt 5.7 did not require it. */
#include <QPainterPath>
namespace Zint {
@ -129,7 +129,8 @@ namespace Zint {
void QZint::encode() {
resetSymbol();
QByteArray bstr = m_text.toUtf8();
m_error = ZBarcode_Encode_and_Buffer_Vector(m_zintSymbol, (unsigned char *) bstr.data(), bstr.length(), 0); /* Note do our own rotation */
/* Note do our own rotation */
m_error = ZBarcode_Encode_and_Buffer_Vector(m_zintSymbol, (unsigned char *) bstr.data(), bstr.length(), 0);
m_lastError = m_zintSymbol->errtxt;
if (m_error < ZINT_ERROR) {
@ -448,14 +449,12 @@ namespace Zint {
}
}
void QZint::render(QPainter & painter, const QRectF & paintRect, AspectRatioMode mode) {
void QZint::render(QPainter& painter, const QRectF& paintRect, AspectRatioMode /*mode*/) {
struct zint_vector_rect *rect;
struct zint_vector_hexagon *hex;
struct zint_vector_circle *circle;
struct zint_vector_string *string;
(void)mode; /* Not currently used */
encode();
painter.save();
@ -507,9 +506,6 @@ namespace Zint {
QBrush bgBrush(m_bgColor);
painter.fillRect(QRectF(0, 0, gwidth, gheight), bgBrush);
//Red square for diagnostics
//painter.fillRect(QRect(0, 0, m_zintSymbol->vector->width, m_zintSymbol->vector->height), QBrush(QColor(255,0,0,255)));
// Plot rectangles
rect = m_zintSymbol->vector->rectangles;
if (rect) {
@ -588,7 +584,8 @@ namespace Zint {
QPen p;
p.setColor(m_fgColor);
painter.setPen(p);
bool bold = (m_zintSymbol->output_options & BOLD_TEXT) && (!isExtendable() || (m_zintSymbol->output_options & SMALL_TEXT));
bool bold = (m_zintSymbol->output_options & BOLD_TEXT)
&& (!isExtendable() || (m_zintSymbol->output_options & SMALL_TEXT));
QFont font(fontStyle, -1 /*pointSize*/, bold ? QFont::Bold : -1);
while (string) {
font.setPixelSize(string->fsize);

View File

@ -16,8 +16,9 @@
***************************************************************************/
/* vim: set ts=4 sw=4 et : */
#ifndef BARCODERENDER_H
#define BARCODERENDER_H
#ifndef QZINT_H
#define QZINT_H
#include <QColor>
#include <QPainter>
#include "zint.h"
@ -30,13 +31,13 @@ class QZint : public QObject
Q_OBJECT
public:
enum AspectRatioMode{IgnoreAspectRatio=0, KeepAspectRatio=1, CenterBarCode=2};
enum AspectRatioMode{ IgnoreAspectRatio = 0, KeepAspectRatio = 1, CenterBarCode = 2 }; /* Legacy - not used */
public:
QZint();
~QZint();
int symbol() const;
int symbol() const; /* Symbology */
void setSymbol(int symbol);
int inputMode() const;
@ -107,7 +108,7 @@ public:
void setDebug(bool debug);
/* Legacy */
/* Legacy property getters/setters */
void setWidth(int width); /* option_1 */
int width() const;
void setSecurityLevel(int securityLevel); /* option_2 */
@ -116,6 +117,7 @@ public:
int pdf417CodeWords() const;
void setHideText(bool hide); /* setShowText(!hide) */
/* Test capabilities - ZBarcode_Cap() */
bool hasHRT(int symbology = 0) const;
bool isExtendable(int symbology = 0) const;
bool supportsECI(int symbology = 0) const;
@ -133,6 +135,7 @@ public:
bool save_to_file(QString filename);
/* Note: legacy argument `mode` is not used */
void render(QPainter& painter, const QRectF& paintRect, AspectRatioMode mode = IgnoreAspectRatio);
int getVersion() const;
@ -179,6 +182,7 @@ private:
bool m_reader_init;
bool m_debug;
};
}
#endif
}
#endif /* QZINT_H */

View File

@ -1,6 +1,7 @@
/***************************************************************************
* Copyright (C) 2008 by BogDan Vatra *
* bogdan@licentia.eu *
* Copyright (C) 2009-2021 by Robin Stuart <rstuart114@gmail.com> *
* *
* This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
@ -23,7 +24,6 @@ BarcodeItem::BarcodeItem()
{
w = 693;
h = 378; // Default widget size when created
ar = Zint::QZint::AspectRatioMode::IgnoreAspectRatio;
}
BarcodeItem::~BarcodeItem()
@ -42,7 +42,5 @@ QRectF BarcodeItem::boundingRect() const
void BarcodeItem::paint(QPainter *painter, const QStyleOptionGraphicsItem * /*option*/, QWidget * /*widget*/)
{
bc.render(*painter, boundingRect(), ar);
bc.render(*painter, boundingRect());
}

View File

@ -1,6 +1,7 @@
/***************************************************************************
* Copyright (C) 2008 by BogDan Vatra *
* bogdan@licentia.eu *
* Copyright (C) 2009-2021 by Robin Stuart <rstuart114@gmail.com> *
* *
* This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
@ -39,8 +40,6 @@ private:
public:
mutable Zint::QZint bc;
Zint::QZint::AspectRatioMode ar;
};
#endif

View File

@ -1171,7 +1171,6 @@ void MainWindow::update_preview()
int item_val;
QCheckBox *checkBox;
//m_bc.ar=(Zint::QZint::AspectRatioMode)1;
if (!grpComposite->isHidden() && chkComposite->isChecked()) {
m_bc.bc.setPrimaryMessage(txtData->text());
m_bc.bc.setText(txtComposite->toPlainText());