View Issue Details

IDProjectCategoryView StatusLast Update
0016785ScribusGraphics / Image Framespublic2023-05-29 18:56
Reporterwillsonlin Assigned Tocbradney  
PrioritynormalSeveritytweakReproducibilityhave not tried
Status closedResolutionfixed 
OSWindowsOS Version8 
Product Version1.6.0.svn 
Fixed in Version1.6.0.svn 
Summary0016785: "Show readable text" Option for QR Code on "Insert Barcode" Window should be grey out
Description"Show readable text" Option for QR Code on "Insert Barcode" Window should be grey out,because "Show readable text" is designed for one-dimension barcode for showing number texts inside the barcode.It's not designed to use with QR code or other kinds of two-dimension barcode.So,either grey out this option or changes it to show the texts of QR code below.
TagsNo tags attached.
PatchNo

Activities

goto_coder

2022-05-24 18:48

reporter   ~0049656

I would like to offer to look into this because it sounds easy enough for someone just starting out with coding for Scribus.

cbradney

2022-06-01 20:07

administrator   ~0049667

Last edited: 2022-06-01 20:10

@goto_coder: I have worked out a solution here (more so I could be sure of the answer we'd need to have).. feel free to paste in some code changes or a patch to this request and I can review for you. Or equally, I can post a patch and you can see what I did.. Up to you!

goto_coder

2022-06-02 07:38

reporter   ~0049669

Great! I'd really like to take the chance and supply a patch for review! I'm just afraid it will still take me a while to figure it out - but if that's not a big problem, I'm in!

goto_coder

2022-06-11 01:02

reporter   ~0049693

Okay, I think I found the source of the problem in `barcodegenerator.cpp`: There's a `foreach` where the `include text available` switches get set to `true` for all the encoders, because there's no test if the `includetext` flag is actually available for any encoder in `barcode.ps`:
I guess you could hardwire this information in the C++ code, just like it's being done for the other options.

What I tried to do so far was to read the available options from the `BarcodeMap map` variable. The odd thing is, that it doesn't find any keys I feed into it. When I query the map with the loop variable `enc` it always returns an emty string. When I test if a key is in the map, it always returns `false`. But: When I make it print out all the keys to the terminal, these keys are in there, correct spelling and all. I'm going to attach a patch with what I tried (basically just inserting some `qDebug()` statements) and a text file with some of the output it generated. Could you by any chance give me a little hint? :-)
missing_keys.patch (2,311 bytes)   
Index: scribus/plugins/barcodegenerator/barcodegenerator.cpp
===================================================================
--- scribus/plugins/barcodegenerator/barcodegenerator.cpp	(Revision 25096)
+++ scribus/plugins/barcodegenerator/barcodegenerator.cpp	(Arbeitskopie)
@@ -44,6 +44,7 @@
 
 	/*
 	 *  We extract the barcode information from the BWIPP metadata which looks like this:
+     *  (N.B. That means it regexes the gs-file `barcode.ps` for the strings after matches to "--BEGIN ENCODER ")
 	 *
 	 *  % --BEGIN ENCODER gs1-128--
 	 *  % --REQUIRES preamble raiseerror renlinear code128--
@@ -78,7 +79,7 @@
 		QString resname = rx.cap(2);
 		QString reshead = rx.cap(3);
 		QString resbody = rx.cap(4);
-
+        qDebug() << "Reshead: " << reshead;
 		resbodys[resname] = resbody;
 
 		if (restype=="ENCODER")
@@ -96,6 +97,7 @@
 				resdescs[resname] = rxhead.cap(2).trimmed();
 				resexams[resname] = rxhead.cap(3).trimmed();
 				resexops[resname] = rxhead.cap(4).trimmed();
+                qDebug() << "resexops[" << resname << "]: " << resexops[resname];
 				resrndrs[resname] = rxhead.cap(5).trimmed();
 				encoderlist.append(resname);
 			}
@@ -153,10 +155,20 @@
 
 
 	// Which options checkboxes are enabled for each encoder
+    // TODO: The list should only contain those encoders for which `includeText` option is available
+    // according to file `barcode.ps`.
+    // However, the list of all encoders is copy-assigned, so the option will be available for every encoder,
+    // whether its possible or not.
 	QStringList includetextAvail = encoderlist;
-	foreach (const QString& enc, includetextAvail)
-		resincludetextAvail[enc] = true;
-
+    for (const QString& enc : includetextAvail){
+        //resincludetextAvail[enc] = true;
+        qDebug() << "Map contains key \"" << enc << "\": " << map.contains(enc);
+        QString foo = map[enc].exampleOptions;
+        resincludetextAvail[enc] = foo.contains("includetext");
+    // Disable "include text" option for QR codes
+    //resincludetextAvail["qrcode"] = false;
+    }
+    qDebug() << "Keys: " << map.keys();
 	QStringList guardwhitespaceAvail;
 	guardwhitespaceAvail << "ean13" << "ean8" << "isbn" << "ismn" << "issn" << "ean13composite" << "ean8composite";
 	foreach (const QString& enc, guardwhitespaceAvail)
missing_keys.patch (2,311 bytes)   
strange_output.txt (8,513 bytes)   
Map contains key " "ean5" ":  false
Map contains key " "ean2" ":  false
Map contains key " "ean13" ":  false
Map contains key " "ean8" ":  false
Map contains key " "upca" ":  false
Map contains key " "upce" ":  false
Map contains key " "isbn" ":  false
Map contains key " "ismn" ":  false
Map contains key " "issn" ":  false
Map contains key " "mands" ":  false
Map contains key " "code128" ":  false
Map contains key " "gs1-128" ":  false
Map contains key " "ean14" ":  false
Map contains key " "sscc18" ":  false
Map contains key " "code39" ":  false
Map contains key " "code39ext" ":  false
Map contains key " "code32" ":  false
Map contains key " "pzn" ":  false
Map contains key " "code93" ":  false
Map contains key " "code93ext" ":  false
Map contains key " "interleaved2of5" ":  false
Map contains key " "itf14" ":  false
Map contains key " "identcode" ":  false
Map contains key " "leitcode" ":  false
Map contains key " "databaromni" ":  false
Map contains key " "databarstacked" ":  false
Map contains key " "databarstackedomni" ":  false
Map contains key " "databartruncated" ":  false
Map contains key " "databarlimited" ":  false
Map contains key " "databarexpanded" ":  false
Map contains key " "databarexpandedstacked" ":  false
Map contains key " "gs1northamericancoupon" ":  false
Map contains key " "pharmacode" ":  false
Map contains key " "pharmacode2" ":  false
Map contains key " "code2of5" ":  false
Map contains key " "industrial2of5" ":  false
Map contains key " "iata2of5" ":  false
Map contains key " "matrix2of5" ":  false
Map contains key " "coop2of5" ":  false
Map contains key " "datalogic2of5" ":  false
Map contains key " "code11" ":  false
Map contains key " "bc412" ":  false
Map contains key " "rationalizedCodabar" ":  false
Map contains key " "onecode" ":  false
Map contains key " "postnet" ":  false
Map contains key " "planet" ":  false
Map contains key " "royalmail" ":  false
Map contains key " "auspost" ":  false
Map contains key " "kix" ":  false
Map contains key " "japanpost" ":  false
Map contains key " "msi" ":  false
Map contains key " "plessey" ":  false
Map contains key " "telepen" ":  false
Map contains key " "telepennumeric" ":  false
Map contains key " "posicode" ":  false
Map contains key " "codablockf" ":  false
Map contains key " "code16k" ":  false
Map contains key " "code49" ":  false
Map contains key " "channelcode" ":  false
Map contains key " "flattermarken" ":  false
Map contains key " "raw" ":  false
Map contains key " "daft" ":  false
Map contains key " "symbol" ":  false
Map contains key " "pdf417" ":  false
Map contains key " "pdf417compact" ":  false
Map contains key " "micropdf417" ":  false
Map contains key " "datamatrix" ":  false
Map contains key " "datamatrixrectangular" ":  false
Map contains key " "datamatrixrectangularextension" ":  false
Map contains key " "mailmark" ":  false
Map contains key " "qrcode" ":  false
Map contains key " "swissqrcode" ":  false
Map contains key " "microqrcode" ":  false
Map contains key " "rectangularmicroqrcode" ":  false
Map contains key " "maxicode" ":  false
Map contains key " "azteccode" ":  false
Map contains key " "azteccodecompact" ":  false
Map contains key " "aztecrune" ":  false
Map contains key " "codeone" ":  false
Map contains key " "hanxin" ":  false
Map contains key " "dotcode" ":  false
Map contains key " "ultracode" ":  false
Map contains key " "jabcode" ":  false
Map contains key " "gs1-cc" ":  false
Map contains key " "ean13composite" ":  false
Map contains key " "ean8composite" ":  false
Map contains key " "upcacomposite" ":  false
Map contains key " "upcecomposite" ":  false
Map contains key " "databaromnicomposite" ":  false
Map contains key " "databarstackedcomposite" ":  false
Map contains key " "databarstackedomnicomposite" ":  false
Map contains key " "databartruncatedcomposite" ":  false
Map contains key " "databarlimitedcomposite" ":  false
Map contains key " "databarexpandedcomposite" ":  false
Map contains key " "databarexpandedstackedcomposite" ":  false
Map contains key " "gs1-128composite" ":  false
Map contains key " "gs1datamatrix" ":  false
Map contains key " "gs1datamatrixrectangular" ":  false
Map contains key " "gs1qrcode" ":  false
Map contains key " "gs1dotcode" ":  false
Map contains key " "hibccode39" ":  false
Map contains key " "hibccode128" ":  false
Map contains key " "hibcdatamatrix" ":  false
Map contains key " "hibcdatamatrixrectangular" ":  false
Map contains key " "hibcpdf417" ":  false
Map contains key " "hibcmicropdf417" ":  false
Map contains key " "hibcqrcode" ":  false
Map contains key " "hibccodablockf" ":  false
Map contains key " "hibcazteccode" ":  false
Keys:  ("AusPost 4 State Customer Code", "Aztec Code", "Aztec Runes", "BC412", "COOP 2 of 5", "Channel Code", "Codabar", "Codablock F", "Code 11", "Code 128", "Code 16K", "Code 25", "Code 39", "Code 39 Extended", "Code 49", "Code 93", "Code 93 Extended", "Code One", "Compact Aztec Code", "Compact PDF417", "Custom 1D symbology", "Custom 4 state symbology", "Data Matrix", "Data Matrix Rectangular", "Data Matrix Rectangular Extension", "Datalogic 2 of 5", "Deutsche Post Identcode", "Deutsche Post Leitcode", "DotCode", "EAN-13", "EAN-13 Composite", "EAN-2 (2 digit addon)", "EAN-5 (5 digit addon)", "EAN-8", "EAN-8 Composite", "Flattermarken", "GS1 Composite 2D Component", "GS1 Data Matrix", "GS1 Data Matrix Rectangular", "GS1 DataBar Expanded", "GS1 DataBar Expanded Composite", "GS1 DataBar Expanded Stacked", "GS1 DataBar Expanded Stacked Composite", "GS1 DataBar Limited", "GS1 DataBar Limited Composite", "GS1 DataBar Omnidirectional", "GS1 DataBar Omnidirectional Composite", "GS1 DataBar Stacked", "GS1 DataBar Stacked Composite", "GS1 DataBar Stacked Omnidirectional", "GS1 DataBar Stacked Omnidirectional Composite", "GS1 DataBar Truncated", "GS1 DataBar Truncated Composite", "GS1 DotCode", "GS1 North American Coupon", "GS1 QR Code", "GS1-128", "GS1-128 Composite", "GS1-14", "HIBC Aztec Code", "HIBC Codablock F", "HIBC Code 128", "HIBC Code 39", "HIBC Data Matrix", "HIBC Data Matrix Rectangular", "HIBC MicroPDF417", "HIBC PDF417", "HIBC QR Code", "Han Xin Code", "IATA 2 of 5", "ISBN", "ISMN", "ISSN", "ITF-14", "Industrial 2 of 5", "Interleaved 2 of 5 (ITF)", "Italian Pharmacode", "JAB Code (Beta)", "Japan Post 4 State Customer Code", "MSI Modified Plessey", "Marks & Spencer", "Matrix 2 of 5", "MaxiCode", "Micro QR Code", "MicroPDF417", "Miscellaneous symbols", "PDF417", "Pharmaceutical Binary Code", "Pharmazentralnummer (PZN)", "Plessey UK", "PosiCode", "QR Code", "Rectangular Micro QR Code", "Royal Dutch TPG Post KIX", "Royal Mail 4 State Customer Code", "Royal Mail Mailmark", "SSCC-18", "Swiss QR Code", "Telepen", "Telepen Numeric", "Two-track Pharmacode", "UPC-A", "UPC-A Composite", "UPC-E", "UPC-E Composite", "USPS Intelligent Mail", "USPS PLANET", "USPS POSTNET", "Ultracode", "auspost", "azteccode", "azteccodecompact", "aztecrune", "bc412", "channelcode", "codablockf", "code11", "code128", "code16k", "code2of5", "code32", "code39", "code39ext", "code49", "code93", "code93ext", "codeone", "coop2of5", "daft", "databarexpanded", "databarexpandedcomposite", "databarexpandedstacked", "databarexpandedstackedcomposite", "databarlimited", "databarlimitedcomposite", "databaromni", "databaromnicomposite", "databarstacked", "databarstackedcomposite", "databarstackedomni", "databarstackedomnicomposite", "databartruncated", "databartruncatedcomposite", "datalogic2of5", "datamatrix", "datamatrixrectangular", "datamatrixrectangularextension", "dotcode", "ean13", "ean13composite", "ean14", "ean2", "ean5", "ean8", "ean8composite", "flattermarken", "gs1-128", "gs1-128composite", "gs1-cc", "gs1datamatrix", "gs1datamatrixrectangular", "gs1dotcode", "gs1northamericancoupon", "gs1qrcode", "hanxin", "hibcazteccode", "hibccodablockf", "hibccode128", "hibccode39", "hibcdatamatrix", "hibcdatamatrixrectangular", "hibcmicropdf417", "hibcpdf417", "hibcqrcode", "iata2of5", "identcode", "industrial2of5", "interleaved2of5", "isbn", "ismn", "issn", "itf14", "jabcode", "japanpost", "kix", "leitcode", "mailmark", "mands", "matrix2of5", "maxicode", "micropdf417", "microqrcode", "msi", "onecode", "pdf417", "pdf417compact", "pharmacode", "pharmacode2", "planet", "plessey", "posicode", "postnet", "pzn", "qrcode", "rationalizedCodabar", "raw", "rectangularmicroqrcode", "royalmail", "sscc18", "swissqrcode", "symbol", "telepen", "telepennumeric", "ultracode", "upca", "upcacomposite", "upce", "upcecomposite")
strange_output.txt (8,513 bytes)   

goto_coder

2022-06-11 21:37

reporter   ~0049694

Nevermind, I think I got it figured out. Just had to look at a different variable...
It seems to work now and I checked it for some of the encoders against the `barcode.ps` file.
qrcode_includetext_0016785_2022_06_11_goto_coder.diff (899 bytes)   
Index: scribus/plugins/barcodegenerator/barcodegenerator.cpp
===================================================================
--- scribus/plugins/barcodegenerator/barcodegenerator.cpp	(Revision 25096)
+++ scribus/plugins/barcodegenerator/barcodegenerator.cpp	(Arbeitskopie)
@@ -153,10 +153,12 @@
 
 
 	// Which options checkboxes are enabled for each encoder
-	QStringList includetextAvail = encoderlist;
-	foreach (const QString& enc, includetextAvail)
-		resincludetextAvail[enc] = true;
 
+    // Check whether `includetext` option is available for each encoder
+    for(const QString &enc : encoderlist){
+        resincludetextAvail[enc] = resexops[enc].contains("includetext");
+    }
+
 	QStringList guardwhitespaceAvail;
 	guardwhitespaceAvail << "ean13" << "ean8" << "isbn" << "ismn" << "issn" << "ean13composite" << "ean8composite";
 	foreach (const QString& enc, guardwhitespaceAvail)

cbradney

2022-06-17 21:03

administrator   ~0049704

Thank you @goto_coder.. patch applied! Nice!

Issue History

Date Modified Username Field Change
2022-04-25 13:20 willsonlin New Issue
2022-05-24 18:48 goto_coder Note Added: 0049656
2022-06-01 20:07 cbradney Note Added: 0049667
2022-06-01 20:10 cbradney Note Edited: 0049667
2022-06-02 07:38 goto_coder Note Added: 0049669
2022-06-11 01:02 goto_coder Note Added: 0049693
2022-06-11 01:02 goto_coder File Added: missing_keys.patch
2022-06-11 01:02 goto_coder File Added: strange_output.txt
2022-06-11 21:37 goto_coder Note Added: 0049694
2022-06-11 21:37 goto_coder File Added: qrcode_includetext_0016785_2022_06_11_goto_coder.diff
2022-06-17 21:03 cbradney Note Added: 0049704
2022-06-17 21:06 cbradney Assigned To => cbradney
2022-06-17 21:06 cbradney Status new => resolved
2022-06-17 21:06 cbradney Resolution open => fixed
2022-06-17 21:06 cbradney Fixed in Version => 1.6.0.svn
2023-05-29 18:56 cbradney Status resolved => closed