From e6aadd96f7a2df8ba68333326ca7087f52253f7c Mon Sep 17 00:00:00 2001 From: taipanromania Date: Fri, 18 Jul 2008 14:49:14 +0000 Subject: [PATCH] qt frontend --- frontend_qt4/barcodeitem.cpp | 47 ++++ frontend_qt4/barcodeitem.h | 45 ++++ frontend_qt4/fontend.pro | 18 ++ frontend_qt4/main.cpp | 32 +++ frontend_qt4/mainWindow.ui | 410 +++++++++++++++++++++++++++++++++++ frontend_qt4/mainwindow.cpp | 93 ++++++++ frontend_qt4/mainwindow.h | 130 +++++++++++ 7 files changed, 775 insertions(+) create mode 100644 frontend_qt4/barcodeitem.cpp create mode 100644 frontend_qt4/barcodeitem.h create mode 100644 frontend_qt4/fontend.pro create mode 100644 frontend_qt4/main.cpp create mode 100644 frontend_qt4/mainWindow.ui create mode 100644 frontend_qt4/mainwindow.cpp create mode 100644 frontend_qt4/mainwindow.h diff --git a/frontend_qt4/barcodeitem.cpp b/frontend_qt4/barcodeitem.cpp new file mode 100644 index 00000000..455b00a8 --- /dev/null +++ b/frontend_qt4/barcodeitem.cpp @@ -0,0 +1,47 @@ +/*************************************************************************** + * Copyright (C) 2008 by BogDan Vatra * + * taipan@licentia.eu * + * * + * 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 * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#include +#include "barcodeitem.h" + +BarcodeItem::BarcodeItem() + : QGraphicsItem() +{ + scaleFactor=1; + w=400; + h=400; +} + + +BarcodeItem::~BarcodeItem() +{ +} + +QRectF BarcodeItem::boundingRect() const +{ + return QRectF(0, 0, w, h); +} + +void BarcodeItem::paint(QPainter * painter, const QStyleOptionGraphicsItem * /*option*/, QWidget * /*widget*/) +{ + bc.render(*painter,boundingRect(),Zint::BareCode::IgnoreAspectRatio,scaleFactor); +} + + diff --git a/frontend_qt4/barcodeitem.h b/frontend_qt4/barcodeitem.h new file mode 100644 index 00000000..4aebce59 --- /dev/null +++ b/frontend_qt4/barcodeitem.h @@ -0,0 +1,45 @@ +/*************************************************************************** + * Copyright (C) 2008 by BogDan Vatra * + * taipan@licentia.eu * + * * + * 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 * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#ifndef BARCODEITEM_H +#define BARCODEITEM_H + +#include +#include + +/** + @author BogDan Vatra +*/ + +class BarcodeItem : public QGraphicsItem +{ +public: + BarcodeItem(); + ~BarcodeItem(); + QRectF boundingRect() const; + void paint(QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget = 0); + +public: + mutable Zint::BareCode bc; + int scaleFactor; + int w,h; +}; + +#endif diff --git a/frontend_qt4/fontend.pro b/frontend_qt4/fontend.pro new file mode 100644 index 00000000..f4ee80d3 --- /dev/null +++ b/frontend_qt4/fontend.pro @@ -0,0 +1,18 @@ +TEMPLATE = app + +CONFIG += warn_on \ + thread \ + qt + +TARGET = qtFontend + +FORMS += mainWindow.ui + +SOURCES += main.cpp \ + mainwindow.cpp \ + barcodeitem.cpp + +HEADERS += mainwindow.h \ + barcodeitem.h + +LIBS += -lQtZint diff --git a/frontend_qt4/main.cpp b/frontend_qt4/main.cpp new file mode 100644 index 00000000..762c88f7 --- /dev/null +++ b/frontend_qt4/main.cpp @@ -0,0 +1,32 @@ +/*************************************************************************** + * Copyright (C) 2008 by BogDan Vatra * + * taipan@licentia.eu * + * * + * 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 * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + + +#include "mainwindow.h" +#include + +int main(int argc, char *argv[]) +{ + QApplication app(argc, argv); + MainWindow w; + w.show(); + return app.exec(); +} + diff --git a/frontend_qt4/mainWindow.ui b/frontend_qt4/mainWindow.ui new file mode 100644 index 00000000..df9856f8 --- /dev/null +++ b/frontend_qt4/mainWindow.ui @@ -0,0 +1,410 @@ + + mainWindow + + + + 0 + 0 + 787 + 748 + + + + Zint Qt fontend + + + + + + + + + + + Type: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + + + + + + + Item Width: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + 10 + + + 1000 + + + 5 + + + 400 + + + + + + + + + + + Item Height: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + 10 + + + 1000 + + + 5 + + + 400 + + + + + + + + + + + Height: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + 300 + + + 50 + + + + + + + + + + + Primary + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + + + + + + + Width (pdf471): + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + 300 + + + 0 + + + + + + + + + + + Data + + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:10pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">123456</p></body></html> + + + false + + + + + + + + + + + Security level: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + -1 + + + 9 + + + -1 + + + + + + + + + + + Scale factor: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + 1 + + + 16 + + + 1 + + + + + + + + + + + Border width: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + 0 + + + 16 + + + 0 + + + + + + + + + + + Border type: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + No border + + + + + Bind + + + + + Box + + + + + + + + + + + + PDF417 CODEWORDS: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + 928 + + + 1800 + + + 928 + + + + + + + + + + + Foreground color + + + + + + + Backgound color + + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + &Generate + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Close + + + + + + + + + + + pushButton_2 + clicked() + mainWindow + close() + + + 585 + 544 + + + 554 + 310 + + + + + diff --git a/frontend_qt4/mainwindow.cpp b/frontend_qt4/mainwindow.cpp new file mode 100644 index 00000000..67f4989f --- /dev/null +++ b/frontend_qt4/mainwindow.cpp @@ -0,0 +1,93 @@ +/*************************************************************************** + * Copyright (C) 2008 by BogDan Vatra * + * taipan@licentia.eu * + * * + * 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 * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#include +#include +#include +#include + + +#include "mainwindow.h" + + +MainWindow::MainWindow(QWidget* parent, Qt::WFlags fl) + : QWidget(parent, fl) +{ + setupUi(this); + view->setScene(new QGraphicsScene); + m_fgcolor=qRgb(0,0,0); + m_bgcolor=qRgb(0xff,0xff,0xff); + for (int i=0;ienumerator(0).keyCount();i++) + stype->addItem(metaObject()->enumerator(0).key(i)); + on_generate_clicked(); + view->scene()->addItem(&m_bc); + connect(stype, SIGNAL(currentIndexChanged( int )), SLOT(on_generate_clicked())); + connect(heightb, SIGNAL(valueChanged( int )), SLOT(on_generate_clicked())); + connect(widthb, SIGNAL(valueChanged( int )), SLOT(on_generate_clicked())); + connect(security, SIGNAL(valueChanged( int )), SLOT(on_generate_clicked())); + connect(scaleFactor, SIGNAL(valueChanged( int )), SLOT(on_generate_clicked())); + connect(bwidth, SIGNAL(valueChanged( int )), SLOT(on_generate_clicked())); + connect(codewords, SIGNAL(valueChanged( int )), SLOT(on_generate_clicked())); + connect(iwidth, SIGNAL(valueChanged( int )), SLOT(on_generate_clicked())); + connect(iheight, SIGNAL(valueChanged( int )), SLOT(on_generate_clicked())); + connect(btype, SIGNAL(currentIndexChanged( int )), SLOT(on_generate_clicked())); + connect(primary, SIGNAL(textChanged( const QString& )), SLOT(on_generate_clicked())); + connect(text, SIGNAL(textChanged()), SLOT(on_generate_clicked())); + +} + +MainWindow::~MainWindow() +{ +} + +void MainWindow::on_fgcolor_clicked() +{ + m_fgcolor=QColorDialog::getColor(m_fgcolor,this); + on_generate_clicked(); +} + +void MainWindow::on_bgcolor_clicked() +{ + m_bgcolor=QColorDialog::getColor(m_bgcolor,this); + on_generate_clicked(); +} + +void MainWindow::on_generate_clicked() +{ + QString error; + m_bc.scaleFactor=scaleFactor->value(); + m_bc.w=iwidth->value(); + m_bc.h=iheight->value(); + m_bc.bc.setText(text->toPlainText()); + m_bc.bc.setPrimaryMessage(primary->text()); + m_bc.bc.setSymbol(metaObject()->enumerator(0).value(stype->currentIndex())); + + m_bc.bc.setBorder((Zint::BareCode::BorderType)btype->currentIndex()); + m_bc.bc.setBorderWidth(bwidth->value()); + m_bc.bc.setHeight(heightb->value()); + m_bc.bc.setWidth(widthb->value()); + m_bc.bc.setSecurityLevel(security->value()); + m_bc.bc.setPdf417CodeWords(codewords->value()); + m_bc.bc.setFgColor(m_fgcolor); + m_bc.bc.setBgColor(m_bgcolor); + m_bc.update(); + view->scene()->update(); +} + diff --git a/frontend_qt4/mainwindow.h b/frontend_qt4/mainwindow.h new file mode 100644 index 00000000..a86fb90e --- /dev/null +++ b/frontend_qt4/mainwindow.h @@ -0,0 +1,130 @@ +/*************************************************************************** + * Copyright (C) 2008 by BogDan Vatra * + * taipan@licentia.eu * + * * + * 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 * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#ifndef MAINWINDOW_H +#define MAINWINDOW_H + +#include +#include + +#include "ui_mainWindow.h" +#include "barcodeitem.h" + +class MainWindow : public QWidget, private Ui::mainWindow +{ + Q_OBJECT + + Q_ENUMS(BarcodeTypes) + +public: + enum BarcodeTypes + { + CODE11 = 1, + C25MATRIX = 2, + C25INTER = 3, + C25IATA = 4, + C25LOGIC = 6, + C25IND = 7, + CODE39 = 8, + EXCODE39 = 9, + EANX = 13, + EAN128 = 16, + CODABAR = 18, + CODE128 = 20, + DPLEIT = 21, + DPIDENT = 22, + CODE16K = 23, + CODE93 = 25, + FLAT = 28, + RSS14 = 29, + RSS_LTD = 30, + RSS_EXP = 31, + TELEPEN = 32, + UPCA = 34, + UPCE = 37, + POSTNET = 40, + MSI_PLESSEY = 47, + FIM = 49, + LOGMARS = 50, + PHARMA = 51, + PZN = 52, + PHARMA_TWO = 53, + PDF417 = 55, + PDF417TRUNC = 56, + MAXICODE = 57, + QRCODE = 58, + CODE128B = 60, + AUSPOST = 63, + AUSREPLY = 66, + AUSROUTE = 67, + AUSREDIRECT = 68, + ISBNX = 69, + RM4SCC = 70, + DATAMATRIX = 71, + ITF14 = 72, + NVE18 = 75, + KOREAPOST = 77, + RSS14STACK = 79, + RSS14STACK_OMNI = 80, + RSS_EXPSTACK = 81, + PLANET = 82, + MICROPDF417 = 84, + ONECODE = 85, + PLESSEY = 86, + TELEPEN_NUM = 100, + MSI_10 = 101, + MSI_10_10 = 102, + MSI_11 = 103, + MSI_11_10 = 104, + CODE39_43 = 105, + EXCODE39_43 = 106, + AZTEC = 107, + SUPER = 108, + ULTRA = 109, + EANX_CC = 110, + EAN128_CC = 111, + RSS14_CC = 112, + RSS_LTD_CC = 113, + RSS_EXP_CC = 114, + UPCA_CC = 115, + UPCE_CC = 116, + RSS14STACK_CC = 117, + RSS14_OMNI_CC = 118, + RSS_EXPSTACK_CC = 119, + }; + +public: + MainWindow(QWidget* parent = 0, Qt::WFlags fl = 0); + ~MainWindow(); + +public slots: + void on_generate_clicked(); + void on_fgcolor_clicked(); + void on_bgcolor_clicked(); + +private: + QColor m_fgcolor,m_bgcolor; + BarcodeItem m_bc; + +}; + +#endif + +