r20308 by craig - Apply major update to barcode generator from Terry Burton. More changes coming. Does not fix strange ps placement hang seen in #13237

scribus-commit scribus-commit at lists.scribus.net
Tue Aug 11 16:55:41 UTC 2015


Author: craig
Date: Tue Aug 11 16:55:41 2015
New Revision: 20308

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=20308
Log:
Apply major update to barcode generator from Terry Burton. More changes coming. Does not fix strange ps placement hang seen in #13237

Modified:
    trunk/Scribus/scribus/plugins/barcodegenerator/barcode.cpp
    trunk/Scribus/scribus/plugins/barcodegenerator/barcodegenerator.cpp
    trunk/Scribus/scribus/plugins/barcodegenerator/barcodegenerator.h
    trunk/Scribus/scribus/plugins/barcodegenerator/barcodegenerator.ui

Modified: trunk/Scribus/scribus/plugins/barcodegenerator/barcode.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=20308&path=/trunk/Scribus/scribus/plugins/barcodegenerator/barcode.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/barcodegenerator/barcode.cpp (original)
+++ trunk/Scribus/scribus/plugins/barcodegenerator/barcode.cpp Tue Aug 11 16:55:41 2015
@@ -10,6 +10,7 @@
 #include "scribuscore.h"
 #include "scribusstructs.h"
 #include "iconmanager.h"
