mirror of
https://github.com/zint/zint
synced 2024-11-16 20:57:25 +13:00
GUI: remove refs to AspectRatioMode and mark as legacy (#243)
This commit is contained in:
parent
c4b7921819
commit
492d9a41c5
@ -27,8 +27,8 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <QFontMetrics>
|
#include <QFontMetrics>
|
||||||
/* the following include was necessary to compile with QT 5.18 on Windows */
|
/* the following include was necessary to compile with Qt 5.15 on Windows */
|
||||||
/* QT 8.7 did not require it. */
|
/* Qt 5.7 did not require it. */
|
||||||
#include <QPainterPath>
|
#include <QPainterPath>
|
||||||
|
|
||||||
namespace Zint {
|
namespace Zint {
|
||||||
@ -129,7 +129,8 @@ namespace Zint {
|
|||||||
void QZint::encode() {
|
void QZint::encode() {
|
||||||
resetSymbol();
|
resetSymbol();
|
||||||
QByteArray bstr = m_text.toUtf8();
|
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;
|
m_lastError = m_zintSymbol->errtxt;
|
||||||
|
|
||||||
if (m_error < ZINT_ERROR) {
|
if (m_error < ZINT_ERROR) {
|
||||||
@ -162,7 +163,7 @@ namespace Zint {
|
|||||||
return m_text;
|
return m_text;
|
||||||
}
|
}
|
||||||
|
|
||||||
void QZint::setText(const QString & text) {
|
void QZint::setText(const QString& text) {
|
||||||
m_text = text;
|
m_text = text;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -170,7 +171,7 @@ namespace Zint {
|
|||||||
return m_primaryMessage;
|
return m_primaryMessage;
|
||||||
}
|
}
|
||||||
|
|
||||||
void QZint::setPrimaryMessage(const QString & primaryMessage) {
|
void QZint::setPrimaryMessage(const QString& primaryMessage) {
|
||||||
m_primaryMessage = primaryMessage;
|
m_primaryMessage = primaryMessage;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -222,7 +223,7 @@ namespace Zint {
|
|||||||
return m_fgColor;
|
return m_fgColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
void QZint::setFgColor(const QColor & fgColor) {
|
void QZint::setFgColor(const QColor& fgColor) {
|
||||||
m_fgColor = fgColor;
|
m_fgColor = fgColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -230,7 +231,7 @@ namespace Zint {
|
|||||||
return m_bgColor;
|
return m_bgColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
void QZint::setBgColor(const QColor & bgColor) {
|
void QZint::setBgColor(const QColor& bgColor) {
|
||||||
m_bgColor = bgColor;
|
m_bgColor = bgColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -394,7 +395,7 @@ namespace Zint {
|
|||||||
return m_lastError;
|
return m_lastError;
|
||||||
}
|
}
|
||||||
|
|
||||||
const QString & QZint::lastError() const {
|
const QString& QZint::lastError() const {
|
||||||
return m_lastError;
|
return m_lastError;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -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_rect *rect;
|
||||||
struct zint_vector_hexagon *hex;
|
struct zint_vector_hexagon *hex;
|
||||||
struct zint_vector_circle *circle;
|
struct zint_vector_circle *circle;
|
||||||
struct zint_vector_string *string;
|
struct zint_vector_string *string;
|
||||||
|
|
||||||
(void)mode; /* Not currently used */
|
|
||||||
|
|
||||||
encode();
|
encode();
|
||||||
|
|
||||||
painter.save();
|
painter.save();
|
||||||
@ -507,9 +506,6 @@ namespace Zint {
|
|||||||
QBrush bgBrush(m_bgColor);
|
QBrush bgBrush(m_bgColor);
|
||||||
painter.fillRect(QRectF(0, 0, gwidth, gheight), bgBrush);
|
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
|
// Plot rectangles
|
||||||
rect = m_zintSymbol->vector->rectangles;
|
rect = m_zintSymbol->vector->rectangles;
|
||||||
if (rect) {
|
if (rect) {
|
||||||
@ -588,7 +584,8 @@ namespace Zint {
|
|||||||
QPen p;
|
QPen p;
|
||||||
p.setColor(m_fgColor);
|
p.setColor(m_fgColor);
|
||||||
painter.setPen(p);
|
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);
|
QFont font(fontStyle, -1 /*pointSize*/, bold ? QFont::Bold : -1);
|
||||||
while (string) {
|
while (string) {
|
||||||
font.setPixelSize(string->fsize);
|
font.setPixelSize(string->fsize);
|
||||||
|
@ -16,8 +16,9 @@
|
|||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
/* vim: set ts=4 sw=4 et : */
|
/* vim: set ts=4 sw=4 et : */
|
||||||
|
|
||||||
#ifndef BARCODERENDER_H
|
#ifndef QZINT_H
|
||||||
#define BARCODERENDER_H
|
#define QZINT_H
|
||||||
|
|
||||||
#include <QColor>
|
#include <QColor>
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
#include "zint.h"
|
#include "zint.h"
|
||||||
@ -30,23 +31,23 @@ class QZint : public QObject
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
enum AspectRatioMode{IgnoreAspectRatio=0, KeepAspectRatio=1, CenterBarCode=2};
|
enum AspectRatioMode{ IgnoreAspectRatio = 0, KeepAspectRatio = 1, CenterBarCode = 2 }; /* Legacy - not used */
|
||||||
|
|
||||||
public:
|
public:
|
||||||
QZint();
|
QZint();
|
||||||
~QZint();
|
~QZint();
|
||||||
|
|
||||||
int symbol() const;
|
int symbol() const; /* Symbology */
|
||||||
void setSymbol(int symbol);
|
void setSymbol(int symbol);
|
||||||
|
|
||||||
int inputMode() const;
|
int inputMode() const;
|
||||||
void setInputMode(int input_mode);
|
void setInputMode(int input_mode);
|
||||||
|
|
||||||
QString text() const;
|
QString text() const;
|
||||||
void setText(const QString & text);
|
void setText(const QString& text);
|
||||||
|
|
||||||
QString primaryMessage() const;
|
QString primaryMessage() const;
|
||||||
void setPrimaryMessage(const QString & primaryMessage);
|
void setPrimaryMessage(const QString& primaryMessage);
|
||||||
|
|
||||||
float height() const;
|
float height() const;
|
||||||
void setHeight(float height);
|
void setHeight(float height);
|
||||||
@ -66,10 +67,10 @@ public:
|
|||||||
void setDotSize(float dot_size);
|
void setDotSize(float dot_size);
|
||||||
|
|
||||||
QColor fgColor() const;
|
QColor fgColor() const;
|
||||||
void setFgColor(const QColor & fgColor);
|
void setFgColor(const QColor& fgColor);
|
||||||
|
|
||||||
QColor bgColor() const;
|
QColor bgColor() const;
|
||||||
void setBgColor(const QColor & bgColor);
|
void setBgColor(const QColor& bgColor);
|
||||||
|
|
||||||
void setCMYK(bool cmyk);
|
void setCMYK(bool cmyk);
|
||||||
|
|
||||||
@ -107,7 +108,7 @@ public:
|
|||||||
|
|
||||||
void setDebug(bool debug);
|
void setDebug(bool debug);
|
||||||
|
|
||||||
/* Legacy */
|
/* Legacy property getters/setters */
|
||||||
void setWidth(int width); /* option_1 */
|
void setWidth(int width); /* option_1 */
|
||||||
int width() const;
|
int width() const;
|
||||||
void setSecurityLevel(int securityLevel); /* option_2 */
|
void setSecurityLevel(int securityLevel); /* option_2 */
|
||||||
@ -116,6 +117,7 @@ public:
|
|||||||
int pdf417CodeWords() const;
|
int pdf417CodeWords() const;
|
||||||
void setHideText(bool hide); /* setShowText(!hide) */
|
void setHideText(bool hide); /* setShowText(!hide) */
|
||||||
|
|
||||||
|
/* Test capabilities - ZBarcode_Cap() */
|
||||||
bool hasHRT(int symbology = 0) const;
|
bool hasHRT(int symbology = 0) const;
|
||||||
bool isExtendable(int symbology = 0) const;
|
bool isExtendable(int symbology = 0) const;
|
||||||
bool supportsECI(int symbology = 0) const;
|
bool supportsECI(int symbology = 0) const;
|
||||||
@ -128,12 +130,13 @@ public:
|
|||||||
|
|
||||||
QString error_message() const;
|
QString error_message() const;
|
||||||
|
|
||||||
const QString & lastError() const;
|
const QString& lastError() const;
|
||||||
bool hasErrors() const;
|
bool hasErrors() const;
|
||||||
|
|
||||||
bool save_to_file(QString filename);
|
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;
|
int getVersion() const;
|
||||||
|
|
||||||
@ -179,6 +182,7 @@ private:
|
|||||||
bool m_reader_init;
|
bool m_reader_init;
|
||||||
bool m_debug;
|
bool m_debug;
|
||||||
};
|
};
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* QZINT_H */
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
/***************************************************************************
|
/***************************************************************************
|
||||||
* Copyright (C) 2008 by BogDan Vatra *
|
* Copyright (C) 2008 by BogDan Vatra *
|
||||||
* bogdan@licentia.eu *
|
* 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 *
|
* 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 *
|
* it under the terms of the GNU General Public License as published by *
|
||||||
@ -23,7 +24,6 @@ BarcodeItem::BarcodeItem()
|
|||||||
{
|
{
|
||||||
w = 693;
|
w = 693;
|
||||||
h = 378; // Default widget size when created
|
h = 378; // Default widget size when created
|
||||||
ar = Zint::QZint::AspectRatioMode::IgnoreAspectRatio;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
BarcodeItem::~BarcodeItem()
|
BarcodeItem::~BarcodeItem()
|
||||||
@ -42,7 +42,5 @@ QRectF BarcodeItem::boundingRect() const
|
|||||||
|
|
||||||
void BarcodeItem::paint(QPainter *painter, const QStyleOptionGraphicsItem * /*option*/, QWidget * /*widget*/)
|
void BarcodeItem::paint(QPainter *painter, const QStyleOptionGraphicsItem * /*option*/, QWidget * /*widget*/)
|
||||||
{
|
{
|
||||||
bc.render(*painter, boundingRect(), ar);
|
bc.render(*painter, boundingRect());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
/***************************************************************************
|
/***************************************************************************
|
||||||
* Copyright (C) 2008 by BogDan Vatra *
|
* Copyright (C) 2008 by BogDan Vatra *
|
||||||
* bogdan@licentia.eu *
|
* 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 *
|
* 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 *
|
* it under the terms of the GNU General Public License as published by *
|
||||||
@ -39,8 +40,6 @@ private:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
mutable Zint::QZint bc;
|
mutable Zint::QZint bc;
|
||||||
Zint::QZint::AspectRatioMode ar;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -1171,7 +1171,6 @@ void MainWindow::update_preview()
|
|||||||
int item_val;
|
int item_val;
|
||||||
QCheckBox *checkBox;
|
QCheckBox *checkBox;
|
||||||
|
|
||||||
//m_bc.ar=(Zint::QZint::AspectRatioMode)1;
|
|
||||||
if (!grpComposite->isHidden() && chkComposite->isChecked()) {
|
if (!grpComposite->isHidden() && chkComposite->isChecked()) {
|
||||||
m_bc.bc.setPrimaryMessage(txtData->text());
|
m_bc.bc.setPrimaryMessage(txtData->text());
|
||||||
m_bc.bc.setText(txtComposite->toPlainText());
|
m_bc.bc.setText(txtComposite->toPlainText());
|
||||||
|
Loading…
Reference in New Issue
Block a user