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) {
@ -162,7 +163,7 @@ namespace Zint {
return m_text;
}
void QZint::setText(const QString & text) {
void QZint::setText(const QString& text) {
m_text = text;
}
@ -170,7 +171,7 @@ namespace Zint {
return m_primaryMessage;
}
void QZint::setPrimaryMessage(const QString & primaryMessage) {
void QZint::setPrimaryMessage(const QString& primaryMessage) {
m_primaryMessage = primaryMessage;
}
@ -222,7 +223,7 @@ namespace Zint {
return m_fgColor;
}
void QZint::setFgColor(const QColor & fgColor) {
void QZint::setFgColor(const QColor& fgColor) {
m_fgColor = fgColor;
}
@ -230,7 +231,7 @@ namespace Zint {
return m_bgColor;
}
void QZint::setBgColor(const QColor & bgColor) {
void QZint::setBgColor(const QColor& bgColor) {
m_bgColor = bgColor;
}
@ -394,14 +395,14 @@ namespace Zint {
return m_lastError;
}
const QString & QZint::lastError() const {
const QString& QZint::lastError() const {
return m_lastError;
}
bool QZint::hasErrors() const {
return m_lastError.length();
}
int QZint::getVersion() const {
return ZBarcode_Version();
}
@ -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,23 +31,23 @@ 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;
void setInputMode(int input_mode);
QString text() const;
void setText(const QString & text);
void setText(const QString& text);
QString primaryMessage() const;
void setPrimaryMessage(const QString & primaryMessage);
void setPrimaryMessage(const QString& primaryMessage);
float height() const;
void setHeight(float height);
@ -66,10 +67,10 @@ public:
void setDotSize(float dot_size);
QColor fgColor() const;
void setFgColor(const QColor & fgColor);
void setFgColor(const QColor& fgColor);
QColor bgColor() const;
void setBgColor(const QColor & bgColor);
void setBgColor(const QColor& bgColor);
void setCMYK(bool cmyk);
@ -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;
@ -128,12 +130,13 @@ public:
QString error_message() const;
const QString & lastError() const;
const QString& lastError() const;
bool hasErrors() const;
bool save_to_file(QString filename);
void render(QPainter & painter, const QRectF & paintRect, AspectRatioMode mode=IgnoreAspectRatio);
/* 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());