+#include "scpaths.h"
 
 Barcode::Barcode() : ScActionPlugin()
 {
@@ -45,12 +46,23 @@
 {
 	AboutData* about = new AboutData;
 	Q_CHECK_PTR(about);
+
 	about->authors = QString::fromUtf8("Terry Burton - <tez at terryburton.co.uk>, Petr Van\xc4\x9bk <petr at scribus.info>");
-	about->shortDescription = tr("Scribus frontend for Pure PostScript Barcode Writer");
-	about->description = "Barcode Writer in Pure PostScript is an award-winning open source barcode maker, as used by NASA, that facilitates the printing of all major barcode symbologies entirely within level 2 PostScript, ideal for variable data printing. The complete process of generating printed barcodes is performed entirely within the printer (or print system) so that it is no longer the responsibility of your application or a library. There is no need for any barcode fonts and the flexibility offered by direct PostScript means you can avoid re-implementing barcode generator code, or migrating to new libraries, whenever your project language needs change.\nhttp://www.terryburton.co.uk/barcodewriter/ . Hence, this plugin requires Ghostscript to be installed on your system.";
-	about->version = "Backend: 2014-12-11";
+	about->shortDescription = tr("Scribus frontend for Barcode Writer in Pure PostScript");
+	about->description = "Barcode Writer in Pure Postscript generates all barcode formats entirely within PostScript hence this plugin requires Ghostscript to be installed on your system. http://bwipp.terryburton.co.uk";
+
+	// Extract the version information from BWIPP
+        QFile f( ScPaths::instance().shareDir() + QString("/plugins/barcode.ps") );
+        f.open(QIODevice::ReadOnly);
+        QTextStream ts(&f);
+        QString bwipp = ts.read(150);
+        f.close();
+        QRegExp rx("\\n% Barcode Writer in Pure PostScript - Version ([\\d-]+)\\n");
+	rx.indexIn(bwipp);
+	about->version = "Backend: "+rx.cap(1);
+
 	// about->releaseDate
-	about->copyright = QString::fromUtf8("Backend: Copyright (c) 2004-2014 Terry Burton - tez at terryburton.co.uk\nFrontend: Copyright (c) 2005 Petr Van\xc4\x9bk - petr at scribus.info");
+	about->copyright = QString::fromUtf8("Backend: Copyright (c) 2004-2015 Terry Burton - tez at terryburton.co.uk\nFrontend: Copyright (c) 2005 Petr Van\xc4\x9bk - petr at scribus.info");
 	about->license = "Backend: MIT/X-Consortium, Frontend: GPL";
 	return about;
 }

Modified: trunk/Scribus/scribus/plugins/barcodegenerator/barcodegenerator.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=20308&path=/trunk/Scribus/scribus/plugins/barcodegenerator/barcodegenerator.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/barcodegenerator/barcodegenerator.cpp (original)
+++ trunk/Scribus/scribus/plugins/barcodegenerator/barcodegenerator.cpp Tue Aug 11 16:55:41 2015
@@ -19,17 +19,13 @@
 
 
 #include <QTextStream>
-
-BarcodeType::BarcodeType(const QString &cmd, const QString &exa,
-	                     const QString &comm, const QString &regExp,
-						 bool includeCheck, bool includeCheckInText)
+#include <QStandardItemModel>
+
+BarcodeType::BarcodeType(const QString &cmd, const QString &exa, const QString &exaop)
 {
 	command = cmd;
-	example = exa;
-	comment = comm;
-	regularExp = regExp;
-	this->includeCheck = includeCheck;
-	this->includeCheckInText = includeCheckInText;
+	exampleContents = exa;
+	exampleOptions = exaop;
 }
 
 BarcodeGenerator::BarcodeGenerator(QWidget* parent, const char* name)
@@ -38,78 +34,228 @@
 	ui.setupUi(this);
 	setObjectName(name);
 	setModal(true);
-	map[tr("EAN-13")] = BarcodeType("ean13", "9780956078001", tr("12 or 13 digits"),
-	                                "[0-9]{12,13}");
-	map[tr("EAN-8")] = BarcodeType("ean8", "12345670", tr("8 digits"),
-	                               "[0-9]{8,8}");
-	map[tr("UPC-A")] = BarcodeType("upca", "78858101497", tr("11 or 12 digits"),
-	                               "[0-9]{11,12}");
-	map[tr("UPC-E")] = BarcodeType("upce", "0123456", tr("7 or 8 digits"),
-	                               "[0-9]{7,8}");
-	map[tr("EAN-5")] = BarcodeType("ean5", "90200", tr("5 digits"),
-	                               "[0-9]{5,5}");
-	map[tr("EAN-2")] = BarcodeType("ean2", "42", tr("2 digits"),
-	                               "[0-9]{2,2}");
-	map[tr("ISBN")] = BarcodeType("isbn", "978-0-9560780-0-1",
-	                              tr("12 or 13 digits with dashes. The legacy ISBN-10 format accepts 9 or 10 digits with dashes, but this standard was depreciated for public use after 1st January 2007. (Note: To convert an old ISBN-10 to a new ISBN-13, prefix 978- to the first 9 digits, e.g. 1-56592-479-7 -> 978-1-56592-479. The final check-digit will be calculated automatically.)"),
-	                              "[0-9]*\\-[0-9]*\\-[0-9]*");
-//    "Code-11"] = "code11"
-	map[tr("Code-39")] = BarcodeType("code39", "CODE-39",
-	                                 tr("Variable number of characters, digits and any of the symbols -. *$/+%."),
-	                                 "[0-9a-zA-Z\\-\\.\\ \\*\\$\\/\\+\\%]*",
-	                                 true, true);
-//    "Code-93"] = "code93"
-	map[tr("Code-128")] = BarcodeType("code128", "Count1234567!",
-	                                  tr("Any data."),
-	                                  ".*",
-	                                  false, false);
-	map[tr("GS1-128")] = BarcodeType("gs1-128", "(01)95012345678903(3103)000123",
-										 tr("GS1 Application Identifier standard format. FNC1 characters are included automatically."),
-										 ".*",false,false);
-	map[tr("Rationalized Codabar")] = BarcodeType("rationalizedCodabar", "A0123456789D",
-	                                              tr("Variable number of digits and any of the symbols -$:/.+ABCD."),
-	                                              "[0-9A-D\\-\\$\\:\\/\\.\\+]*",
-	                                              true, true);
-	map[tr("Interleaved 2 of 5")] = BarcodeType("interleaved2of5", "05012345678900",
-	                                            tr("Variable number of digits"),
-	                                            "[0-9]*",
-	                                            true, true);
-	map[tr("ITF-14")] = BarcodeType("interleaved2of5", "05012345678900",
-	                                tr("Variable number of digits. An ITF-14 is 14 characters and does not have a check digit"),
-	                                "[0-9]*",
-	                                true, true);
-	map[tr("Code 2 of 5")] = BarcodeType("code2of5", "0123456789",
-	                                     tr("Variable number of digits"),
-	                                     "[0-9]*");
-	map[tr("Postnet")] = BarcodeType("postnet", "012345678",
-	                                 tr("Variable number of digits"),
-	                                 "[0-9]*",
-	                                 false, true);
-	map[tr("Royal Mail")] = BarcodeType("royalmail", "LE28HS9Z",
-	                                    tr("Variable number of digits and capital letters"),
-	                                    "[0-9A-Z]*",
-	                                    false, true);
-//    "Auspost"] = "auspost"
-	map[tr("MSI")] = BarcodeType("msi", "0120823635162", tr("Variable number of digits"),
-	                             "[0-9]*",
-	                             true, true);
-//    "KIX"] = "kix"
-	map[tr("Plessey")] = BarcodeType("plessey", "012345ABCDEF",
-	                                tr("Variable number of hexadecimal characters"),
-	                                "[0-9A-F]*",
-	                                false, true);
-	map[tr("QR Code")] = BarcodeType("qrcode", "http://www.scribus.net",
-	                                 tr("Variable number of characters, digits and any symbols."),
-	                                 ".*",
-	                                 false, false);
-	//    "Symbol"] = "symbol"
-
-	initializeQROptions();
-
-	useSamples = true;
+
+	/*
+	 *  We extract the barcode information from the BWIPP metadata which looks like this:
+	 *
+	 *  % --BEGIN ENCODER gs1-128--
+	 *  % --REQUIRES preamble raiseerror renlinear code128--
+	 *  % --DESC: GS1-128
+	 *  % --EXAM: (01)95012345678903(3103)000123
+	 *  % --EXOP: includetext
+	 *  % --RNDR: renlinear
+	 *
+	 */
+
+	QFile f( ScPaths::instance().shareDir() + QString("/plugins/barcode.ps") );
+	f.open(QIODevice::ReadOnly);
+	QTextStream ts(&f);
+	QString bwipp = ts.readAll();
+	f.close();
+
+	QRegExp rx(
+		"\\n% --BEGIN (RESOURCE|RENDERER|ENCODER) ([\\w-]+)--\\n"
+		"(.*\\n)?"
+		"(%%BeginResource.*\\n)"
+		"% --END \\1 \\2--\\n");
+	rx.setMinimal(true);
+	int pos = 0;
+	while ( (pos = rx.indexIn(bwipp, pos)) != -1 )
+	{
+		int len=rx.matchedLength();
+		QString restype=rx.cap(1);
+	 	QString resname=rx.cap(2);
+	 	QString reshead=rx.cap(3);
+	 	QString resbody=rx.cap(4);
+
+	 	resbodys[resname]=resbody;
+
+	 	if (restype=="ENCODER")
+		{
+	     		QRegExp rxhead(
+	         		"% --REQUIRES (.*)--\\n"
+	         		"% --DESC:(.*)\\n"
+	         		"% --EXAM:(.*)\\n"
+	         		"% --EXOP:(.*)\\n"
+	         		"% --RNDR:(.*)\\n"
+	     		);
+	     		rxhead.indexIn(reshead);
+	     		resreqs[resname]=rxhead.cap(1).trimmed();
+	     		resdescs[resname]=rxhead.cap(2).trimmed();
+	     		resexams[resname]=rxhead.cap(3).trimmed();
+	     		resexops[resname]=rxhead.cap(4).trimmed();
+	     		resrndrs[resname]=rxhead.cap(5).trimmed();
+	     		encoderlist.append(resname);
+	 	}
+		pos+=len;
+    	}
+
+	QString enc;
+	foreach (enc, encoderlist) map[resdescs[enc]] = BarcodeType(enc, resexams[enc], resexops[enc]);
+
+	/*
+	 *  Ultimately all of this static data about the capabilities of each barcode
+	 *  encoder will be replaced by data read from the barcode.ps metadata, when 
+	 *  such data exists...
+	 *
+	 */ 
+
+	// Content for the version and ecc combos
+	resvers["qrcode"]="1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40";
+	resecls["qrcode"]="L,Q,M,H";
+	resvers["gs1qrcode"]=resvers["qrcode"];
+	resecls["gs1qrcode"]=resecls["qrcode"];
+	resvers["hibcqrcode"]=resvers["qrcode"];
+	resecls["hibcqrcode"]=resecls["qrcode"];
+	resvers["microqrcode"]="M1,M2,M3,M4";
+	resecls["microqrcode"]="L,Q,M,H";
+	resvers["datamatrix"]="10x10,12x12,14x14,16x16,18x18,20x20,22x22,24x24,26x26,32x32,36x36,40x40,44x44,48x48,52x52,64x64,72x72,80x80,88x88,96x96,104x104,120x120,132x132,144x144,8x18,8x32,12x26,12x36,16x36,16x48";
+	resecls["datamatrix"]="";
+	resvers["gs1datamatrix"]=resvers["datamatrix"];
+	resecls["gs1datamatrix"]=resvers["datamatrix"];
+        resvers["hibcdatamatrix"]=resvers["datamatrix"];
+        resecls["hibcdatamatrix"]=resecls["datamatrix"];
+	resvers["azteccode"]="1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32";
+	resvlbl["azteccode"]="Layers";
+	resecls["azteccode"]="5,10,15,20,25,30,35,40,45,50,55,60,65,70,75,80,85,90,95";
+	resvers["azteccodecompact"]="1,2,3,4";
+	resvlbl["azteccodecompact"]=resvlbl["azteccode"];
+	resecls["azteccodecompact"]=resecls["azteccode"];
+	resvers["pdf417"]="1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30";
+	resvlbl["pdf417"]="Columns";
+	resecls["pdf417"]="1,2,3,4,5";
+	resvers["pdf417compact"]=resvers["pdf417"];
+	resvlbl["pdf417compact"]=resvlbl["pdf417"];
+	resecls["pdf417compact"]=resecls["pdf417"];
+	resvers["hibcpdf417"]=resvers["pdf417"];
+	resvlbl["hibcpdf417"]=resvlbl["pdf417"];
+	resecls["hibcpdf417"]=resecls["pdf417"];
+	resvers["micropdf417"]="1x11,1x14,1x17,1x20,1x24,1x28,2x8,2x11,2x14,2x17,2x20,2x23,2x26,3x6,3x8,3x10,3x12,3x15,3x20,3x26,3x32,3x38,3x44,4x4,4x6,4x8,4x10,4x12,4x15,4x20,4x26,4x32,4x38,4x44";
+	resecls["micropdf417"]="";
+	resvers["hibcmicropdf417"]=resvers["micropdf417"];
+	resecls["hibcmicropdf417"]=resecls["micropdf417"];
+
+	// Which options checkboxes are enabled for each encoder
+	QStringList includetextAvail=encoderlist;
+        foreach (enc,includetextAvail) resincludetextAvail[enc]=true; 
+
+	QStringList guardwhitespaceAvail;
+	guardwhitespaceAvail << "ean13" << "ean8" << "isbn" << "ismn" << "issn" << "ean13composite";
+        guardwhitespaceAvail << "ean8composite";
+        foreach (enc,guardwhitespaceAvail) resguardwhitespaceAvail[enc]=true; 
+
+        QStringList includecheckAvail;
+        includecheckAvail << "bc412" << "channelcode" << "code11" << "code2of5" << "coop2of5" << "datalogic2of5";
+        includecheckAvail << "iata2of5" << "industrial2of5" << "matrix2of5" << "code39" << "code39ext";
+        includecheckAvail << "code93" << "code93ext" << "interleaved2of5" << "msi" << "rationalizedCodabar"; 
+        foreach (enc,includecheckAvail) resincludecheckAvail[enc]=true; 
+
+        QStringList includecheckintextAvail;
+        includecheckintextAvail << "bc412" << "code11" << "code2of5" << "coop2of5" << "datalogic2of5" << "iata2of5";
+        includecheckintextAvail << "industrial2of5" << "matrix2of5" << "code39" << "code39ext" << "interleaved2of5";
+        includecheckintextAvail << "japanpost" << "msi" << "planet" << "plessey" << "postnet" << "rationalizedCodabar" << "royalmail";
+        foreach (enc,includecheckintextAvail) resincludecheckintextAvail[enc]=true; 
+
+        QStringList parseAvail;
+        parseAvail << "azteccode" << "azteccodecompact" << "codablockf" << "hibccodablockf" << "code128" << "hibccode128" << "code16k" << "code39ext" << "code49";
+        parseAvail << "code93ext" << "codeone" << "datamatrix" << "hibcdatamatrix" << "maxicode" << "micropdf417" << "hibcmicropdf417" << "pdf417" << "hibcpdf417" << "pdf417compact";
+        parseAvail << "posicode" << "qrcode" << "hibcqrcode" << "microqrcode" << "telepen";
+        foreach (enc,parseAvail) resparseAvail[enc]=true; 
+
+        QStringList parsefncAvail;
+        parsefncAvail << "codablockf" << "code128" << "code16k" << "code49" << "code93" << "codeone";
+        parsefncAvail << "datamatrix" << "posicode" << "qrcode" << "microqrcode";
+        foreach (enc,parsefncAvail) resparsefncAvail[enc]=true; 
+
+        // Building up the bcCombo grouping the formats for readablity
+	ui.bcCombo->addItem(tr("Select a barcode format")); // to prevent 1st gs call
+        ui.bcCombo->insertSeparator(999);
+
+	QStringList bcpos;
+	bcpos << "EAN-13" << "EAN-8" << "UPC-A" << "UPC-E" << "ISBN" << "ISMN" << "ISSN";
+	ui.bcCombo->addItem(tr("Point of Sale"));
+        qobject_cast<QStandardItemModel *>(ui.bcCombo->model())->item(ui.bcCombo->findText("Point of Sale"))->setEnabled(false);
+	ui.bcCombo->addItems(bcpos);
+        ui.bcCombo->insertSeparator(999);
+
+	QStringList bcsupplychain;
+	bcsupplychain << "GS1-14" << "GS1 Data Matrix" << "GS1 QR Code" << "GS1-128" << "ITF-14" << "SSCC-18";
+	ui.bcCombo->addItem(tr("Supply Chain"));
+        qobject_cast<QStandardItemModel *>(ui.bcCombo->model())->item(ui.bcCombo->findText("Supply Chain"))->setEnabled(false);
+	ui.bcCombo->addItems(bcsupplychain);
+        ui.bcCombo->insertSeparator(999);
+
+	QStringList bctwodim;
+	bctwodim << "QR Code" << "Micro QR Code" << "Data Matrix" << "Aztec Code" << "Compact Aztec Code";
+        bctwodim << "Aztec Runes" << "PDF417" << "Compact PDF417" << "MicroPDF417";
+	ui.bcCombo->addItem(tr("Two-dimensional symbols"));
+        qobject_cast<QStandardItemModel *>(ui.bcCombo->model())->item(ui.bcCombo->findText("Two-dimensional symbols"))->setEnabled(false);
+	ui.bcCombo->addItems(bctwodim);
+        ui.bcCombo->insertSeparator(999);
+
+	QStringList bconedim;
+	bconedim << "Code 128" << "Code 39" << "Code 39 Extended" << "Code 93" << "Code 93 Extended";
+        bconedim << "Interleaved 2 of 5 (ITF)";
+	ui.bcCombo->addItem(tr("One-dimensional symbols"));
+        qobject_cast<QStandardItemModel *>(ui.bcCombo->model())->item(ui.bcCombo->findText("One-dimensional symbols"))->setEnabled(false);
+	ui.bcCombo->addItems(bconedim);
+        ui.bcCombo->insertSeparator(999);
+
+	QStringList bcdatabar;
+	bcdatabar << "GS1 DataBar Omnidirectional" << "GS1 DataBar Stacked Omnidirectional";
+        bcdatabar << "GS1 DataBar Expanded" << "GS1 DataBar Expanded Stacked" << "GS1 DataBar Truncated";
+	bcdatabar << "GS1 DataBar Stacked" << "GS1 DataBar Limited";
+	ui.bcCombo->addItem(tr("GS1 DataBar family"));
+        qobject_cast<QStandardItemModel *>(ui.bcCombo->model())->item(ui.bcCombo->findText("GS1 DataBar family"))->setEnabled(false);
+	ui.bcCombo->addItems(bcdatabar);
+        ui.bcCombo->insertSeparator(999);
+
+	QStringList bcpostal;
+	bcpostal << "AusPost 4 State Customer Code" << "Deutsche Post Identcode" << "Deutsche Post Leitcode";
+	bcpostal << "Japan Post 4 State Customer Code" << "Royal Dutch TPG Post KIX";
+	bcpostal << "Royal Mail 4 State Customer Code" << "USPS Intelligent Mail" << "USPS PLANET" << "USPS POSTNET";
+	ui.bcCombo->addItem(tr("Postal symbols"));
+        qobject_cast<QStandardItemModel *>(ui.bcCombo->model())->item(ui.bcCombo->findText("Postal symbols"))->setEnabled(false);
+	ui.bcCombo->addItems(bcpostal);
+        ui.bcCombo->insertSeparator(999);
+
+	QStringList bcpharma;
+	bcpharma << "Italian Pharmacode" << "Pharmaceutical Binary Code" << "Two-track Pharmacode";
+	bcpharma << "Pharmazentralnummer (PZN)" << "HIBC Codablock F" << "HIBC Code 128" << "HIBC Code 39";
+	bcpharma << "HIBC Data Matrix" << "HIBC MicroPDF417" << "HIBC PDF417" << "HIBC QR Code";
+	ui.bcCombo->addItem(tr("Pharmaceutical symbols"));
+        qobject_cast<QStandardItemModel *>(ui.bcCombo->model())->item(ui.bcCombo->findText("Pharmaceutical symbols"))->setEnabled(false);
+	ui.bcCombo->addItems(bcpharma);
+        ui.bcCombo->insertSeparator(999);
+
+	QStringList bclessused;
+	bclessused << "Code 11" << "Codabar" << "Code 25" << "COOP 2 of 5" << "Datalogic 2 of 5" << "IATA 2 of 5";
+	bclessused << "Industrial 2 of 5" << "Matrix 2 of 5" << "MSI Modified Plessey" << "Plessey UK";
+	bclessused << "PosiCode" << "Telepen" << "Telepen Numeric"<< "Code 16K" << "Codablock F" << "Code 49";
+	bclessused << "Code One";
+	ui.bcCombo->addItem(tr("Less-used symbols"));
+        qobject_cast<QStandardItemModel *>(ui.bcCombo->model())->item(ui.bcCombo->findText("Less-used symbols"))->setEnabled(false);
+	ui.bcCombo->addItems(bclessused);
+        ui.bcCombo->insertSeparator(999);
+
+	QStringList bcgs1comp;
+	bcgs1comp << "EAN-13 Composite" << "EAN-8 Composite" << "UPC-A Composite" << "UPC-E Composite";
+	bcgs1comp << "GS1 DataBar Omnidirectional Composite" << "GS1 DataBar Stacked Omnidirectional Composite";
+	bcgs1comp << "GS1 DataBar Expanded Composite" << "GS1 DataBar Expanded Stacked Composite";
+	bcgs1comp << "GS1 DataBar Truncated Composite" << "GS1 DataBar Stacked Composite";
+	bcgs1comp << "GS1 DataBar Limited Composite" << "GS1-128 Composite";
+	ui.bcCombo->addItem(tr("GS1 Composite symbols"));
+        qobject_cast<QStandardItemModel *>(ui.bcCombo->model())->item(ui.bcCombo->findText("GS1 Composite symbols"))->setEnabled(false);
+	ui.bcCombo->addItems(bcgs1comp);
+
+	/*
+	 *  End of the hard-coded data 
+	 *
+	 */
+
+//	useSamples = true;
 	guiColor = ui.codeEdit->palette().color(QPalette::Window);
-	ui.bcCombo->addItem(tr("Barcode")); // to prevent 1st gs call
-	ui.bcCombo->addItems(map.keys());
+
 	ui.okButton->setText(CommonStrings::tr_OK);
 	ui.cancelButton->setText(CommonStrings::tr_Cancel);
 	ui.resetButton->setIcon(IconManager::instance()->loadIcon("u_undo16.png"));
@@ -141,17 +287,6 @@
 	tmpFile = QDir::toNativeSeparators(ScPaths::getTempFileDir() + "bcode.png");
 	psFile = QDir::toNativeSeparators(ScPaths::getTempFileDir() + "bcode.ps");
 
-	// PS engine
-	psCommand.append("%!PS-Adobe-2.0 EPSF-2.0\n");
-	QFile f( ScPaths::instance().shareDir() + QString("/plugins/barcode.ps") );
-	f.open(QIODevice::ReadOnly);
-	QTextStream ts(&f);
-	QString s = ts.readAll();
-	int begin = s.indexOf("% --BEGIN TEMPLATE--");
-	int end = s.indexOf("% --END TEMPLATE--");
-	psCommand.append(s.mid(begin, end));
-	f.close();
-	psCommand.append("\n\n%command\n");
 	bcComboChanged();
 }
 
