mirror of
https://github.com/zint/zint
synced 2024-11-16 20:57:25 +13:00
more qt code
trying to catch up robin ;)
This commit is contained in:
parent
0704f600f0
commit
3b0a048fa9
@ -19,14 +19,11 @@ DEFINES += NO_PNG NO_QR
|
|||||||
LIBS += -lpng
|
LIBS += -lpng
|
||||||
}
|
}
|
||||||
|
|
||||||
contains(DEFINES, NO_QR){
|
|
||||||
SOURCES += ../backend/no_qr.c
|
|
||||||
}else{
|
|
||||||
SOURCES += ../backend/qr.c
|
|
||||||
|
|
||||||
contains(DEFINES, QR_SYSTEM){
|
contains(DEFINES, QR_SYSTEM){
|
||||||
LIBS += -lqrencode
|
LIBS += -lqrencode
|
||||||
}else{
|
}
|
||||||
|
|
||||||
|
contains(DEFINES, QR){
|
||||||
|
|
||||||
INCLUDEPATH += qrencode
|
INCLUDEPATH += qrencode
|
||||||
|
|
||||||
@ -48,8 +45,6 @@ SOURCES += qrencode/bitstream.c \
|
|||||||
qrencode/split.c
|
qrencode/split.c
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
HEADERS += ../backend/common.h \
|
HEADERS += ../backend/common.h \
|
||||||
../backend/composite.h \
|
../backend/composite.h \
|
||||||
../backend/dm200.h \
|
../backend/dm200.h \
|
||||||
@ -84,6 +79,7 @@ SOURCES += ../backend/2of5.c \
|
|||||||
../backend/rss.c \
|
../backend/rss.c \
|
||||||
../backend/telepen.c \
|
../backend/telepen.c \
|
||||||
../backend/upcean.c \
|
../backend/upcean.c \
|
||||||
|
../backend/qr.c \
|
||||||
barcoderender.cpp
|
barcoderender.cpp
|
||||||
|
|
||||||
VERSION = 1.6.0
|
VERSION = 1.6.0
|
||||||
|
@ -13,7 +13,6 @@
|
|||||||
* You should have received a copy of the GNU General Public License *
|
* You should have received a copy of the GNU General Public License *
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
#include <QPainter>
|
|
||||||
|
|
||||||
#include "barcoderender.h"
|
#include "barcoderender.h"
|
||||||
|
|
||||||
@ -26,12 +25,13 @@ BareCode::BareCode()
|
|||||||
m_height=50;
|
m_height=50;
|
||||||
m_border=NO_BORDER;
|
m_border=NO_BORDER;
|
||||||
m_boderWidth=0;
|
m_boderWidth=0;
|
||||||
m_width=0;
|
|
||||||
m_securityLevel=-1;
|
m_securityLevel=-1;
|
||||||
m_pdf417CodeWords=928;
|
m_pdf417CodeWords=928;
|
||||||
m_fgColor=Qt::black;
|
m_fgColor=Qt::black;
|
||||||
m_bgColor=Qt::white;
|
m_bgColor=Qt::white;
|
||||||
m_zintSymbol=0;
|
m_zintSymbol=0;
|
||||||
|
m_excode39SymbologyNumber=m_code39SymbologyNumber=m_msiSymbologyNumber=0;
|
||||||
|
m_error=0;
|
||||||
}
|
}
|
||||||
|
|
||||||
BareCode::~BareCode()
|
BareCode::~BareCode()
|
||||||
@ -53,7 +53,24 @@ void BareCode::encode()
|
|||||||
m_zintSymbol->whitespace_width=0;
|
m_zintSymbol->whitespace_width=0;
|
||||||
m_zintSymbol->border_width=0;
|
m_zintSymbol->border_width=0;
|
||||||
m_zintSymbol->option_1=m_securityLevel;
|
m_zintSymbol->option_1=m_securityLevel;
|
||||||
m_zintSymbol->option_2=m_width;
|
switch (m_symbol)
|
||||||
|
{
|
||||||
|
case BARCODE_MSI_PLESSEY:
|
||||||
|
m_zintSymbol->option_2=m_msiSymbologyNumber;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case BARCODE_CODE39:
|
||||||
|
m_zintSymbol->option_2=m_code39SymbologyNumber;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case BARCODE_EXCODE39:
|
||||||
|
m_zintSymbol->option_2=m_excode39SymbologyNumber;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
m_zintSymbol->option_2=m_width;
|
||||||
|
break;
|
||||||
|
}
|
||||||
m_zintSymbol->option_3=m_pdf417CodeWords;
|
m_zintSymbol->option_3=m_pdf417CodeWords;
|
||||||
QByteArray bstr=m_text.toAscii();
|
QByteArray bstr=m_text.toAscii();
|
||||||
QByteArray pstr=m_primaryMessage.left(99).toAscii();
|
QByteArray pstr=m_primaryMessage.left(99).toAscii();
|
||||||
@ -78,40 +95,42 @@ void BareCode::encode()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int BareCode::symbol()
|
||||||
|
{
|
||||||
|
return m_symbol;
|
||||||
|
}
|
||||||
void BareCode::setSymbol(int symbol)
|
void BareCode::setSymbol(int symbol)
|
||||||
{
|
{
|
||||||
m_symbol=symbol;
|
m_symbol=symbol;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString BareCode::text()
|
||||||
|
{
|
||||||
|
return m_text;
|
||||||
|
}
|
||||||
void BareCode::setText(const QString & text)
|
void BareCode::setText(const QString & text)
|
||||||
{
|
{
|
||||||
m_text=text;
|
m_text=text;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString BareCode::primaryMessage()
|
||||||
|
{
|
||||||
|
return m_primaryMessage;
|
||||||
|
}
|
||||||
void BareCode::setPrimaryMessage(const QString & primaryMessage)
|
void BareCode::setPrimaryMessage(const QString & primaryMessage)
|
||||||
{
|
{
|
||||||
m_primaryMessage=primaryMessage;
|
m_primaryMessage=primaryMessage;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BareCode::setHeight(int height)
|
|
||||||
{
|
|
||||||
m_height=height;
|
|
||||||
}
|
|
||||||
|
|
||||||
int BareCode::height()
|
int BareCode::height()
|
||||||
{
|
{
|
||||||
encode();
|
encode();
|
||||||
return m_zintSymbol->height+(m_border==BOX)?m_boderWidth*2:0;
|
return m_zintSymbol->height+(m_border==BOX)?m_boderWidth*2:0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BareCode::setBorder(BorderType border)
|
void BareCode::setHeight(int height)
|
||||||
{
|
{
|
||||||
m_border=border;
|
m_height=height;
|
||||||
}
|
|
||||||
|
|
||||||
void BareCode::setBorderWidth(int boderWidth)
|
|
||||||
{
|
|
||||||
m_boderWidth=boderWidth;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void BareCode::setWidth(int width)
|
void BareCode::setWidth(int width)
|
||||||
@ -125,34 +144,85 @@ int BareCode::width()
|
|||||||
return m_zintSymbol->width+(m_border!=NO_BORDER)?m_boderWidth*2:0;
|
return m_zintSymbol->width+(m_border!=NO_BORDER)?m_boderWidth*2:0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BareCode::setSecurityLevel(int securityLevel)
|
QColor BareCode::fgColor()
|
||||||
{
|
{
|
||||||
m_securityLevel=securityLevel;
|
return m_fgColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BareCode::setPdf417CodeWords(int pdf417CodeWords)
|
|
||||||
{
|
|
||||||
m_pdf417CodeWords=pdf417CodeWords;
|
|
||||||
}
|
|
||||||
|
|
||||||
void BareCode::setFgColor(const QColor & fgColor)
|
void BareCode::setFgColor(const QColor & fgColor)
|
||||||
{
|
{
|
||||||
m_fgColor=fgColor;
|
m_fgColor=fgColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QColor BareCode::bgColor()
|
||||||
|
{
|
||||||
|
return m_bgColor;
|
||||||
|
}
|
||||||
void BareCode::setBgColor(const QColor & bgColor)
|
void BareCode::setBgColor(const QColor & bgColor)
|
||||||
{
|
{
|
||||||
m_bgColor=bgColor;
|
m_bgColor=bgColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
const QString & BareCode::lastError()
|
BareCode::BorderType BareCode::borderType()
|
||||||
{
|
{
|
||||||
return m_lastError;
|
return m_border;
|
||||||
|
}
|
||||||
|
void BareCode::setBorderType(BorderType border)
|
||||||
|
{
|
||||||
|
m_border=border;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BareCode::hasErrors()
|
int BareCode::borderWidth()
|
||||||
{
|
{
|
||||||
return m_lastError.length();
|
return m_boderWidth;
|
||||||
|
}
|
||||||
|
void BareCode::setBorderWidth(int boderWidth)
|
||||||
|
{
|
||||||
|
m_boderWidth=boderWidth;
|
||||||
|
}
|
||||||
|
|
||||||
|
int BareCode::pdf417CodeWords()
|
||||||
|
{
|
||||||
|
return m_pdf417CodeWords;
|
||||||
|
}
|
||||||
|
void BareCode::setPdf417CodeWords(int pdf417CodeWords)
|
||||||
|
{
|
||||||
|
m_pdf417CodeWords=pdf417CodeWords;
|
||||||
|
}
|
||||||
|
|
||||||
|
int BareCode::securityLevel()
|
||||||
|
{
|
||||||
|
return m_securityLevel;
|
||||||
|
}
|
||||||
|
void BareCode::setSecurityLevel(int securityLevel)
|
||||||
|
{
|
||||||
|
m_securityLevel=securityLevel;
|
||||||
|
}
|
||||||
|
|
||||||
|
int BareCode::msiExtraSymbology()
|
||||||
|
{
|
||||||
|
return m_msiSymbologyNumber;
|
||||||
|
}
|
||||||
|
void BareCode::setMsiExtraSymbology(int msiSymbologyNumber)
|
||||||
|
{
|
||||||
|
m_msiSymbologyNumber=msiSymbologyNumber;
|
||||||
|
}
|
||||||
|
|
||||||
|
int BareCode::code39ExtraSymbology()
|
||||||
|
{
|
||||||
|
return m_code39SymbologyNumber;
|
||||||
|
}
|
||||||
|
void BareCode::setCode39ExtraSymbology(int m_code39SymbologyNumber)
|
||||||
|
{
|
||||||
|
m_code39SymbologyNumber=m_code39SymbologyNumber;
|
||||||
|
}
|
||||||
|
|
||||||
|
int BareCode::excode39ExtraSymbology()
|
||||||
|
{
|
||||||
|
return m_excode39SymbologyNumber;
|
||||||
|
}
|
||||||
|
void BareCode::setExcode39ExtraSymbology(int excode39SymbologyNumber)
|
||||||
|
{
|
||||||
|
m_excode39SymbologyNumber=excode39SymbologyNumber;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BareCode::render(QPainter & painter, const QRectF & paintRect, AspectRatioMode mode, qreal scaleFactor)
|
void BareCode::render(QPainter & painter, const QRectF & paintRect, AspectRatioMode mode, qreal scaleFactor)
|
||||||
@ -327,5 +397,15 @@ void BareCode::render(QPainter & painter, const QRectF & paintRect, AspectRatioM
|
|||||||
painter.restore();
|
painter.restore();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const QString & BareCode::lastError()
|
||||||
|
{
|
||||||
|
return m_lastError;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool BareCode::hasErrors()
|
||||||
|
{
|
||||||
|
return m_lastError.length();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,8 +16,8 @@
|
|||||||
|
|
||||||
#ifndef BARCODERENDER_H
|
#ifndef BARCODERENDER_H
|
||||||
#define BARCODERENDER_H
|
#define BARCODERENDER_H
|
||||||
#include <QImage>
|
|
||||||
#include <QColor>
|
#include <QColor>
|
||||||
|
#include <QPainter>
|
||||||
|
|
||||||
#include "zint.h"
|
#include "zint.h"
|
||||||
|
|
||||||
@ -25,7 +25,29 @@ namespace Zint
|
|||||||
{
|
{
|
||||||
|
|
||||||
class BareCode
|
class BareCode
|
||||||
|
#ifndef NO_QT_KEYWORDS
|
||||||
|
: public QObject
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
|
#ifndef NO_QT_KEYWORDS
|
||||||
|
Q_OBJECT
|
||||||
|
Q_PROPERTY(int symbol READ symbol WRITE setSymbol)
|
||||||
|
Q_PROPERTY(QString text READ text WRITE setText)
|
||||||
|
Q_PROPERTY(QString primaryMessage READ primaryMessage WRITE setPrimaryMessage)
|
||||||
|
Q_PROPERTY(int height READ height WRITE setHeight)
|
||||||
|
Q_PROPERTY(int width READ width WRITE setWidth)
|
||||||
|
Q_PROPERTY(QColor fgColor READ fgColor WRITE setFgColor)
|
||||||
|
Q_PROPERTY(QColor bgColor READ bgColor WRITE setBgColor)
|
||||||
|
Q_PROPERTY(BorderType borderType READ borderType WRITE setBorderType)
|
||||||
|
Q_PROPERTY(int borderWidth READ borderWidth WRITE setBorderWidth)
|
||||||
|
Q_PROPERTY(int pdf417CodeWords READ pdf417CodeWords WRITE setPdf417CodeWords)
|
||||||
|
Q_PROPERTY(int securityLevel READ securityLevel WRITE setSecurityLevel)
|
||||||
|
Q_PROPERTY(int msiExtraSymbology READ msiExtraSymbology WRITE setMsiExtraSymbology)
|
||||||
|
Q_PROPERTY(int code39ExtraSymbology READ code39ExtraSymbology WRITE setCode39ExtraSymbology)
|
||||||
|
Q_PROPERTY(int excode39ExtraSymbology READ excode39ExtraSymbology WRITE setExcode39ExtraSymbology)
|
||||||
|
Q_ENUMS(BorderType)
|
||||||
|
#endif
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
enum BorderType{NO_BORDER=0, BIND=1, BOX=2};
|
enum BorderType{NO_BORDER=0, BIND=1, BOX=2};
|
||||||
@ -35,25 +57,52 @@ public:
|
|||||||
BareCode();
|
BareCode();
|
||||||
~BareCode();
|
~BareCode();
|
||||||
|
|
||||||
|
int symbol();
|
||||||
void setSymbol(int symbol);
|
void setSymbol(int symbol);
|
||||||
|
|
||||||
|
QString text();
|
||||||
void setText(const QString & text);
|
void setText(const QString & text);
|
||||||
|
|
||||||
|
QString primaryMessage();
|
||||||
void setPrimaryMessage(const QString & primaryMessage);
|
void setPrimaryMessage(const QString & primaryMessage);
|
||||||
|
|
||||||
void setHeight(int height);
|
void setHeight(int height);
|
||||||
int height();
|
int height();
|
||||||
void setBorder(BorderType border);
|
|
||||||
void setBorderWidth(int boderWidth);
|
|
||||||
void setWidth(int width);
|
void setWidth(int width);
|
||||||
int width();
|
int width();
|
||||||
void setSecurityLevel(int securityLevel);
|
|
||||||
void setPdf417CodeWords(int pdf417CodeWords);
|
QColor fgColor();
|
||||||
void setFgColor(const QColor & fgColor);
|
void setFgColor(const QColor & fgColor);
|
||||||
|
|
||||||
|
QColor bgColor();
|
||||||
void setBgColor(const QColor & bgColor);
|
void setBgColor(const QColor & bgColor);
|
||||||
|
|
||||||
|
BorderType borderType();
|
||||||
|
void setBorderType(BorderType border);
|
||||||
|
|
||||||
|
int borderWidth();
|
||||||
|
void setBorderWidth(int boderWidth);
|
||||||
|
|
||||||
|
int pdf417CodeWords();
|
||||||
|
void setPdf417CodeWords(int pdf417CodeWords);
|
||||||
|
|
||||||
|
int securityLevel();
|
||||||
|
void setSecurityLevel(int securityLevel);
|
||||||
|
|
||||||
|
int msiExtraSymbology();
|
||||||
|
void setMsiExtraSymbology(int msiSymbologyNumber);
|
||||||
|
|
||||||
|
int code39ExtraSymbology();
|
||||||
|
void setCode39ExtraSymbology(int m_code39SymbologyNumber);
|
||||||
|
|
||||||
|
int excode39ExtraSymbology();
|
||||||
|
void setExcode39ExtraSymbology(int excode39SymbologyNumber);
|
||||||
|
|
||||||
void render(QPainter & painter, const QRectF & paintRect, AspectRatioMode mode=IgnoreAspectRatio, qreal scaleFactor=1);
|
void render(QPainter & painter, const QRectF & paintRect, AspectRatioMode mode=IgnoreAspectRatio, qreal scaleFactor=1);
|
||||||
|
|
||||||
const QString & lastError();
|
const QString & lastError();
|
||||||
bool hasErrors();
|
bool hasErrors();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void encode();
|
void encode();
|
||||||
|
|
||||||
@ -67,9 +116,13 @@ private:
|
|||||||
int m_width;
|
int m_width;
|
||||||
int m_securityLevel;
|
int m_securityLevel;
|
||||||
int m_pdf417CodeWords;
|
int m_pdf417CodeWords;
|
||||||
|
int m_msiSymbologyNumber;
|
||||||
|
int m_code39SymbologyNumber;
|
||||||
|
int m_excode39SymbologyNumber;
|
||||||
QColor m_fgColor;
|
QColor m_fgColor;
|
||||||
QColor m_bgColor;
|
QColor m_bgColor;
|
||||||
QString m_lastError;
|
QString m_lastError;
|
||||||
|
int m_error;
|
||||||
zint_symbol * m_zintSymbol;
|
zint_symbol * m_zintSymbol;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user