zint-barcode-generator/frontend_qt4/mainwindow.cpp

754 lines
27 KiB
C++
Raw Normal View History

2008-07-18 10:49:14 -04:00
/***************************************************************************
2009-04-26 18:04:51 -04:00
* Copyright (C) 2008 by BogDan Vatra <bogdan@licentia.eu> *
* Copyright (C) 2009 by Robin Stuart <robin@zint.org.uk> *
2008-07-18 10:49:14 -04:00
* *
* This program is free software: you can redistribute it and/or modify *
2008-07-18 10:49:14 -04:00
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation, either version 3 of the License, or *
2008-07-18 10:49:14 -04:00
* (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, see <http://www.gnu.org/licenses/>. *
2008-07-18 10:49:14 -04:00
***************************************************************************/
#include <QDebug>
#include <QGraphicsScene>
#include <QImage>
#include <QColorDialog>
2009-05-21 17:00:23 -04:00
#include <QUiLoader>
#include <QFile>
2008-07-18 10:49:14 -04:00
#include "mainwindow.h"
2009-04-26 18:04:51 -04:00
#include <stdio.h>
2008-07-18 10:49:14 -04:00
MainWindow::MainWindow(QWidget* parent, Qt::WFlags fl)
2009-05-21 17:00:23 -04:00
: QWidget(parent, fl),m_optionWidget(0)
2008-07-18 10:49:14 -04:00
{
2009-05-19 10:05:26 -04:00
2009-04-26 18:04:51 -04:00
char bstyle_text[][50] = {
"Australia Post Standard Customer",
"Australia Post Reply-Paid",
"Australia Post Routing Code",
"Australia Post Redirect Code",
"Aztec Code",
"Aztec Runes",
2009-05-16 10:19:43 -04:00
"Channel Code",
2009-07-04 16:48:42 -04:00
"Codabar",
"Codablock-F",
2009-04-26 18:04:51 -04:00
"Code 11",
"Code 128",
"Code 16k",
"Code 2 of 5 Data Logic",
"Code 2 of 5 IATA",
"Code 2 of 5 Industrial",
"Code 2 of 5 Interleaved",
"Code 2 of 5 Matrix",
"Code 32 (Italian Pharmacode)",
"Code 39",
"Code 39 Extended",
2009-05-10 07:47:20 -04:00
"Code 49",
2009-04-26 18:04:51 -04:00
"Code 93",
2009-07-04 16:48:42 -04:00
"Code One",
2009-04-26 18:04:51 -04:00
"Databar",
"Databar Expanded",
"Databar Expanded Stacked",
"Databar Limited",
"Databar Stacked",
"Databar Stacked Omnidirectional",
"Data Matrix",
"Deutsche Post Identcode",
"Deutsche Post Leitcode",
"Dutch Post KIX",
"EAN-14",
"European Article Number (EAN)",
"FIM",
"Flattermarken",
"ITF-14",
"International Standard Book Number (ISBN)",
"Japanese Postal Barcode",
"Korean Postal Barcode",
"LOGMARS",
"Maxicode",
"MicroPDF417",
"Micro QR Code",
"MSI Plessey",
"NVE-18",
"PDF417",
"Pharmacode",
"Pharmacode 2-track",
"Pharma Zentralnummer (PZN)",
"PLANET",
"Postnet",
"QR Code",
"Royal Mail 4-state Barcode",
"Telepen",
"Telepen Numeric",
"UK Plessey",
"UPC-A",
"UPC-E",
"USPS One Code"
2008-10-07 10:28:32 -04:00
};
2009-05-19 10:05:26 -04:00
/* createActions();
createMenus(); */
2008-07-18 10:49:14 -04:00
setupUi(this);
view->setScene(new QGraphicsScene);
2009-05-19 10:05:26 -04:00
2008-07-18 10:49:14 -04:00
m_fgcolor=qRgb(0,0,0);
m_bgcolor=qRgb(0xff,0xff,0xff);
2008-10-07 10:28:32 -04:00
for (int i=0;i<metaObject()->enumerator(0).keyCount();i++) {
2008-09-24 05:38:32 -04:00
bstyle->addItem(metaObject()->enumerator(0).key(i));
2008-10-07 10:28:32 -04:00
bstyle->setItemText(i,bstyle_text[i]);
}
2009-07-04 16:48:42 -04:00
bstyle->setCurrentIndex(10);
2009-04-26 18:04:51 -04:00
change_options();
update_preview();
2008-07-18 10:49:14 -04:00
view->scene()->addItem(&m_bc);
2009-04-26 18:04:51 -04:00
connect(bstyle, SIGNAL(currentIndexChanged( int )), SLOT(change_options()));
connect(bstyle, SIGNAL(currentIndexChanged( int )), SLOT(update_preview()));
connect(heightb, SIGNAL(valueChanged( int )), SLOT(update_preview()));
connect(bwidth, SIGNAL(valueChanged( int )), SLOT(update_preview()));
connect(btype, SIGNAL(currentIndexChanged( int )), SLOT(update_preview()));
connect(txtData, SIGNAL(textChanged( const QString& )), SLOT(update_preview()));
connect(txtComposite, SIGNAL(textChanged()), SLOT(update_preview()));
connect(chkComposite, SIGNAL(stateChanged( int )), SLOT(composite_enable()));
connect(chkComposite, SIGNAL(stateChanged( int )), SLOT(update_preview()));
connect(cmbCompType, SIGNAL(currentIndexChanged( int )), SLOT(update_preview()));
2009-05-21 17:00:23 -04:00
connect(rotateSlider, SIGNAL(valueChanged(int)), SLOT(scaleRotate()));
connect(scaleSlider, SIGNAL(valueChanged(int)), SLOT(scaleRotate()));
connect(spnWhitespace, SIGNAL(valueChanged( int )), SLOT(update_preview()));
2009-05-19 10:05:26 -04:00
connect(btnAbout, SIGNAL(clicked( bool )), SLOT(about()));
connect(btnSave, SIGNAL(clicked( bool )), SLOT(save()));
connect(spnScale, SIGNAL(valueChanged( double )), SLOT(change_print_scale()));
connect(btnExit, SIGNAL(clicked( bool )), SLOT(quit_now()));
2008-07-18 10:49:14 -04:00
}
MainWindow::~MainWindow()
{
}
2009-05-21 17:00:23 -04:00
void MainWindow::scaleRotate()
{
view->resetTransform();
view->rotate(rotateSlider->value());
view->scale((double)scaleSlider->value()/100,(double)scaleSlider->value()/100);
}
2009-05-19 10:05:26 -04:00
/*
void MainWindow::createActions()
{
saveAct = new QAction(tr("&Save"), this);
saveAct->setShortcut(tr("Ctrl+S"));
saveAct->setStatusTip(tr("Save the document to disk"));
connect(saveAct, SIGNAL(triggered()), this, SLOT(save()));
aboutQtAct = new QAction(tr("About &Qt"), this);
aboutQtAct->setStatusTip(tr("Show the Qt library's About box"));
connect(aboutQtAct, SIGNAL(triggered()), qApp, SLOT(aboutQt()));
}
void MainWindow::createMenus()
{
fileMenu = menuBar()->addMenu(tr("&File"));
fileMenu->addAction(saveAct);
fileMenu->addAction(exitAction);
helpMenu = menuBar()->addMenu(tr("&Help"));
helpMenu->addAction(aboutQtAct);
} */
bool MainWindow::save()
{
bool status;
/* Does nothing yet! */
QString fileName = QFileDialog::getSaveFileName(this,
tr("Save Barcode Image"), ".",
tr("Barcode Images (*.png *.eps *.svg)"));
if (fileName.isEmpty())
return false;
status = m_bc.bc.save_to_file(fileName);
if(status == false) {
QMessageBox::critical(this,tr("Save Error"),m_bc.bc.error_message());
}
return status;
}
void MainWindow::about()
{
QMessageBox::about(this, tr("About Zint"),
tr("<h2>Zint Barcode Studio 0.3</h2>"
2009-05-19 10:05:26 -04:00
"<p>A simple barcode generator"
"<p>Requires libzint 2.1.3 or greater."
"<p>Visit the <a href=\"http://www.zint.org.uk\">Zint Project Homepage</a> for more information."
"<p>Copyright &copy; 2009 Robin Stuart &amp; Bogdan Vatra.<br>"
"QR Code support by Kentaro Fukuchi.<br>"
"Released under the GNU General Public License ver. 3"
"<p>\"QR Code\" is a Registered Trademark of Denso Corp."
));
}
2008-07-18 10:49:14 -04:00
void MainWindow::on_fgcolor_clicked()
{
m_fgcolor=QColorDialog::getColor(m_fgcolor,this);
2009-04-26 18:04:51 -04:00
update_preview();
2008-07-18 10:49:14 -04:00
}
void MainWindow::on_bgcolor_clicked()
{
m_bgcolor=QColorDialog::getColor(m_bgcolor,this);
2009-04-26 18:04:51 -04:00
update_preview();
2008-07-18 10:49:14 -04:00
}
2009-05-19 10:05:26 -04:00
void MainWindow::change_print_scale()
{
/* This value is only used when printing (saving) to file */
m_bc.bc.setScale((float)spnScale->value());
}
void MainWindow::quit_now()
{
2009-05-21 17:00:23 -04:00
close();
2009-05-19 10:05:26 -04:00
}
2009-04-26 18:04:51 -04:00
void MainWindow::change_options()
2008-07-18 10:49:14 -04:00
{
2009-05-21 17:00:23 -04:00
QUiLoader uiload;
2009-04-26 18:04:51 -04:00
2009-05-21 17:00:23 -04:00
if (tabMain->count()==3)
tabMain->removeTab(1);
2009-04-26 18:04:51 -04:00
if(metaObject()->enumerator(0).value(bstyle->currentIndex()) == BARCODE_CODE128)
2008-09-24 05:38:32 -04:00
{
2009-05-21 17:00:23 -04:00
QFile file(":/grpC128.ui");
if (!file.open(QIODevice::ReadOnly))
return;
m_optionWidget=uiload.load(&file);
file.close();
tabMain->insertTab(1,m_optionWidget,tr("Code 128"));
2009-04-26 18:04:51 -04:00
chkComposite->setText(tr("Add 2D Component (GS1-128 only)"));
2009-05-21 17:00:23 -04:00
connect(m_optionWidget->findChild<QObject*>("radC128EAN"), SIGNAL(toggled( bool )), SLOT(composite_ean_check()));
connect(m_optionWidget->findChild<QObject*>("radC128Stand"), SIGNAL(clicked( bool )), SLOT(update_preview()));
connect(m_optionWidget->findChild<QObject*>("radC128CSup"), SIGNAL(clicked( bool )), SLOT(update_preview()));
connect(m_optionWidget->findChild<QObject*>("radC128EAN"), SIGNAL(clicked( bool )), SLOT(update_preview()));
connect(m_optionWidget->findChild<QObject*>("radC128HIBC"), SIGNAL(clicked( bool )), SLOT(update_preview()));
}
else
2009-04-26 18:04:51 -04:00
chkComposite->setText(tr("Add 2D Component"));
2009-05-21 17:00:23 -04:00
2009-04-26 18:04:51 -04:00
if(metaObject()->enumerator(0).value(bstyle->currentIndex()) == BARCODE_PDF417)
{
2009-05-21 17:00:23 -04:00
QFile file(":/grpPDF417.ui");
if (!file.open(QIODevice::ReadOnly))
return;
m_optionWidget=uiload.load(&file);
file.close();
tabMain->insertTab(1,m_optionWidget,tr("PDF417"));
2009-05-21 17:00:23 -04:00
connect(m_optionWidget->findChild<QObject*>("codewords"), SIGNAL(valueChanged( int )), SLOT(update_preview()));
connect(m_optionWidget->findChild<QObject*>("cmbPDFECC"), SIGNAL(currentIndexChanged( int )), SLOT(update_preview()));
connect(m_optionWidget->findChild<QObject*>("cmbPDFCols"), SIGNAL(currentIndexChanged( int )), SLOT(update_preview()));
connect(m_optionWidget->findChild<QObject*>("radPDFTruncated"), SIGNAL(clicked( bool )), SLOT(update_preview()));
connect(m_optionWidget->findChild<QObject*>("radPDFStand"), SIGNAL(clicked( bool )), SLOT(update_preview()));
connect(m_optionWidget->findChild<QObject*>("radPDFHIBC"), SIGNAL(clicked( bool )), SLOT(update_preview()));
2009-04-26 18:04:51 -04:00
}
if(metaObject()->enumerator(0).value(bstyle->currentIndex()) == BARCODE_MICROPDF417)
{
2009-05-21 17:00:23 -04:00
QFile file(":/grpMicroPDF.ui");
if (!file.open(QIODevice::ReadOnly))
return;
m_optionWidget=uiload.load(&file);
file.close();
tabMain->insertTab(1,m_optionWidget,tr("Micro PDF417"));
2009-05-21 17:00:23 -04:00
connect(m_optionWidget->findChild<QObject*>("cmbMPDFCols"), SIGNAL(currentIndexChanged( int )), SLOT(update_preview()));
connect(m_optionWidget->findChild<QObject*>("radMPDFStand"), SIGNAL(toggled( bool )), SLOT(update_preview()));
2009-04-26 18:04:51 -04:00
}
if(metaObject()->enumerator(0).value(bstyle->currentIndex()) == BARCODE_AZTEC)
{
2009-05-21 17:00:23 -04:00
QFile file(":/grpAztec.ui");
if (!file.open(QIODevice::ReadOnly))
return;
m_optionWidget=uiload.load(&file);
file.close();
tabMain->insertTab(1,m_optionWidget,tr("Aztec Code"));
2009-05-21 17:00:23 -04:00
connect(m_optionWidget->findChild<QObject*>("radAztecAuto"), SIGNAL(clicked( bool )), SLOT(update_preview()));
connect(m_optionWidget->findChild<QObject*>("radAztecSize"), SIGNAL(clicked( bool )), SLOT(update_preview()));
connect(m_optionWidget->findChild<QObject*>("radAztecECC"), SIGNAL(clicked( bool )), SLOT(update_preview()));
connect(m_optionWidget->findChild<QObject*>("cmbAztecSize"), SIGNAL(currentIndexChanged( int )), SLOT(update_preview()));
connect(m_optionWidget->findChild<QObject*>("cmbAztecECC"), SIGNAL(currentIndexChanged( int )), SLOT(update_preview()));
connect(m_optionWidget->findChild<QObject*>("chkAztecMode"), SIGNAL(stateChanged( int )), SLOT(update_preview()));
2009-04-26 18:04:51 -04:00
}
if(metaObject()->enumerator(0).value(bstyle->currentIndex()) == BARCODE_MSI_PLESSEY)
{
2009-05-21 17:00:23 -04:00
QFile file(":/grpMSICheck.ui");
if (!file.open(QIODevice::ReadOnly))
return;
m_optionWidget=uiload.load(&file);
file.close();
tabMain->insertTab(1,m_optionWidget,tr("MSI Plessey"));
2009-05-21 17:00:23 -04:00
connect(m_optionWidget->findChild<QObject*>("cmbMSICheck"), SIGNAL(currentIndexChanged( int )), SLOT(update_preview()));
2009-04-26 18:04:51 -04:00
}
if((metaObject()->enumerator(0).value(bstyle->currentIndex()) == BARCODE_CODE39) ||
(metaObject()->enumerator(0).value(bstyle->currentIndex()) == BARCODE_EXCODE39))
{
2009-05-21 17:00:23 -04:00
QFile file(":/grpC39.ui");
if (!file.open(QIODevice::ReadOnly))
return;
m_optionWidget=uiload.load(&file);
file.close();
tabMain->insertTab(1,m_optionWidget,tr("Code 39"));
2009-05-21 17:00:23 -04:00
connect(m_optionWidget->findChild<QObject*>("radC39Stand"), SIGNAL(clicked( bool )), SLOT(update_preview()));
connect(m_optionWidget->findChild<QObject*>("radC39Check"), SIGNAL(clicked( bool )), SLOT(update_preview()));
connect(m_optionWidget->findChild<QObject*>("radC39HIBC"), SIGNAL(clicked( bool )), SLOT(update_preview()));
if(metaObject()->enumerator(0).value(bstyle->currentIndex()) == BARCODE_EXCODE39)
{
if(m_optionWidget->findChild<QRadioButton*>("radC39HIBC")->isChecked() == true)
{
m_optionWidget->findChild<QRadioButton*>("radC39HIBC")->setChecked(false);
m_optionWidget->findChild<QRadioButton*>("radC39Stand")->setChecked(true);
}
m_optionWidget->findChild<QRadioButton*>("radC39HIBC")->setEnabled(false);
}
else
m_optionWidget->findChild<QRadioButton*>("radC39HIBC")->setEnabled(true);
2009-04-26 18:04:51 -04:00
}
if(metaObject()->enumerator(0).value(bstyle->currentIndex()) == BARCODE_CODABLOCKF)
{
2009-05-21 17:00:23 -04:00
QFile file(":/grpCodablock.ui");
if (!file.open(QIODevice::ReadOnly))
return;
m_optionWidget=uiload.load(&file);
file.close();
tabMain->insertTab(1,m_optionWidget,tr("Codablock-F"));
2009-05-21 17:00:23 -04:00
connect(m_optionWidget->findChild<QObject*>("radCodaStand"), SIGNAL(clicked( bool )), SLOT(update_preview()));
connect(m_optionWidget->findChild<QObject*>("radCodaGS1"), SIGNAL(clicked( bool )), SLOT(update_preview()));
connect(m_optionWidget->findChild<QObject*>("radCodaHIBC"), SIGNAL(clicked( bool )), SLOT(update_preview()));
2009-04-26 18:04:51 -04:00
}
if(metaObject()->enumerator(0).value(bstyle->currentIndex()) == BARCODE_CODE16K)
{
2009-05-21 17:00:23 -04:00
QFile file(":/grpC16k.ui");
if (!file.open(QIODevice::ReadOnly))
return;
m_optionWidget=uiload.load(&file);
file.close();
tabMain->insertTab(1,m_optionWidget,tr("Code 16K"));
2009-05-21 17:00:23 -04:00
connect(m_optionWidget->findChild<QObject*>("radC16kStand"), SIGNAL(toggled( bool )), SLOT(update_preview()));
2009-04-26 18:04:51 -04:00
}
if(metaObject()->enumerator(0).value(bstyle->currentIndex()) == BARCODE_DATAMATRIX)
{
2009-05-21 17:00:23 -04:00
QFile file(":/grpDM.ui");
if (!file.open(QIODevice::ReadOnly))
return;
m_optionWidget=uiload.load(&file);
file.close();
tabMain->insertTab(1,m_optionWidget,tr("Data Matrix"));
2009-05-21 17:00:23 -04:00
connect(m_optionWidget->findChild<QObject*>("cmbDMMode"), SIGNAL(currentIndexChanged( int )), SLOT(update_preview()));
connect(m_optionWidget->findChild<QObject*>("cmbDMMode"), SIGNAL(currentIndexChanged( int )), SLOT(datamatrix_options()));
connect(m_optionWidget->findChild<QObject*>("radDM200Stand"), SIGNAL(clicked( bool )), SLOT(update_preview()));
connect(m_optionWidget->findChild<QObject*>("radDM200GS1"), SIGNAL(clicked( bool )), SLOT(update_preview()));
connect(m_optionWidget->findChild<QObject*>("radDM200HIBC"), SIGNAL(clicked( bool )), SLOT(update_preview()));
connect(m_optionWidget->findChild<QObject*>("cmbDM200Size"), SIGNAL(currentIndexChanged( int )), SLOT(update_preview()));
connect(m_optionWidget->findChild<QObject*>("cmbDMNon200Size"), SIGNAL(currentIndexChanged( int )), SLOT(update_preview()));
2009-04-26 18:04:51 -04:00
datamatrix_options();
}
if(metaObject()->enumerator(0).value(bstyle->currentIndex()) == BARCODE_QRCODE)
{
2009-05-21 17:00:23 -04:00
QFile file(":/grpQR.ui");
if (!file.open(QIODevice::ReadOnly))
return;
m_optionWidget=uiload.load(&file);
file.close();
tabMain->insertTab(1,m_optionWidget,tr("QR Code"));
2009-05-21 17:00:23 -04:00
connect(m_optionWidget->findChild<QObject*>("radQRAuto"), SIGNAL(clicked( bool )), SLOT(update_preview()));
connect(m_optionWidget->findChild<QObject*>("radQRSize"), SIGNAL(clicked( bool )), SLOT(update_preview()));
connect(m_optionWidget->findChild<QObject*>("radQRECC"), SIGNAL(clicked( bool )), SLOT(update_preview()));
connect(m_optionWidget->findChild<QObject*>("cmbQRSize"), SIGNAL(currentIndexChanged( int )), SLOT(update_preview()));
connect(m_optionWidget->findChild<QObject*>("cmbQRECC"), SIGNAL(currentIndexChanged( int )), SLOT(update_preview()));
connect(m_optionWidget->findChild<QObject*>("chkQRHIBC"), SIGNAL(stateChanged( int )), SLOT(update_preview()));
2009-04-26 18:04:51 -04:00
}
if(metaObject()->enumerator(0).value(bstyle->currentIndex()) == BARCODE_MICROQR)
{
2009-05-21 17:00:23 -04:00
QFile file(":/grpMQR.ui");
if (!file.open(QIODevice::ReadOnly))
return;
m_optionWidget=uiload.load(&file);
file.close();
tabMain->insertTab(1,m_optionWidget,tr("Micro QR Code"));
2009-05-21 17:00:23 -04:00
connect(m_optionWidget->findChild<QObject*>("radMQRAuto"), SIGNAL(clicked( bool )), SLOT(update_preview()));
connect(m_optionWidget->findChild<QObject*>("radMQRSize"), SIGNAL(clicked( bool )), SLOT(update_preview()));
connect(m_optionWidget->findChild<QObject*>("radMQRECC"), SIGNAL(clicked( bool )), SLOT(update_preview()));
connect(m_optionWidget->findChild<QObject*>("cmbMQRSize"), SIGNAL(currentIndexChanged( int )), SLOT(update_preview()));
connect(m_optionWidget->findChild<QObject*>("cmbMQRECC"), SIGNAL(currentIndexChanged( int )), SLOT(update_preview()));
2009-04-26 18:04:51 -04:00
}
if(metaObject()->enumerator(0).value(bstyle->currentIndex()) == BARCODE_MAXICODE)
{
2009-05-26 19:07:16 -04:00
QFile file(":/grpMaxicode.ui");
2009-05-21 17:00:23 -04:00
if (!file.open(QIODevice::ReadOnly))
return;
m_optionWidget=uiload.load(&file);
file.close();
tabMain->insertTab(1,m_optionWidget,tr("Maxicode"));
2009-05-26 19:07:16 -04:00
connect(m_optionWidget->findChild<QObject*>("cmbMaxiMode"), SIGNAL(currentIndexChanged( int )), SLOT(update_preview()));
connect(m_optionWidget->findChild<QObject*>("cmbMaxiMode"), SIGNAL(currentIndexChanged( int )), SLOT(maxi_primary()));
connect(m_optionWidget->findChild<QObject*>("txtMaxiPrimary"), SIGNAL(textChanged( const QString& )), SLOT(update_preview()));
2009-04-26 18:04:51 -04:00
}
2009-05-16 10:19:43 -04:00
if(metaObject()->enumerator(0).value(bstyle->currentIndex()) == BARCODE_CHANNEL)
{
2009-05-21 17:00:23 -04:00
QFile file(":/grpChannel.ui");
if (!file.open(QIODevice::ReadOnly))
return;
m_optionWidget=uiload.load(&file);
file.close();
tabMain->insertTab(1,m_optionWidget,tr("Channel Code"));
2009-05-21 17:00:23 -04:00
connect(m_optionWidget->findChild<QObject*>("cmbChannel"), SIGNAL(currentIndexChanged( int )), SLOT(update_preview()));
2009-05-16 10:19:43 -04:00
}
2009-04-26 18:04:51 -04:00
switch(metaObject()->enumerator(0).value(bstyle->currentIndex()))
{
case BARCODE_CODE128:
case BARCODE_EANX:
case BARCODE_UPCA:
case BARCODE_UPCE:
case BARCODE_RSS14:
case BARCODE_RSS_LTD:
case BARCODE_RSS_EXP:
case BARCODE_RSS14STACK:
case BARCODE_RSS14STACK_OMNI:
case BARCODE_RSS_EXPSTACK:
grpComposite->show();
2008-09-24 05:38:32 -04:00
break;
2009-04-26 18:04:51 -04:00
default:
chkComposite->setChecked(false);
grpComposite->hide();
2008-09-24 05:38:32 -04:00
break;
}
2009-05-21 17:00:23 -04:00
tabMain->setCurrentIndex(0);
2008-07-18 10:49:14 -04:00
}
2009-04-26 18:04:51 -04:00
void MainWindow::composite_enable()
{
2009-05-21 17:00:23 -04:00
if(chkComposite->isChecked() == true)
{
2009-04-26 18:04:51 -04:00
lblCompType->setEnabled(true);
cmbCompType->setEnabled(true);
lblComposite->setEnabled(true);
txtComposite->setEnabled(true);
2009-05-21 17:00:23 -04:00
if (metaObject()->enumerator(0).value(bstyle->currentIndex())==BARCODE_CODE128)
m_optionWidget->findChild<QRadioButton*>("radC128EAN")->setChecked(true);
}
else
{
2009-04-26 18:04:51 -04:00
lblCompType->setEnabled(false);
cmbCompType->setEnabled(false);
lblComposite->setEnabled(false);
txtComposite->setEnabled(false);
}
}
void MainWindow::composite_ean_check()
{
2009-05-21 17:00:23 -04:00
if (metaObject()->enumerator(0).value(bstyle->currentIndex())!=BARCODE_CODE128)
return;
if(!m_optionWidget->findChild<QRadioButton*>("radC128EAN")->isChecked())
2009-04-26 18:04:51 -04:00
chkComposite->setChecked(false);
}
2008-10-07 10:28:32 -04:00
2009-04-26 18:04:51 -04:00
void MainWindow::datamatrix_options()
2008-10-07 10:28:32 -04:00
{
2009-05-21 17:00:23 -04:00
if (metaObject()->enumerator(0).value(bstyle->currentIndex())!=BARCODE_DATAMATRIX)
return;
if(m_optionWidget->findChild<QComboBox*>("cmbDMMode")->currentIndex() == 0)
{
m_optionWidget->findChild<QGroupBox*>("grpDMNon200")->hide();
m_optionWidget->findChild<QGroupBox*>("grpDM200")->show();
}
else
{
m_optionWidget->findChild<QGroupBox*>("grpDM200")->hide();
m_optionWidget->findChild<QGroupBox*>("grpDMNon200")->show();
2009-04-26 18:04:51 -04:00
}
2008-10-07 10:28:32 -04:00
}
2009-04-26 18:04:51 -04:00
void MainWindow::maxi_primary()
2008-10-07 10:28:32 -04:00
{
2009-05-26 19:07:16 -04:00
if (metaObject()->enumerator(0).value(bstyle->currentIndex())!=BARCODE_MAXICODE)
return;
if(m_optionWidget->findChild<QComboBox*>("cmbMaxiMode")->currentIndex() == 0) {
m_optionWidget->findChild<QLabel*>("lblMaxiPrimary")->setEnabled(true);
m_optionWidget->findChild<QLineEdit*>("txtMaxiPrimary")->setEnabled(true);
2009-04-26 18:04:51 -04:00
} else {
2009-05-26 19:07:16 -04:00
m_optionWidget->findChild<QLabel*>("lblMaxiPrimary")->setEnabled(false);
m_optionWidget->findChild<QLineEdit*>("txtMaxiPrimary")->setEnabled(false);
2009-04-26 18:04:51 -04:00
}
2008-10-07 10:28:32 -04:00
}
2009-04-26 18:04:51 -04:00
void MainWindow::update_preview()
2008-10-07 10:28:32 -04:00
{
2009-04-26 18:04:51 -04:00
QString error;
m_bc.ar=(Zint::QZint::AspectRatioMode)1;
if(chkComposite->isChecked() == true) {
m_bc.bc.setPrimaryMessage(txtData->text());
m_bc.bc.setText(txtComposite->toPlainText());
} else {
m_bc.bc.setText(txtData->text());
/*m_bc.bc.setPrimaryMessage(txtComposite->text());*/
}
m_bc.bc.setSecurityLevel(0);
m_bc.bc.setWidth(0);
m_bc.bc.setInputMode(UNICODE_MODE);
switch(metaObject()->enumerator(0).value(bstyle->currentIndex()))
{
case BARCODE_CODE128:
2009-05-21 17:00:23 -04:00
if(m_optionWidget->findChild<QRadioButton*>("radC128Stand")->isChecked())
2009-04-26 18:04:51 -04:00
m_bc.bc.setSymbol(BARCODE_CODE128);
2009-05-21 17:00:23 -04:00
if(m_optionWidget->findChild<QRadioButton*>("radC128CSup")->isChecked())
2009-04-26 18:04:51 -04:00
m_bc.bc.setSymbol(BARCODE_CODE128B);
2009-05-21 17:00:23 -04:00
if(m_optionWidget->findChild<QRadioButton*>("radC128EAN")->isChecked())
{
if(chkComposite->isChecked())
2009-04-26 18:04:51 -04:00
m_bc.bc.setSymbol(BARCODE_EAN128_CC);
2009-05-21 17:00:23 -04:00
else
2009-04-26 18:04:51 -04:00
m_bc.bc.setSymbol(BARCODE_EAN128);
}
2009-05-21 17:00:23 -04:00
if(m_optionWidget->findChild<QRadioButton*>("radC128HIBC")->isChecked())
2009-04-26 18:04:51 -04:00
m_bc.bc.setSymbol(BARCODE_HIBC_128);
break;
2009-05-21 17:00:23 -04:00
2009-04-26 18:04:51 -04:00
case BARCODE_EANX:
2009-05-21 17:00:23 -04:00
if(chkComposite->isChecked())
2009-04-26 18:04:51 -04:00
m_bc.bc.setSymbol(BARCODE_EANX_CC);
2009-05-21 17:00:23 -04:00
else
2009-04-26 18:04:51 -04:00
m_bc.bc.setSymbol(BARCODE_EANX);
break;
2009-05-21 17:00:23 -04:00
2009-04-26 18:04:51 -04:00
case BARCODE_UPCA:
2009-05-21 17:00:23 -04:00
if(chkComposite->isChecked())
2009-04-26 18:04:51 -04:00
m_bc.bc.setSymbol(BARCODE_UPCA_CC);
2009-05-21 17:00:23 -04:00
else
2009-04-26 18:04:51 -04:00
m_bc.bc.setSymbol(BARCODE_UPCA);
break;
2009-05-21 17:00:23 -04:00
2009-04-26 18:04:51 -04:00
case BARCODE_UPCE:
2009-05-21 17:00:23 -04:00
if(chkComposite->isChecked())
2009-04-26 18:04:51 -04:00
m_bc.bc.setSymbol(BARCODE_UPCE_CC);
2009-05-21 17:00:23 -04:00
else
2009-04-26 18:04:51 -04:00
m_bc.bc.setSymbol(BARCODE_UPCE);
break;
2009-05-21 17:00:23 -04:00
2009-04-26 18:04:51 -04:00
case BARCODE_RSS14:
2009-05-21 17:00:23 -04:00
if(chkComposite->isChecked())
2009-04-26 18:04:51 -04:00
m_bc.bc.setSymbol(BARCODE_RSS14_CC);
2009-05-21 17:00:23 -04:00
else
2009-04-26 18:04:51 -04:00
m_bc.bc.setSymbol(BARCODE_RSS14);
break;
2009-05-21 17:00:23 -04:00
2009-04-26 18:04:51 -04:00
case BARCODE_RSS_LTD:
2009-05-21 17:00:23 -04:00
if(chkComposite->isChecked())
2009-04-26 18:04:51 -04:00
m_bc.bc.setSymbol(BARCODE_RSS_LTD_CC);
2009-05-21 17:00:23 -04:00
else
2009-04-26 18:04:51 -04:00
m_bc.bc.setSymbol(BARCODE_RSS_LTD);
break;
2009-05-21 17:00:23 -04:00
2009-04-26 18:04:51 -04:00
case BARCODE_RSS_EXP:
2009-05-21 17:00:23 -04:00
if(chkComposite->isChecked())
2009-04-26 18:04:51 -04:00
m_bc.bc.setSymbol(BARCODE_RSS_EXP_CC);
2009-05-21 17:00:23 -04:00
else
2009-04-26 18:04:51 -04:00
m_bc.bc.setSymbol(BARCODE_RSS_EXP);
break;
2009-05-21 17:00:23 -04:00
2009-04-26 18:04:51 -04:00
case BARCODE_RSS14STACK:
2009-05-21 17:00:23 -04:00
if(chkComposite->isChecked())
2009-04-26 18:04:51 -04:00
m_bc.bc.setSymbol(BARCODE_RSS14STACK_CC);
2009-05-21 17:00:23 -04:00
else
2009-04-26 18:04:51 -04:00
m_bc.bc.setSymbol(BARCODE_RSS14STACK);
break;
2009-05-21 17:00:23 -04:00
2009-04-26 18:04:51 -04:00
case BARCODE_RSS14STACK_OMNI:
2009-05-21 17:00:23 -04:00
if(chkComposite->isChecked())
2009-04-26 18:04:51 -04:00
m_bc.bc.setSymbol(BARCODE_RSS14_OMNI_CC);
2009-05-21 17:00:23 -04:00
else
2009-04-26 18:04:51 -04:00
m_bc.bc.setSymbol(BARCODE_RSS14STACK_OMNI);
break;
2009-05-21 17:00:23 -04:00
2009-04-26 18:04:51 -04:00
case BARCODE_RSS_EXPSTACK:
2009-05-21 17:00:23 -04:00
if(chkComposite->isChecked())
2009-04-26 18:04:51 -04:00
m_bc.bc.setSymbol(BARCODE_RSS_EXPSTACK_CC);
2009-05-21 17:00:23 -04:00
else
2009-04-26 18:04:51 -04:00
m_bc.bc.setSymbol(BARCODE_RSS_EXPSTACK);
break;
2009-05-21 17:00:23 -04:00
2009-04-26 18:04:51 -04:00
case BARCODE_PDF417:
2009-05-21 17:00:23 -04:00
m_bc.bc.setWidth(m_optionWidget->findChild<QComboBox*>("cmbPDFCols")->currentIndex());
m_bc.bc.setSecurityLevel(m_optionWidget->findChild<QComboBox*>("cmbPDFECC")->currentIndex()-1);
m_bc.bc.setPdf417CodeWords(m_optionWidget->findChild<QSpinBox*>("codewords")->value());
if(m_optionWidget->findChild<QRadioButton*>("radPDFStand")->isChecked())
2009-04-26 18:04:51 -04:00
m_bc.bc.setSymbol(BARCODE_PDF417);
2009-05-21 17:00:23 -04:00
if(m_optionWidget->findChild<QRadioButton*>("radPDFTruncated")->isChecked())
2009-04-26 18:04:51 -04:00
m_bc.bc.setSymbol(BARCODE_PDF417TRUNC);
2009-05-21 17:00:23 -04:00
if(m_optionWidget->findChild<QRadioButton*>("radPDFHIBC")->isChecked())
2009-04-26 18:04:51 -04:00
m_bc.bc.setSymbol(BARCODE_HIBC_PDF);
break;
2009-05-21 17:00:23 -04:00
2009-04-26 18:04:51 -04:00
case BARCODE_MICROPDF417:
2009-05-21 17:00:23 -04:00
m_bc.bc.setWidth(m_optionWidget->findChild<QComboBox*>("cmbMPDFCols")->currentIndex());
if(m_optionWidget->findChild<QRadioButton*>("radMPDFStand")->isChecked())
2009-04-26 18:04:51 -04:00
m_bc.bc.setSymbol(BARCODE_MICROPDF417);
2009-05-21 17:00:23 -04:00
if(m_optionWidget->findChild<QRadioButton*>("radMPDFHIBC")->isChecked())
2009-04-26 18:04:51 -04:00
m_bc.bc.setSymbol(BARCODE_HIBC_MICPDF);
break;
2009-05-21 17:00:23 -04:00
2009-04-26 18:04:51 -04:00
case BARCODE_AZTEC:
m_bc.bc.setSymbol(BARCODE_AZTEC);
2009-05-21 17:00:23 -04:00
if(m_optionWidget->findChild<QRadioButton*>("radAztecSize")->isChecked())
m_bc.bc.setWidth(m_optionWidget->findChild<QComboBox*>("cmbAztecSize")->currentIndex() + 1);
if(m_optionWidget->findChild<QRadioButton*>("radAztecECC")->isChecked())
m_bc.bc.setSecurityLevel(m_optionWidget->findChild<QComboBox*>("cmbAztecECC")->currentIndex() + 1);
if(m_optionWidget->findChild<QCheckBox*>("chkAztecMode")->isChecked())
2009-04-26 18:04:51 -04:00
m_bc.bc.setInputMode(GS1_MODE);
break;
2009-05-21 17:00:23 -04:00
2009-04-26 18:04:51 -04:00
case MSI_PLESSEY:
m_bc.bc.setSymbol(BARCODE_MSI_PLESSEY);
2009-05-21 17:00:23 -04:00
m_bc.bc.setWidth(m_optionWidget->findChild<QComboBox*>("cmbMSICheck")->currentIndex());
2009-04-26 18:04:51 -04:00
break;
2009-05-21 17:00:23 -04:00
2009-04-26 18:04:51 -04:00
case BARCODE_CODE39:
2009-05-21 17:00:23 -04:00
if(m_optionWidget->findChild<QRadioButton*>("radC39HIBC")->isChecked())
m_bc.bc.setSymbol(BARCODE_HIBC_39);
else
2009-05-21 17:00:23 -04:00
{
2009-04-26 18:04:51 -04:00
m_bc.bc.setSymbol(BARCODE_CODE39);
2009-05-21 17:00:23 -04:00
if(m_optionWidget->findChild<QRadioButton*>("radC39Check")->isChecked())
2009-04-26 18:04:51 -04:00
m_bc.bc.setWidth(1);
}
2009-04-26 18:04:51 -04:00
break;
2009-05-21 17:00:23 -04:00
2009-04-26 18:04:51 -04:00
case BARCODE_EXCODE39:
m_bc.bc.setSymbol(BARCODE_EXCODE39);
2009-05-21 17:00:23 -04:00
if(m_optionWidget->findChild<QRadioButton*>("radC39Check")->isChecked())
2009-04-26 18:04:51 -04:00
m_bc.bc.setWidth(1);
2009-05-21 17:00:23 -04:00
2009-04-26 18:04:51 -04:00
break;
case BARCODE_CODE16K:
m_bc.bc.setSymbol(BARCODE_CODE16K);
2009-05-21 17:00:23 -04:00
if(m_optionWidget->findChild<QRadioButton*>("radC16kStand")->isChecked())
2009-04-26 18:04:51 -04:00
m_bc.bc.setInputMode(UNICODE_MODE);
2009-05-21 17:00:23 -04:00
else
2009-04-26 18:04:51 -04:00
m_bc.bc.setInputMode(GS1_MODE);
break;
2009-05-21 17:00:23 -04:00
2009-04-26 18:04:51 -04:00
case BARCODE_CODABLOCKF:
2009-05-21 17:00:23 -04:00
if(m_optionWidget->findChild<QRadioButton*>("radCodaGS1")->isChecked())
2009-04-26 18:04:51 -04:00
m_bc.bc.setInputMode(GS1_MODE);
2009-05-21 17:00:23 -04:00
if(m_optionWidget->findChild<QRadioButton*>("radCodaHIBC")->isChecked())
2009-04-26 18:04:51 -04:00
m_bc.bc.setSymbol(BARCODE_HIBC_BLOCKF);
2009-05-21 17:00:23 -04:00
else
m_bc.bc.setSymbol(BARCODE_CODABLOCKF);
2009-04-26 18:04:51 -04:00
break;
2009-05-21 17:00:23 -04:00
2009-04-26 18:04:51 -04:00
case BARCODE_DATAMATRIX:
2009-05-21 17:00:23 -04:00
m_bc.bc.setSecurityLevel(m_optionWidget->findChild<QComboBox*>("cmbDMMode")->currentIndex() + 1);
if(m_optionWidget->findChild<QComboBox*>("cmbDMMode")->currentIndex() == 0)
{ /* ECC 200 */
if(m_optionWidget->findChild<QRadioButton*>("radDM200HIBC")->isChecked())
2009-04-26 18:04:51 -04:00
m_bc.bc.setSymbol(BARCODE_HIBC_DM);
2009-05-21 17:00:23 -04:00
else
2009-04-26 18:04:51 -04:00
m_bc.bc.setSymbol(BARCODE_DATAMATRIX);
2009-05-21 17:00:23 -04:00
if(m_optionWidget->findChild<QRadioButton*>("radDM200GS1")->isChecked())
2009-04-26 18:04:51 -04:00
m_bc.bc.setInputMode(GS1_MODE);
2009-05-21 17:00:23 -04:00
m_bc.bc.setWidth(m_optionWidget->findChild<QComboBox*>("cmbDM200Size")->currentIndex());
}
else
{ /* Not ECC 200 */
2009-04-26 18:04:51 -04:00
m_bc.bc.setSymbol(BARCODE_DATAMATRIX);
2009-05-21 17:00:23 -04:00
m_bc.bc.setWidth(m_optionWidget->findChild<QComboBox*>("cmbDMNon200Size")->currentIndex());
2009-04-26 18:04:51 -04:00
}
break;
2009-05-21 17:00:23 -04:00
2009-04-26 18:04:51 -04:00
case BARCODE_QRCODE:
2009-05-21 17:00:23 -04:00
if(m_optionWidget->findChild<QCheckBox*>("chkQRHIBC")->isChecked())
2009-04-26 18:04:51 -04:00
m_bc.bc.setSymbol(BARCODE_HIBC_QR);
2009-05-21 17:00:23 -04:00
else
2009-04-26 18:04:51 -04:00
m_bc.bc.setSymbol(BARCODE_QRCODE);
2009-05-21 17:00:23 -04:00
if(m_optionWidget->findChild<QRadioButton*>("radQRSize")->isChecked())
m_bc.bc.setWidth(m_optionWidget->findChild<QComboBox*>("cmbQRSize")->currentIndex() + 1);
if(m_optionWidget->findChild<QRadioButton*>("radQRECC")->isChecked())
m_bc.bc.setSecurityLevel(m_optionWidget->findChild<QComboBox*>("cmbQRECC")->currentIndex() + 1);
2009-04-26 18:04:51 -04:00
break;
2009-05-21 17:00:23 -04:00
2009-04-26 18:04:51 -04:00
case BARCODE_MICROQR:
m_bc.bc.setSymbol(BARCODE_MICROQR);
2009-05-21 17:00:23 -04:00
if(m_optionWidget->findChild<QRadioButton*>("radMQRSize")->isChecked())
m_bc.bc.setWidth(m_optionWidget->findChild<QComboBox*>("cmbMQRSize")->currentIndex() + 1);
if(m_optionWidget->findChild<QRadioButton*>("radMQRECC")->isChecked())
m_bc.bc.setSecurityLevel(m_optionWidget->findChild<QComboBox*>("cmbMQRECC")->currentIndex() + 1);
2009-04-26 18:04:51 -04:00
break;
2009-05-21 17:00:23 -04:00
2009-04-26 18:04:51 -04:00
case BARCODE_MAXICODE:
m_bc.bc.setSymbol(BARCODE_MAXICODE);
2009-05-26 19:07:16 -04:00
if(m_optionWidget->findChild<QComboBox*>("cmbMaxiMode")->currentIndex() == 0)
2009-05-21 17:00:23 -04:00
{
2009-04-26 18:04:51 -04:00
m_bc.bc.setSecurityLevel(2);
2009-05-26 19:07:16 -04:00
m_bc.bc.setPrimaryMessage(m_optionWidget->findChild<QLineEdit*>("txtMaxiPrimary")->text());
2009-04-26 18:04:51 -04:00
}
2009-05-21 17:00:23 -04:00
else
2009-05-26 19:07:16 -04:00
m_bc.bc.setSecurityLevel(m_optionWidget->findChild<QComboBox*>("cmbMaxiMode")->currentIndex() + 3);
2009-04-26 18:04:51 -04:00
break;
2009-05-21 17:00:23 -04:00
2009-05-16 10:19:43 -04:00
case BARCODE_CHANNEL:
m_bc.bc.setSymbol(BARCODE_CHANNEL);
2009-05-21 17:00:23 -04:00
if(m_optionWidget->findChild<QComboBox*>("cmbChannel")->currentIndex() == 0)
2009-05-16 10:19:43 -04:00
m_bc.bc.setWidth(0);
2009-05-21 17:00:23 -04:00
else
m_bc.bc.setWidth(m_optionWidget->findChild<QComboBox*>("cmbChannel")->currentIndex() + 2);
2009-05-16 10:19:43 -04:00
break;
2009-04-26 18:04:51 -04:00
default:
m_bc.bc.setSymbol(metaObject()->enumerator(0).value(bstyle->currentIndex()));
break;
}
2009-05-21 17:00:23 -04:00
if(chkComposite->isChecked())
2009-04-26 18:04:51 -04:00
m_bc.bc.setSecurityLevel(cmbCompType->currentIndex());
2009-05-21 17:00:23 -04:00
2009-04-26 18:04:51 -04:00
m_bc.bc.setBorderType((Zint::QZint::BorderType)(btype->currentIndex()*2));
m_bc.bc.setBorderWidth(bwidth->value());
m_bc.bc.setHeight(heightb->value());
m_bc.bc.setWhitespace(spnWhitespace->value());
2009-04-26 18:04:51 -04:00
m_bc.bc.setFgColor(m_fgcolor);
m_bc.bc.setBgColor(m_bgcolor);
m_bc.update();
view->scene()->update();
2008-10-07 10:28:32 -04:00
}
2009-04-26 18:04:51 -04:00