@@ -161,30 +296,46 @@
 	QFile::remove(tmpFile);
 }
 
-void BarcodeGenerator::initializeQROptions()
-{
-	QStringList qrEccKeys, qrEccValues;
-
-	ui.formatCombo->addItem("Standard", "format=full");
-	ui.formatCombo->addItem("Micro", "format=micro");
-
-	ui.eccCombo->addItem("Auto", "");
-	ui.eccCombo->addItem("L", "");
-	ui.eccCombo->addItem("M", "eclevel=M");
-	ui.eccCombo->addItem("Q", "eclevel=Q");
-	ui.eccCombo->addItem("H", "eclevel=H");
-
-	qrOptionsEnabled(false);
-	connect(ui.formatCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(bcComboChanged(int)));
-	connect(ui.eccCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(bcComboChanged(int)));
-}
-
-void BarcodeGenerator::qrOptionsEnabled(bool enabled) 
-{
-	ui.formatLabel->setEnabled(enabled);
-	ui.formatCombo->setEnabled(enabled);
-	ui.eccLabel->setEnabled(enabled);
-	ui.eccCombo->setEnabled(enabled);
+void BarcodeGenerator::updateOptions()
+{
+
+	QString enc=map[ui.bcCombo->currentText()].command;
+
+	ui.formatLabel->setText(resvlbl[enc]!="" ? resvlbl[enc]+":" : "Version:");
+	ui.formatCombo->blockSignals(true);
+	ui.formatCombo->clear();
+	ui.formatCombo->addItem("Auto");
+        if (resvers[enc]!="")
+	{
+		ui.formatCombo->insertSeparator(999);
+		ui.formatCombo->addItems(resvers[enc].split(","));
+		ui.formatLabel->setEnabled(true);
+		ui.formatCombo->setEnabled(true);
+	}
+	else
+	{
+		ui.formatLabel->setEnabled(false);
+		ui.formatCombo->setEnabled(false);
+	}
+        ui.formatCombo->blockSignals(false);
+
+	ui.eccCombo->blockSignals(true);
+        ui.eccCombo->clear();
+        ui.eccCombo->addItem("Auto");
+        if (resecls[enc]!="")
+	{
+		ui.eccCombo->insertSeparator(999);
+	        ui.eccCombo->addItems(resecls[enc].split(","));
+	        ui.eccLabel->setEnabled(true);
+	        ui.eccCombo->setEnabled(true);
+        }
+	else
+	{
+		ui.eccLabel->setEnabled(false);
+		ui.eccCombo->setEnabled(false);
+	}
+        ui.eccCombo->blockSignals(false);
+
 }
 
 void BarcodeGenerator::bcComboChanged(int i)
@@ -194,59 +345,207 @@
 
 void BarcodeGenerator::bcComboChanged()
 {
+	updateOptions();
+
 	if (ui.bcCombo->currentIndex() == 0)
 	{
 		ui.okButton->setEnabled(false);
 		ui.sampleLabel->setText(tr("Select Type"));
+                ui.codeEdit->clear();
+		ui.codeEdit->setEnabled(false);
+                ui.optionsEdit->clear();
+		ui.optionsEdit->setEnabled(false);
+	        ui.includetextCheck->setEnabled(false);
+	        ui.guardwhitespaceCheck->setEnabled(false);
+	        ui.includecheckCheck->setEnabled(false);
+	        ui.includecheckintextCheck->setEnabled(false);
+	        ui.parseCheck->setEnabled(false);
+	        ui.parsefncCheck->setEnabled(false);
+                ui.formatLabel->setEnabled(false);
+                ui.formatCombo->setEnabled(false);
+                ui.eccLabel->setEnabled(false);
+                ui.eccCombo->setEnabled(false);
+		ui.bgColorButton->setEnabled(false);
+		ui.lnColorButton->setEnabled(false);
+		ui.txtColorButton->setEnabled(false);
 		return;
 	}
 	
+	ui.codeEdit->setEnabled(true);
+	ui.optionsEdit->setEnabled(true);
+	ui.bgColorButton->setEnabled(true);
+	ui.lnColorButton->setEnabled(true);
+	ui.txtColorButton->setEnabled(true);
 	ui.okButton->setEnabled(true);
 
 	QString s = ui.bcCombo->currentText();
-	ui.commentEdit->setText(map[s].comment);
-	if (useSamples)
-	{
-		disconnect(ui.codeEdit, SIGNAL(textChanged(const QString&)), this, SLOT(codeEdit_textChanged(const QString&)));
-		ui.codeEdit->setText(map[s].example);
-		connect(ui.codeEdit, SIGNAL(textChanged(const QString&)), this, SLOT(codeEdit_textChanged(const QString&)));
-	}
-
-	ui.includeCheck->setEnabled(map[s].includeCheck ? true : false);
-	if (ui.textCheck->isChecked())
-		ui.includeCheckInText->setEnabled(map[s].includeCheckInText ? true : false);
-	else
-		ui.includeCheckInText->setEnabled(false);
-
-	if (QString::compare(s, "QR Code") == 0)
-		qrOptionsEnabled(true);
-	else
-		qrOptionsEnabled(false);
-
-	codeEdit_check(ui.codeEdit->text());
-	paintBarcode();
-}
-
-void BarcodeGenerator::textCheck_changed()
-{
-	bool s = ui.textCheck->checkState();
-	ui.txtColorButton->setEnabled(s);
-	ui.includeCheckInText->setEnabled(s);
-	paintBarcode();
-}
-
-void BarcodeGenerator::guardCheck_changed()
-{
-	paintBarcode();
-}
-
-void BarcodeGenerator::includeCheck_stateChanged(int)
-{
-	paintBarcode();
-}
-
-void BarcodeGenerator::includeCheckInText_stateChanged(int)
-{
+//	if (useSamples)
+//	{
+		ui.codeEdit->blockSignals(true);
+		ui.codeEdit->setText(map[s].exampleContents);
+		ui.codeEdit->blockSignals(false);
+		ui.optionsEdit->blockSignals(true);
+		ui.optionsEdit->setText(map[s].exampleOptions);
+		ui.optionsEdit->blockSignals(false);
+//	}
+
+        QString enc=map[s].command;
+        ui.includetextCheck->setEnabled(resincludetextAvail[enc]);
+        ui.guardwhitespaceCheck->setEnabled(resguardwhitespaceAvail[enc]);
+        ui.includecheckCheck->setEnabled(resincludecheckAvail[enc]);
+        ui.includecheckintextCheck->setEnabled(resincludetextAvail[enc] && resincludecheckintextAvail[enc]);
+        ui.parseCheck->setEnabled(resparseAvail[enc]);
+        ui.parsefncCheck->setEnabled(resparsefncAvail[enc]);
+
+	updateUIFromOptionsText();
+
+	paintBarcode();
+}
+
+void BarcodeGenerator::updateOptionsTextFromUI() {
+
+	QString opts=ui.optionsEdit->text();
+
+ 	if (ui.includetextCheck->isChecked()) {
+		if (!opts.contains(QRegExp("\\bincludetext\\b"))) { opts.append(" includetext"); }
+	} else { opts.replace(QRegExp("\\bincludetext\\b")," "); }
+
+ 	if (ui.guardwhitespaceCheck->isChecked()) {
+		if (!opts.contains(QRegExp("\\bguardwhitespace\\b"))) { opts.append(" guardwhitespace"); }
+	} else { opts.replace(QRegExp("\\bguardwhitespace\\b")," "); }
+
+ 	if (ui.includecheckCheck->isChecked()) {
+		if (!opts.contains(QRegExp("\\bincludecheck\\b"))) { opts.append(" includecheck"); }
+	} else { opts.replace(QRegExp("\\bincludecheck\\b")," "); }
+
+ 	if (ui.includecheckintextCheck->isChecked()) {
+		if (!opts.contains(QRegExp("\\bincludecheckintext\\b"))) { opts.append(" includecheckintext"); }
+	} else { opts.replace(QRegExp("\\bincludecheckintext\\b")," "); }
+
+ 	if (ui.parseCheck->isChecked()) {
+		if (!opts.contains(QRegExp("\\bparse\\b"))) { opts.append(" parse"); }
+	} else { opts.replace(QRegExp("\\bparse\\b")," "); }
+
+ 	if (ui.parsefncCheck->isChecked()) {
+		if (!opts.contains(QRegExp("\\bparsefnc\\b"))) { opts.append(" parsefnc"); }
+	} else { opts.replace(QRegExp("\\bparsefnc\\b")," "); }
+
+        QString enc=map[ui.bcCombo->currentText()].command;
+	QString vlbl=resvlbl[enc]!="" ? resvlbl[enc].toLower() : "version";
+
+ 	if (ui.formatCombo->currentIndex() != 0) {
+		QString t=ui.formatCombo->currentText();
+		if (!opts.contains(QRegExp("\\b"+vlbl+"=.*\\b"))) { opts.append(" "+vlbl+"="+t); } else
+		{ opts.replace(QRegExp("\\b"+vlbl+"=\\S*\\b"),vlbl+"="+t); }
+	} else { opts.replace(QRegExp("\\b"+vlbl+"=\\S*\\b")," "); }
+
+ 	if (ui.eccCombo->currentIndex() != 0) {
+		QString t=ui.eccCombo->currentText();
+		if (!opts.contains(QRegExp("\\beclevel=.*\\b"))) { opts.append(" eclevel="+t); } else
+		{ opts.replace(QRegExp("\\beclevel=\\S*\\b"),"eclevel="+t); }
+	} else { opts.replace(QRegExp("\\beclevel=\\S*\\b")," "); }
+
+	ui.optionsEdit->blockSignals(true);
+        ui.optionsEdit->setText(opts.simplified());
+	ui.optionsEdit->blockSignals(false);
+
+}
+
+void BarcodeGenerator::updateUIFromOptionsText()
+{
+	ui.includetextCheck->blockSignals(true);	
+	ui.includetextCheck->setChecked(ui.optionsEdit->text().contains(QRegExp("\\bincludetext\\b")));
+	ui.includetextCheck->blockSignals(false);	
+
+	ui.guardwhitespaceCheck->blockSignals(true);	
+	ui.guardwhitespaceCheck->setChecked(ui.optionsEdit->text().contains(QRegExp("\\bguardwhitespace\\b")));
+	ui.guardwhitespaceCheck->blockSignals(false);	
+
+	ui.includecheckCheck->blockSignals(true);	
+	ui.includecheckCheck->setChecked(ui.optionsEdit->text().contains(QRegExp("\\bincludecheck\\b")));
+	ui.includecheckCheck->blockSignals(false);	
+
+	ui.includecheckintextCheck->blockSignals(true);	
+	ui.includecheckintextCheck->setChecked(ui.optionsEdit->text().contains(QRegExp("\\bincludecheckintext\\b")));
+	ui.includecheckintextCheck->blockSignals(false);	
+
+	ui.parseCheck->blockSignals(true);	
+	ui.parseCheck->setChecked(ui.optionsEdit->text().contains(QRegExp("\\bparse\\b")));
+	ui.parseCheck->blockSignals(false);	
+
+	ui.parsefncCheck->blockSignals(true);	
+	ui.parsefncCheck->setChecked(ui.optionsEdit->text().contains(QRegExp("\\bparsefnc\\b")));
+	ui.parsefncCheck->blockSignals(false);	
+
+	QRegExp rxf("\\bversion=(\\S*)\\b");
+	ui.formatCombo->blockSignals(true);	
+        if (ui.optionsEdit->text().contains(rxf)) {
+		int idx=ui.formatCombo->findText(rxf.cap(1));
+		if (idx == -1) idx=0;
+		ui.formatCombo->setCurrentIndex(idx);
+        } else {
+		ui.formatCombo->setCurrentIndex(0);
+        }
+	ui.formatCombo->blockSignals(false);	
+
+	QRegExp rxe("\\beclevel=(\\S*)\\b");
+	ui.eccCombo->blockSignals(true);	
+        if (ui.optionsEdit->text().contains(rxe)) {
+                int idx=ui.eccCombo->findText(rxe.cap(1));
+                if (idx == -1) idx=0;
+                ui.eccCombo->setCurrentIndex(idx);
+        } else {
+		ui.eccCombo->setCurrentIndex(0);
+        }
+	ui.eccCombo->blockSignals(false);	
+
+}
+
+void BarcodeGenerator::on_includetextCheck_stateChanged(int)
+{
+	updateOptionsTextFromUI();
+	paintBarcode();
+}
+
+void BarcodeGenerator::on_guardwhitespaceCheck_stateChanged(int)
+{
+	updateOptionsTextFromUI();
+	paintBarcode();
+}
+
+void BarcodeGenerator::on_includecheckCheck_stateChanged(int)
+{
+	updateOptionsTextFromUI();
+	paintBarcode();
+}
+
+void BarcodeGenerator::on_includecheckintextCheck_stateChanged(int)
+{
+	updateOptionsTextFromUI();
+	paintBarcode();
+}
+
+void BarcodeGenerator::on_parseCheck_stateChanged(int)
+{
+	updateOptionsTextFromUI();
+	paintBarcode();
+}
+
+void BarcodeGenerator::on_parsefncCheck_stateChanged(int)
+{
+	updateOptionsTextFromUI();
+	paintBarcode();
+}
+
+void BarcodeGenerator::on_formatCombo_currentIndexChanged(int)
+{
+	updateOptionsTextFromUI();
+	paintBarcode();
+}
+
+void BarcodeGenerator::on_eccCombo_currentIndexChanged(int)
+{
+	updateOptionsTextFromUI();
 	paintBarcode();
 }
 
@@ -266,6 +565,7 @@
 	bgColor = d.selectedColor();
 	ui.bgLabel->setToolTip(d.selectedColorName());
 	paintColorSample(ui.bgLabel, bgColor);
+	updateOptionsTextFromUI();
 	paintBarcode();
 }
 
