hlp:桂林国际齿轮泵代码
This commit is contained in:
+606
@@ -0,0 +1,606 @@
|
||||
#include "dlgQrCode.h"
|
||||
#include "ui_dlgQrCode.h"
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <QImage>
|
||||
#include <getopt.h>
|
||||
|
||||
#include <qdebug.h>
|
||||
#include <QApplication>
|
||||
#include "SysPara.h"
|
||||
#include "InkJetPrinter.h"
|
||||
|
||||
#define AUTOREF true
|
||||
|
||||
|
||||
#include "Matrix/dm200.h"
|
||||
|
||||
#define MDTFLAG 0xff00FF10
|
||||
#define QRFLAG 0xff00FF20
|
||||
#define BARFLAG 0xff00FF30
|
||||
|
||||
char DataMatrixdDraw(U08 *OutBuff, U16 cRows, U16 cColumns, U08 MSize);
|
||||
char DataMatrixdDrawImg(U08 *OutBuff, U16 cRows, U16 cColumns, U08 MSize);
|
||||
void Draw_MatrixToImg(unsigned char *buffer,QImage *pImg);
|
||||
|
||||
extern InkJetPrinter *pInkJectPrinter;
|
||||
//void MatrixEnCode(unsigned char *intext,int Size);
|
||||
|
||||
static int casesensitive = 1;
|
||||
static int eightbit = 0;
|
||||
static int kanji = 0;
|
||||
static int version = 0;
|
||||
|
||||
static int margin = 1;
|
||||
|
||||
static QRecLevel level = QR_ECLEVEL_L;
|
||||
|
||||
|
||||
static int AutoCount=0;
|
||||
static QImage img1;
|
||||
static int InkColor=0;
|
||||
|
||||
|
||||
dlgQrCode::dlgQrCode(QWidget *parent) :
|
||||
QDialog(parent),
|
||||
ui(new Ui::dlgQrCode)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
qrOption = new qrOption_t;
|
||||
//ui->labQRImage->setText("");
|
||||
ui->labName->setText("");
|
||||
ui->labRECT->setText("");
|
||||
bcWidth=bcHeight=0;
|
||||
counter =0;
|
||||
scene = new QGraphicsScene;
|
||||
connect(ui->lineEditIn,SIGNAL(editingFinished()),this,SLOT(onTextChanged()));
|
||||
connect(ui->checkBoxAuto,SIGNAL(clicked(bool)),this,SLOT(onQRCodeAuto(bool)));
|
||||
// img1 =0;
|
||||
|
||||
connect(ui->comboBoxType, SIGNAL(currentIndexChanged(int)),this, SLOT(onComboBoxType(int)));
|
||||
}
|
||||
|
||||
dlgQrCode::~dlgQrCode()
|
||||
{
|
||||
delete ui;
|
||||
if(scene)
|
||||
{
|
||||
delete scene;
|
||||
}
|
||||
}
|
||||
|
||||
enum {
|
||||
O_HELP,
|
||||
O_OUTPUT,
|
||||
O_SIZE,
|
||||
O_VERSION,
|
||||
O_LEVEL,
|
||||
O_MARGIN,
|
||||
O_KANJI,
|
||||
O_CASE,
|
||||
O_8BIT,
|
||||
};
|
||||
|
||||
static const struct option options[] = {
|
||||
{"h", no_argument , NULL, O_HELP},
|
||||
{"o", required_argument, NULL, O_OUTPUT},
|
||||
{"l", required_argument, NULL, O_LEVEL},
|
||||
{"s", required_argument, NULL, O_SIZE},
|
||||
{"v", required_argument, NULL, O_VERSION},
|
||||
{"m", required_argument, NULL, O_MARGIN},
|
||||
{"k", no_argument , NULL, O_KANJI},
|
||||
{"c", no_argument , NULL, O_CASE},
|
||||
{"8", no_argument , NULL, O_8BIT},
|
||||
{NULL, 0, NULL, 0}
|
||||
};
|
||||
|
||||
static QRcode *encode(const char *intext)
|
||||
{
|
||||
QRencodeMode hint;
|
||||
QRcode *code;
|
||||
|
||||
if(kanji) {
|
||||
hint = QR_MODE_KANJI;
|
||||
} else {
|
||||
hint = QR_MODE_8;
|
||||
}
|
||||
|
||||
if(eightbit) {
|
||||
code = QRcode_encodeString8bit(intext, version, QR_ECLEVEL_L);
|
||||
} else {
|
||||
code = QRcode_encodeString(intext, version, QR_ECLEVEL_L, hint, casesensitive);
|
||||
}
|
||||
|
||||
return code;
|
||||
}
|
||||
|
||||
static void qrencode(const char *intext,int Size)
|
||||
{
|
||||
QRcode *qrcode;
|
||||
//png_structp png_ptr;
|
||||
//png_infop info_ptr;
|
||||
unsigned char *row, *p, *q;
|
||||
int x, y, xx, yy, bit;
|
||||
int realwidth;
|
||||
|
||||
qrcode = encode(intext);
|
||||
if(qrcode == NULL) {
|
||||
fprintf(stderr, "Failed to encode the input data.\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
realwidth = (qrcode->width + margin * 2) * Size;
|
||||
|
||||
row = (unsigned char *)malloc(realwidth);
|
||||
// top margin
|
||||
memset(row, 0x0, realwidth );
|
||||
QImage QRImage(realwidth, InkColor?realwidth:qrcode->width*Size ,QImage::Format_ARGB32 );
|
||||
QImage *img;
|
||||
img = &QRImage;
|
||||
if( AutoCount ) {
|
||||
InkColor =0;
|
||||
img->fill(0xff00ff00); // 0xff00ff01(DMT) 0xff00ff02(QR) 0xff00ff03(BAR)
|
||||
}
|
||||
else
|
||||
img->fill(InkColor?0xff000000:0x00ffffff);
|
||||
/* data */
|
||||
p = qrcode->data;
|
||||
int ypos=InkColor?margin:0;//margin * Size;
|
||||
int xpos=0;
|
||||
|
||||
for(y=0; y<qrcode->width; y++) {
|
||||
bit = 7;
|
||||
bit = 7 - (margin * Size % 8);
|
||||
xpos=margin * Size;
|
||||
for(x=0; x<qrcode->width; x++) {
|
||||
for(xx=0; xx<Size; xx++) {
|
||||
if((*p & 1) << bit){
|
||||
for(yy=0; yy<Size; yy++) {
|
||||
//img->setPixel(xpos,ypos+yy,InkColor? 0x00ffffff:0xff000000);
|
||||
img->setPixel(xpos,ypos+yy,InkColor? 0x00ffffff:0xff000000);
|
||||
}
|
||||
}
|
||||
xpos++;
|
||||
|
||||
}
|
||||
p++;
|
||||
bit--;
|
||||
if(bit < 0) {
|
||||
//q++;
|
||||
bit = 7;
|
||||
}
|
||||
}
|
||||
ypos+=Size;
|
||||
}
|
||||
img1 = img->copy(img->rect());
|
||||
if(AutoCount) img1.setPixel(0,ypos-1,QRFLAG);
|
||||
free(row);
|
||||
QRcode_free(qrcode);
|
||||
}
|
||||
|
||||
void dlgQrCode::MatrixEnCode(unsigned char *intext,int Size)
|
||||
{
|
||||
U16 sColumns, sRows;
|
||||
U08 *Grid;
|
||||
sColumns = sRows = 0;
|
||||
Grid = 0;
|
||||
short sizeType = ui->comboBox_DMType->currentIndex();
|
||||
Grid = iec16022ecc200((short*)&sColumns, (short*)&sRows, intext, &sizeType);
|
||||
if(sizeType == -1)
|
||||
{
|
||||
QMessageBox::warning(0,tr("警告"),tr("输入内容超出选择DM码尺寸大小,请选择更大的尺寸!"));
|
||||
return;
|
||||
}
|
||||
DataMatrixdDrawImg(Grid,sRows,sColumns,Size);
|
||||
}
|
||||
|
||||
void dlgQrCode::on_pushBtnClose_pressed(){
|
||||
|
||||
flagInsert = ui->checkBox->checkState()?1:0;
|
||||
AutoCount=(ui->checkBoxAutoCount->checkState())?1:0;
|
||||
ui->checkBox->setChecked(0);
|
||||
barCodeFlag = ui->barCodeCheckBox->checkState()?1:0;
|
||||
|
||||
emit onQRCodeCloseNow();
|
||||
this->close();
|
||||
}
|
||||
|
||||
char DataMatrixdDrawImg(U08 *OutBuff, U16 cRows, U16 cColumns, U08 MSize)
|
||||
{
|
||||
int Size=MSize;
|
||||
int w = cColumns*Size;
|
||||
int h = cRows*Size;
|
||||
//qDebug()<<w<<h<<Size;
|
||||
QImage QRImage(w+2,h,QImage::Format_ARGB32 );
|
||||
QImage *img;
|
||||
img = &QRImage;
|
||||
img->fill( AutoCount?0xff00ff00:0x00ffffff);
|
||||
/* data */
|
||||
int margin=0;
|
||||
U08 *p = OutBuff;
|
||||
int ypos=0;//margin * Size;
|
||||
int xpos=0;
|
||||
int x,y,xx,yy,bit;
|
||||
for(y=0; y<cRows; y++) {
|
||||
bit = 7;
|
||||
bit = 7 - (margin * Size % 8);
|
||||
xpos=1;
|
||||
xpos +=margin * Size;
|
||||
|
||||
for(x=0; x<cColumns; x++) {
|
||||
for(xx=0; xx<Size; xx++) {
|
||||
if((*p & 1) << bit){
|
||||
for(yy=0; yy<Size; yy++) {
|
||||
img->setPixel(xpos,h-1-(ypos+yy),AutoCount?0xff000000:0xff000000);
|
||||
}
|
||||
}
|
||||
xpos++;
|
||||
}
|
||||
p++;
|
||||
bit--;
|
||||
if(bit < 0) {
|
||||
//q++;
|
||||
bit = 7;
|
||||
}
|
||||
}
|
||||
// xpos++;
|
||||
for(xx=0; xx<margin; xx++){
|
||||
for(yy=0; yy<Size; yy++) {
|
||||
img->setPixel(xpos,h-1-(ypos+yy),0x00ffffff);
|
||||
}
|
||||
xpos++;
|
||||
}
|
||||
|
||||
ypos+=Size;
|
||||
|
||||
}
|
||||
//img->save("Myqr.bmp");
|
||||
img1 = img->copy(img->rect());
|
||||
if(AutoCount) img1.setPixel(0,ypos-1,MDTFLAG); // 设置定位标志
|
||||
return 0;
|
||||
}
|
||||
void dlgQrCode::on_pushBtnPreView_pressed(){
|
||||
QString in;
|
||||
InkColor = ui->comboBoxInkColor->currentIndex()?1:0;
|
||||
AutoCount=(ui->checkBoxAutoCount->checkState())?1:0;
|
||||
|
||||
QString s1=ui->lineEditCNT->text();
|
||||
QString s2;
|
||||
int len = s1.length();
|
||||
|
||||
|
||||
if(ui->checkBoxAutoCount->checkState()) {
|
||||
|
||||
in = ui->lineEditIn->text() + ui->lineEditCNT->text() +ui->lineEditIn2->text();// "%04d"
|
||||
|
||||
}
|
||||
else in = ui->lineEditIn->text()+ui->lineEditIn2->text();
|
||||
if(flagCount==0) in=ui->lineEditIn->text();
|
||||
|
||||
ui->lineEdit->setText(in);
|
||||
|
||||
if(in.isEmpty())
|
||||
{
|
||||
// qDebug()<<"QRcode string isEmpty";
|
||||
return;
|
||||
}QByteArray inUtf8 = in.toUtf8();
|
||||
char *intext ="";
|
||||
intext = (char *)malloc(inUtf8.length()*2);//intext = (char *)malloc(in.length()*2);
|
||||
memset(intext,0,sizeof(intext));
|
||||
memcpy(intext,inUtf8.data(),2*inUtf8.length());//memcpy(intext,in.toLocal8Bit().data(),2*in.length());
|
||||
|
||||
if(ui->comboBoxType->currentIndex()){ qrencode(intext,1); }
|
||||
else { MatrixEnCode((unsigned char *)intext,1); }
|
||||
|
||||
//if(pInkJectPrinter->modbus->modbus_up_QRCODE == 0)
|
||||
{
|
||||
ShowQRCode(&img1);
|
||||
}
|
||||
bcWidth = img1.width();
|
||||
bcHeight = img1.height();
|
||||
ui->labRECT->setText(tr("[%1 X %2]").arg(img1.width()).arg(img1.height()));
|
||||
if(!ui->checkBoxAutoCount->isChecked())
|
||||
{
|
||||
ui->pushBtnSave->setEnabled(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
ui->pushBtnSave->setEnabled(false);
|
||||
}
|
||||
}
|
||||
|
||||
void dlgQrCode::onTextChanged(){
|
||||
//qDebug()<<"onTextChanged:";
|
||||
if(AutoRefresh){
|
||||
emit on_pushBtnPreView_pressed();
|
||||
}
|
||||
}
|
||||
|
||||
void dlgQrCode::ShowQRCode(QImage *img)
|
||||
{
|
||||
//scene = new QGraphicsScene; 一直new不释放会让内存耗尽
|
||||
scene->clear();
|
||||
int scale = 4;
|
||||
int bcWidth= img->width();
|
||||
int bcHeight = img->height();
|
||||
scene->setSceneRect( 0,0,bcWidth*(scale),bcHeight*(scale));
|
||||
scene->setItemIndexMethod(QGraphicsScene::NoIndex);
|
||||
QPixmap pixmap(QPixmap::fromImage(*img));
|
||||
pixmap = pixmap.scaledToHeight(bcHeight*(scale));
|
||||
//pixmap = pixmap.scaledToWidth(scale*bcWidth);
|
||||
item = scene->addPixmap(pixmap);
|
||||
/***************设置view的场景*****************************/
|
||||
ui->BarCodeView->setScene(scene);
|
||||
ui->BarCodeView->setRenderHint(QPainter::Antialiasing);
|
||||
ui->BarCodeView->setCacheMode(QGraphicsView::CacheBackground);
|
||||
ui->BarCodeView->setViewportUpdateMode(QGraphicsView::BoundingRectViewportUpdate);
|
||||
ui->BarCodeView->setDragMode(QGraphicsView::ScrollHandDrag);
|
||||
//ui->graphicsView->resize(400,300);
|
||||
ui->BarCodeView->setScene(scene);//设置view的场景
|
||||
}
|
||||
|
||||
|
||||
void dlgQrCode::on_pushBtnSave_pressed(){
|
||||
//if(img1.width()<10)
|
||||
// on_pushBtnPreView_pressed();
|
||||
|
||||
QString s1 = ui->lineEditIn->text();
|
||||
QString s2="";
|
||||
int len =s1.length()<10?s1.length():10;
|
||||
for(int i=1;i<len;i++)
|
||||
{ QChar c=s1.at(i);
|
||||
if( (c >='0' && c<='9') || (c>='A' && c<='Z') || (c>='a' && c<='z') )
|
||||
s2+= QString(c);
|
||||
}
|
||||
|
||||
s2 = (ui->comboBoxType->currentIndex()?"QR_":"DMT_")+s2.left(10)+".bmp";
|
||||
if(AutoCount) s2 = (ui->comboBoxType->currentIndex()?"QRV":"DMTV")+ QString().sprintf("%02d",img1.height())+".bmp";
|
||||
ui->labName->setText(s2);
|
||||
|
||||
if(pInkJectPrinter->modbus->modbus_up_QRCODE == 1)
|
||||
{
|
||||
// qDebug()<<"save modbusQR";
|
||||
s2 = "modbusQR.bmp";
|
||||
this->pictureName=DOC_ROOT_DIR+s2;
|
||||
img1.save(pictureName);
|
||||
pInkJectPrinter->modbus->modbus_up_QRCODE = 0;
|
||||
}else
|
||||
{
|
||||
this->pictureName=DOC_ROOT_DIR+s2;
|
||||
//如果是自动计数不作保存
|
||||
if(AutoCount)
|
||||
{
|
||||
return;
|
||||
}
|
||||
img1.save(pictureName);
|
||||
}
|
||||
|
||||
}
|
||||
QString dlgQrCode::getCounterText( int counter,int QRCntNum){
|
||||
QString s1="";
|
||||
//counter = qrOption->counter;
|
||||
char mFormat[20];
|
||||
memset(mFormat,0,20);
|
||||
if(QRCntNum>0) {snprintf(mFormat,20,"%%%02dd",QRCntNum);
|
||||
if(QRCntNum==1) s1 = QString().sprintf(mFormat,counter%10);
|
||||
else if(QRCntNum==2) s1 = QString().sprintf(mFormat,counter%100);
|
||||
else if(QRCntNum==3) s1 = QString().sprintf(mFormat,counter%1000);
|
||||
else if(QRCntNum==4) s1 = QString().sprintf(mFormat,counter%10000);
|
||||
else if(QRCntNum==5) s1 = QString().sprintf(mFormat,counter%100000);
|
||||
else if(QRCntNum==6) s1 = QString().sprintf(mFormat,counter%1000000);
|
||||
else if(QRCntNum==7) s1 = QString().sprintf(mFormat,counter%10000000);
|
||||
else if(QRCntNum==8) s1 = QString().sprintf(mFormat,counter%100000000);
|
||||
else if(QRCntNum==9) s1 = QString().sprintf(mFormat,counter%1000000000);
|
||||
else if(QRCntNum>=10) s1= QString().sprintf(mFormat,counter%10000000000);
|
||||
//else s1 = QString().sprintf(mFormat,counter);
|
||||
}
|
||||
return s1;
|
||||
}
|
||||
|
||||
void dlgQrCode::SetOption(qrOption_t *qrOption){
|
||||
//memcpy( qrOption,qrOption0,sizeof(qrOption));
|
||||
QString s1=qrOption->text2;
|
||||
ui->checkBoxAuto->setChecked(qrOption->AutoRefresh);
|
||||
ui->checkBox->setChecked(0);
|
||||
ui->lineEditIn2->setText(s1);//后缀
|
||||
ui->lineEditVarInc->setText(QString("%1").arg(qrOption->CntInc));
|
||||
//qDebug()<<qrOption->CntInc;
|
||||
s1=getCounterText(qrOption->counter,qrOption->cntNum);
|
||||
ui->lineEditCNT->setText(s1);//变量
|
||||
s1=qrOption->text;
|
||||
ui->lineEditIn->setText(s1);//前缀
|
||||
ui->comboBoxInkColor->setCurrentIndex(qrOption->InkColor);
|
||||
ui->checkBoxAutoCount->setChecked(qrOption->AutoCount);//z//计数器变量
|
||||
ui->checkBox->setChecked(flagInsert);
|
||||
ui->barCodeCheckBox->setChecked(qrOption->barCodeFlag);
|
||||
ui->comboBoxType->setCurrentIndex(qrOption->type);
|
||||
QRCntNum = qrOption->cntNum;
|
||||
if(qrOption->AutoCount) {
|
||||
counter = qrOption->counter;
|
||||
s1 = ui->lineEditIn->text()+ui->lineEditCNT->text()+ui->lineEditIn2->text();
|
||||
}
|
||||
else s1 = ui->lineEditIn->text()+ui->lineEditIn2->text();
|
||||
|
||||
ui->lineEdit->setText(s1);
|
||||
|
||||
if(s1.length()>10) s1 = "QR_"+s1.left(10)+".bmp";
|
||||
if(AutoCount) s1 = (ui->comboBoxType->currentIndex()?"QRV":"DMTV")+ QString().sprintf("%02d",img1.height())+".bmp";
|
||||
this->pictureName=DOC_ROOT_DIR+s1;
|
||||
if(!qrOption->AutoRefresh) emit on_pushBtnPreView_pressed();
|
||||
//AutoRefresh = AUTOREF;
|
||||
ui->pushBtnSave->setEnabled(false);
|
||||
if(sysPara)
|
||||
{
|
||||
sysPara->para.isCheckInsertTime ? ui->checkBoxInsertTime->setChecked(true) : ui->checkBoxInsertTime->setChecked(false);
|
||||
}
|
||||
}
|
||||
|
||||
void dlgQrCode::GetOption(qrOption_t *qrOption0){
|
||||
//qrOption = qrOption0;
|
||||
if(qrOption0){
|
||||
qrOption0->width = img1.width();
|
||||
qrOption0->height = img1.height();
|
||||
//qrOption0->level = level; // ui->qrLevel->currentIndex()+1;
|
||||
qrOption0->InkColor = ui->comboBoxInkColor->currentIndex()?1:0;
|
||||
qrOption0->AutoRefresh = AutoRefresh;
|
||||
qrOption0->type = ui->comboBoxType->currentIndex();
|
||||
qrOption0->AutoCount=(ui->checkBoxAutoCount->checkState())?1:0;
|
||||
snprintf(qrOption0->text,sizeof(qrOption0->text),"%s",ui->lineEditIn->text().toAscii().constData());
|
||||
snprintf(qrOption0->text2,sizeof(qrOption0->text2),"%s",ui->lineEditIn2->text().toAscii().constData());
|
||||
snprintf(qrOption0->textCnt,sizeof(qrOption0->textCnt),"%s",ui->lineEditCNT->text().toAscii().constData());
|
||||
qrOption0->cntNum =ui->lineEditCNT->text().length();
|
||||
//qDebug()<<"GetOption cntNum"<<qrOption0->cntNum;
|
||||
//bool ok;
|
||||
qrOption0->counter = ui->lineEditCNT->text().toInt(0,10);
|
||||
qrOption0->CntInc = ui->lineEditVarInc->text().toInt(0,10);
|
||||
//qrOption->CntInc =11;
|
||||
//qDebug()<<"TTTT"<<ok<<(qrOption->CntInc)<<(qrOption0->counter)<<(qrOption0->cntNum);
|
||||
ui->pushBtnSave->setEnabled(false);
|
||||
if(sysPara)
|
||||
{
|
||||
sysPara->para.isCheckInsertTime = ui->checkBoxInsertTime->isChecked() ? true : false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int dlgQrCode::getDat(SysPara* sysPara,int varNum){
|
||||
|
||||
//TextToQRImg((QRvars_t *)&sysPara->print.QRvars[varNum]);
|
||||
|
||||
int w= img1.width();
|
||||
int h= img1.height();
|
||||
if(varNum>1)varNum=0;
|
||||
int wStart=sysPara->print.QRvars[varNum].startColPos;
|
||||
int hStart= sysPara->print.QRvars[varNum].startRowPos;
|
||||
//if(hStart)hStart-=1;
|
||||
//qDebug()<<"wStart"<<wStart<<hStart<<w<<h<<sysPara->status.printDat;
|
||||
for(int i = 0 ; i < w; i++)
|
||||
{
|
||||
unsigned char c=0,c1=0;
|
||||
int j=0;
|
||||
hStart= sysPara->print.QRvars[varNum].startRowPos;
|
||||
c=sysPara->status.printDat[(wStart)*5+(hStart)/8];
|
||||
for( j = 0; j < h; j++)
|
||||
{
|
||||
QRgb rgb = img1.pixel(i,j);
|
||||
if((rgb == 0xff000000)) c |= (1 << (hStart%8));
|
||||
else c &= ~(1 << (hStart%8));
|
||||
if(hStart%8==7) {
|
||||
sysPara->status.printDat[(wStart)*5+(hStart)/8]=c;
|
||||
c=sysPara->status.printDat[(wStart)*5+(hStart+1)/8];
|
||||
}
|
||||
hStart++;
|
||||
}
|
||||
sysPara->status.printDat[(wStart)*5+(hStart)/8]=c;
|
||||
wStart++;
|
||||
if(sysPara->status.addSpace ) wStart++; //&& sysPara->print.QRvars[varNum].type==0
|
||||
}
|
||||
return w;
|
||||
}
|
||||
|
||||
|
||||
#include "QDateTime"
|
||||
void dlgQrCode::extSetText(QString text, bool flag)
|
||||
{
|
||||
if(flag)
|
||||
{
|
||||
ui->comboBoxType->setCurrentIndex(1);
|
||||
}
|
||||
else{
|
||||
ui->comboBoxType->setCurrentIndex(0);
|
||||
}
|
||||
ui->lineEditIn->setText(text);
|
||||
ui->lineEditIn2->setText("");
|
||||
ui->lineEditCNT->setText("");
|
||||
|
||||
pInkJectPrinter->modbus->modbus_up_QRCODE =1;
|
||||
|
||||
emit on_pushBtnPreView_pressed();
|
||||
emit on_pushBtnSave_pressed();
|
||||
}
|
||||
|
||||
QString dlgQrCode::TextToQRImg(qrOption_t *qrVar){
|
||||
QString in,s1,s2,s3;
|
||||
|
||||
//snprintf(qrVar->text,sizeof(qrVar->text),"%s",ui->lineEditIn->text().toAscii().constData());
|
||||
s1 = qrVar->text;//ui->lineEditIn->text();
|
||||
s2 = qrVar->text2;
|
||||
s3 = getCounterText(qrVar->counter,qrVar->cntNum) ;
|
||||
QRCntNum = qrVar->cntNum;
|
||||
in = s1+s2;
|
||||
|
||||
if(QRCntNum>0) {
|
||||
in =s1+s3+s2;
|
||||
}
|
||||
|
||||
|
||||
// if(qrVar->TimeEn)
|
||||
// in += " "+ QDateTime::currentDateTime().toString(tr("yy-MM-dd HH:mm:SS"));
|
||||
counter = qrVar->counter;
|
||||
if(in.isEmpty())in = "";
|
||||
#ifdef MYARMTEST
|
||||
//qDebug()<<"txtToImg:"<<in;
|
||||
#endif
|
||||
char *intext ="";
|
||||
intext = (char *)malloc(in.length()*2);
|
||||
memset(intext,0,sizeof(intext));
|
||||
memcpy(intext,in.toLocal8Bit().data(),2*in.length());
|
||||
if(qrVar->type){ qrencode(intext,1); }
|
||||
else { MatrixEnCode((unsigned char *)intext,1); }
|
||||
//ShowQRCode(&img1);
|
||||
free(intext);
|
||||
qrVar->width = img1.width();
|
||||
qrVar->height = img1.height();
|
||||
//qrVar->startRowPos = qrVar->endRowPos-qrVar->height;
|
||||
bcWidth = img1.width();
|
||||
bcHeight = img1.height();
|
||||
return in;// 返回文件名
|
||||
}
|
||||
|
||||
void dlgQrCode::onQRCodeAuto(bool En){
|
||||
AutoRefresh = En;
|
||||
//ui->pushBtnPreView->setEnabled(!En);
|
||||
}
|
||||
|
||||
void dlgQrCode::onComboBoxType(int type)
|
||||
{
|
||||
if(type == 0)
|
||||
{
|
||||
ui->comboBox_DMType->setEnabled(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
ui->comboBox_DMType->setEnabled(false);
|
||||
}
|
||||
}
|
||||
|
||||
void dlgQrCode::setCntCheckBoxHide(bool hideEn){
|
||||
if(hideEn){
|
||||
ui->checkBoxAutoCount->setChecked(0);
|
||||
ui->checkBoxAutoCount->hide();
|
||||
flagCount = 0;
|
||||
ui->lineEditCNT->hide();
|
||||
ui->labelVarInc->hide();
|
||||
ui->lineEditVarInc->hide();
|
||||
ui->lineEditIn2->hide();
|
||||
ui->label_4->hide();
|
||||
ui->label_3->hide();
|
||||
}
|
||||
else {
|
||||
ui->checkBoxAutoCount->show();
|
||||
ui->lineEditCNT->show();
|
||||
ui->labelVarInc->show();
|
||||
ui->lineEditIn2->show();
|
||||
ui->label_4->show();
|
||||
ui->lineEditVarInc->show();
|
||||
ui->label_3->show();
|
||||
flagCount =1;
|
||||
}
|
||||
}
|
||||
|
||||
void dlgQrCode::setSysPara(SysPara * sysPara)
|
||||
{
|
||||
this->sysPara = sysPara;
|
||||
}
|
||||
Reference in New Issue
Block a user