From 492d9a41c5906c74cac761386a73a6be0e70c13c Mon Sep 17 00:00:00 2001 From: gitlost Date: Sun, 5 Sep 2021 21:52:00 +0100 Subject: [PATCH] GUI: remove refs to AspectRatioMode and mark as legacy (#243) --- backend_qt/qzint.cpp | 29 +++++++++++++---------------- backend_qt/qzint.h | 30 +++++++++++++++++------------- frontend_qt/barcodeitem.cpp | 6 ++---- frontend_qt/barcodeitem.h | 3 +-- frontend_qt/mainwindow.cpp | 1 - 5 files changed, 33 insertions(+), 36 deletions(-) diff --git a/backend_qt/qzint.cpp b/backend_qt/qzint.cpp index b2e3f6c1..23498e7a 100644 --- a/backend_qt/qzint.cpp +++ b/backend_qt/qzint.cpp @@ -27,8 +27,8 @@ #include #include #include -/* 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 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); diff --git a/backend_qt/qzint.h b/backend_qt/qzint.h index 309ec03f..e97d250c 100644 --- a/backend_qt/qzint.h +++ b/backend_qt/qzint.h @@ -16,8 +16,9 @@ ***************************************************************************/ /* vim: set ts=4 sw=4 et : */ -#ifndef BARCODERENDER_H -#define BARCODERENDER_H +#ifndef QZINT_H +#define QZINT_H + #include #include #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 */ diff --git a/frontend_qt/barcodeitem.cpp b/frontend_qt/barcodeitem.cpp index 170c3e42..7fd622db 100644 --- a/frontend_qt/barcodeitem.cpp +++ b/frontend_qt/barcodeitem.cpp @@ -1,6 +1,7 @@ /*************************************************************************** * Copyright (C) 2008 by BogDan Vatra * * bogdan@licentia.eu * + * Copyright (C) 2009-2021 by Robin Stuart * * * * 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()); } - - diff --git a/frontend_qt/barcodeitem.h b/frontend_qt/barcodeitem.h index bde5ab17..d3f9e5aa 100644 --- a/frontend_qt/barcodeitem.h +++ b/frontend_qt/barcodeitem.h @@ -1,6 +1,7 @@ /*************************************************************************** * Copyright (C) 2008 by BogDan Vatra * * bogdan@licentia.eu * + * Copyright (C) 2009-2021 by Robin Stuart * * * * 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 - diff --git a/frontend_qt/mainwindow.cpp b/frontend_qt/mainwindow.cpp index 1565b7fa..8522be98 100644 --- a/frontend_qt/mainwindow.cpp +++ b/frontend_qt/mainwindow.cpp @@ -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());