@@ -277,19 +577,19 @@
 	lnColor = d.selectedColor();
 	ui.linesLabel->setToolTip(d.selectedColorName());
 	paintColorSample(ui.linesLabel, lnColor);
+	updateOptionsTextFromUI();
 	paintBarcode();
 }
 
 void BarcodeGenerator::txtColorButton_pressed()
 {
 	PaintManagerDialog d(this, &ScCore->primaryMainWindow()->doc->docGradients, ScCore->primaryMainWindow()->doc->PageColors, "", &ScCore->primaryMainWindow()->doc->docPatterns, ScCore->primaryMainWindow()->doc, ScCore->primaryMainWindow());
-
 	if (!d.exec())
 		return;
-
 	txtColor = d.selectedColor();
 	ui.txtLabel->setToolTip(d.selectedColorName());
 	paintColorSample(ui.txtLabel, txtColor);
+	updateOptionsTextFromUI();
 	paintBarcode();
 }
 
@@ -325,32 +625,22 @@
 	reject();
 }
 
-bool BarcodeGenerator::codeEdit_check(const QString& )//s)
-{
-	/* probably not needed as the backend do it for us (PV)
-	QRegExp rx(map[bcCombo->currentText()].regularExp);
-	if (!rx.exactMatch(s))
-	{
-		ui.codeEdit->setPaletteBackgroundColor(QColor(255, 0, 0));
-		ui.sampleLabel->setText("<qt>" + tr("Barcode incomplete") + "</qt>");
-		ui.okButton->setEnabled(false);
-		return false;
-	}
-	else
-	{
-		ui.codeEdit->setPaletteBackgroundColor(guiColor);
-		ui.okButton->setEnabled(true);
-		paintBarcode();
-		return true;
-	} */
-	paintBarcode();
-	return true;
-}
-
 void BarcodeGenerator::codeEdit_textChanged(const QString& s)
 {
-	useSamples = false;
-	codeEdit_check(s);
+//	useSamples = false;
+	paintBarcode();
+}
+
+void BarcodeGenerator::optionsEdit_textChanged(const QString& s)
+{
+
+}
+
+void BarcodeGenerator::on_optionsEdit_textChanged(const QString &s )
+{
+//    useSamples = false;
+    updateUIFromOptionsText();
+    paintBarcode();
 }
 
 bool BarcodeGenerator::paintBarcode(const QString &fileName, int dpi)
@@ -358,33 +648,27 @@
 	QString realFile(fileName);
 	if (fileName.isEmpty())
 	    realFile = tmpFile;
-	QString opts("barcolor=%1 showbackground backgroundcolor=%2 textcolor=%3");
-	opts = opts.arg(lnColor.name().replace('#', "")) \
+
+	QString coloropts("barcolor=%1 showbackground backgroundcolor=%2 textcolor=%3");
+	coloropts = coloropts.arg(lnColor.name().replace('#', "")) \
 			.arg(bgColor.name().replace('#', "")) \
 			.arg(txtColor.name().replace('#', ""));
-	if (ui.textCheck->isChecked())
-		opts += " includetext";
-	if (ui.guardCheck->isChecked())
-		opts += " guardwhitespace";
-	if (ui.includeCheckInText->isChecked() & ui.includeCheckInText->isEnabled())
-		opts += " includecheckintext";
-	if (ui.includeCheck->isChecked() & ui.includeCheck->isEnabled())
-		opts += " includecheck";
-	if (ui.formatCombo->isEnabled())
-	{
-		int index = ui.formatCombo->currentIndex();
-		QVariant currentData = ui.formatCombo->itemData(index);
-		opts += " " + currentData.toString();
-	}
-	if (ui.eccCombo->isEnabled())
-	{
-		int index = ui.eccCombo->currentIndex();
-		QVariant currentData = ui.eccCombo->itemData(index);
-		opts += " " + currentData.toString();
-	}
-	QString comm("15 10 moveto (%1) (%2) /%3 /uk.co.terryburton.bwipp findresource exec");
-	comm = comm.arg(ui.codeEdit->text()).arg(opts).arg(map[ui.bcCombo->currentText()].command);
-	comm = psCommand + comm;
+
+	QString opts=ui.optionsEdit->text()+" "+coloropts;
+
+        // Assemble PS from encoder and requirement bodies
+        QString psCommand="%!PS-Adobe-2.0 EPSF-2.0\n";
+        QString req;
+        QString enc=map[ui.bcCombo->currentText()].command;
+	foreach (req, resreqs[enc].split(" ")) psCommand.append(resbodys[req]);
+        psCommand.append(resbodys[enc]);
+	QString comm("20 10 moveto <%1> <%2> /%3 /uk.co.terryburton.bwipp findresource exec\n");
+        QString bcdata(ui.codeEdit->text().toLatin1().toHex());
+        QString bcopts(opts.toLatin1().toHex());
+	comm = comm.arg(bcdata).arg(bcopts).arg(map[ui.bcCombo->currentText()].command);
+        psCommand.append(comm);
+        psCommand.append("showpage\n");
+
 	QFile f(psFile);
 	if (!f.open(QIODevice::WriteOnly))
 	{
@@ -392,36 +676,36 @@
 		return false;
 	}
 	QTextStream ts(&f);
-	ts << comm;
+	ts << psCommand;
 	f.close();
 
 	QStringList gargs;
 	// limit the area only for preview. EPS importer bounds the box itself.
 	if (realFile == tmpFile)
 	{
-		gargs.append("-dDEVICEWIDTHPOINTS=200");
+		gargs.append("-dDEVICEWIDTHPOINTS=440");
 		gargs.append("-dDEVICEHEIGHTPOINTS=150");
 	}
 	gargs.append( QString("-r%1").arg(dpi) );
 	gargs.append( QString("-sOutputFile=%1").arg(realFile) );
 	gargs.append( psFile );
 	qApp->changeOverrideCursor(Qt::WaitCursor);
+	QFile::remove(realFile);
 	int gs = callGS(gargs);
-	bool retval = true;
-	if (gs != 0)
-		retval = false;
+	bool retval = gs==0 && QFile::exists(realFile);   // GS returns 0 for BWIPP-handled errors
 	qApp->changeOverrideCursor(Qt::ArrowCursor);
 //	qApp->restoreOverrideCursor();
 	// setup only preview
 	if (realFile != tmpFile)
 		return retval;
-	if (gs == 0)
+	if (retval)
 	{
 	    ui.sampleLabel->setPixmap(QPixmap(realFile));
 		ui.okButton->setEnabled(true);
 	}
 	else
 	{
+// TODO capture gs output and display handled errors 
 		ui.sampleLabel->setText("<qt>" + tr("Barcode incomplete") + "</qt>");
 		ui.okButton->setEnabled(false);
 	}
@@ -430,6 +714,6 @@
 
 void BarcodeGenerator::resetButton_clicked()
 {
-	useSamples = true;
+//	useSamples = true;
 	bcComboChanged();
 }

Modified: trunk/Scribus/scribus/plugins/barcodegenerator/barcodegenerator.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=20308&path=/trunk/Scribus/scribus/plugins/barcodegenerator/barcodegenerator.h
==============================================================================
--- trunk/Scribus/scribus/plugins/barcodegenerator/barcodegenerator.h (original)
+++ trunk/Scribus/scribus/plugins/barcodegenerator/barcodegenerator.h Tue Aug 11 16:55:41 2015
@@ -29,23 +29,16 @@
 		/*! \brief Setup the Barcode entity.
 		\todo Make better regular expressions for BCDs.
 		\param cmd a Postsript command for given BC type
-		\param exa an example of the BC
-		\param comm a comment/help for current BC type
-		\param checkType how to validate the input */
-	    BarcodeType(const QString &cmd, const QString &exa,
-	                const QString &comm, const QString &regExp,
-	                bool includeCheck=false, bool includeCheckInText=false);
+		\param exa an example of the contents
+		\param exaop an example of the options */
+	    BarcodeType(const QString &cmd, const QString &exa, const QString &exaop);
 		~BarcodeType(){};
-		//! \brief postscript command
+		//! \brief PostScript encoder
 		QString command;
-		//! \brief BC example
-		QString example;
-		//! \brief comment or help for given BC type
-		QString comment;
-		//! \brief Regular expression for valid barcode of this type.
-		QString regularExp;
-		bool includeCheck;
-		bool includeCheckInText;
+		//! \brief BC example contents
+		QString exampleContents;
+		//! \brief BC example options
+		QString exampleOptions;
 };
 
 
@@ -78,6 +71,39 @@
 		//! \brief BC/BC type mapping. QMap keys are used as BC names.
 		BarcodeMap map;
 
+		//! \brief List of available barcode encoders.
+		QList<QString> encoderlist;
+		//! \brief Descriptions of each encoder.
+		QHash<QString, QString> resdescs;
+		//! \brief Dependancies of each encoder.
+		QHash<QString, QString> resreqs;
+		//! \brief Example data input for each encoder.
+		QHash<QString, QString> resexams;
+		//! \brief Example options input for each encoder.
+		QHash<QString, QString> resexops;
+		//! \brief Renderers for each encoder.
+		QHash<QString, QString> resrndrs;
+		//! \brief PS body of each encoder.
+		QHash<QString, QString> resbodys;
+		//! \brief Symbol Versions of each encoder.
+		QHash<QString, QString> resvers;
+		//! \brief Label for the versions field.
+		QHash<QString, QString> resvlbl;
+		//! \brief Error correction levels of each encoder.
+		QHash<QString, QString> resecls;
+		//! \brief includetext option available for each encoder.
+                QHash<QString, bool> resincludetextAvail;
+		//! \brief guardwhitespace option available for each encoder.
+                QHash<QString, bool> resguardwhitespaceAvail;
+		//! \brief includecheck option available for each encoder.
+                QHash<QString, bool> resincludecheckAvail;
+		//! \brief includecheckintext option available for each encoder.
+                QHash<QString, bool> resincludecheckintextAvail;
+		//! \brief parse option available for each encoder.
+                QHash<QString, bool> resparseAvail;
+		//! \brief parsefnc option available for each encoder.
+                QHash<QString, bool> resparsefncAvail;
+
 		//! \brief Color of the BC lines.
 		ScColor lnColor;
 		//! \brief Color of the BC font.
@@ -85,8 +111,6 @@
 		//! \brief Background color of the BC.
 		ScColor bgColor;
 
-		//! \brief A PS command taken from barcode.ps with scribus related addons.
-		QString psCommand;
 		//! \brief A temporary png pixmap to store the preview image.
 		QString tmpFile;
 		//! \brief A temporary PS file to store commants for Ghostscript.
@@ -113,8 +137,10 @@
 		/*! \brief Perform BarcodeCheckType checks here
 		\param s new string */
 		bool codeEdit_check(const QString & s);
-		void qrOptionsEnabled(bool);
-		void initializeQROptions();
+		bool optionsEdit_check(const QString & s);
+		void updateOptions();
+		void updateOptionsTextFromUI();
+		void updateUIFromOptionsText();
 
 	protected slots:
 		void bcComboChanged();
@@ -123,13 +149,26 @@
 		void guardCheck_changed();
 		void includeCheck_stateChanged(int state);
 		void includeCheckInText_stateChanged(int state);
+		void parseCheck_stateChanged(int state);
+		void parsefncCheck_stateChanged(int state);
 		void bgColorButton_pressed();
 		void lnColorButton_pressed();
 		void txtColorButton_pressed();
 		void codeEdit_textChanged(const QString& s);
+		void optionsEdit_textChanged(const QString& s);
 		void resetButton_clicked();
 		void okButton_pressed();
 		void cancelButton_pressed();
+private slots:
+        void on_includetextCheck_stateChanged(int arg1);
+        void on_includecheckCheck_stateChanged(int arg1);
+        void on_includecheckintextCheck_stateChanged(int arg1);
+        void on_parseCheck_stateChanged(int arg1);
+        void on_parsefncCheck_stateChanged(int arg1);
+        void on_formatCombo_currentIndexChanged(int index);
+        void on_eccCombo_currentIndexChanged(int index);
+        void on_guardwhitespaceCheck_stateChanged(int arg1);
+        void on_optionsEdit_textChanged(const QString &arg1);
 };
 
 #endif

Modified: trunk/Scribus/scribus/plugins/barcodegenerator/barcodegenerator.ui
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=20308&path=/trunk/Scribus/scribus/plugins/barcodegenerator/barcodegenerator.ui
==============================================================================
--- trunk/Scribus/scribus/plugins/barcodegenerator/barcodegenerator.ui (original)
+++ trunk/Scribus/scribus/plugins/barcodegenerator/barcodegenerator.ui Tue Aug 11 16:55:41 2015
@@ -8,8 +8,8 @@
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>511</width>
-    <height>559</height>
+    <width>494</width>
+    <height>535</height>
    </rect>
   </property>
   <property name="windowTitle">
@@ -19,274 +19,7 @@
    <string/>
   </property>
   <layout class="QGridLayout">
-   <item row="0" column="0">
-    <widget class="QGroupBox" name="bcodeBox">
-     <property name="title">
-      <string>Format</string>
-     </property>
-     <layout class="QGridLayout">
-      <item row="5" column="0" colspan="3">
-       <widget class="QCheckBox" name="includeCheckInText">
-        <property name="toolTip">
-         <string>Include the checksum digit in the barcode text</string>
-        </property>
-        <property name="text">
-         <string>Incl&ude Checksum Digit</string>
-        </property>
-        <property name="shortcut">
-         <string>Alt+U</string>
-        </property>
-       </widget>
-      </item>
-      <item row="4" column="0" colspan="3">
-       <widget class="QCheckBox" name="includeCheck">
-        <property name="toolTip">
-         <string>Generate and include a checksum in barcode</string>
-        </property>
-        <property name="text">
-         <string>I&nclude Checksum</string>
-        </property>
-        <property name="shortcut">
-         <string>Alt+N</string>
-        </property>
-       </widget>
-      </item>
-      <item row="3" column="0" colspan="3">
-       <widget class="QCheckBox" name="guardCheck">
-        <property name="toolTip">
-         <string>Draw arrows to be sure of space next the code</string>
-        </property>
-        <property name="text">
-         <string>&Guard Whitespace</string>
-        </property>
-        <property name="shortcut">
-         <string>Alt+G</string>
-        </property>
-       </widget>
-      </item>
-      <item row="2" column="0" colspan="3">
-       <widget class="QCheckBox" name="textCheck">
-        <property name="toolTip">
-         <string>If checked, there will be numbers in the barcode too</string>
-        </property>
-        <property name="text">
-         <string>&Include Text in Barcode</string>
-        </property>
-        <property name="shortcut">
-         <string>Alt+I</string>
-        </property>
-        <property name="checked">
-         <bool>true</bool>
-        </property>
-       </widget>
-      </item>
-      <item row="1" column="2">
-       <widget class="QPushButton" name="resetButton">
-        <property name="sizePolicy">
-         <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
-          <horstretch>0</horstretch>
-          <verstretch>0</verstretch>
-         </sizepolicy>
-        </property>
-        <property name="maximumSize">
-         <size>
-          <width>24</width>
-          <height>32767</height>
-         </size>
-        </property>
-        <property name="toolTip">
-         <string>Reset the barcode samples</string>
-        </property>
-        <property name="text">
-         <string/>
-        </property>
-       </widget>
-      </item>
-      <item row="1" column="1">
-       <widget class="QLineEdit" name="codeEdit">
-        <property name="toolTip">
-         <string>The numeric representation of the code itself. See the help message below.</string>
-        </property>
-       </widget>
-      </item>
-      <item row="1" column="0">
-       <widget class="QLabel" name="codeLabel">
-        <property name="text">
-         <string>Co&de:</string>
-        </property>
-        <property name="wordWrap">
-         <bool>false</bool>
-        </property>
-        <property name="buddy">
-         <cstring>codeEdit</cstring>
-        </property>
-       </widget>
-      </item>
-      <item row="0" column="0">
-       <widget class="QLabel" name="bcLabel">
-        <property name="text">
-         <string>&Type:</string>
-        </property>
-        <property name="wordWrap">
-         <bool>false</bool>
-        </property>
-        <property name="buddy">
-         <cstring>bcCombo</cstring>
-        </property>
-       </widget>
-      </item>
-      <item row="0" column="1">
-       <widget class="QComboBox" name="bcCombo">
-        <property name="toolTip">
-         <string>Select one of the available barcode type here</string>
-        </property>
-       </widget>
-      </item>
-     </layout>
-    </widget>
-   </item>
-   <item row="0" column="1" colspan="2">
-    <widget class="QGroupBox" name="colorBox">
-     <property name="title">
-      <string>Colors</string>
-     </property>
-     <layout class="QGridLayout">
-      <item row="3" column="0">
-       <spacer>
-        <property name="orientation">
-         <enum>Qt::Vertical</enum>
-        </property>
-        <property name="sizeHint" stdset="0">
-         <size>
-          <width>20</width>
-          <height>40</height>
-         </size>
-        </property>
-       </spacer>
-      </item>
-      <item row="0" column="0">
-       <widget class="QPushButton" name="bgColorButton">
-        <property name="toolTip">
-         <string>Background color - under the code lines</string>
-        </property>
-        <property name="text">
-         <string>&Background</string>
-        </property>
-        <property name="shortcut">
-         <string>Alt+B</string>
-        </property>
-       </widget>
-      </item>
-      <item row="0" column="1">
-       <widget class="QLabel" name="bgLabel">
-        <property name="minimumSize">
-         <size>
-          <width>10</width>
-          <height>0</height>
-         </size>
-        </property>
-        <property name="frameShape">
-         <enum>QFrame::Box</enum>
-        </property>
-        <property name="scaledContents">
-         <bool>true</bool>
-        </property>
-        <property name="wordWrap">
-         <bool>false</bool>
-        </property>
-       </widget>
-      </item>
-      <item row="1" column="0">
-       <widget class="QPushButton" name="lnColorButton">
-        <property name="toolTip">
-         <string>Color of the lines in barcode</string>
-        </property>
-        <property name="text">
-         <string>&Lines</string>
-        </property>
-        <property name="shortcut">
-         <string>Alt+L</string>
-        </property>
-       </widget>
-      </item>
-      <item row="1" column="1">
-       <widget class="QLabel" name="linesLabel">
-        <property name="minimumSize">
-         <size>
-          <width>10</width>
-          <height>0</height>
-         </size>
-        </property>
-        <property name="frameShape">
-         <enum>QFrame::Box</enum>
-        </property>
-        <property name="scaledContents">
-         <bool>true</bool>
-        </property>
-        <property name="wordWrap">
-         <bool>false</bool>
-        </property>
-       </widget>
-      </item>
-      <item row="2" column="0">
-       <widget class="QPushButton" name="txtColorButton">
-        <property name="toolTip">
-         <string>Color of the text and numbers</string>
-        </property>
-        <property name="text">
-         <string>&Text</string>
-        </property>
-        <property name="shortcut">
-         <string>Alt+T</string>
-        </property>
-       </widget>
-      </item>
-      <item row="2" column="1">
-       <widget class="QLabel" name="txtLabel">
-        <property name="minimumSize">
-         <size>
-          <width>10</width>
-          <height>0</height>
-         </size>
-        </property>
-        <property name="frameShape">
-         <enum>QFrame::Box</enum>
-        </property>
-        <property name="scaledContents">
-         <bool>true</bool>
-        </property>
-        <property name="wordWrap">
-         <bool>false</bool>
-        </property>
-       </widget>
-      </item>
-     </layout>
-    </widget>
-   </item>
-   <item row="3" column="0" colspan="2">
-    <widget class="QTextEdit" name="commentEdit">
-     <property name="toolTip">
-      <string>Hints and help is shown here</string>
-     </property>
-     <property name="readOnly">
-      <bool>true</bool>
-     </property>
-    </widget>
-   </item>
-   <item row="3" column="2">
-    <widget class="QLabel" name="sampleLabel">
-     <property name="frameShape">
-      <enum>QFrame::Box</enum>
-     </property>
-     <property name="alignment">
-      <set>Qt::AlignCenter</set>
-     </property>
-     <property name="wordWrap">
-      <bool>false</bool>
-     </property>
-    </widget>
-   </item>
-   <item row="4" column="0" colspan="3">
+   <item row="8" column="0" colspan="3">
     <layout class="QHBoxLayout">
      <item>
       <spacer>
@@ -317,16 +50,370 @@
      </item>
     </layout>
    </item>
-   <item row="2" column="0" colspan="3">
+   <item row="4" column="0">
+    <widget class="QGroupBox" name="bcodeBox">
+     <property name="title">
+      <string/>
+     </property>
+     <layout class="QGridLayout">
+      <property name="topMargin">
+       <number>0</number>
+      </property>
+      <property name="bottomMargin">
+       <number>0</number>
+      </property>
+      <item row="6" column="1">
+       <widget class="QCheckBox" name="includecheckintextCheck">
+        <property name="toolTip">
+         <string>Include the checksum digit in the barcode text</string>
+        </property>
+        <property name="text">
+         <string>Display checksum</string>
+        </property>
+        <property name="shortcut">
+         <string>Alt+U</string>
+        </property>
+       </widget>
+      </item>
+      <item row="5" column="0">
+       <widget class="QCheckBox" name="includetextCheck">
+        <property name="toolTip">
+         <string>If checked, there will be numbers in the barcode too</string>
+        </property>
+        <property name="text">
+         <string>Show readable text</string>
+        </property>
+        <property name="shortcut">
+         <string>Alt+I</string>
+        </property>
+        <property name="checked">
+         <bool>false</bool>
+        </property>
+       </widget>
+      </item>
+      <item row="8" column="1">
+       <widget class="QCheckBox" name="parsefncCheck">
+        <property name="text">
+         <string>Parse specials</string>
+        </property>
+       </widget>
+      </item>
+      <item row="5" column="1">
+       <widget class="QCheckBox" name="guardwhitespaceCheck">
+        <property name="toolTip">
+         <string>Draw arrows to be sure of space next the code</string>
+        </property>
+        <property name="text">
+         <string>Guard whitespace</string>
+        </property>
+        <property name="shortcut">
+         <string>Alt+G</string>
+        </property>
+       </widget>
+      </item>
+      <item row="8" column="0">
+       <widget class="QCheckBox" name="parseCheck">
+        <property name="text">
+         <string>^NNN as ASCII</string>
+        </property>
+       </widget>
+      </item>
+      <item row="6" column="0">
+       <widget class="QCheckBox" name="includecheckCheck">
+        <property name="toolTip">
+         <string>Generate and include a checksum in barcode</string>
+        </property>
+        <property name="text">
+         <string>Add checksum</string>
+        </property>
+        <property name="shortcut">
+         <string>Alt+N</string>
+        </property>
+       </widget>
+      </item>
+     </layout>
+    </widget>
+   </item>
+   <item row="4" column="1" colspan="2">
+    <widget class="QGroupBox" name="colorBox">
+     <property name="title">
+      <string/>
+     </property>
+     <layout class="QGridLayout">
+      <property name="topMargin">
+       <number>0</number>
+      </property>
+      <item row="0" column="0">
+       <widget class="QPushButton" name="bgColorButton">
+        <property name="toolTip">
+         <string>Background color - under the code lines</string>
+        </property>
+        <property name="text">
+         <string>&Background</string>
+        </property>
+        <property name="shortcut">
+         <string>Alt+B</string>
+        </property>
+       </widget>
+      </item>
+      <item row="0" column="1">
+       <widget class="QLabel" name="bgLabel">
+        <property name="minimumSize">
+         <size>
+          <width>10</width>
+          <height>0</height>
+         </size>
+        </property>
+        <property name="frameShape">
+         <enum>QFrame::Box</enum>
+        </property>
+        <property name="scaledContents">
+         <bool>true</bool>
+        </property>
+        <property name="wordWrap">
+         <bool>false</bool>
+        </property>
+       </widget>
+      </item>
+      <item row="1" column="0">
+       <widget class="QPushButton" name="lnColorButton">
+        <property name="toolTip">
+         <string>Color of the lines in barcode</string>
+        </property>
+        <property name="text">
+         <string>&Lines</string>
+        </property>
+        <property name="shortcut">
+         <string>Alt+L</string>
+        </property>
+       </widget>
+      </item>
+      <item row="1" column="1">
+       <widget class="QLabel" name="linesLabel">
+        <property name="minimumSize">
+         <size>
+          <width>10</width>
+          <height>0</height>
+         </size>
+        </property>
+        <property name="frameShape">
+         <enum>QFrame::Box</enum>
+        </property>
+        <property name="scaledContents">
+         <bool>true</bool>
+        </property>
+        <property name="wordWrap">
+         <bool>false</bool>
+        </property>
+       </widget>
+      </item>
+      <item row="2" column="0">
+       <widget class="QPushButton" name="txtColorButton">
+        <property name="toolTip">
+         <string>Color of the text and numbers</string>
+        </property>
+        <property name="text">
+         <string>&Text</string>
+        </property>
+        <property name="shortcut">
+         <string>Alt+T</string>
+        </property>
+       </widget>
+      </item>
+      <item row="2" column="1">
+       <widget class="QLabel" name="txtLabel">
+        <property name="minimumSize">
+         <size>
+          <width>10</width>
+          <height>0</height>
+         </size>
+        </property>
+        <property name="frameShape">
+         <enum>QFrame::Box</enum>
+        </property>
+        <property name="scaledContents">
+         <bool>true</bool>
+        </property>
+        <property name="wordWrap">
+         <bool>false</bool>
+        </property>
+       </widget>
+      </item>
+     </layout>
+    </widget>
+   </item>
+   <item row="2" column="0" rowspan="2" colspan="3">
+    <widget class="QGroupBox" name="groupBox">
+     <property name="minimumSize">
+      <size>
+       <width>0</width>
+       <height>100</height>
+      </size>
+     </property>
+     <property name="title">
+      <string/>
+     </property>
+     <widget class="QLineEdit" name="optionsEdit">
+      <property name="geometry">
+       <rect>
+        <x>80</x>
+        <y>70</y>
+        <width>331</width>
+        <height>27</height>
+       </rect>
+      </property>
+      <property name="toolTip">
+       <string>Advanced options for the barcode</string>
+      </property>
+     </widget>
+     <widget class="QLabel" name="bcLabel">
+      <property name="geometry">
+       <rect>
+        <x>10</x>
+        <y>10</y>
+        <width>171</width>
+        <height>27</height>
+       </rect>
+      </property>
+      <property name="text">
+       <string>&Barcode:</string>
+      </property>
+      <property name="wordWrap">
+       <bool>false</bool>
+      </property>
+      <property name="buddy">
+       <cstring>bcCombo</cstring>
+      </property>
+     </widget>
+     <widget class="QLabel" name="codeLabel">
+      <property name="geometry">
+       <rect>
+        <x>10</x>
+        <y>40</y>
+        <width>101</width>
+        <height>20</height>
+       </rect>
+      </property>
+      <property name="text">
+       <string>&Contents:</string>
+      </property>
+      <property name="wordWrap">
+       <bool>false</bool>
+      </property>
+      <property name="buddy">
+       <cstring>codeEdit</cstring>
+      </property>
+     </widget>
+     <widget class="QLabel" name="optionsLabel">
+      <property name="geometry">
+       <rect>
+        <x>10</x>
+        <y>70</y>
+        <width>61</width>
+        <height>20</height>
+       </rect>
+      </property>
+      <property name="text">
+       <string>Options:</string>
+      </property>
+      <property name="textInteractionFlags">
+       <set>Qt::LinksAccessibleByMouse</set>
+      </property>
+     </widget>
+     <widget class="QLineEdit" name="codeEdit">
+      <property name="geometry">
+       <rect>
+        <x>80</x>
+        <y>40</y>
+        <width>331</width>
+        <height>27</height>
+       </rect>
+      </property>
+      <property name="toolTip">
+       <string>The contents encoded in the barcode</string>
+      </property>
+     </widget>
+     <widget class="QComboBox" name="bcCombo">
+      <property name="geometry">
+       <rect>
+        <x>80</x>
+        <y>10</y>
+        <width>331</width>
+        <height>27</height>
+       </rect>
+      </property>
+      <property name="toolTip">
+       <string>Select one of the available barcode types here</string>
+      </property>
+     </widget>
+     <widget class="QPushButton" name="resetButton">
+      <property name="geometry">
+       <rect>
+        <x>420</x>
+        <y>40</y>
+        <width>24</width>
+        <height>27</height>
+       </rect>
+      </property>
+      <property name="sizePolicy">
+       <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
+        <horstretch>0</horstretch>
+        <verstretch>0</verstretch>
+       </sizepolicy>
+      </property>
+      <property name="maximumSize">
+       <size>
+        <width>24</width>
+        <height>32767</height>
+       </size>
+      </property>
+      <property name="toolTip">
+       <string>Reset the barcode samples</string>
+      </property>
+      <property name="text">
+       <string/>
+      </property>
+     </widget>
+    </widget>
+   </item>
+   <item row="6" column="0" colspan="3">
     <widget class="QGroupBox" name="optionsBox">
      <property name="title">
-      <string>Options</string>
+      <string/>
      </property>
      <layout class="QGridLayout">
+      <property name="topMargin">
+       <number>0</number>
+      </property>
+      <property name="verticalSpacing">
+       <number>6</number>
+      </property>
+      <item row="2" column="0" colspan="5">
+       <widget class="QLabel" name="sampleLabel">
+        <property name="minimumSize">
+         <size>
+          <width>450</width>
+          <height>190</height>
+         </size>
+        </property>
+        <property name="styleSheet">
+         <string notr="true">background-color : #FFF</string>
+        </property>
+        <property name="frameShape">
+         <enum>QFrame::Box</enum>
+        </property>
+        <property name="alignment">
+         <set>Qt::AlignCenter</set>
+        </property>
+        <property name="wordWrap">
+         <bool>false</bool>
+        </property>
+       </widget>
+      </item>
       <item row="0" column="0">
        <widget class="QLabel" name="formatLabel">
         <property name="text">
-         <string>&Format:</string>
+         <string>Version:</string>
         </property>
         <property name="wordWrap">
          <bool>false</bool>
@@ -338,28 +425,40 @@
       </item>
       <item row="0" column="1">
        <widget class="QComboBox" name="formatCombo">
-        <property name="toolTip">
-         <string/>
-        </property>
-       </widget>
-      </item>
-      <item row="1" column="0">
+        <property name="minimumSize">
+         <size>
+          <width>125</width>
+          <height>1</height>
+         </size>
+        </property>
+        <property name="toolTip">
+         <string>Version of the symbol.</string>
+        </property>
+       </widget>
+      </item>
+      <item row="0" column="4">
+       <widget class="QComboBox" name="eccCombo">
+        <property name="minimumSize">
+         <size>
+          <width>125</width>
+          <height>0</height>
+         </size>
+        </property>
+        <property name="toolTip">
+         <string>Error correction level.</string>
+        </property>
+       </widget>
+      </item>
+      <item row="0" column="3">
        <widget class="QLabel" name="eccLabel">
         <property name="text">
-         <string>Error &checking:</string>
+         <string>Error correction level:</string>
         </property>
         <property name="wordWrap">
          <bool>false</bool>
         </property>
         <property name="buddy">
          <cstring>eccCombo</cstring>
-        </property>
-       </widget>
-      </item>
-      <item row="1" column="1">
-       <widget class="QComboBox" name="eccCombo">
-        <property name="toolTip">
-         <string>Minimum error checking; raised opportunistically if size of symbol is not increased</string>
         </property>
        </widget>
       </item>
@@ -370,19 +469,9 @@
  </widget>
  <layoutdefault spacing="6" margin="11"/>
  <tabstops>
-  <tabstop>bcCombo</tabstop>
-  <tabstop>codeEdit</tabstop>
-  <tabstop>resetButton</tabstop>
-  <tabstop>textCheck</tabstop>
-  <tabstop>guardCheck</tabstop>
-  <tabstop>includeCheck</tabstop>
-  <tabstop>includeCheckInText</tabstop>
   <tabstop>bgColorButton</tabstop>
   <tabstop>lnColorButton</tabstop>
   <tabstop>txtColorButton</tabstop>
-  <tabstop>formatCombo</tabstop>
-  <tabstop>eccCombo</tabstop>
-  <tabstop>commentEdit</tabstop>
   <tabstop>okButton</tabstop>
   <tabstop>cancelButton</tabstop>
  </tabstops>
@@ -405,38 +494,6 @@
    </hints>
   </connection>
   <connection>
-   <sender>textCheck</sender>
-   <signal>stateChanged(int)</signal>
-   <receiver>BarcodeGeneratorBase</receiver>
-   <slot>textCheck_changed()</slot>
-   <hints>
-    <hint type="sourcelabel">
-     <x>20</x>
-     <y>20</y>
-    </hint>
-    <hint type="destinationlabel">
-     <x>20</x>
-     <y>20</y>
-    </hint>
-   </hints>
-  </connection>
-  <connection>
-   <sender>guardCheck</sender>
-   <signal>stateChanged(int)</signal>
-   <receiver>BarcodeGeneratorBase</receiver>
-   <slot>guardCheck_changed()</slot>
-   <hints>
-    <hint type="sourcelabel">
-     <x>20</x>
-     <y>20</y>
-    </hint>
-    <hint type="destinationlabel">
-     <x>20</x>
-     <y>20</y>
-    </hint>
-   </hints>
-  </connection>
-  <connection>
    <sender>bgColorButton</sender>
    <signal>clicked()</signal>
    <receiver>BarcodeGeneratorBase</receiver>
@@ -548,37 +605,5 @@
     </hint>
    </hints>
   </connection>
-  <connection>
-   <sender>includeCheck</sender>
-   <signal>stateChanged(int)</signal>
-   <receiver>BarcodeGeneratorBase</receiver>
-   <slot>includeCheck_stateChanged(int)</slot>
-   <hints>
-    <hint type="sourcelabel">
-     <x>20</x>
-     <y>20</y>
-    </hint>
-    <hint type="destinationlabel">
-     <x>20</x>
-     <y>20</y>
-    </hint>
-   </hints>
-  </connection>
-  <connection>
-   <sender>includeCheckInText</sender>
-   <signal>stateChanged(int)</signal>
-   <receiver>BarcodeGeneratorBase</receiver>
-   <slot>includeCheckInText_stateChanged(int)</slot>
-   <hints>
-    <hint type="sourcelabel">
-     <x>20</x>
-     <y>20</y>
-    </hint>
-    <hint type="destinationlabel">
-     <x>20</x>
-     <y>20</y>
-    </hint>
-   </hints>
-  </connection>
  </connections>
 </ui>




More information about the scribus-commit mailing list