1
0
mirror of https://github.com/woo-j/zint.git synced 2024-10-26 08:55:05 +03:00

GUI: add CLI equivalent dialog (#163); use spinboxes in Sequence dialog

and restrict sequence to max 10,000, add button icons;
   make Export dialog sizable and show every 100 results, add button icon;
   fix saving CHANNEL option, fix Export painting main window (Windows), fix
   guard descent not-resetting
 qzint: add getAsCLI(), warnLevel(), extra isStackable()/isComposite() etc
 Add ZBarcode_BarcodeName()
 manual: doc above, some fixes, tweaks
This commit is contained in:
gitlost 2021-11-23 19:12:48 +00:00
parent 9d85c425f4
commit 739a64a6ff
34 changed files with 2264 additions and 1199 deletions

View File

@ -41,6 +41,8 @@ Changes
- Add HEIGHTPERROW_MODE input mode flag
- DBAR_EXPSTK: add max rows option
- CODE16K/CODE49: add min rows option
- GUI: add CLI equivalent dialog (#163)
- Add ZBarcode_BarcodeName()
Bugs
----

View File

@ -175,7 +175,7 @@ INTERNAL int code16k(struct zint_symbol *symbol, unsigned char source[], int len
/* Calculate how tall the symbol will be */
glyph_count = glyph_count + 2.0f;
i = (int)glyph_count;
i = (int) glyph_count;
rows = (i / 5);
if (i % 5 > 0) {
rows++;

View File

@ -42,6 +42,10 @@
#define TRUE 1
#endif
#ifndef ARRAY_SIZE
#define ARRAY_SIZE(x) ((int) (sizeof(x) / sizeof((x)[0])))
#endif
/* `is_sane()` flags */
#define IS_SPC_F 0x0001 /* Space */
#define IS_HSH_F 0x0002 /* Hash sign # */

View File

@ -30,12 +30,13 @@
*/
/* vim: set ts=4 sw=4 et : */
#include <stdio.h>
#include <assert.h>
#include <errno.h>
#include <limits.h>
#ifdef _MSC_VER
#include <malloc.h>
#endif
#include <stdio.h>
#include "common.h"
#include "eci.h"
#include "gs1.h"
@ -1308,6 +1309,181 @@ int ZBarcode_ValidID(int symbol_id) {
return barcode_funcs[symbol_id] != NULL;
}
/* Copy BARCODE_XXX name of `symbol_id` into `name` buffer, NUL-terminated.
Returns 0 if valid, non-zero (1 or -1) if not valid */
int ZBarcode_BarcodeName(int symbol_id, char name[32]) {
struct item {
const char *name;
int define;
int val;
};
static const struct item data[] = {
{ "", -1, 0 },
{ "BARCODE_CODE11", BARCODE_CODE11, 1 },
{ "BARCODE_C25STANDARD", BARCODE_C25STANDARD, 2 },
{ "BARCODE_C25INTER", BARCODE_C25INTER, 3 },
{ "BARCODE_C25IATA", BARCODE_C25IATA, 4 },
{ "", -1, 5 },
{ "BARCODE_C25LOGIC", BARCODE_C25LOGIC, 6 },
{ "BARCODE_C25IND", BARCODE_C25IND, 7 },
{ "BARCODE_CODE39", BARCODE_CODE39, 8 },
{ "BARCODE_EXCODE39", BARCODE_EXCODE39, 9 },
{ "", -1, 10 },
{ "", -1, 11 },
{ "", -1, 12 },
{ "BARCODE_EANX", BARCODE_EANX, 13 },
{ "BARCODE_EANX_CHK", BARCODE_EANX_CHK, 14 },
{ "", -1, 15 },
{ "BARCODE_GS1_128", BARCODE_GS1_128, 16 },
{ "", -1, 17 },
{ "BARCODE_CODABAR", BARCODE_CODABAR, 18 },
{ "", -1, 19 },
{ "BARCODE_CODE128", BARCODE_CODE128, 20 },
{ "BARCODE_DPLEIT", BARCODE_DPLEIT, 21 },
{ "BARCODE_DPIDENT", BARCODE_DPIDENT, 22 },
{ "BARCODE_CODE16K", BARCODE_CODE16K, 23 },
{ "BARCODE_CODE49", BARCODE_CODE49, 24 },
{ "BARCODE_CODE93", BARCODE_CODE93, 25 },
{ "", -1, 26 },
{ "", -1, 27 },
{ "BARCODE_FLAT", BARCODE_FLAT, 28 },
{ "BARCODE_DBAR_OMN", BARCODE_DBAR_OMN, 29 },
{ "BARCODE_DBAR_LTD", BARCODE_DBAR_LTD, 30 },
{ "BARCODE_DBAR_EXP", BARCODE_DBAR_EXP, 31 },
{ "BARCODE_TELEPEN", BARCODE_TELEPEN, 32 },
{ "", -1, 33 },
{ "BARCODE_UPCA", BARCODE_UPCA, 34 },
{ "BARCODE_UPCA_CHK", BARCODE_UPCA_CHK, 35 },
{ "", -1, 36 },
{ "BARCODE_UPCE", BARCODE_UPCE, 37 },
{ "BARCODE_UPCE_CHK", BARCODE_UPCE_CHK, 38 },
{ "", -1, 39 },
{ "BARCODE_POSTNET", BARCODE_POSTNET, 40 },
{ "", -1, 41 },
{ "", -1, 42 },
{ "", -1, 43 },
{ "", -1, 44 },
{ "", -1, 45 },
{ "", -1, 46 },
{ "BARCODE_MSI_PLESSEY", BARCODE_MSI_PLESSEY, 47 },
{ "", -1, 48 },
{ "BARCODE_FIM", BARCODE_FIM, 49 },
{ "BARCODE_LOGMARS", BARCODE_LOGMARS, 50 },
{ "BARCODE_PHARMA", BARCODE_PHARMA, 51 },
{ "BARCODE_PZN", BARCODE_PZN, 52 },
{ "BARCODE_PHARMA_TWO", BARCODE_PHARMA_TWO, 53 },
{ "", -1, 54 },
{ "BARCODE_PDF417", BARCODE_PDF417, 55 },
{ "BARCODE_PDF417COMP", BARCODE_PDF417COMP, 56 },
{ "BARCODE_MAXICODE", BARCODE_MAXICODE, 57 },
{ "BARCODE_QRCODE", BARCODE_QRCODE, 58 },
{ "", -1, 59 },
{ "BARCODE_CODE128B", BARCODE_CODE128B, 60 },
{ "", -1, 61 },
{ "", -1, 62 },
{ "BARCODE_AUSPOST", BARCODE_AUSPOST, 63 },
{ "", -1, 64 },
{ "", -1, 65 },
{ "BARCODE_AUSREPLY", BARCODE_AUSREPLY, 66 },
{ "BARCODE_AUSROUTE", BARCODE_AUSROUTE, 67 },
{ "BARCODE_AUSREDIRECT", BARCODE_AUSREDIRECT, 68 },
{ "BARCODE_ISBNX", BARCODE_ISBNX, 69 },
{ "BARCODE_RM4SCC", BARCODE_RM4SCC, 70 },
{ "BARCODE_DATAMATRIX", BARCODE_DATAMATRIX, 71 },
{ "BARCODE_EAN14", BARCODE_EAN14, 72 },
{ "BARCODE_VIN", BARCODE_VIN, 73 },
{ "BARCODE_CODABLOCKF", BARCODE_CODABLOCKF, 74 },
{ "BARCODE_NVE18", BARCODE_NVE18, 75 },
{ "BARCODE_JAPANPOST", BARCODE_JAPANPOST, 76 },
{ "BARCODE_KOREAPOST", BARCODE_KOREAPOST, 77 },
{ "", -1, 78 },
{ "BARCODE_DBAR_STK", BARCODE_DBAR_STK, 79 },
{ "BARCODE_DBAR_OMNSTK", BARCODE_DBAR_OMNSTK, 80 },
{ "BARCODE_DBAR_EXPSTK", BARCODE_DBAR_EXPSTK, 81 },
{ "BARCODE_PLANET", BARCODE_PLANET, 82 },
{ "", -1, 83 },
{ "BARCODE_MICROPDF417", BARCODE_MICROPDF417, 84 },
{ "BARCODE_USPS_IMAIL", BARCODE_USPS_IMAIL, 85 },
{ "BARCODE_PLESSEY", BARCODE_PLESSEY, 86 },
{ "BARCODE_TELEPEN_NUM", BARCODE_TELEPEN_NUM, 87 },
{ "", -1, 88 },
{ "BARCODE_ITF14", BARCODE_ITF14, 89 },
{ "BARCODE_KIX", BARCODE_KIX, 90 },
{ "", -1, 91 },
{ "BARCODE_AZTEC", BARCODE_AZTEC, 92 },
{ "BARCODE_DAFT", BARCODE_DAFT, 93 },
{ "", -1, 94 },
{ "", -1, 95 },
{ "BARCODE_DPD", BARCODE_DPD, 96 },
{ "BARCODE_MICROQR", BARCODE_MICROQR, 97 },
{ "BARCODE_HIBC_128", BARCODE_HIBC_128, 98 },
{ "BARCODE_HIBC_39", BARCODE_HIBC_39, 99 },
{ "", -1, 100 },
{ "", -1, 101 },
{ "BARCODE_HIBC_DM", BARCODE_HIBC_DM, 102 },
{ "", -1, 103 },
{ "BARCODE_HIBC_QR", BARCODE_HIBC_QR, 104 },
{ "", -1, 105 },
{ "BARCODE_HIBC_PDF", BARCODE_HIBC_PDF, 106 },
{ "", -1, 107 },
{ "BARCODE_HIBC_MICPDF", BARCODE_HIBC_MICPDF, 108 },
{ "", -1, 109 },
{ "BARCODE_HIBC_BLOCKF", BARCODE_HIBC_BLOCKF, 110 },
{ "", -1, 111 },
{ "BARCODE_HIBC_AZTEC", BARCODE_HIBC_AZTEC, 112 },
{ "", -1, 113 },
{ "", -1, 114 },
{ "BARCODE_DOTCODE", BARCODE_DOTCODE, 115 },
{ "BARCODE_HANXIN", BARCODE_HANXIN, 116 },
{ "", -1, 117 },
{ "", -1, 118 },
{ "", -1, 119 },
{ "", -1, 120 },
{ "BARCODE_MAILMARK", BARCODE_MAILMARK, 121 },
{ "", -1, 122 },
{ "", -1, 123 },
{ "", -1, 124 },
{ "", -1, 125 },
{ "", -1, 126 },
{ "", -1, 127 },
{ "BARCODE_AZRUNE", BARCODE_AZRUNE, 128 },
{ "BARCODE_CODE32", BARCODE_CODE32, 129 },
{ "BARCODE_EANX_CC", BARCODE_EANX_CC, 130 },
{ "BARCODE_GS1_128_CC", BARCODE_GS1_128_CC, 131 },
{ "BARCODE_DBAR_OMN_CC", BARCODE_DBAR_OMN_CC, 132 },
{ "BARCODE_DBAR_LTD_CC", BARCODE_DBAR_LTD_CC, 133 },
{ "BARCODE_DBAR_EXP_CC", BARCODE_DBAR_EXP_CC, 134 },
{ "BARCODE_UPCA_CC", BARCODE_UPCA_CC, 135 },
{ "BARCODE_UPCE_CC", BARCODE_UPCE_CC, 136 },
{ "BARCODE_DBAR_STK_CC", BARCODE_DBAR_STK_CC, 137 },
{ "BARCODE_DBAR_OMNSTK_CC", BARCODE_DBAR_OMNSTK_CC, 138 },
{ "BARCODE_DBAR_EXPSTK_CC", BARCODE_DBAR_EXPSTK_CC, 139 },
{ "BARCODE_CHANNEL", BARCODE_CHANNEL, 140 },
{ "BARCODE_CODEONE", BARCODE_CODEONE, 141 },
{ "BARCODE_GRIDMATRIX", BARCODE_GRIDMATRIX, 142 },
{ "BARCODE_UPNQR", BARCODE_UPNQR, 143 },
{ "BARCODE_ULTRA", BARCODE_ULTRA, 144 },
{ "BARCODE_RMQR", BARCODE_RMQR, 145 },
};
name[0] = '\0';
if (!ZBarcode_ValidID(symbol_id)) {
return 1;
}
assert(symbol_id >= 0 && symbol_id < ARRAY_SIZE(data) && data[symbol_id].name[0]);
/* Self-check, shouldn't happen */
if (data[symbol_id].val != symbol_id || (data[symbol_id].define != -1 && data[symbol_id].define != symbol_id)) {
assert(0); /* Not reached */
return -1;
}
strcpy(name, data[symbol_id].name);
return 0;
}
/* Return the capability flags for symbology `symbol_id` that match `cap_flag` */
unsigned int ZBarcode_Cap(int symbol_id, unsigned int cap_flag) {
unsigned int result = 0;

View File

@ -330,170 +330,13 @@ int testUtilSetSymbol(struct zint_symbol *symbol, int symbology, int input_mode,
/* Pretty name for symbology */
const char *testUtilBarcodeName(int symbology) {
struct item {
const char *name;
int define;
int val;
};
static const struct item data[] = {
{ "", -1, 0 },
{ "BARCODE_CODE11", BARCODE_CODE11, 1 },
{ "BARCODE_C25STANDARD", BARCODE_C25STANDARD, 2 },
{ "BARCODE_C25INTER", BARCODE_C25INTER, 3 },
{ "BARCODE_C25IATA", BARCODE_C25IATA, 4 },
{ "", -1, 5 },
{ "BARCODE_C25LOGIC", BARCODE_C25LOGIC, 6 },
{ "BARCODE_C25IND", BARCODE_C25IND, 7 },
{ "BARCODE_CODE39", BARCODE_CODE39, 8 },
{ "BARCODE_EXCODE39", BARCODE_EXCODE39, 9 },
{ "", -1, 10 },
{ "", -1, 11 },
{ "", -1, 12 },
{ "BARCODE_EANX", BARCODE_EANX, 13 },
{ "BARCODE_EANX_CHK", BARCODE_EANX_CHK, 14 },
{ "", -1, 15 },
{ "BARCODE_GS1_128", BARCODE_GS1_128, 16 },
{ "", -1, 17 },
{ "BARCODE_CODABAR", BARCODE_CODABAR, 18 },
{ "", -1, 19 },
{ "BARCODE_CODE128", BARCODE_CODE128, 20 },
{ "BARCODE_DPLEIT", BARCODE_DPLEIT, 21 },
{ "BARCODE_DPIDENT", BARCODE_DPIDENT, 22 },
{ "BARCODE_CODE16K", BARCODE_CODE16K, 23 },
{ "BARCODE_CODE49", BARCODE_CODE49, 24 },
{ "BARCODE_CODE93", BARCODE_CODE93, 25 },
{ "", -1, 26 },
{ "", -1, 27 },
{ "BARCODE_FLAT", BARCODE_FLAT, 28 },
{ "BARCODE_DBAR_OMN", BARCODE_DBAR_OMN, 29 },
{ "BARCODE_DBAR_LTD", BARCODE_DBAR_LTD, 30 },
{ "BARCODE_DBAR_EXP", BARCODE_DBAR_EXP, 31 },
{ "BARCODE_TELEPEN", BARCODE_TELEPEN, 32 },
{ "", -1, 33 },
{ "BARCODE_UPCA", BARCODE_UPCA, 34 },
{ "BARCODE_UPCA_CHK", BARCODE_UPCA_CHK, 35 },
{ "", -1, 36 },
{ "BARCODE_UPCE", BARCODE_UPCE, 37 },
{ "BARCODE_UPCE_CHK", BARCODE_UPCE_CHK, 38 },
{ "", -1, 39 },
{ "BARCODE_POSTNET", BARCODE_POSTNET, 40 },
{ "", -1, 41 },
{ "", -1, 42 },
{ "", -1, 43 },
{ "", -1, 44 },
{ "", -1, 45 },
{ "", -1, 46 },
{ "BARCODE_MSI_PLESSEY", BARCODE_MSI_PLESSEY, 47 },
{ "", -1, 48 },
{ "BARCODE_FIM", BARCODE_FIM, 49 },
{ "BARCODE_LOGMARS", BARCODE_LOGMARS, 50 },
{ "BARCODE_PHARMA", BARCODE_PHARMA, 51 },
{ "BARCODE_PZN", BARCODE_PZN, 52 },
{ "BARCODE_PHARMA_TWO", BARCODE_PHARMA_TWO, 53 },
{ "", -1, 54 },
{ "BARCODE_PDF417", BARCODE_PDF417, 55 },
{ "BARCODE_PDF417COMP", BARCODE_PDF417COMP, 56 },
{ "BARCODE_MAXICODE", BARCODE_MAXICODE, 57 },
{ "BARCODE_QRCODE", BARCODE_QRCODE, 58 },
{ "", -1, 59 },
{ "BARCODE_CODE128B", BARCODE_CODE128B, 60 },
{ "", -1, 61 },
{ "", -1, 62 },
{ "BARCODE_AUSPOST", BARCODE_AUSPOST, 63 },
{ "", -1, 64 },
{ "", -1, 65 },
{ "BARCODE_AUSREPLY", BARCODE_AUSREPLY, 66 },
{ "BARCODE_AUSROUTE", BARCODE_AUSROUTE, 67 },
{ "BARCODE_AUSREDIRECT", BARCODE_AUSREDIRECT, 68 },
{ "BARCODE_ISBNX", BARCODE_ISBNX, 69 },
{ "BARCODE_RM4SCC", BARCODE_RM4SCC, 70 },
{ "BARCODE_DATAMATRIX", BARCODE_DATAMATRIX, 71 },
{ "BARCODE_EAN14", BARCODE_EAN14, 72 },
{ "BARCODE_VIN", BARCODE_VIN, 73 },
{ "BARCODE_CODABLOCKF", BARCODE_CODABLOCKF, 74 },
{ "BARCODE_NVE18", BARCODE_NVE18, 75 },
{ "BARCODE_JAPANPOST", BARCODE_JAPANPOST, 76 },
{ "BARCODE_KOREAPOST", BARCODE_KOREAPOST, 77 },
{ "", -1, 78 },
{ "BARCODE_DBAR_STK", BARCODE_DBAR_STK, 79 },
{ "BARCODE_DBAR_OMNSTK", BARCODE_DBAR_OMNSTK, 80 },
{ "BARCODE_DBAR_EXPSTK", BARCODE_DBAR_EXPSTK, 81 },
{ "BARCODE_PLANET", BARCODE_PLANET, 82 },
{ "", -1, 83 },
{ "BARCODE_MICROPDF417", BARCODE_MICROPDF417, 84 },
{ "BARCODE_USPS_IMAIL", BARCODE_USPS_IMAIL, 85 },
{ "BARCODE_PLESSEY", BARCODE_PLESSEY, 86 },
{ "BARCODE_TELEPEN_NUM", BARCODE_TELEPEN_NUM, 87 },
{ "", -1, 88 },
{ "BARCODE_ITF14", BARCODE_ITF14, 89 },
{ "BARCODE_KIX", BARCODE_KIX, 90 },
{ "", -1, 91 },
{ "BARCODE_AZTEC", BARCODE_AZTEC, 92 },
{ "BARCODE_DAFT", BARCODE_DAFT, 93 },
{ "", -1, 94 },
{ "", -1, 95 },
{ "BARCODE_DPD", BARCODE_DPD, 96 },
{ "BARCODE_MICROQR", BARCODE_MICROQR, 97 },
{ "BARCODE_HIBC_128", BARCODE_HIBC_128, 98 },
{ "BARCODE_HIBC_39", BARCODE_HIBC_39, 99 },
{ "", -1, 100 },
{ "", -1, 101 },
{ "BARCODE_HIBC_DM", BARCODE_HIBC_DM, 102 },
{ "", -1, 103 },
{ "BARCODE_HIBC_QR", BARCODE_HIBC_QR, 104 },
{ "", -1, 105 },
{ "BARCODE_HIBC_PDF", BARCODE_HIBC_PDF, 106 },
{ "", -1, 107 },
{ "BARCODE_HIBC_MICPDF", BARCODE_HIBC_MICPDF, 108 },
{ "", -1, 109 },
{ "BARCODE_HIBC_BLOCKF", BARCODE_HIBC_BLOCKF, 110 },
{ "", -1, 111 },
{ "BARCODE_HIBC_AZTEC", BARCODE_HIBC_AZTEC, 112 },
{ "", -1, 113 },
{ "", -1, 114 },
{ "BARCODE_DOTCODE", BARCODE_DOTCODE, 115 },
{ "BARCODE_HANXIN", BARCODE_HANXIN, 116 },
{ "", -1, 117 },
{ "", -1, 118 },
{ "", -1, 119 },
{ "", -1, 120 },
{ "BARCODE_MAILMARK", BARCODE_MAILMARK, 121 },
{ "", -1, 122 },
{ "", -1, 123 },
{ "", -1, 124 },
{ "", -1, 125 },
{ "", -1, 126 },
{ "", -1, 127 },
{ "BARCODE_AZRUNE", BARCODE_AZRUNE, 128 },
{ "BARCODE_CODE32", BARCODE_CODE32, 129 },
{ "BARCODE_EANX_CC", BARCODE_EANX_CC, 130 },
{ "BARCODE_GS1_128_CC", BARCODE_GS1_128_CC, 131 },
{ "BARCODE_DBAR_OMN_CC", BARCODE_DBAR_OMN_CC, 132 },
{ "BARCODE_DBAR_LTD_CC", BARCODE_DBAR_LTD_CC, 133 },
{ "BARCODE_DBAR_EXP_CC", BARCODE_DBAR_EXP_CC, 134 },
{ "BARCODE_UPCA_CC", BARCODE_UPCA_CC, 135 },
{ "BARCODE_UPCE_CC", BARCODE_UPCE_CC, 136 },
{ "BARCODE_DBAR_STK_CC", BARCODE_DBAR_STK_CC, 137 },
{ "BARCODE_DBAR_OMNSTK_CC", BARCODE_DBAR_OMNSTK_CC, 138 },
{ "BARCODE_DBAR_EXPSTK_CC", BARCODE_DBAR_EXPSTK_CC, 139 },
{ "BARCODE_CHANNEL", BARCODE_CHANNEL, 140 },
{ "BARCODE_CODEONE", BARCODE_CODEONE, 141 },
{ "BARCODE_GRIDMATRIX", BARCODE_GRIDMATRIX, 142 },
{ "BARCODE_UPNQR", BARCODE_UPNQR, 143 },
{ "BARCODE_ULTRA", BARCODE_ULTRA, 144 },
{ "BARCODE_RMQR", BARCODE_RMQR, 145 },
};
static const int data_size = ARRAY_SIZE(data);
static char name[32];
if (symbology < 0 || symbology >= data_size) {
return "";
}
// Self-check
if (data[symbology].val != symbology || (data[symbology].define != -1 && data[symbology].define != symbology)) {
if (ZBarcode_BarcodeName(symbology, name) == -1) {
fprintf(stderr, "testUtilBarcodeName: data table out of sync (%d)\n", symbology);
abort();
}
return data[symbology].name;
return name;
}
/* Pretty name for error/warning */

View File

@ -70,10 +70,6 @@
extern "C" {
#endif
#ifndef ARRAY_SIZE
#define ARRAY_SIZE(x) ((int) (sizeof(x) / sizeof((x)[0])))
#endif
extern int assertionFailed;
extern int assertionNum;
extern const char *assertionFilename;

View File

@ -404,6 +404,10 @@ extern "C" {
/* Is `symbol_id` a recognized symbology? */
ZINT_EXTERN int ZBarcode_ValidID(int symbol_id);
/* Copy BARCODE_XXX name of `symbol_id` into `name` buffer, NUL-terminated.
Returns 0 if valid, non-zero (1 or -1) if not valid */
ZINT_EXTERN int ZBarcode_BarcodeName(int symbol_id, char name[32]);
/* Return the capability flags for symbology `symbol_id` that match `cap_flag` */
ZINT_EXTERN unsigned int ZBarcode_Cap(int symbol_id, unsigned int cap_flag);

View File

@ -31,49 +31,39 @@
/* Qt 5.7 did not require it. */
#include <QPainterPath>
// Shorthand
#define QSL QStringLiteral
namespace Zint {
static const char *fontStyle = "Helvetica";
static const char *fontStyleError = "Helvetica";
static const int fontSizeError = 14; /* Point size */
QZint::QZint() {
m_zintSymbol = NULL;
m_symbol = BARCODE_CODE128;
m_height = 0.0f;
m_borderType = 0;
m_borderWidth = 0;
m_fontSetting = 0;
m_option_1 = -1;
m_option_2 = 0;
m_option_3 = 0;
m_fgColor = Qt::black;
m_bgColor = Qt::white;
m_cmyk = false;
m_error = 0;
m_input_mode = UNICODE_MODE;
m_scale = 1.0f;
m_show_hrt = 1;
m_eci = 0;
m_dotty = false;
m_dot_size = 4.0f / 5.0f;
m_guardDescent = 5.0f;
QZint::QZint()
: m_zintSymbol(NULL), m_symbol(BARCODE_CODE128), m_input_mode(UNICODE_MODE),
m_height(0.0f),
m_option_1(-1), m_option_2(0), m_option_3(0),
m_scale(1.0f),
m_dotty(false), m_dot_size(4.0f / 5.0f),
m_guardDescent(5.0f),
m_fgColor(Qt::black), m_bgColor(Qt::white), m_cmyk(false),
m_borderType(0), m_borderWidth(0),
m_whitespace(0), m_vwhitespace(0),
m_fontSetting(0),
m_show_hrt(true),
m_gssep(false),
m_quiet_zones(false), m_no_quiet_zones(false),
m_compliant_height(false),
m_rotate_angle(0),
m_eci(0),
m_gs1parens(false), m_gs1nocheck(false),
m_reader_init(false),
m_warn_level(WARN_DEFAULT), m_debug(false),
m_encodedWidth(0), m_encodedRows(0),
m_error(0),
target_size_horiz(0), target_size_vert(0) // Legacy
{
memset(&m_structapp, 0, sizeof(m_structapp));
m_whitespace = 0;
m_vwhitespace = 0;
m_gs1parens = false;
m_gs1nocheck = false;
m_gssep = false;
m_quiet_zones = false;
m_no_quiet_zones = false;
m_compliant_height = false;
m_reader_init = false;
m_rotate_angle = 0;
m_debug = false;
m_encodedWidth = 0;
m_encodedRows = 0;
target_size_horiz = 0; /* Legacy */
target_size_vert = 0; /* Legacy */
}
QZint::~QZint() {
@ -127,16 +117,19 @@ namespace Zint {
if (m_reader_init) {
m_zintSymbol->output_options |= READER_INIT;
}
if (m_warn_level) {
m_zintSymbol->warn_level = m_warn_level;
}
if (m_debug) {
m_zintSymbol->debug |= ZINT_DEBUG_PRINT;
}
strcpy(m_zintSymbol->fgcolour, m_fgColor.name().toLatin1().right(6));
if (m_fgColor.alpha() != 0xff) {
if (m_fgColor.alpha() != 0xFF) {
strcat(m_zintSymbol->fgcolour, m_fgColor.name(QColor::HexArgb).toLatin1().mid(1,2));
}
strcpy(m_zintSymbol->bgcolour, m_bgColor.name().toLatin1().right(6));
if (m_bgColor.alpha() != 0xff) {
if (m_bgColor.alpha() != 0xFF) {
strcat(m_zintSymbol->bgcolour, m_bgColor.name(QColor::HexArgb).toLatin1().mid(1,2));
}
if (m_cmyk) {
@ -507,6 +500,14 @@ namespace Zint {
m_reader_init = readerInit;
}
int QZint::warnLevel() const {
return m_warn_level;
}
void QZint::setWarnLevel(int warnLevel) {
m_warn_level = warnLevel;
}
bool QZint::debug() const {
return m_debug;
}
@ -541,10 +542,18 @@ namespace Zint {
return ZBarcode_Cap(symbology ? symbology : m_symbol, ZINT_CAP_HRT);
}
bool QZint::isStackable(int symbology) const {
return ZBarcode_Cap(symbology ? symbology : m_symbol, ZINT_CAP_STACKABLE);
}
bool QZint::isExtendable(int symbology) const {
return ZBarcode_Cap(symbology ? symbology : m_symbol, ZINT_CAP_EXTENDABLE);
}
bool QZint::isComposite(int symbology) const {
return ZBarcode_Cap(symbology ? symbology : m_symbol, ZINT_CAP_COMPOSITE);
}
bool QZint::supportsECI(int symbology) const {
return ZBarcode_Cap(symbology ? symbology : m_symbol, ZINT_CAP_ECI);
}
@ -553,6 +562,10 @@ namespace Zint {
return ZBarcode_Cap(symbology ? symbology : m_symbol, ZINT_CAP_GS1);
}
bool QZint::isDotty(int symbology) const {
return ZBarcode_Cap(symbology ? symbology : m_symbol, ZINT_CAP_DOTTY);
}
bool QZint::hasDefaultQuietZones(int symbology) const {
return ZBarcode_Cap(symbology ? symbology : m_symbol, ZINT_CAP_QUIET_ZONES);
}
@ -561,14 +574,22 @@ namespace Zint {
return ZBarcode_Cap(symbology ? symbology : m_symbol, ZINT_CAP_FIXED_RATIO);
}
bool QZint::isDotty(int symbology) const {
return ZBarcode_Cap(symbology ? symbology : m_symbol, ZINT_CAP_DOTTY);
}
bool QZint::supportsReaderInit(int symbology) const {
return ZBarcode_Cap(symbology ? symbology : m_symbol, ZINT_CAP_READER_INIT);
}
bool QZint::supportsFullMultibyte(int symbology) const {
return ZBarcode_Cap(symbology ? symbology : m_symbol, ZINT_CAP_FULL_MULTIBYTE);
}
bool QZint::hasMask(int symbology) const {
return ZBarcode_Cap(symbology ? symbology : m_symbol, ZINT_CAP_MASK);
}
bool QZint::supportsStructApp(int symbology) const {
return ZBarcode_Cap(symbology ? symbology : m_symbol, ZINT_CAP_STRUCTAPP);
}
bool QZint::hasCompliantHeight(int symbology) const {
return ZBarcode_Cap(symbology ? symbology : m_symbol, ZINT_CAP_COMPLIANT_HEIGHT);
}
@ -589,7 +610,7 @@ namespace Zint {
return ZBarcode_Version();
}
bool QZint::save_to_file(QString filename) {
bool QZint::save_to_file(const QString &filename) {
resetSymbol();
strcpy(m_zintSymbol->outfile, filename.toLatin1().left(255));
QByteArray bstr = m_text.toUtf8();
@ -796,4 +817,239 @@ namespace Zint {
painter.restore();
}
/* Translate settings into Command Line equivalent. Set `win` to use Windows escaping of data.
If `autoHeight` set then `--height=` option will not be emitted.
If HEIGHTPERROW_MODE set and non-zero `heightPerRow` given then use that for height instead of internal
height */
QString QZint::getAsCLI(const bool win, const bool longOptOnly, const bool barcodeNames,
const bool autoHeight, const float heightPerRow, const QString &outfile) const {
QString cmd(win ? QSL("zint.exe") : QSL("zint"));
char name_buf[32];
if (barcodeNames && ZBarcode_BarcodeName(m_symbol, name_buf) == 0) {
QString name(name_buf + 8); // Strip "BARCODE_" prefix
arg_str(cmd, longOptOnly ? "--barcode=" : "-b ", name);
} else {
arg_int(cmd, longOptOnly ? "--barcode=" : "-b ", m_symbol);
}
if (isExtendable()) {
arg_int(cmd, "--addongap=", option2());
}
if (bgColor() != Qt::white && bgColor() != QColor(0xFF, 0xFF, 0xFF, 0)) {
arg_color(cmd, "--bg=", bgColor());
}
arg_bool(cmd, "--binary", (inputMode() & 0x07) == DATA_MODE);
arg_bool(cmd, "--bind", (borderType() & BARCODE_BIND) && !(borderType() & BARCODE_BOX));
arg_bool(cmd, "--bold", fontSetting() & BOLD_TEXT);
arg_int(cmd, "--border=", borderWidth());
arg_bool(cmd, "--box", borderType() & BARCODE_BOX);
arg_bool(cmd, "--cmyk", cmyk());
if (m_symbol == BARCODE_DBAR_EXPSTK || m_symbol == BARCODE_DBAR_EXPSTK_CC
|| m_symbol == BARCODE_PDF417 || m_symbol == BARCODE_PDF417COMP || m_symbol == BARCODE_HIBC_PDF
|| m_symbol == BARCODE_MICROPDF417 || m_symbol == BARCODE_HIBC_MICPDF
|| m_symbol == BARCODE_DOTCODE || m_symbol == BARCODE_CODABLOCKF || m_symbol == BARCODE_HIBC_BLOCKF) {
arg_int(cmd, "--cols=", option2());
}
arg_bool(cmd, "--compliantheight", hasCompliantHeight() && compliantHeight());
arg_data(cmd, longOptOnly ? "--data=" : "-d ", text(), win);
if (m_symbol == BARCODE_DATAMATRIX || m_symbol == BARCODE_HIBC_DM) {
arg_bool(cmd, "--dmre", option3() == DM_DMRE);
}
if ((m_symbol == BARCODE_DOTCODE || (isDotty() && dotty())) && dotSize() != 0.8f) {
arg_float(cmd, "--dotsize=", dotSize());
}
if (m_symbol != BARCODE_DOTCODE && isDotty() && dotty()) {
arg_bool(cmd, "--dotty", dotty());
}
if (supportsECI()) {
arg_int(cmd, "--eci=", eci());
}
arg_bool(cmd, "--esc", inputMode() & ESCAPE_MODE);
if (fgColor() != Qt::black) {
arg_color(cmd, "--fg=", fgColor());
}
arg_bool(cmd, "--fullmultibyte", supportsFullMultibyte() && (option3() & 0xFF) == ZINT_FULL_MULTIBYTE);
if (supportsGS1()) {
arg_bool(cmd, "--gs1", (inputMode() & 0x07) == GS1_MODE);
arg_bool(cmd, "--gs1parens", gs1Parens());
arg_bool(cmd, "--gs1nocheck", gs1NoCheck());
arg_bool(cmd, "--gssep", gsSep());
}
if (isExtendable() && guardDescent() != 5.0f) {
arg_float(cmd, "--guarddescent=", guardDescent(), true /*allowZero*/);
}
if (!autoHeight && !isFixedRatio()) {
if (inputMode() & HEIGHTPERROW_MODE) {
arg_float(cmd, "--height=", heightPerRow ? heightPerRow : height());
arg_bool(cmd, "--heightperrow", true);
} else {
arg_float(cmd, "--height=", height());
}
}
arg_bool(cmd, "--init", supportsReaderInit() && readerInit());
if (hasMask()) {
arg_int(cmd, "--mask=", (option3() >> 8) - 1, true /*allowZero*/);
}
if (m_symbol == BARCODE_MAXICODE || isComposite()) {
arg_int(cmd, "--mode=", option1());
}
arg_bool(cmd, "--nobackground", bgColor() == QColor(0xFF, 0xFF, 0xFF, 0));
arg_bool(cmd, "--noquietzones", hasDefaultQuietZones() && noQuietZones());
arg_bool(cmd, "--notext", hasHRT() && !showText());
arg_data(cmd, longOptOnly ? "--output=" : "-o ", outfile, win);
if (m_symbol == BARCODE_MAXICODE || isComposite()) {
arg_data(cmd, "--primary=", primaryMessage(), win);
}
arg_bool(cmd, "--quietzones", !hasDefaultQuietZones() && quietZones());
arg_int(cmd, "--rotate=", rotateAngle());
if (m_symbol == BARCODE_CODE16K || m_symbol == BARCODE_CODABLOCKF || m_symbol == BARCODE_HIBC_BLOCKF
|| m_symbol == BARCODE_CODE49) {
arg_int(cmd, "--rows=", option1());
} else if (m_symbol == BARCODE_DBAR_EXPSTK || m_symbol == BARCODE_DBAR_EXPSTK_CC
|| m_symbol == BARCODE_PDF417 || m_symbol == BARCODE_PDF417COMP || m_symbol == BARCODE_HIBC_PDF) {
arg_int(cmd, "--rows=", option3());
}
if (scale() != 1.0f) {
arg_float(cmd, "--scale=", scale());
}
if (m_symbol == BARCODE_MAXICODE) {
arg_int(cmd, "--scmvv=", option2() - 1, true /*allowZero*/);
}
if (m_symbol == BARCODE_PDF417 || m_symbol == BARCODE_PDF417COMP || m_symbol == BARCODE_HIBC_PDF
|| m_symbol == BARCODE_AZTEC || m_symbol == BARCODE_HIBC_AZTEC
|| m_symbol == BARCODE_QRCODE || m_symbol == BARCODE_HIBC_QR || m_symbol == BARCODE_MICROQR
|| m_symbol == BARCODE_RMQR || m_symbol == BARCODE_GRIDMATRIX || m_symbol == BARCODE_HANXIN
|| m_symbol == BARCODE_ULTRA) {
arg_int(cmd, "--secure=", option1());
}
if (m_symbol == BARCODE_CODE16K || m_symbol == BARCODE_CODABLOCKF || m_symbol == BARCODE_HIBC_BLOCKF
|| m_symbol == BARCODE_CODE49) {
arg_int(cmd, "--separator=", option3());
}
arg_bool(cmd, "--small", fontSetting() & SMALL_TEXT);
if (m_symbol == BARCODE_DATAMATRIX || m_symbol == BARCODE_HIBC_DM) {
arg_bool(cmd, "--square", option3() == DM_SQUARE);
}
if (supportsStructApp()) {
arg_structapp(cmd, "--structapp=", structAppCount(), structAppIndex(), structAppID(), win);
}
arg_bool(cmd, "--verbose", debug());
if (m_symbol == BARCODE_AZTEC || m_symbol == BARCODE_HIBC_AZTEC
|| m_symbol == BARCODE_MSI_PLESSEY || m_symbol == BARCODE_CODE11
|| m_symbol == BARCODE_C25STANDARD || m_symbol == BARCODE_C25INTER || m_symbol == BARCODE_C25IATA
|| m_symbol == BARCODE_C25LOGIC || m_symbol == BARCODE_C25IND
|| m_symbol == BARCODE_CODE39 || m_symbol == BARCODE_HIBC_39 || m_symbol == BARCODE_EXCODE39
|| m_symbol == BARCODE_LOGMARS || m_symbol == BARCODE_CODABAR
|| m_symbol == BARCODE_DATAMATRIX || m_symbol == BARCODE_HIBC_DM
|| m_symbol == BARCODE_QRCODE || m_symbol == BARCODE_HIBC_QR || m_symbol == BARCODE_MICROQR
|| m_symbol == BARCODE_RMQR || m_symbol == BARCODE_GRIDMATRIX || m_symbol == BARCODE_HANXIN
|| m_symbol == BARCODE_CHANNEL || m_symbol == BARCODE_CODEONE || m_symbol == BARCODE_CODE93
|| m_symbol == BARCODE_ULTRA || m_symbol == BARCODE_VIN) {
arg_int(cmd, "--vers=", option2());
} else if (m_symbol == BARCODE_DAFT && option2() != 250) {
arg_int(cmd, "--vers=", option2());
}
arg_int(cmd, "--vwhitesp=", vWhitespace());
arg_int(cmd, longOptOnly ? "--whitesp=" : "-w ", whitespace());
arg_bool(cmd, "--werror", warnLevel() == WARN_FAIL_ALL);
return cmd;
}
/* `getAsCLI()` helpers */
void QZint::arg_str(QString &cmd, const char *const opt, const QString &val) {
if (!val.isEmpty()) {
QByteArray bstr = val.toUtf8();
cmd += QString::asprintf(" %s%.*s", opt, bstr.length(), bstr.data());
}
}
void QZint::arg_int(QString &cmd, const char *const opt, const int val, const bool allowZero) {
if (val > 0 || (val == 0 && allowZero)) {
cmd += QString::asprintf(" %s%d", opt, val);
}
}
void QZint::arg_bool(QString &cmd, const char *const opt, const bool val) {
if (val) {
cmd += QString::asprintf(" %s", opt);
}
}
void QZint::arg_color(QString &cmd, const char *const opt, const QColor val) {
if (val.alpha() != 0xFF) {
cmd += QString::asprintf(" %s%02X%02X%02X%02X", opt, val.red(), val.green(), val.blue(), val.alpha());
} else {
cmd += QString::asprintf(" %s%02X%02X%02X", opt, val.red(), val.green(), val.blue());
}
}
void QZint::arg_data(QString &cmd, const char *const opt, const QString &val, const bool win) {
if (!val.isEmpty()) {
QString text(val);
const char delim = win ? '"' : '\'';
if (win) {
// Difficult (impossible?) to fully escape strings on Windows, e.g. "blah%PATH%" will substitute
// env var PATH, so just doing basic escaping here
text.replace("\\\\", "\\\\\\\\"); // Double-up backslashed backslash `\\` -> `\\\\`
text.replace("\"", "\\\""); // Backslash quote `"` -> `\"`
QByteArray bstr = text.toUtf8();
cmd += QString::asprintf(" %s%c%.*s%c", opt, delim, bstr.length(), bstr.data(), delim);
} else {
text.replace("'", "'\\''"); // Single quote `'` -> `'\''`
QByteArray bstr = text.toUtf8();
cmd += QString::asprintf(" %s%c%.*s%c", opt, delim, bstr.length(), bstr.data(), delim);
}
}
}
void QZint::arg_float(QString &cmd, const char *const opt, const float val, const bool allowZero) {
if (val > 0 || (val == 0 && allowZero)) {
cmd += QString::asprintf(" %s%g", opt, val);
}
}
void QZint::arg_structapp(QString &cmd, const char *const opt, const int count, const int index,
const QString &id, const bool win) {
if (count >= 2 && index >= 1) {
if (id.isEmpty()) {
cmd += QString::asprintf(" %s%d,%d", opt, index, count);
} else {
QByteArray bstr = id.toUtf8();
arg_data(cmd, opt, QString::asprintf("%d,%d,%.*s", index, count, bstr.length(), bstr.data()), win);
}
}
}
} /* namespace Zint */

View File

@ -136,6 +136,9 @@ public:
bool readerInit() const;
void setReaderInit(bool readerInit);
int warnLevel() const;
void setWarnLevel(int warnLevel);
bool debug() const;
void setDebug(bool debug);
@ -155,13 +158,18 @@ public:
/* Test capabilities - ZBarcode_Cap() */
bool hasHRT(int symbology = 0) const;
bool isStackable(int symbology = 0) const;
bool isExtendable(int symbology = 0) const;
bool isComposite(int symbology = 0) const;
bool supportsECI(int symbology = 0) const;
bool supportsGS1(int symbology = 0) const;
bool isDotty(int symbology = 0) const;
bool hasDefaultQuietZones(int symbology = 0) const;
bool isFixedRatio(int symbology = 0) const;
bool isDotty(int symbology = 0) const;
bool supportsReaderInit(int symbology = 0) const;
bool supportsFullMultibyte(int symbology = 0) const;
bool hasMask(int symbology = 0) const;
bool supportsStructApp(int symbology = 0) const;
bool hasCompliantHeight(int symbology = 0) const;
int getError() const;
@ -169,13 +177,20 @@ public:
const QString& lastError() const;
bool hasErrors() const;
bool save_to_file(QString filename);
bool save_to_file(const QString &filename);
/* Note: legacy argument `mode` is not used */
void render(QPainter& painter, const QRectF& paintRect, AspectRatioMode mode = IgnoreAspectRatio);
int getVersion() const;
/* Translate settings into Command Line equivalent. Set `win` to use Windows escaping of data.
If `autoHeight` set then `--height=` option will not be emitted.
If HEIGHTPERROW_MODE set and non-zero `heightPerRow` given then use that for height instead of internal
height */
QString getAsCLI(const bool win, const bool longOptOnly = false, const bool barcodeNames = false,
const bool autoHeight = false, const float heightPerRow = 0.0f, const QString &outfile = "") const;
signals:
void encoded();
void errored();
@ -185,44 +200,55 @@ private:
void encode();
static Qt::GlobalColor colourToQtColor(int colour);
/* `getAsCLI()` helpers */
static void arg_str(QString &cmd, const char *const opt, const QString &val);
static void arg_int(QString &cmd, const char *const opt, const int val, const bool allowZero = false);
static void arg_bool(QString &cmd, const char *const opt, const bool val);
static void arg_color(QString &cmd, const char *const opt, const QColor val);
static void arg_data(QString &cmd, const char *const opt, const QString &val, const bool win);
static void arg_float(QString &cmd, const char *const opt, const float val, const bool allowZero = false);
static void arg_structapp(QString &cmd, const char *const opt, const int count, const int index,
const QString &id, const bool win);
private:
zint_symbol *m_zintSymbol;
int m_symbol;
int m_input_mode;
QString m_text;
QString m_primaryMessage;
float m_height;
int m_borderType;
int m_borderWidth;
int m_fontSetting;
int m_option_1;
int m_option_2;
int m_option_3;
int m_input_mode;
QColor m_fgColor;
QColor m_bgColor;
bool m_cmyk;
QString m_lastError;
int m_error;
int m_whitespace;
int m_vwhitespace;
zint_symbol * m_zintSymbol;
float m_scale;
bool m_show_hrt;
int m_eci;
int m_rotate_angle;
bool m_dotty;
float m_dot_size;
float m_guardDescent;
struct zint_structapp m_structapp;
bool m_gs1parens;
bool m_gs1nocheck;
QColor m_fgColor;
QColor m_bgColor;
bool m_cmyk;
int m_borderType;
int m_borderWidth;
int m_whitespace;
int m_vwhitespace;
int m_fontSetting;
bool m_show_hrt;
bool m_gssep;
bool m_quiet_zones;
bool m_no_quiet_zones;
bool m_compliant_height;
int m_rotate_angle;
int m_eci;
bool m_gs1parens;
bool m_gs1nocheck;
bool m_reader_init;
int m_warn_level;
bool m_debug;
int m_encodedWidth;
int m_encodedRows;
QString m_lastError;
int m_error;
int target_size_horiz; /* Legacy */
int target_size_vert; /* Legacy */

View File

@ -220,6 +220,10 @@ private slots:
bc.setReaderInit(readerInit);
QCOMPARE(bc.readerInit(), readerInit);
int warnLevel = WARN_FAIL_ALL;
bc.setWarnLevel(warnLevel);
QCOMPARE(bc.warnLevel(), warnLevel);
bool debug = true;
bc.setDebug(debug);
QCOMPARE(bc.debug(), debug);
@ -286,10 +290,19 @@ private slots:
QTest::addColumn<int>("symbology");
QTest::addColumn<int>("cap_flag");
QTest::newRow("BARCODE_CODE11") << BARCODE_CODE11 << (ZINT_CAP_HRT);
QTest::newRow("BARCODE_CODE128") << BARCODE_CODE128 << (ZINT_CAP_HRT | ZINT_CAP_READER_INIT);
QTest::newRow("BARCODE_EANX") << BARCODE_EANX << (ZINT_CAP_HRT | ZINT_CAP_EXTENDABLE | ZINT_CAP_QUIET_ZONES | ZINT_CAP_COMPLIANT_HEIGHT);
QTest::newRow("BARCODE_QRCODE") << BARCODE_QRCODE << (ZINT_CAP_ECI | ZINT_CAP_GS1 | ZINT_CAP_DOTTY | ZINT_CAP_FIXED_RATIO);
QTest::newRow("BARCODE_CODE11") << BARCODE_CODE11
<< (ZINT_CAP_HRT | ZINT_CAP_STACKABLE);
QTest::newRow("BARCODE_CODE128") << BARCODE_CODE128
<< (ZINT_CAP_HRT | ZINT_CAP_STACKABLE | ZINT_CAP_READER_INIT);
QTest::newRow("BARCODE_EANX") << BARCODE_EANX
<< (ZINT_CAP_HRT | ZINT_CAP_STACKABLE | ZINT_CAP_EXTENDABLE | ZINT_CAP_QUIET_ZONES
| ZINT_CAP_COMPLIANT_HEIGHT);
QTest::newRow("BARCODE_EANX_CC") << BARCODE_EANX_CC
<< (ZINT_CAP_HRT | ZINT_CAP_EXTENDABLE | ZINT_CAP_COMPOSITE | ZINT_CAP_GS1 | ZINT_CAP_QUIET_ZONES
| ZINT_CAP_COMPLIANT_HEIGHT);
QTest::newRow("BARCODE_QRCODE") << BARCODE_QRCODE
<< (ZINT_CAP_ECI | ZINT_CAP_GS1 | ZINT_CAP_DOTTY | ZINT_CAP_FIXED_RATIO | ZINT_CAP_FULL_MULTIBYTE
| ZINT_CAP_MASK | ZINT_CAP_STRUCTAPP);
}
void capTest()
@ -301,13 +314,18 @@ private slots:
bc.setSymbol(symbology);
QCOMPARE(bc.hasHRT(), (cap_flag & ZINT_CAP_HRT) != 0);
QCOMPARE(bc.isStackable(), (cap_flag & ZINT_CAP_STACKABLE) != 0);
QCOMPARE(bc.isExtendable(), (cap_flag & ZINT_CAP_EXTENDABLE) != 0);
QCOMPARE(bc.isComposite(), (cap_flag & ZINT_CAP_COMPOSITE) != 0);
QCOMPARE(bc.supportsECI(), (cap_flag & ZINT_CAP_ECI) != 0);
QCOMPARE(bc.supportsGS1(), (cap_flag & ZINT_CAP_GS1) != 0);
QCOMPARE(bc.isDotty(), (cap_flag & ZINT_CAP_DOTTY) != 0);
QCOMPARE(bc.hasDefaultQuietZones(), (cap_flag & ZINT_CAP_QUIET_ZONES) != 0);
QCOMPARE(bc.isFixedRatio(), (cap_flag & ZINT_CAP_FIXED_RATIO) != 0);
QCOMPARE(bc.isDotty(), (cap_flag & ZINT_CAP_DOTTY) != 0);
QCOMPARE(bc.supportsReaderInit(), (cap_flag & ZINT_CAP_READER_INIT) != 0);
QCOMPARE(bc.supportsFullMultibyte(), (cap_flag & ZINT_CAP_FULL_MULTIBYTE) != 0);
QCOMPARE(bc.hasMask(), (cap_flag & ZINT_CAP_MASK) != 0);
QCOMPARE(bc.supportsStructApp(), (cap_flag & ZINT_CAP_STRUCTAPP) != 0);
QCOMPARE(bc.hasCompliantHeight(), (cap_flag & ZINT_CAP_COMPLIANT_HEIGHT) != 0);
}
@ -409,6 +427,453 @@ private slots:
QCOMPARE(ret, 0);
}
}
void getAsCLITest_data()
{
QTest::addColumn<bool>("autoHeight");
QTest::addColumn<float>("heightPerRow");
QTest::addColumn<QString>("outfile");
QTest::addColumn<int>("symbology");
QTest::addColumn<int>("inputMode");
QTest::addColumn<QString>("text");
QTest::addColumn<QString>("primary");
QTest::addColumn<float>("height");
QTest::addColumn<int>("option1");
QTest::addColumn<int>("option2");
QTest::addColumn<int>("option3");
QTest::addColumn<float>("scale");
QTest::addColumn<bool>("dotty");
QTest::addColumn<float>("dotSize");
QTest::addColumn<float>("guardDescent");
QTest::addColumn<int>("structAppCount");
QTest::addColumn<int>("structAppIndex");
QTest::addColumn<QString>("structAppID");
QTest::addColumn<QColor>("fgColor");
QTest::addColumn<QColor>("bgColor");
QTest::addColumn<bool>("cmyk");
QTest::addColumn<int>("borderTypeIndex");
QTest::addColumn<int>("borderWidth");
QTest::addColumn<int>("whitespace");
QTest::addColumn<int>("vWhitespace");
QTest::addColumn<int>("fontSetting");
QTest::addColumn<bool>("showText");
QTest::addColumn<bool>("gsSep");
QTest::addColumn<bool>("quietZones");
QTest::addColumn<bool>("noQuietZones");
QTest::addColumn<bool>("compliantHeight");
QTest::addColumn<int>("rotateAngle");
QTest::addColumn<int>("eci");
QTest::addColumn<bool>("gs1Parens");
QTest::addColumn<bool>("gs1NoCheck");
QTest::addColumn<bool>("readerInit");
QTest::addColumn<int>("warnLevel");
QTest::addColumn<bool>("debug");
QTest::addColumn<QString>("expected_cmd");
QTest::addColumn<QString>("expected_win");
QTest::addColumn<QString>("expected_longOptOnly");
QTest::addColumn<QString>("expected_barcodeNames");
QTest::newRow("BARCODE_AUSPOST") << true << 0.0f << ""
<< BARCODE_AUSPOST << DATA_MODE // symbology-inputMode
<< "12345678" << "" // text-primary
<< 30.0f << -1 << 0 << 0 << 1.0f << false << 0.8f // height-dotSize
<< 5.0f << 0 << 0 << "" << QColor(Qt::black) << QColor(Qt::white) // guardDescent-bgColor
<< false << 0 << 0 << 0 << 0 << 0 // cmyk-fontSetting
<< true << false << false << false << true << 0 // showText-rotateAngle
<< 0 << false << false << false << WARN_DEFAULT << false // eci-debug
<< "zint -b 63 --binary --compliantheight -d '12345678'"
<< "zint.exe -b 63 --binary --compliantheight -d \"12345678\""
<< "zint --barcode=63 --binary --compliantheight --data='12345678'"
<< "zint -b AUSPOST --binary --compliantheight -d '12345678'";
QTest::newRow("BARCODE_AZTEC") << false << 0.0f << ""
<< BARCODE_AZTEC << UNICODE_MODE // symbology-inputMode
<< "12345678Ж0%var%" << "" // text-primary
<< 0.0f << 1 << 0 << 0 << 4.0f << true << 0.9f // height-dotSize
<< 5.0f << 2 << 1 << "as\"dfa'sdf" << QColor(Qt::blue) << QColor(Qt::white) // guardDescent-bgColor
<< true << 0 << 0 << 2 << 3 << 0 // cmyk-fontSetting
<< true << false << false << false << false << 0 // showText-rotateAngle
<< 7 << false << false << false << WARN_DEFAULT << false // eci-debug
<< "zint -b 92 --cmyk -d '12345678Ж0%var%' --dotsize=0.9 --dotty --eci=7 --fg=0000FF --scale=4"
" --secure=1 --structapp='1,2,as\"dfa'\\''sdf' --vwhitesp=3 -w 2"
<< "zint.exe -b 92 --cmyk -d \"12345678Ж0%var%\" --dotsize=0.9 --dotty --eci=7 --fg=0000FF --scale=4"
" --secure=1 --structapp=\"1,2,as\\\"dfa'sdf\" --vwhitesp=3 -w 2"
<< "" << "";
QTest::newRow("BARCODE_C25INTER") << true << 0.0f << ""
<< BARCODE_C25INTER << UNICODE_MODE // symbology-inputMode
<< "12345" << "" // text-primary
<< 0.0f << -1 << 2 << 0 << 1.0f << false << 0.8f // height-dotSize
<< 5.0f << 0 << 0 << "" << QColor(Qt::black) << QColor(Qt::white) // guardDescent-bgColor
<< false << 0 << 0 << 0 << 0 << SMALL_TEXT // cmyk-fontSetting
<< true << false << false << false << true << 0 // showText-rotateAngle
<< 0 << false << false << false << WARN_DEFAULT << false // eci-debug
<< "zint -b 3 --compliantheight -d '12345' --small --vers=2"
<< "zint.exe -b 3 --compliantheight -d \"12345\" --small --vers=2"
<< "" << "";
QTest::newRow("BARCODE_CHANNEL") << false << 0.0f << ""
<< BARCODE_CHANNEL << UNICODE_MODE // symbology-inputMode
<< "453678" << "" // text-primary
<< 19.7f << -1 << 7 << 0 << 1.0f << false << 0.8f // height-dotSize
<< 5.0f << 0 << 0 << "" << QColor(Qt::black) << QColor(255, 255, 255, 0) // guardDescent-bgColor
<< false << 1 << 2 << 0 << 0 << BOLD_TEXT // cmyk-fontSetting
<< true << false << true << false << false << 90 // showText-rotateAngle
<< 0 << false << false << false << WARN_DEFAULT << true // eci-debug
<< "zint -b 140 --bind --bold --border=2 -d '453678' --height=19.7 --nobackground --quietzones"
" --rotate=90 --verbose --vers=7"
<< "zint.exe -b 140 --bind --bold --border=2 -d \"453678\" --height=19.7 --nobackground --quietzones"
" --rotate=90 --verbose --vers=7"
<< "" << "";
QTest::newRow("BARCODE_GS1_128_CC") << false << 0.0f << ""
<< BARCODE_GS1_128_CC << UNICODE_MODE // symbology-inputMode
<< "[01]12345678901231[15]121212" << "[11]901222[99]ABCDE" // text-primary
<< 71.142f << 3 << 0 << 0 << 3.5f << false << 0.8f // height-dotSize
<< 5.0f << 0 << 0 << "" << QColor(Qt::black) << QColor(Qt::white) // guardDescent-bgColor
<< false << 0 << 0 << 0 << 0 << 0 // cmyk-fontSetting
<< false << false << true << false << true << 0 // showText-rotateAngle
<< 0 << false << false << false << WARN_DEFAULT << false // eci-debug
<< "zint -b 131 --compliantheight -d '[11]901222[99]ABCDE' --height=71.142 --mode=3 --notext"
" --primary='[01]12345678901231[15]121212' --quietzones --scale=3.5"
<< "zint.exe -b 131 --compliantheight -d \"[11]901222[99]ABCDE\" --height=71.142 --mode=3 --notext"
" --primary=\"[01]12345678901231[15]121212\" --quietzones --scale=3.5"
<< "" << "";
QTest::newRow("BARCODE_CODE16K") << false << 11.7f << ""
<< BARCODE_CODE16K << (UNICODE_MODE | HEIGHTPERROW_MODE) // symbology-inputMode
<< "12345678901234567890123456789012" << "" // text-primary
<< 0.0f << 4 << 0 << 2 << 1.0f << false << 0.8f // height-dotSize
<< 5.0f << 0 << 0 << "" << QColor(Qt::black) << QColor(Qt::white) // guardDescent-bgColor
<< false << 1 << 1 << 0 << 0 << SMALL_TEXT // cmyk-fontSetting
<< true << false << false << true << true << 0 // showText-rotateAngle
<< 0 << false << false << false << WARN_DEFAULT << false // eci-debug
<< "zint -b 23 --bind --border=1 --compliantheight -d '12345678901234567890123456789012'"
" --height=11.7 --heightperrow --noquietzones --rows=4 --separator=2 --small"
<< "zint.exe -b 23 --bind --border=1 --compliantheight -d \"12345678901234567890123456789012\""
" --height=11.7 --heightperrow --noquietzones --rows=4 --separator=2 --small"
<< "" << "";
QTest::newRow("BARCODE_CODABLOCKF") << true << 0.0f << ""
<< BARCODE_CODABLOCKF << (DATA_MODE | ESCAPE_MODE) // symbology-inputMode
<< "T\\n\\xA0t\\\"" << "" // text-primary
<< 0.0f << 2 << 5 << 3 << 3.0f << false << 0.8f // height-dotSize
<< 5.0f << 0 << 0 << "" << QColor(Qt::black) << QColor(Qt::white) // guardDescent-bgColor
<< false << 2 << 4 << 0 << 0 << 0 // cmyk-fontSetting
<< true << false << false << false << true << 0 // showText-rotateAngle
<< 0 << false << false << true << WARN_DEFAULT << false // eci-debug
<< "zint -b 74 --binary --border=4 --box --cols=5 --compliantheight -d 'T\\n\\xA0t\\\"' --esc --init"
" --rows=2 --scale=3 --separator=3"
<< "zint.exe -b 74 --binary --border=4 --box --cols=5 --compliantheight -d \"T\\n\\xA0t\\\\\"\" --esc --init"
" --rows=2 --scale=3 --separator=3"
<< "" << "";
QTest::newRow("BARCODE_DAFT") << false << 0.0f << ""
<< BARCODE_DAFT << UNICODE_MODE // symbology-inputMode
<< "daft" << "" // text-primary
<< 9.2f << -1 << 251 << 0 << 1.0f << false << 0.7f // height-dotSize
<< 5.0f << 0 << 0 << "" << QColor(0x30, 0x31, 0x32, 0x33) << QColor(0xBF, 0xBE, 0xBD, 0xBC) // guardDescent-bgColor
<< false << 0 << 0 << 0 << 0 << 0 // cmyk-fontSetting
<< true << false << false << false << true << 0 // showText-rotateAngle
<< 0 << false << false << false << WARN_DEFAULT << false // eci-debug
<< "zint -b 93 --bg=BFBEBDBC -d 'daft' --fg=30313233 --height=9.2 --vers=251"
<< "zint.exe -b 93 --bg=BFBEBDBC -d \"daft\" --fg=30313233 --height=9.2 --vers=251"
<< "" << "";
QTest::newRow("BARCODE_DATAMATRIX") << true << 0.0f << ""
<< BARCODE_DATAMATRIX << GS1_MODE // symbology-inputMode
<< "[20]12" << "" // text-primary
<< 0.0f << -1 << 0 << DM_SQUARE << 1.0f << false << 0.7f // height-dotSize
<< 5.0f << 0 << 0 << "" << QColor(Qt::black) << QColor(Qt::white) // guardDescent-bgColor
<< false << 0 << 0 << 0 << 0 << 0 // cmyk-fontSetting
<< true << true << false << false << true << 0 // showText-rotateAngle
<< 0 << false << false << false << WARN_DEFAULT << false // eci-debug
<< "zint -b 71 -d '[20]12' --gs1 --gssep --square"
<< "zint.exe -b 71 -d \"[20]12\" --gs1 --gssep --square"
<< "" << "";
QTest::newRow("BARCODE_DBAR_EXPSTK_CC") << false << 40.8f << ""
<< BARCODE_DBAR_EXPSTK_CC << (DATA_MODE | HEIGHTPERROW_MODE) // symbology-inputMode
<< "[91]ABCDEFGHIJKL" << "[11]901222[99]ABCDE" // text-primary
<< 0.0f << -1 << 0 << 2 << 1.0f << true << 0.9f // height-dotSize
<< 3.0f << 2 << 1 << "" << QColor(Qt::black) << QColor(Qt::white) // guardDescent-bgColor
<< false << 0 << 0 << 0 << 0 << 0 // cmyk-fontSetting
<< true << false << false << false << true << 0 // showText-rotateAngle
<< 0 << false << false << false << WARN_DEFAULT << false // eci-debug
<< "zint -b 139 --binary --compliantheight -d '[11]901222[99]ABCDE' --height=40.8 --heightperrow"
" --primary='[91]ABCDEFGHIJKL' --rows=2"
<< "zint.exe -b 139 --binary --compliantheight -d \"[11]901222[99]ABCDE\" --height=40.8 --heightperrow"
" --primary=\"[91]ABCDEFGHIJKL\" --rows=2"
<< "" << "";
QTest::newRow("BARCODE_DOTCODE") << false << 1.0f << ""
<< BARCODE_DOTCODE << GS1_MODE // symbology-inputMode
<< "[20]01" << "" // text-primary
<< 30.0f << -1 << 8 << ((0 + 1) << 8) << 1.0f << false << 0.7f // height-dotSize
<< 0.0f << 0 << 0 << "" << QColor(Qt::black) << QColor(Qt::white) // guardDescent-bgColor
<< false << 0 << 0 << 0 << 0 << 0 // cmyk-fontSetting
<< true << false << false << false << true << 0 // showText-rotateAngle
<< 0 << false << false << false << WARN_DEFAULT << false // eci-debug
<< "zint -b 115 --cols=8 -d '[20]01' --dotsize=0.7 --gs1 --mask=0"
<< "zint.exe -b 115 --cols=8 -d \"[20]01\" --dotsize=0.7 --gs1 --mask=0"
<< "" << "";
QTest::newRow("BARCODE_EANX") << true << 0.0f << ""
<< BARCODE_EANX << UNICODE_MODE // symbology-inputMode
<< "123456789012+12" << "" // text-primary
<< 0.0f << -1 << 8 << 0 << 1.0f << true << 0.8f // height-dotSize
<< 0.0f << 0 << 0 << "" << QColor(Qt::black) << QColor(Qt::white) // guardDescent-bgColor
<< false << 0 << 0 << 0 << 0 << 0 // cmyk-fontSetting
<< true << false << false << false << true << 0 // showText-rotateAngle
<< 0 << false << false << false << WARN_DEFAULT << false // eci-debug
<< "zint -b 13 --addongap=8 --compliantheight -d '123456789012+12' --guarddescent=0"
<< "zint.exe -b 13 --addongap=8 --compliantheight -d \"123456789012+12\" --guarddescent=0"
<< "" << "";
QTest::newRow("BARCODE_GRIDMATRIX") << false << 0.0f << ""
<< BARCODE_GRIDMATRIX << UNICODE_MODE // symbology-inputMode
<< "Your Data Here!" << "" // text-primary
<< 0.0f << 1 << 5 << 0 << 0.5f << false << 0.8f // height-dotSize
<< 5.0f << 0 << 0 << "" << QColor(Qt::black) << QColor(Qt::white) // guardDescent-bgColor
<< false << 0 << 0 << 0 << 0 << 0 // cmyk-fontSetting
<< true << false << true << false << true << 270 // showText-rotateAngle
<< 0 << false << false << false << WARN_DEFAULT << false // eci-debug
<< "zint -b 142 -d 'Your Data Here!' --quietzones --rotate=270 --scale=0.5 --secure=1 --vers=5"
<< "zint.exe -b 142 -d \"Your Data Here!\" --quietzones --rotate=270 --scale=0.5 --secure=1 --vers=5"
<< "" << "";
QTest::newRow("BARCODE_HANXIN") << false << 0.0f << ""
<< BARCODE_HANXIN << (UNICODE_MODE | ESCAPE_MODE) // symbology-inputMode
<< "éβÿ啊\\e\"'" << "" // text-primary
<< 30.0f << 2 << 5 << ((0 + 1) << 8) << 1.0f << false << 0.8f // height-dotSize
<< 5.0f << 0 << 0 << "" << QColor(Qt::black) << QColor(Qt::white) // guardDescent-bgColor
<< false << 0 << 0 << 0 << 0 << 0 // cmyk-fontSetting
<< true << false << false << false << true << 0 // showText-rotateAngle
<< 29 << false << false << false << WARN_DEFAULT << false // eci-debug
<< "zint -b 116 -d 'éβÿ啊\\e\"'\\''' --eci=29 --esc --mask=0 --secure=2 --vers=5"
<< "zint.exe -b 116 -d \"éβÿ啊\\e\\\"'\" --eci=29 --esc --mask=0 --secure=2 --vers=5"
<< "" << "";
QTest::newRow("BARCODE_HIBC_DM") << false << 10.0f << ""
<< BARCODE_HIBC_DM << UNICODE_MODE // symbology-inputMode
<< "1234" << "" // text-primary
<< 0.0f << -1 << 8 << DM_DMRE << 1.0f << false << 0.7f // height-dotSize
<< 5.0f << 0 << 0 << "" << QColor(Qt::black) << QColor(Qt::white) // guardDescent-bgColor
<< false << 0 << 0 << 0 << 0 << 0 // cmyk-fontSetting
<< true << true << false << false << true << 0 // showText-rotateAngle
<< 0 << false << false << false << WARN_DEFAULT << false // eci-debug
<< "zint -b 102 -d '1234' --dmre --vers=8"
<< "zint.exe -b 102 -d \"1234\" --dmre --vers=8"
<< "" << "";
QTest::newRow("BARCODE_HIBC_PDF") << false << 0.0f << ""
<< BARCODE_HIBC_PDF << (DATA_MODE | HEIGHTPERROW_MODE) // symbology-inputMode
<< "TEXT" << "" // text-primary
<< 3.5f << 3 << 4 << 10 << 10.0f << false << 0.8f // height-dotSize
<< 5.0f << 2 << 1 << "" << QColor(Qt::black) << QColor(Qt::white) // guardDescent-bgColor
<< false << 0 << 0 << 0 << 0 << 0 // cmyk-fontSetting
<< true << false << true << false << true << 0 // showText-rotateAngle
<< 0 << false << false << false << WARN_DEFAULT << false // eci-debug
<< "zint -b 106 --binary --cols=4 -d 'TEXT' --height=3.5 --heightperrow --quietzones"
" --rows=10 --scale=10 --secure=3 --structapp=1,2"
<< "zint.exe -b 106 --binary --cols=4 -d \"TEXT\" --height=3.5 --heightperrow --quietzones"
" --rows=10 --scale=10 --secure=3 --structapp=1,2"
<< "" << "";
QTest::newRow("BARCODE_MAXICODE") << true << 0.0f << ""
<< BARCODE_MAXICODE << (UNICODE_MODE | ESCAPE_MODE) // symbology-inputMode
<< "152382802840001"
<< "1Z00004951\\GUPSN\\G06X610\\G159\\G1234567\\G1/1\\G\\GY\\G1 MAIN ST\\GTOWN\\GNY\\R\\E" // text-primary
<< 0.0f << -1 << (96 + 1) << 0 << 2.5f << false << 0.8f // height-dotSize
<< 5.0f << 0 << 0 << "" << QColor(Qt::black) << QColor(Qt::white) // guardDescent-bgColor
<< false << 0 << 0 << 0 << 0 << 0 // cmyk-fontSetting
<< true << false << true << false << true << 0 // showText-rotateAngle
<< 0 << false << false << false << WARN_DEFAULT << false // eci-debug
<< "zint -b 57 -d '1Z00004951\\GUPSN\\G06X610\\G159\\G1234567\\G1/1\\G\\GY\\G1 MAIN ST\\GTOWN\\GNY\\R\\E'"
" --esc --primary='152382802840001' --quietzones --scale=2.5 --scmvv=96"
<< "zint.exe -b 57 -d \"1Z00004951\\GUPSN\\G06X610\\G159\\G1234567\\G1/1\\G\\GY\\G1 MAIN ST\\GTOWN\\GNY\\R\\E\""
" --esc --primary=\"152382802840001\" --quietzones --scale=2.5 --scmvv=96"
<< "" << "";
QTest::newRow("BARCODE_MICROQR") << false << 0.0f << ""
<< BARCODE_MICROQR << UNICODE_MODE // symbology-inputMode
<< "1234" << "" // text-primary
<< 30.0f << 2 << 3 << (ZINT_FULL_MULTIBYTE | (3 + 1) << 8) << 1.0f << false << 0.8f // height-dotSize
<< 5.0f << 0 << 0 << "" << QColor(Qt::black) << QColor(Qt::white) // guardDescent-bgColor
<< false << 0 << 0 << 0 << 0 << 0 // cmyk-fontSetting
<< true << false << false << false << true << 0 // showText-rotateAngle
<< 0 << false << false << false << WARN_DEFAULT << false // eci-debug
<< "zint -b 97 -d '1234' --fullmultibyte --mask=3 --secure=2 --vers=3"
<< "zint.exe -b 97 -d \"1234\" --fullmultibyte --mask=3 --secure=2 --vers=3"
<< "" << "";
QTest::newRow("BARCODE_QRCODE") << true << 0.0f << ""
<< BARCODE_QRCODE << GS1_MODE // symbology-inputMode
<< "(01)12" << "" // text-primary
<< 0.0f << 1 << 5 << (ZINT_FULL_MULTIBYTE | (0 + 1) << 8) << 1.0f << false << 0.8f // height-dotSize
<< 5.0f << 0 << 0 << "" << QColor(Qt::black) << QColor(Qt::white) // guardDescent-bgColor
<< false << 0 << 0 << 0 << 0 << 0 // cmyk-fontSetting
<< true << false << true << false << true << 0 // showText-rotateAngle
<< 0 << true << true << false << WARN_DEFAULT << false // eci-debug
<< "zint -b 58 -d '(01)12' --fullmultibyte --gs1 --gs1parens --gs1nocheck --mask=0 --quietzones"
" --secure=1 --vers=5"
<< "zint.exe -b 58 -d \"(01)12\" --fullmultibyte --gs1 --gs1parens --gs1nocheck --mask=0 --quietzones"
" --secure=1 --vers=5"
<< "" << "";
QTest::newRow("BARCODE_RMQR") << true << 0.0f << ""
<< BARCODE_RMQR << UNICODE_MODE // symbology-inputMode
<< "" << "" // text-primary
<< 30.0f << -1 << 8 << 0 << 1.0f << false << 0.8f // height-dotSize
<< 5.0f << 0 << 0 << "" << QColor(Qt::black) << QColor(Qt::white) // guardDescent-bgColor
<< false << 0 << 0 << 0 << 0 << 0 // cmyk-fontSetting
<< true << false << false << false << true << 180 // showText-rotateAngle
<< 20 << false << false << false << WARN_DEFAULT << false // eci-debug
<< "zint -b 145 -d 'テ' --eci=20 --rotate=180 --vers=8"
<< "zint.exe -b 145 -d \"\" --eci=20 --rotate=180 --vers=8"
<< "" << "";
QTest::newRow("BARCODE_UPCE_CC") << true << 0.0f << "out.svg"
<< BARCODE_UPCE_CC << UNICODE_MODE // symbology-inputMode
<< "12345670+1234" << "[11]901222[99]ABCDE" // text-primary
<< 0.0f << -1 << 0 << 0 << 1.0f << false << 0.8f // height-dotSize
<< 6.5f << 0 << 0 << "" << QColor(0xEF, 0x29, 0x29) << QColor(Qt::white) // guardDescent-bgColor
<< false << 0 << 0 << 0 << 0 << (BOLD_TEXT | SMALL_TEXT) // cmyk-fontSetting
<< true << false << false << true << true << 0 // showText-rotateAngle
<< 0 << false << false << false << WARN_FAIL_ALL << false // eci-debug
<< "zint -b 136 --bold --compliantheight -d '[11]901222[99]ABCDE' --fg=EF2929 --guarddescent=6.5"
" --noquietzones -o 'out.svg' --primary='12345670+1234' --small --werror"
<< "zint.exe -b 136 --bold --compliantheight -d \"[11]901222[99]ABCDE\" --fg=EF2929 --guarddescent=6.5"
" --noquietzones -o \"out.svg\" --primary=\"12345670+1234\" --small --werror"
<< "zint --barcode=136 --bold --compliantheight --data='[11]901222[99]ABCDE' --fg=EF2929"
" --guarddescent=6.5 --noquietzones --output='out.svg' --primary='12345670+1234' --small --werror"
<< "zint -b UPCE_CC --bold --compliantheight -d '[11]901222[99]ABCDE' --fg=EF2929 --guarddescent=6.5"
" --noquietzones -o 'out.svg' --primary='12345670+1234' --small --werror";
QTest::newRow("BARCODE_VIN") << false << 2.0f << ""
<< BARCODE_VIN << UNICODE_MODE // symbology-inputMode
<< "12345678701234567" << "" // text-primary
<< 20.0f << -1 << 1 << 0 << 1.0f << false << 0.8f // height-dotSize
<< 5.0f << 0 << 0 << "" << QColor(Qt::black) << QColor(Qt::white) // guardDescent-bgColor
<< false << 0 << 0 << 0 << 0 << 0 // cmyk-fontSetting
<< true << false << false << false << true << 0 // showText-rotateAngle
<< 0 << false << false << false << WARN_DEFAULT << false // eci-debug
<< "zint -b 73 -d '12345678701234567' --height=20 --vers=1"
<< "zint.exe -b 73 -d \"12345678701234567\" --height=20 --vers=1"
<< "" << "";
}
void getAsCLITest()
{
Zint::QZint bc;
QString cmd;
QFETCH(bool, autoHeight);
QFETCH(float, heightPerRow);
QFETCH(QString, outfile);
QFETCH(int, symbology);
QFETCH(int, inputMode);
QFETCH(QString, text);
QFETCH(QString, primary);
QFETCH(float, height);
QFETCH(int, option1);
QFETCH(int, option2);
QFETCH(int, option3);
QFETCH(float, scale);
QFETCH(bool, dotty);
QFETCH(float, dotSize);
QFETCH(float, guardDescent);
QFETCH(int, structAppCount);
QFETCH(int, structAppIndex);
QFETCH(QString, structAppID);
QFETCH(QColor, fgColor);
QFETCH(QColor, bgColor);
QFETCH(bool, cmyk);
QFETCH(int, borderTypeIndex);
QFETCH(int, borderWidth);
QFETCH(int, whitespace);
QFETCH(int, vWhitespace);
QFETCH(int, fontSetting);
QFETCH(bool, showText);
QFETCH(bool, gsSep);
QFETCH(bool, quietZones);
QFETCH(bool, noQuietZones);
QFETCH(bool, compliantHeight);
QFETCH(int, rotateAngle);
QFETCH(int, eci);
QFETCH(bool, gs1Parens);
QFETCH(bool, gs1NoCheck);
QFETCH(bool, readerInit);
QFETCH(int, warnLevel);
QFETCH(bool, debug);
QFETCH(QString, expected_cmd);
QFETCH(QString, expected_win);
QFETCH(QString, expected_longOptOnly);
QFETCH(QString, expected_barcodeNames);
bc.setSymbol(symbology);
bc.setInputMode(inputMode);
if (primary.isEmpty()) {
bc.setText(text);
} else {
bc.setText(primary);
bc.setPrimaryMessage(text);
}
bc.setHeight(height);
bc.setOption1(option1);
bc.setOption2(option2);
bc.setOption3(option3);
bc.setScale(scale);
bc.setDotty(dotty);
bc.setDotSize(dotSize);
bc.setGuardDescent(guardDescent);
bc.setStructApp(structAppCount, structAppIndex, structAppID);
bc.setFgColor(fgColor);
bc.setBgColor(bgColor);
bc.setCMYK(cmyk);
bc.setBorderType(borderTypeIndex);
bc.setBorderWidth(borderWidth);
bc.setWhitespace(whitespace);
bc.setVWhitespace(vWhitespace);
bc.setFontSettingValue(fontSetting);
bc.setShowText(showText);
bc.setGSSep(gsSep);
bc.setQuietZones(quietZones);
bc.setNoQuietZones(noQuietZones);
bc.setCompliantHeight(compliantHeight);
bc.setRotateAngleValue(rotateAngle);
bc.setECIValue(eci);
bc.setGS1Parens(gs1Parens);
bc.setGS1NoCheck(gs1NoCheck);
bc.setReaderInit(readerInit);
bc.setWarnLevel(warnLevel);
bc.setDebug(debug);
cmd = bc.getAsCLI(false /*win*/, false /*longOptOnly*/, false /*barcodeNames*/,
autoHeight, heightPerRow, outfile);
QCOMPARE(cmd, expected_cmd);
cmd = bc.getAsCLI(true /*win*/, false /*longOptOnly*/, false /*barcodeNames*/,
autoHeight, heightPerRow, outfile);
QCOMPARE(cmd, expected_win);
if (!expected_longOptOnly.isEmpty()) {
cmd = bc.getAsCLI(false /*win*/, true /*longOptOnly*/, false /*barcodeNames*/,
autoHeight, heightPerRow, outfile);
QCOMPARE(cmd, expected_longOptOnly);
}
if (!expected_barcodeNames.isEmpty()) {
cmd = bc.getAsCLI(false /*win*/, false /*longOptOnly*/, true /*barcodeNames*/,
autoHeight, heightPerRow, outfile);
QCOMPARE(cmd, expected_barcodeNames);
}
}
};
QTEST_MAIN(TestQZint)

View File

@ -19,7 +19,7 @@ barcode image.
The library which forms the main component of the Zint project is currently
able to encode data in over 50 barcode symbologies (types of barcode), for each
of which it is possible to translate that data from either Unicode (UTF-8) or a
of which it is possible to translate that data from either UTF-8 (Unicode) or a
raw 8-bit data stream. The image can be rendered as either a Portable Network
Graphic (PNG) image, Windows Bitmap (BMP), Graphics Interchange Format (GIF),
ZSoft Paintbrush image (PCX), Tagged Image File Format (TIF), Enhanced Metafile
@ -112,7 +112,7 @@ sudo make install
The CLI command line program can be accessed by typing
zint {options}
zint [options]
The GUI can be accessed by typing
@ -145,20 +145,21 @@ To build Zint on Windows from source, see "win32/README".
2.3 Apple macOS
---------------
Zint can be installed using Homebrew. To install homebrew input the following
line into the MacOS terminal
Zint can be installed using Homebrew. To install Homebrew input the following
line into the macOS terminal
/usr/bin/ruby -e "$(curl -fsSL
https://raw.githubusercontent.com/Homebrew/install/master/install)"
Once homebrew is installed use the following command to install Zint.
Once Homebrew is installed use the following command to install Zint.
brew install zint
2.4 zint tcl backend
2.4 Zint Tcl Backend
--------------------
The tcl backend may be built using the provided TEA build on Linux, Windows,
Mac-OS and Android. For Windows, an MS-VC6 makefile is also available.
The Tcl backend in the backend_tcl sub-directory may be built using the
provided TEA (Tcl Extension Architecture) build on Linux, Windows, macOS and
Android. For Windows, an MSVC6 makefile is also available.
3. Using Zint Barcode Studio
@ -195,10 +196,25 @@ single quote, and then continuing:
zint -d 'Text containing a single quote '\'' in the middle'
4.1 Inputting data
Some examples use backslash (\) to continue commands onto the next line. For
Windows, use caret (^) instead.
Certain options that take values have short names as well as long ones, namely
-b (--barcode), -d (--data), -i (--input), -o (--output) and -w (--whitesp). For
these a space should be used to separate the short name from its value, to avoid
ambiguity. For long names a space or an equals sign may be used. For instance:
zint -d "This Text"
zint --data="This Text"
zint --data "This Text"
The examples use a space separator for short option names, and an equals sign
for long option names.
4.1 Inputting Data
------------------
The data to encode can be entered at the command line using the -d option, for
example
The data to encode can be entered at the command line using the -d or --data
option, for example
zint -d "This Text"
@ -207,13 +223,13 @@ Code 128, and output to the default file out.png in the current directory.
Alternatively, if libpng was not present when Zint was built, the default
output file will be out.gif.
The data input to the Zint CLI is assumed to be encoded in Unicode (UTF-8)
The data input to the Zint CLI is assumed to be encoded in UTF-8 (Unicode)
format (Zint will correctly handle UTF-8 data on Windows). If you are encoding
characters beyond the 7-bit ASCII set using a scheme other than UTF-8 then you
will need to set the appropriate input options as shown in section 4.10 below.
Non-printing characters can be entered on the command line using the backslash
(\) as an escape character in combination with the --esc switch. Permissible
Non-printing characters can be entered on the command line using backslash (\)
as an escape character in combination with the --esc switch. Permissible
sequences are shown in the table below.
------------------------------------------------------------------------------
@ -240,11 +256,11 @@ Escape Sequence | ASCII Equivalent | Name | Interpretation
| | | hexadecimal
------------------------------------------------------------------------------
Input data can be read directly from file using the -i switch as shown below.
The input file is assumed to be Unicode (UTF-8) formatted unless an alternative
mode is selected. This command replaces the use of the -d switch.
Input data can be read directly from file using the -i or --input switch as
shown below. The input file is assumed to be UTF-8 (Unicode) formatted unless an
alternative mode is selected. This command replaces the use of the -d switch.
zint -i ./somefile.txt
zint -i somefile.txt
Note that except when batch processing (section 4.11 below), the file should not
end with a newline (LF on Unix, CR+LF on Windows) unless you want the newline to
@ -252,18 +268,18 @@ be encoded in the symbol.
4.2 Directing Output
--------------------
Output can be directed to a file other than the default using the -o switch.
For example:
Output can be directed to a file other than the default using the -o or --output
switch. For example:
zint -o here.png -d "This Text"
This draws a Code 128 barcode in the file here.png. If an encapsulated
PostScript file is needed simply append the file name with .eps, and so on for
This draws a Code 128 barcode in the file here.png. If an Encapsulated
PostScript file is needed simply append the filename with .eps, and so on for
the other supported file types:
zint -o there.eps -d "This Text"
4.3 Selecting barcode type
4.3 Selecting Barcode Type
--------------------------
Selecting which type of barcode you wish to produce (i.e. which symbology to
use) can be done at the command line using the -b or --barcode= switch followed
@ -385,7 +401,7 @@ Value | insensitive) |
145 | RMQR | Rectangular Micro QR Code (rMQR)
--------------------------------------------------------------------------------
4.4 Adjusting height
4.4 Adjusting Height
--------------------
The height of a symbol (except those with a fixed width-to-height ratio) can be
adjusted using the --height switch. For example:
@ -416,7 +432,7 @@ zint -b PDF417 -d "This Text" --height=4 --heightperrow
will produce a barcode of height 32X, with each of the 8 rows 4X high.
4.5 Adjusting whitespace
4.5 Adjusting Whitespace
------------------------
The amount of horizontal whitespace to the left and right of the generated
barcode can be altered using the -w or --whitesp switch. For example:
@ -429,13 +445,13 @@ both to the left and to the right of the barcode.
The amount of vertical whitespace above and below the barcode can be altered
using the --vwhitesp switch. For example for 3 times the X-dimension:
zint --vwhitesp 3 -d "This Text"
zint --vwhitesp=3 -d "This Text"
Note that the whitespace at the bottom appears below the text, if any.
Horizontal and vertical whitespace can of course be used together:
zint -b DATAMATRIX --whitesp 1 --vwhitesp 1 -d "This Text"
zint -b DATAMATRIX --whitesp=1 --vwhitesp=1 -d "This Text"
A --quietzones option is also available which adds quiet zones compliant with
the symbology's specification. This is in addition to any whitespace specified
@ -445,7 +461,7 @@ Note that Codablock-F, Code 16K, Code 49, ITF-14, EAN-13, EAN-8, EAN-5, EAN-2,
ISBN, UPC-A and UPC-E have compliant quiet zones added by default. This can be
disabled with the option --noquietzones.
4.6 Adding boundary bars and boxes
4.6 Adding Boundary Bars and Boxes
----------------------------------
Zint allows the symbol to be bound with 'boundary bars' (also known as 'bearer
bars') using the option --bind. These bars help to prevent misreading of the
@ -466,18 +482,18 @@ Codablock-F, Code 16K and Code 49 always have boundary bars, and default to
particular horizontal whitespace values. Special considerations apply to ITF-14
- see the specific section 6.1.2.6 for that symbology.
4.7 Using colour
4.7 Using Colour
----------------
The default colours of a symbol are a black symbol on a white background. Zint
allows you to change this. The -r switch allows the default colours to be
inverted so that a white symbol is shown on a black background. For example the
command
allows you to change this. The -r or --reverse switch allows the default colours
to be inverted so that a white symbol is shown on a black background (known as
reflectance reversal). For example the command
zint -r -d "This"
gives an inverted Code 128 symbol. This is not practical for most symbologies
but white-on-black is allowed by the Data Matrix and Aztec Code symbology
specifications.
but white-on-black is allowed by the Aztec Code, Data Matrix, Han Xin Code, Grid
Matrix and QR Code symbology specifications.
For more specific needs the foreground (ink) and background (paper) colours can
be specified using the --fg= and --bg= options followed by a number in RRGGBB
@ -514,7 +530,7 @@ followed by the angle of rotation as shown below.
--rotate=180
--rotate=270
4.9 Adjusting image size
4.9 Adjusting Image Size
------------------------
The scale of the image can be altered using the --scale= option followed by a
multiple of the default X-dimension. The scale is multiplied by 2 before being
@ -534,7 +550,7 @@ The minimum scale for vector output is 0.1, giving a minimum X-dimension of 0.2.
The maximum scale for both raster and vector is 100.
4.9.1 Scaling example
4.9.1 Scaling Example
---------------------
The GS1 General Specifications Section 5.2.6.6 "Symbol dimensions at nominal
size" gives an example of an EAN-13 barcode using the X-dimension of 0.33mm.
@ -542,7 +558,7 @@ To print that example as a PNG at 12 dots per mm (dpmm), the equivalent of 300
dots per inch (dpi = dpmm * 25.4), specify a scale of 2, since 0.33 * 12 = 3.96
pixels, or 4 pixels rounding to the nearest pixel:
zint -b EANX -d "501234567890" --height 69 --scale 2
zint -b EANX -d "501234567890" --compliantheight --scale=2
This will result in output of 38.27mm x 26.08mm (WxH) at 300 dpi. The following
table shows the scale to use (in 0.5 increments) depending on the dpmm desired,
@ -561,7 +577,7 @@ dpmm | dpi | scale
189 | 4800 | 31
-------------------
4.9.2 MaxiCode raster scaling
4.9.2 MaxiCode Raster Scaling
-----------------------------
For MaxiCode symbols, which use hexagons, the scale for raster output is
multiplied by 10 before being applied. The minimum scale is 0.2, so the minimum
@ -588,35 +604,37 @@ Note that the 0.5 increment recommended for normal raster output does not apply.
Scales below 0.5 are not recommended and may produce symbols that are not within
the minimum/maximum size ranges.
4.10 Input modes
4.10 Input Modes
----------------
By default all input data is assumed to be encoded in Unicode (UTF-8) format.
Many barcode symbologies encode data using Latin-1 (ISO/IEC 8859-1) character
encoding, so input is converted from UTF-8 to Latin-1 before being put in the
symbol. In addition QR Code, Micro QR Code, Rectangular Micro QR Code, Han Xin
Code and Grid Matrix can encode Japanese or Chinese characters which are also
converted from UTF-8. If Zint encounters characters which can not be encoded
using the default character encoding then it will take advantage of the ECI
(Extended Channel Interpretations) mechanism to encode the data if the symbology
supports it. Be aware that not all barcode readers support ECI mode, so this can
sometimes lead to unreadable barcodes. If you are using characters beyond those
supported by Latin-1 then you should check that the resulting barcode can be
understood by your target barcode reader. Zint will generate a warning message
when an ECI code that has not been explicitly requested has been inserted into a
symbol.
By default all CLI input data is assumed to be encoded in UTF-8 (Unicode)
format. Many barcode symbologies encode data using Latin-1 (ISO/IEC 8859-1)
character encoding, so input is converted from UTF-8 to Latin-1 before being put
in the symbol. In addition QR Code, Micro QR Code, Rectangular Micro QR Code,
Han Xin Code and Grid Matrix can encode Japanese (Kanji) or Chinese (Hanzi)
characters which are also converted from UTF-8.
If Zint encounters characters which can not be encoded using the default
character encoding then it will take advantage of the ECI (Extended Channel
Interpretations) mechanism to encode the data if the symbology supports it. Be
aware that not all barcode readers support ECI mode, so this can sometimes lead
to unreadable barcodes. If you are using characters beyond those supported by
Latin-1 then you should check that the resulting barcode can be understood by
your target barcode reader. Zint will generate a warning message when an ECI
code that has not been explicitly requested has been inserted into a symbol.
GS1 data can be encoded in a number of symbologies. Application Identifiers
should be enclosed in [square brackets] followed by the data to be encoded (see
6.1.11.3). To encode GS1 data use the --gs1 option. GS1 mode is assumed (and
doesn't need to be set) for GS1-128, EAN-14, DataBar and Composite symbologies
but is also available for Aztec Code, Code 16K, Code 49, Code One, Data Matrix,
DotCode, QR Code and Ultracode.
(AIs) should be enclosed in [square brackets] followed by the data to be encoded
(see 6.1.11.3). To encode GS1 data use the --gs1 option. GS1 mode is assumed
(and doesn't need to be set) for GS1-128, EAN-14, DataBar and Composite
symbologies but is also available for Aztec Code, Code 16K, Code 49, Code One,
Data Matrix, DotCode, QR Code and Ultracode.
HIBC data may also be encoded in the symbologies Code 39, Code 128, Codablock-F,
Data Matrix, QR Code, PDF417, MicroPDF417 and Aztec Code. Within this mode, the
leading '+' and the check character are automatically added, conforming to HIBC
Labeler Identification Code (HIBC LIC). For HIBC Provider Applications Standard
(HIBC PAS), preface the data with a slash "/".
Health Industry Barcode (HIBC) data may also be encoded in the symbologies Code
39, Code 128, Codablock-F, Data Matrix, QR Code, PDF417, MicroPDF417 and Aztec
Code. Within this mode, the leading '+' and the check character are
automatically added, conforming to HIBC Labeler Identification Code (HIBC LIC).
For HIBC Provider Applications Standard (HIBC PAS), preface the data with a
slash "/".
The --binary option encodes the input data as given. Automatic code page
translation to an ECI page is disabled, and no validation of the data's encoding
@ -648,7 +666,7 @@ Latin alphabet No. 1".
The row marked with an asterisk (*) translates GB 2312 codepoints, except when
using Han Xin Code, which translates GB 18030 codepoints, a superset of GB 2312.
Note: the "--eci 3" specification should only be used for special purposes.
Note: the "--eci=3" specification should only be used for special purposes.
Using this parameter, the ECI information is explicitly added to the code
symbol. Nevertheless, for ECI Code 3, this is not required, as this is the
default encoding, which is also active without any ECI information.
@ -691,33 +709,33 @@ the ISO/IEC 8859-15 codepoint hex A4. It is encoded in UTF-8 as the hex
sequence: E2 82 AC. Those 3 bytes are contained in the file "utf8euro.txt". This
command will generate the corresponding code:
zint -b 71 --square --scale 10 --eci 17 -i utf8euro.txt
zint -b 71 --square --scale=10 --eci=17 -i utf8euro.txt
This is equivalent to the commands (using the --esc switch):
zint -b 71 --square --scale 10 --eci 17 --esc -d "\xE2\x82\xAC"
zint -b 71 --square --scale=10 --eci=17 --esc -d "\xE2\x82\xAC"
zint -b 71 --square --scale 10 --eci 17 --esc -d "\u20AC"
zint -b 71 --square --scale=10 --eci=17 --esc -d "\u20AC"
and to the command:
zint -b 71 --square --scale 10 --eci 17 -d "€"
zint -b 71 --square --scale=10 --eci=17 -d "€"
Ex2: The Chinese character with Unicode codepoint U+5E38 can be encoded in Big5
encoding. The Big5 representation of this character is the two hex bytes: B1 60
(contained in the file big5char.txt). The generation command for Data Matrix is:
zint -b 71 --square --scale 10 --eci 28 --binary -i big5char.txt
zint -b 71 --square --scale=10 --eci=28 --binary -i big5char.txt
This is equivalent to the command (using the --esc switch):
zint -b 71 --square --scale 10 --eci 28 --binary --esc -d "\xB1\x60"
zint -b 71 --square --scale=10 --eci=28 --binary --esc -d "\xB1\x60"
and to the commands (no --binary switch so conversion occurs):
zint -b 71 --square --scale 10 --eci 28 --esc -d "\u5E38"
zint -b 71 --square --scale=10 --eci=28 --esc -d "\u5E38"
zint -b 71 --square --scale 10 --eci 28 -d "常"
zint -b 71 --square --scale=10 --eci=28 -d "常"
Ex3: Some decoders (in particular mobile app ones) for QR Code assume UTF-8
encoding by default and do not support ECI. In this case supply UTF-8 data and
@ -726,7 +744,7 @@ conversion:
zint -b 58 --binary -d "UTF-8 data"
4.11 Batch processing
4.11 Batch Processing
---------------------
Data can be batch processed by reading from a text file and producing a
separate barcode image for each line of text in that file. To do this use the
@ -762,7 +780,7 @@ Input | Filenames Generated
-o t@es~t~.png | t*es0t1.png, t*es0t2.png, t*es0t3.png
--------------------------------------------------------------
4.12 Direct output
4.12 Direct Output
------------------
The finished image files can be output directly to stdout for use as part of a
pipe by using the --direct option. By default --direct will output data as a PNG
@ -794,29 +812,28 @@ CAUTION: Outputting binary files to the command shell without catching that
data in a pipe can have unpredictable results. Use with care!
=============================================================================
4.13 Automatic filenames
4.13 Automatic Filenames
------------------------
The --mirror option instructs Zint to use the data to be encoded as an
indicator of the filename to be used. This is particularly useful if you are
processing batch data. For example the input data "1234567" will result in
a file named 1234567.png.
There are restrictions, however, on what characters can be stored in a file
name, so the file name may vary from the data if the data includes non-
printable characters, for example, and may be shortened if the data input is
long.
There are restrictions, however, on what characters can be stored in a filename,
so the filename may vary from the data if the data includes non-printable
characters, for example, and may be shortened if the data input is long.
To set the output file format use the --filetype= option as detailed in
section 4.12.
4.14 Working with dots
4.14 Working with Dots
----------------------
Matrix codes can be rendered as a series of dots or circles rather than the
normal squares by using the --dotty option. This option is only available for
matrix symbologies, and is automatically selected for DotCode. The size of
the dots can be adjusted using the --dotsize= option followed by the radius
of the dot, where that radius is given as a multiple of the X-dimension. The
minimum dot size is 0.01, the maximum is 20.
the dots can be adjusted using the --dotsize= option followed by the diameter
of the dot, where that diameter is given as a multiple of the X-dimension. The
minimum dot size is 0.01, the maximum is 20. The default size is 0.8.
The default and minimum scale for raster output in dotty mode is 1.
@ -839,7 +856,7 @@ for all symbols belonging to the same sequence. The index is 1-based and goes
from 1 to count. Count must be 2 or more. See the individual symbologies for
further details.
4.16 Help options
4.16 Help Options
-----------------
There are three help options which give information about how to use the
command line. The -h or --help option will display a list of all of the valid
@ -850,7 +867,7 @@ ID numbers and names.
The -e or --ecinos option gives a list of the ECI codes.
4.17 Other output options
4.17 Other Output Options
-------------------------
For linear barcodes the text present in the output image can be removed by
using the --notext option.
@ -863,7 +880,7 @@ Zint can output a representation of the symbol data as a set of hexadecimal
values if asked to output to a text file (*.txt) or if given the option
--filetype=txt. This can be used for test and diagnostic purposes.
The --cmyk option is specific to output in encapsulated PostScript and TIF, and
The --cmyk option is specific to output in Encapsulated PostScript and TIF, and
converts the RGB colours used to the CMYK colour space. Setting custom colours
at the command line will still need to be done in RRGGBB format.
@ -966,7 +983,8 @@ int ZBarcode_Encode_File_and_Print(struct zint_symbol *symbol,
In these definitions "length" can be used to set the length of the input
string. This allows the encoding of NUL (ASCII 0) characters in those
symbologies which allow this. A value of 0 will disable this usage and Zint
will encode data up to the first NUL character in the input string.
will encode data up to the first NUL character in the input string, which must
be present.
The "rotate_angle" value can be used to rotate the image when outputting. Valid
values are 0, 90, 180 and 270.
@ -1221,10 +1239,10 @@ strcpy(my_symbol->bgcolour, "55555500");
5.6 Handling Errors
-------------------
If errors occur during encoding an integer value is passed back to the calling
application. In addition the errtxt value is used to give a message detailing
the nature of the error. The errors generated by Zint are given in the table
below:
If errors occur during encoding a non-zero integer value is passed back to the
calling application. In addition the errtxt value is used to give a message
detailing the nature of the error. The errors generated by Zint are given in the
table below:
--------------------------------------------------------------------------------
Return Value | Meaning
@ -1433,7 +1451,7 @@ names in Zint before version 2.9.0. For example, symbology 29 used the name
"BARCODE_RSS14". These names are now deprecated but are still recognised by Zint
and will continue to be supported in future versions.
5.9 Adjusting other output options
5.9 Adjusting Other Output Options
----------------------------------
The output_options variable can be used to adjust various aspects of the output
file. To select more than one option from the table below simply OR them
@ -1453,7 +1471,7 @@ READER_INIT | Add a reader initialisation symbol to the data before
| encoding.
SMALL_TEXT | Use a smaller font for the Human Readable Text.
BOLD_TEXT | Embolden the Human Readable Text.
CMYK_COLOUR | Select the CMYK colour space option for encapsulated
CMYK_COLOUR | Select the CMYK colour space option for Encapsulated
| PostScript and TIF files.
BARCODE_DOTTY_MODE | Plot a matrix symbol using dots rather than squares.
GS1_GS_SEPARATOR | Use GS instead of FNC1 as GS1 separator (Data Matrix)
@ -1462,6 +1480,8 @@ OUT_BUFFER_INTERMEDIATE | Return the bitmap buffer as ASCII values instead of
BARCODE_QUIET_ZONES | Add compliant quiet zones (additional to any
| specified whitespace). [3]
BARCODE_NO_QUIET_ZONES | Disable quiet zones, notably those with defaults. [3]
COMPLIANT_HEIGHT | Warn if height not compliant and use standard height
| (if any) as default.
--------------------------------------------------------------------------------
[2] This flag is always set for Codablock-F, Code 16K and Code 49. Special
@ -1497,7 +1517,8 @@ HEIGHTPERROW_MODE | Interpret the height variable as per-row rather than as
The default mode is DATA_MODE.
DATA_MODE, UNICODE_MODE and GS1_MODE are mutually exclusive, whereas ESCAPE_MODE,
GS1PARENS_MODE and GS1NOCHECK_MODE are optional. So, for example, you can set
GS1PARENS_MODE, GS1NOCHECK_MODE and HEIGHTPERROW_MODE are optional. So, for
example, you can set
my_symbol->input_mode = UNICODE_MODE | ESCAPE_MODE;
@ -1539,6 +1560,21 @@ if (ZBarcode_ValidID(BARCODE_PDF417) != 0) {
printf("PDF417 not available\n");
}
Another function that may be useful is:
int ZBarcode_BarcodeName(int symbol_id, char name[32]);
which copies the name of a symbology into the supplied "name" buffer, which
should be 32 characters in length. The name is NUL-terminated, and zero is
returned on success. For instance:
char name[32];
if (ZBarcode_BarcodeName(BARCODE_PDF417, name) == 0) {
printf("%s\n", name);
}
will print "BARCODE_PDF417".
5.12 Checking Symbology Capabilities
------------------------------------
It can be useful for frontend programs to know the capabilities of a symbology.
@ -1549,27 +1585,28 @@ unsigned int ZBarcode_Cap(int symbol_id, unsigned int cap_flag);
by OR-ing the flags below in the "cap_flag" argument and checking the return to
see which are set.
-------------------------------------------------------------------------------
Value | Meaning
-------------------------------------------------------------------------------
ZINT_CAP_HRT | Can the symbology print Human Readable Text?
ZINT_CAP_STACKABLE | Is the symbology stackable?
ZINT_CAP_EXTENDABLE | Is the symbology extendable with add-on data?
| (i.e. is it UPC/EAN?)
ZINT_CAP_COMPOSITE | Does the symbology support composite data?
| (see 6.3 below)
ZINT_CAP_ECI | Does the symbology support Extended Channel
| Interpretations?
ZINT_CAP_GS1 | Does the symbology support GS1 data?
ZINT_CAP_DOTTY | Can the symbology be outputted as dots?
ZINT_CAP_QUIET_ZONES | Does the symbology have default quiet zones?
ZINT_CAP_FIXED_RATIO | Does the symbology have a fixed width-to-height
| (aspect) ratio?
ZINT_CAP_READER_INIT | Does the symbology support Reader Initialisation?
ZINT_CAP_FULL_MULTIBYTE | Is the ZINT_FULL_MULTIBYTE option applicable?
ZINT_CAP_MASK | Is mask selection applicable?
ZINT_CAP_STRUCTAPP | Does the symbology support Structured Append?
-------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Value | Meaning
---------------------------------------------------------------------------------
ZINT_CAP_HRT | Can the symbology print Human Readable Text?
ZINT_CAP_STACKABLE | Is the symbology stackable?
ZINT_CAP_EXTENDABLE | Is the symbology extendable with add-on data?
| (i.e. is it UPC/EAN?)
ZINT_CAP_COMPOSITE | Does the symbology support composite data?
| (see 6.3 below)
ZINT_CAP_ECI | Does the symbology support Extended Channel
| Interpretations?
ZINT_CAP_GS1 | Does the symbology support GS1 data?
ZINT_CAP_DOTTY | Can the symbology be outputted as dots?
ZINT_CAP_QUIET_ZONES | Does the symbology have default quiet zones?
ZINT_CAP_FIXED_RATIO | Does the symbology have a fixed width-to-height
| (aspect) ratio?
ZINT_CAP_READER_INIT | Does the symbology support Reader Initialisation?
ZINT_CAP_FULL_MULTIBYTE | Is the ZINT_FULL_MULTIBYTE option applicable?
ZINT_CAP_MASK | Is mask selection applicable?
ZINT_CAP_STRUCTAPP | Does the symbology support Structured Append?
ZINT_CAP_COMPLIANT_HEIGHT | Does the symbology have a compliant height defined?
--------------------------------------------------------------------------------
For example:
@ -1605,10 +1642,11 @@ They consist of a number of bars and a number of spaces of differing widths.
6.1.1 Code 11
-------------
Developed by Intermec in 1977, Code 11 is similar to Code 2 of 5 Matrix and is
primarily used in telecommunications. The symbol can encode any length string
consisting of the digits 0-9 and the dash character (-). Two modulo-11 check
digits are added by default. To add just one check digit, set option_2 = 1 or
--vers=1. To add no check digits, set option_2 = 2 or --vers=2.
primarily used in telecommunications. The symbol can encode data consisting of
the digits 0-9 and the dash character (\-) up to a maximum of 121 characters.
Two modulo-11 check digits are added by default. To add just one check digit,
set option_2 = 1 or --vers=1. To add no check digits, set option_2 = 2 or
--vers=2.
6.1.2 Code 2 of 5
-----------------
@ -1620,40 +1658,41 @@ before using these standards.
6.1.2.1 Standard Code 2 of 5
----------------------------
Also known as Code 2 of 5 Matrix this is a self-checking code used in industrial
applications and photo development. Standard Code 2 of 5 will encode any length
numeric input (digits 0-9). No check digit is added by default. To add a check
digit, set option_2 = 1 or --vers=1. To add a check digit but not show it in
the Human Readable Text, set option_2 = 2 or --vers=2.
applications and photo development. Standard Code 2 of 5 will encode numeric
input (digits 0-9) up to a maximum of 80 digits. No check digit is added by
default. To add a check digit, set option_2 = 1 or --vers=1. To add a check
digit but not show it in the Human Readable Text, set option_2 = 2 or --vers=2.
6.1.2.2 IATA Code 2 of 5
------------------------
Used for baggage handling in the air-transport industry by the International
Air Transport Agency, this self-checking code will encode any length numeric
input (digits 0-9). No check digit is added by default. To add a check digit,
set option_2 = 1 or --vers=1. To add a check digit but not show it in the Human
Readable Text, set option_2 = 2 or --vers=2.
Air Transport Agency, this self-checking code will encode numeric input (digits
0-9) up to a maximum of 45 digits. No check digit is added by default. To add a
check digit, set option_2 = 1 or --vers=1. To add a check digit but not show it
in the Human Readable Text, set option_2 = 2 or --vers=2.
6.1.2.3 Industrial Code 2 of 5
------------------------------
Industrial Code 2 of 5 can encode any length numeric input (digits 0-9). No
check digit is added by default. To add a check digit, set option_2 = 1 or
--vers=1. To add a check digit but not show it in the Human Readable Text, set
option_2 = 2 or --vers=2.
Industrial Code 2 of 5 can encode numeric input (digits 0-9) up to a maximum of
45 digits. No check digit is added by default. To add a check digit, set
option_2 = 1 or --vers=1. To add a check digit but not show it in the Human
Readable Text, set option_2 = 2 or --vers=2.
6.1.2.4 Interleaved Code 2 of 5 (ISO 16390)
-------------------------------------------
This self-checking symbology encodes pairs of numbers, and so can only encode
an even number of digits (0-9). If an odd number of digits is entered a leading
zero is added by Zint. No check digit is added by default. To add a check digit,
set option_2 = 1 or --vers=1. To add a check digit but not show it in the Human
Readable Text, set option_2 = 2 or --vers=2.
zero is added by Zint. A maximum of 45 pairs (90 digits) can be encoded. No
check digit is added by default. To add a check digit, set option_2 = 1 or
--vers=1. To add a check digit but not show it in the Human Readable Text, set
option_2 = 2 or --vers=2.
6.1.2.5 Code 2 of 5 Data Logic
------------------------------
Data Logic does not include a check digit by default and can encode any length
numeric input (digits 0-9). To add a check digit, set option_2 = 1 or --vers=1.
To add a check digit but not show it in the Human Readable Text, set option_2 =
2 or --vers=2.
Data Logic does not include a check digit by default and can encode numeric
input (digits 0-9) up to a maximum of 80 digits. To add a check digit, set
option_2 = 1 or --vers=1. To add a check digit but not show it in the Human
Readable Text, set option_2 = 2 or --vers=2.
6.1.2.6 ITF-14
--------------
@ -1665,8 +1704,8 @@ If no border option is specified Zint defaults to adding a bounding box with a
border width of 5. This behaviour can be overridden by using the --bind option
(or adding BARCODE_BIND to symbol->output_options). Similarly the border width
can be overridden using --border= (or by setting symbol->border_width). If a
symbol with no border is explicitly required this can be achieved by setting
the border type to box or bind and setting the border width to 0.
symbol with no border is required this can be achieved by explicitly setting
the border type to bind (or box) and setting the border width to 0.
6.1.2.7 Deutsche Post Leitcode
------------------------------
@ -1743,7 +1782,7 @@ The EAN system is used in retail across Europe and includes standards for EAN-2
and EAN-5 add-on codes, EAN-8 and EAN-13 which encode 2, 5, 7 or 12 digit
numbers respectively. Zint will decide which symbology to use depending on the
length of the input data. In addition EAN-2 and EAN-5 add-on symbols can be
added using the + symbol as with UPC symbols. For example:
added using the + character as with UPC symbols. For example:
zint --barcode=EANX -d 54321
@ -1778,7 +1817,7 @@ EAN-13 symbols (also known as Bookland EAN-13) can also be produced from
9-digit SBN, 10-digit ISBN or 13-digit ISBN-13 data. The relevant check digit
needs to be present in the input data and will be verified before the symbol is
generated. In addition EAN-2 and EAN-5 add-on symbols can be added using the +
symbol as with UPC symbols, and the gap set with --addongap= (option_2) to
character as with UPC symbols, and the gap set with --addongap= (option_2) to
between 7 (default) and 12. The height that the guard bars descend can be
adjusted by setting --guarddescent= (variable guard_descent in the symbol
structure) to a value between 0 and 20 (default 5).
@ -1791,10 +1830,10 @@ Ltd. in the UK. The symbol can encode any length data consisting of digits
6.1.6 MSI Plessey
-----------------
Based on Plessey and developed by MSE Data Corporation, MSI Plessey is
available with a range of check digit options available by setting option_2 or
by using the --vers= switch. Any length numeric (digits 0-9) input can be
encoded. The table below shows the options available:
Based on Plessey and developed by MSE Data Corporation, MSI Plessey has a range
of check digit options that are selectable by setting option_2 or by using the
--vers= switch. Numeric (digits 0-9) input can be encoded, up to a maximum of 65
digits. The table below shows the options available:
-------------------------------------------
Value of option_2 | Check Digits
@ -1815,26 +1854,28 @@ option_2 value.
-------------
6.1.7.1 Telepen Alpha
---------------------
Telepen Alpha was developed by SB Electronic Systems Limited and can encode any
length of ASCII text input. Telepen includes a modulo-127 check digit.
Telepen Alpha was developed by SB Electronic Systems Limited and can encode
ASCII text input, up to a maximum of 30 characters. Telepen includes a
modulo-127 check digit.
6.1.7.2 Telepen Numeric
-----------------------
Telepen Numeric allows compression of numeric data into a Telepen symbol. Data
can consist of pairs of numbers or pairs consisting of a numerical digit
followed an X character. For example: 466333 and 466X33 are valid codes whereas
46X333 is not (the digit pair "X3" is not valid). Telepen Numeric includes a
modulo-127 check digit which is added by Zint.
46X333 is not (the digit pair "X3" is not valid). Up to 60 digits can be
encoded. Telepen Numeric includes a modulo-127 check digit which is added by
Zint.
6.1.8 Code 39
-------------
6.1.8.1 Standard Code 39 (ISO 16388)
------------------------------------
Standard Code 39 was developed in 1974 by Intermec. Input data can be of any
length and can include the characters 0-9, A-Z, dash (-), full stop (.), space,
asterisk (*), dollar ($), slash (/), plus (+) and percent (%). The standard
does not require a check digit but a modulo-43 check digit can be added if
required by setting option_2 = 1 or using --vers=1.
Standard Code 39 was developed in 1974 by Intermec. Input data can be up to 85
characters in length and can include the characters 0-9, A-Z, dash (-), full
stop (.), space, asterisk (*), dollar ($), slash (/), plus (+) and percent (%).
The standard does not require a check digit but a modulo-43 check digit can be
added if required by setting option_2 = 1 or using --vers=1.
6.1.8.2 Extended Code 39
------------------------
@ -1888,7 +1929,7 @@ An Import character prefix 'I' can be added by setting option_2 = 1 or using
Also known as NW-7, Monarch, ABC Codabar, USD-4, Ames Code and Code 27, this
symbology was developed in 1972 by Monarch Marketing Systems for retail
purposes. The American Blood Commission adopted Codabar in 1977 as the standard
symbology for blood identification. Codabar can encode any length string
symbology for blood identification. Codabar can encode up to 60 characters
starting and ending with the letters A-D and containing between these letters
the numbers 0-9, dash (-), dollar ($), colon (:), slash (/), full stop (.) or
plus (+). No check characater is generated by default, but a modulo-16 one can
@ -1915,9 +1956,9 @@ Latin-1 character set is shown in Appendix A.
6.1.11.2 Code 128 Subset B
--------------------------
It is sometimes advantageous to stop Code 128 from using subset mode C which
compresses numerical data. The BARCODE_CODE128B option (symbology 60) suppresses
mode C in favour of mode B.
It is sometimes advantageous to stop Code 128 from beginning in subset mode C
which compresses numerical data. The BARCODE_CODE128B option (symbology 60)
suppresses beginning in mode C in favour of mode B.
6.1.11.3 GS1-128
----------------
@ -1989,8 +2030,8 @@ of 33 or greater.
Previously known as RSS Limited this standard encodes a 13 digit item code and
can be used in the same way as DataBar above. DataBar Limited, however, is
limited to data starting with digits 0 and 1 (i.e. numbers in the range 0 to
1999999999999). As with DataBar Omnidirectional a check digit and application
identifier of (01) are added by Zint, and a 14 digit code may be given in which
1999999999999). As with DataBar Omnidirectional a check digit and Application
Identifier of (01) are added by Zint, and a 14 digit code may be given in which
case the check digit will be verified.
6.1.12.3 DataBar Expanded
@ -2058,6 +2099,9 @@ error = ZBarcode_Encode(my_symbol, "That", 0);
error = ZBarcode_Print(my_symbol);
Note that the Human Readable Text will be that of the last data, so it's best to
use the option --notext (API show_hrt = 0).
The stacked barcode rows can be separated by row separator bars by specifying
--bind (output_options |= BARCODE_BIND). The height of the row separator bars in
multiples of the X-dimension (minimum and default 1, maximum 4) can be set by
@ -2116,28 +2160,30 @@ If an ID is not given, no ID is encoded.
6.2.5 Compact PDF417
--------------------
Previously known as Truncated PDF417. Options are the same as for PDF417 above.
Previously known as Truncated PDF417, Compact PDF417 omits some per-row
overhead to produce a narrower but less robust symbol. Options are the same as
for PDF417 above.
6.2.6 MicroPDF417 (ISO 24728)
-----------------------------
A variation of the PDF417 standard, MicroPDF417 is intended for applications
where symbol size needs to be kept to a minimum. 34 predefined symbol sizes are
available with 1 - 4 columns and 4 - 44 rows. The maximum size MicroPDF417
symbol can hold 250 alphanumeric characters or 366 digits. The amount of error
correction used is dependent on symbol size. The number of columns used can be
determined using the --cols switch or option_2 as with PDF417. This symbology
uses Latin-1 character encoding by default but also supports the ECI encoding
mechanism. A separate symbology ID can be used to encode Health Industry
Barcode (HIBC) data which adds a leading '+' character and a modulo-49 check
digit to the encoded data. MicroPDF417 supports Structured Append the same as
PDF417, for which see details.
available with 1 - 4 columns and 4 - 44 rows. The maximum size a MicroPDF417
symbol can hold is 250 alphanumeric characters or 366 digits. The amount of
error correction used is dependent on symbol size. The number of columns used
can be determined using the --cols switch or option_2 as with PDF417. This
symbology uses Latin-1 character encoding by default but also supports the ECI
encoding mechanism. A separate symbology ID can be used to encode Health
Industry Barcode (HIBC) data which adds a leading '+' character and a modulo-49
check digit to the encoded data. MicroPDF417 supports Structured Append the same
as PDF417, for which see details.
6.2.7 GS1 DataBar Stacked (ISO 24724)
-------------------------------------
A stacked variation of the GS1 DataBar Truncated symbol requiring the same input
(see section 6.1.12.1). The height of this symbol is fixed. The data is encoded
in two rows of bars with a central finder pattern. This symbol can be generated
with a two-dimensional component to make a composite symbol.
(see section 6.1.12.1). The data is encoded in two rows of bars with a central
finder pattern. This symbol can be generated with a two-dimensional component to
make a composite symbol.
6.2.8 GS1 DataBar Stacked Omnidirectional (ISO 24724)
-----------------------------------------------------
@ -2233,8 +2279,8 @@ option_1 variable as shown above.
6.3.1 CC-A
----------
This system uses a variation of MicroPDF417 which optimised to fit into a small
space. The size of the 2D component and the amount of error correction is
This system uses a variation of MicroPDF417 which is optimised to fit into a
small space. The size of the 2D component and the amount of error correction is
determined by the amount of data to be encoded and the type of linear component
which is being used. CC-A can encode up to 56 numeric digits or an alphanumeric
string of shorter length. To select CC-A use --mode=1.
@ -2291,8 +2337,8 @@ by Australia Post for printing Delivery Point ID (DPID) and customer
information on mail items. Valid data characters are 0-9, A-Z, a-z, space and
hash (#). A Format Control Code (FCC) is added by Zint and should not be
included in the input data. Reed-Solomon error correction data is generated by
Zint. Encoding behaviour is determined by the length of the input data
according to the formula shown in the following table:
Zint. Encoding behaviour is determined by the length of the input data according
to the formula shown in the following table:
-----------------------------------------------------------------
Input | Required Input Format | Symbol | FCC | Encoding
@ -2449,9 +2495,8 @@ Input | Symbol Size
DMRE symbol sizes may be activated in automatic size mode using the option
--dmre or by the API option_3 = DM_DMRE
GS1 data may be encoded using FNC1 (preferred) or GS as separator.
Use the option --gssep to change to GS or use the API output_options |=
GS1_GS_SEPARATOR
GS1 data may be encoded using FNC1 (preferred) or GS as separator. Use the
option --gssep to change to GS or use the API output_options |= GS1_GS_SEPARATOR
Data Matrix supports Structured Append of up to 16 symbols and a numeric ID
(file identifications), which can be set by using the --structapp option (see
@ -2530,7 +2575,7 @@ The maximum capacity of a (version 40) QR Code symbol is 7089 numeric digits,
used to encode GS1 data. QR Code symbols can by default encode characters in
the Latin-1 set and Kanji characters which are members of the Shift JIS
encoding scheme. In addition QR Code supports using other character sets using
the ECI mechanism. Input should usually be entered as Unicode (UTF-8) with
the ECI mechanism. Input should usually be entered as UTF-8 (Unicode) with
conversion to Shift JIS being carried out by Zint. A separate symbology ID can
be used to encode Health Industry Barcode (HIBC) data which adds a leading '+'
character and a modulo-49 check digit to the encoded data.
@ -2586,12 +2631,11 @@ ZINT_FULL_MULTIBYTE | (N + 1) << 8.
A rectangular version of QR Code, it is still under development, so it is
recommended it should not yet be used for a production environment. Like QR
Code, rMQR supports encoding of GS1 data, and Latin-1 characters in the ISO/IEC
8859-1 set and Kanji characters in the Shift JIS encoding scheme. It does not
support other ISO/IEC 8859 character sets or encodings. As with other
symbologies data should be entered as UTF-8 with the conversion to Latin-1 or
Shift JIS being handled by Zint. The amount of ECC codewords can be adjusted
using the --secure= option (API option_1), however only ECC levels M and H are
valid for this type of symbol.
8859-1 set and Kanji characters in the Shift JIS encoding scheme, and other
encodings using the ECI mechanism. As with other symbologies data should be
entered as UTF-8 with conversion being handled by Zint. The amount of ECC
codewords can be adjusted using the --secure= option (API option_1), however
only ECC levels M and H are valid for this type of symbol.
-------------------------------------------------------------------------
Input | ECC Level | Error Correction Capacity | Recovery Capacity
@ -2663,7 +2707,7 @@ API set symbol->input_mode = DATA MODE;
The following example creates a symbol from data saved as an ISO/IEC 8859-2
file:
zint -o upnqr.png -b 143 --border=5 --scale=3 --binary -i ./upn.txt
zint -o upnqr.png -b 143 --border=5 --scale=3 --binary -i upn.txt
6.6.6 MaxiCode (ISO 16023)
--------------------------
@ -2741,7 +2785,8 @@ using the --structapp option (see section 4.15) or the API structapp variable.
It does not support specifying an ID.
MaxiCode uses a different scaling than other symbols for raster output, see
4.9.2.
4.9.2, and also for EMF vector output, when the scale is multiplied by 20
instead of 2.
6.6.7 Aztec Code (ISO 24778)
----------------------------
@ -2833,8 +2878,8 @@ cannot contain spaces. If an ID is not given, no ID is encoded.
6.6.8 Aztec Runes
-----------------
A truncated version of compact Aztec Code for encoding whole integers between 0
and 255. Includes Reed-Solomon error correction. As defined in ISO/IEC 24778
Annex A. It does not support Structured Append.
and 255, as defined in ISO/IEC 24778 Annex A. Includes Reed-Solomon error
correction. It does not support Structured Append.
6.6.9 Code One
--------------
@ -2870,13 +2915,15 @@ It does not support specifying an ID. Structured Append is not supported with
GS1 data nor for Version S symbols.
6.6.10 Grid Matrix
-----------------
------------------
By default Grid Matrix supports encoding in Latin-1 and Chinese characters
within the GB 2312 standard set to be encoded in a chequerboard pattern. Input
should be entered as Unicode (UTF-8) with conversion to GB 2312 being carried
out automatically by Zint. The symbology also supports the ECI mechanism. The
size of the symbol and the error correction capacity can be specified. If you
specify both of these values then Zint will make a 'best-fit' attempt to
should be entered as UTF-8 (Unicode) with conversion to GB 2312 being carried
out automatically by Zint. The symbology also supports the ECI mechanism.
Support for GS1 data has not yet been implemented.
The size of the symbol and the error correction capacity can be specified. If
you specify both of these values then Zint will make a 'best-fit' attempt to
satisfy both conditions. The symbol size can be specified using the --vers=
option or by setting option_2, and the error correction capacity can be
specified by using the --secure= option or by setting option_1 according to
@ -2919,7 +2966,7 @@ Grid Matrix supports Structured Append of up to 16 symbols and a numeric ID
4.15) or the API structapp variable. The ID ranges from 0 (default) to 255.
6.6.11 DotCode
-------------
--------------
DotCode uses a grid of dots in a rectangular formation to encode characters up
to a maximum of approximately 450 characters (or 900 numeric digits). The
symbology supports ECI encoding and GS1 data encoding. By default Zint will
@ -2945,8 +2992,9 @@ It does not support specifying an ID.
Also known as Chinese Sensible Code, Han Xin is a symbology which is still under
development, so it is recommended it should not yet be used for a production
environment. The symbology is capable of encoding characters in the GB 18030
character set (up to 4-byte characters) and is also able to support the ECI
mechanism. Support for the encoding of GS1 data has not yet been implemented.
character set (which includes all Unicode characters) and is also able to
support the ECI mechanism. Support for the encoding of GS1 data has not yet been
implemented.
The size of the symbol can be specified using the --vers= option or setting
option_2 to a value between 1 and 84 according to the following table.
@ -3100,8 +3148,8 @@ not given, no ID is encoded.
6.7 Other Barcode-Like Markings
-------------------------------
6.7.1. Facing Identification Mark (FIM)
---------------------------------------
6.7.1 Facing Identification Mark (FIM)
--------------------------------------
Used by the United States Postal Service (USPS), the FIM symbology is used to
assist automated mail processing. There are only 4 valid symbols which can be
generated using the characters A-D as shown in the table below.
@ -3120,8 +3168,8 @@ D | Used for Information Based Indicia (IBI) postage.
-------------------
Used for the recognition of page sequences in print-shops, the Flattermarken is
not a true barcode symbol and requires precise knowledge of the position of the
mark on the page. The Flattermarken system can encode any length numeric data
and does not include a check digit.
mark on the page. The Flattermarken system can encode numeric data up to a
maximum of 90 digits and does not include a check digit.
6.7.3 DAFT Code
---------------
@ -3140,9 +3188,10 @@ default value is 250 (25%).
-----------
Zint, libzint and Zint Barcode Studio are Copyright © 2021 Robin Stuart. All
historical versions are distributed under the GNU General Public License
version 3 or later. Version 2.5 is released under a dual license: the encoding
library is released under the BSD license whereas the GUI, Zint Barcode Studio,
is released under the GNU General Public License version 3 or later.
version 3 or later. Version 2.5 (and later) is released under a dual license:
the encoding library is released under the BSD license whereas the GUI, Zint
Barcode Studio, is released under the GNU General Public License version 3 or
later.
Telepen is a trademark of SB Electronic Systems Ltd.
@ -3299,7 +3348,7 @@ A.2 Latin Alphabet No 1 (ISO/IEC 8859-1)
----------------------------------------
A common extension to the ASCII standard, Latin-1 is used to expand the range
of Code 128, PDF417 and other symbols. Input strings to the CLI should be in
Unicode (UTF-8) format, unless the --binary switch is given.
UTF-8 (Unicode) format, unless the --binary switch is given.
------------------------------------------------------
Hex | 8 | 9 | A | B | C | D | E | F

View File

@ -6,14 +6,15 @@ project(zint-qt)
set(CMAKE_AUTORCC ON)
set(${PROJECT_NAME}_SRCS barcodeitem.cpp main.cpp mainwindow.cpp datawindow.cpp sequencewindow.cpp exportwindow.cpp)
set(${PROJECT_NAME}_SRCS barcodeitem.cpp main.cpp mainwindow.cpp
cliwindow.cpp datawindow.cpp sequencewindow.cpp exportwindow.cpp)
if(USE_QT6)
qt6_wrap_cpp(zint-qt_SRCS mainwindow.h datawindow.h sequencewindow.h exportwindow.h)
qt6_wrap_ui(zint-qt_SRCS mainWindow.ui extData.ui extSequence.ui extExport.ui)
qt6_wrap_cpp(zint-qt_SRCS mainwindow.h cliwindow.h datawindow.h sequencewindow.h exportwindow.h)
qt6_wrap_ui(zint-qt_SRCS mainWindow.ui extCLI.ui extData.ui extSequence.ui extExport.ui)
else()
qt5_wrap_cpp(zint-qt_SRCS mainwindow.h datawindow.h sequencewindow.h exportwindow.h)
qt5_wrap_ui(zint-qt_SRCS mainWindow.ui extData.ui extSequence.ui extExport.ui)
qt5_wrap_cpp(zint-qt_SRCS mainwindow.h cliwindow.h datawindow.h sequencewindow.h exportwindow.h)
qt5_wrap_ui(zint-qt_SRCS mainWindow.ui extCLI.ui extData.ui extSequence.ui extExport.ui)
endif()
# grpAztec.ui grpC39.ui grpCodablockF.ui grpDotCode.ui grpMaxicode.ui grpQR.ui grpVIN.ui
@ -30,7 +31,9 @@ endif()
target_include_directories(${PROJECT_NAME} PUBLIC "${CMAKE_SOURCE_DIR}/backend" "${CMAKE_SOURCE_DIR}/backend_qt")
target_link_libraries(${PROJECT_NAME} zint QZint Qt${QT_VERSION_MAJOR}::UiTools Qt${QT_VERSION_MAJOR}::Xml Qt${QT_VERSION_MAJOR}::Gui Qt${QT_VERSION_MAJOR}::Core)
target_link_libraries(${PROJECT_NAME} zint QZint
Qt${QT_VERSION_MAJOR}::UiTools Qt${QT_VERSION_MAJOR}::Xml Qt${QT_VERSION_MAJOR}::Gui
Qt${QT_VERSION_MAJOR}::Core)
install(TARGETS ${PROJECT_NAME} DESTINATION "${BIN_INSTALL_DIR}" RUNTIME)

View File

@ -31,6 +31,7 @@ class BarcodeItem : public QGraphicsItem
public:
BarcodeItem();
~BarcodeItem();
void setSize(int width, int height);
QRectF boundingRect() const;
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);

103
frontend_qt/cliwindow.cpp Normal file
View File

@ -0,0 +1,103 @@
/*
Zint Barcode Generator - the open source barcode generator
Copyright (C) 2021 Robin Stuart <rstuart114@gmail.com>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
/* vim: set ts=4 sw=4 et : */
//#include <QDebug>
#include <QSettings>
#include <QClipboard>
#include <QMimeData>
#include "cliwindow.h"
#include "barcodeitem.h"
#include "mainwindow.h"
// Shorthand
#define QSL QStringLiteral
static const int tempMessageTimeout = 2000;
CLIWindow::CLIWindow(BarcodeItem *bc, const bool autoHeight, const double heightPerRow)
: m_bc(bc), m_autoHeight(autoHeight), m_heightPerRow(heightPerRow)
{
setupUi(this);
QSettings settings;
#if QT_VERSION < 0x60000
settings.setIniCodec("UTF-8");
#endif
QByteArray geometry = settings.value(QSL("studio/cli/window_geometry")).toByteArray();
restoreGeometry(geometry);
#if _WIN32
const int index = settings.value(QSL("studio/cli/rad_unix_win"), 1).toInt();
#else
const int index = settings.value(QSL("studio/cli/rad_unix_win"), 0).toInt();
#endif
if (index == 1) {
radCLIWin->setChecked(true);
} else {
radCLIUnix->setChecked(true);
}
chkCLILongOpts->setChecked(settings.value(QSL("studio/cli/chk_long_opts"), 0).toInt() ? true : false);
chkCLIBarcodeName->setChecked(settings.value(QSL("studio/cli/chk_barcode_name"), 0).toInt() ? true : false);
QIcon copyIcon(QIcon::fromTheme(QSL("edit-copy"), QIcon(QSL(":res/copy.svg"))));
QIcon closeIcon(QIcon::fromTheme(QSL("window-close"), QIcon(QSL(":res/x.svg"))));
btnCLICopy->setIcon(copyIcon);
btnCLIClose->setIcon(closeIcon);
connect(btnCLIClose, SIGNAL( clicked( bool )), SLOT(close()));
connect(btnCLICopy, SIGNAL( clicked( bool )), SLOT(copy_to_clipboard()));
connect(radCLIUnix, SIGNAL(toggled( bool )), SLOT(generate_cli()));
connect(radCLIWin, SIGNAL(toggled( bool )), SLOT(generate_cli()));
connect(chkCLILongOpts, SIGNAL(toggled( bool )), SLOT(generate_cli()));
connect(chkCLIBarcodeName, SIGNAL(toggled( bool )), SLOT(generate_cli()));
generate_cli();
}
CLIWindow::~CLIWindow()
{
QSettings settings;
#if QT_VERSION < 0x60000
settings.setIniCodec("UTF-8");
#endif
settings.setValue(QSL("studio/cli/window_geometry"), saveGeometry());
settings.setValue(QSL("studio/cli/rad_unix_win"), radCLIWin->isChecked() ? 1 : 0);
settings.setValue(QSL("studio/cli/chk_long_opts"), chkCLILongOpts->isChecked() ? 1 : 0);
settings.setValue(QSL("studio/cli/chk_barcode_name"), chkCLIBarcodeName->isChecked() ? 1 : 0);
}
void CLIWindow::copy_to_clipboard()
{
QClipboard *clipboard = QGuiApplication::clipboard();
QMimeData *mdata = new QMimeData;
mdata->setData("text/plain", txtCLICmd->toPlainText().toUtf8());
clipboard->setMimeData(mdata, QClipboard::Clipboard);
statusBarCLI->showMessage(tr("Copied to clipboard"), tempMessageTimeout);
}
void CLIWindow::generate_cli()
{
QString cmd = m_bc->bc.getAsCLI(radCLIWin->isChecked(), chkCLILongOpts->isChecked(),
chkCLIBarcodeName->isChecked(), m_autoHeight, m_heightPerRow);
txtCLICmd->setPlainText(cmd);
statusBarCLI->clearMessage();
}

46
frontend_qt/cliwindow.h Normal file
View File

@ -0,0 +1,46 @@
/*
Zint Barcode Generator - the open source barcode generator
Copyright (C) 2021 Robin Stuart <rstuart114@gmail.com>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
/* vim: set ts=4 sw=4 et : */
#ifndef CLIWINDOW_H
#define CLIWINDOW_H
#include "ui_extCLI.h"
class BarcodeItem;
class CLIWindow : public QDialog, private Ui::CLIDialog
{
Q_OBJECT
public:
CLIWindow(BarcodeItem *bc, const bool autoHeight, const double heightPerRow);
virtual ~CLIWindow();
private slots:
void copy_to_clipboard();
void generate_cli();
protected:
BarcodeItem *m_bc;
bool m_autoHeight;
double m_heightPerRow;
};
#endif

View File

@ -27,35 +27,43 @@
#include "datawindow.h"
DataWindow::DataWindow()
// Shorthand
#define QSL QStringLiteral
DataWindow::DataWindow(const QString &input) : Valid(false)
{
setupUi(this);
QSettings settings;
#if QT_VERSION < 0x60000
settings.setIniCodec("UTF-8");
#endif
connect(btnCancel, SIGNAL( clicked( bool )), SLOT(quit_now()));
connect(btnReset, SIGNAL( clicked( bool )), SLOT(clear_data()));
connect(btnOK, SIGNAL( clicked( bool )), SLOT(okay()));
}
QByteArray geometry = settings.value(QSL("studio/data/window_geometry")).toByteArray();
restoreGeometry(geometry);
QIcon closeIcon(QIcon::fromTheme(QSL("window-close"), QIcon(QSL(":res/x.svg"))));
QIcon clearIcon(QIcon::fromTheme(QSL("edit-clear"), QIcon(QSL(":res/delete.svg"))));
QIcon okIcon(QIcon(QSL(":res/check.svg")));
btnCancel->setIcon(closeIcon);
btnDataClear->setIcon(clearIcon);
btnOK->setIcon(okIcon);
DataWindow::DataWindow(const QString &input)
{
setupUi(this);
txtDataInput->setPlainText(input);
txtDataInput->moveCursor(QTextCursor::End, QTextCursor::MoveAnchor);
connect(btnCancel, SIGNAL( clicked( bool )), SLOT(quit_now()));
connect(btnReset, SIGNAL( clicked( bool )), SLOT(clear_data()));
connect(btnCancel, SIGNAL( clicked( bool )), SLOT(close()));
connect(btnDataClear, SIGNAL( clicked( bool )), SLOT(clear_data()));
connect(btnOK, SIGNAL( clicked( bool )), SLOT(okay()));
connect(btnFromFile, SIGNAL( clicked( bool )), SLOT(from_file()));
}
DataWindow::~DataWindow()
{
}
void DataWindow::quit_now()
{
Valid = 0;
close();
QSettings settings;
#if QT_VERSION < 0x60000
settings.setIniCodec("UTF-8");
#endif
settings.setValue(QSL("studio/data/window_geometry"), saveGeometry());
}
void DataWindow::clear_data()
@ -65,7 +73,7 @@ void DataWindow::clear_data()
void DataWindow::okay()
{
Valid = 1;
Valid = true;
DataOutput = txtDataInput->toPlainText();
close();
}
@ -93,7 +101,7 @@ void DataWindow::from_file()
}
file.setFileName(filename);
if(!file.open(QIODevice::ReadOnly)) {
if (!file.open(QIODevice::ReadOnly)) {
QMessageBox::critical(this, tr("Open Error"), tr("Could not open selected file."));
return;
}

View File

@ -1,6 +1,6 @@
/*
Zint Barcode Generator - the open source barcode generator
Copyright (C) 2009-2017 Robin Stuart <rstuart114@gmail.com>
Copyright (C) 2009-2021 Robin Stuart <rstuart114@gmail.com>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@ -16,6 +16,7 @@
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
/* vim: set ts=4 sw=4 et : */
#ifndef DATAWINDOW_H
#define DATAWINDOW_H
@ -24,20 +25,19 @@
class DataWindow : public QDialog, private Ui::DataDialog
{
Q_OBJECT
Q_OBJECT
public:
DataWindow();
explicit DataWindow(const QString &input);
~DataWindow();
int Valid;
QString DataOutput;
DataWindow(const QString &input);
~DataWindow();
bool Valid;
QString DataOutput;
private slots:
void quit_now();
void clear_data();
void okay();
void from_file();
void clear_data();
void okay();
void from_file();
};
#endif

View File

@ -23,24 +23,34 @@
#include <QFileDialog>
#include <QMessageBox>
#include <QSettings>
#include <QStringBuilder>
#include "exportwindow.h"
ExportWindow::ExportWindow()
// Shorthand
#define QSL QStringLiteral
ExportWindow::ExportWindow(BarcodeItem *bc, const QString& output_data) : m_bc(bc), m_output_data(output_data)
{
setupUi(this);
QSettings settings;
#if QT_VERSION < 0x60000
settings.setIniCodec("UTF-8");
#endif
setupUi(this);
linDestPath->setText(settings.value("studio/export/destination",
QByteArray geometry = settings.value(QSL("studio/export/window_geometry")).toByteArray();
restoreGeometry(geometry);
linDestPath->setText(settings.value(QSL("studio/export/destination"),
QDir::toNativeSeparators(QDir::homePath())).toString());
linPrefix->setText(settings.value("studio/export/file_prefix", "bcs_").toString());
cmbFileName->setCurrentIndex(settings.value("studio/export/name_format", 0).toInt());
cmbFileFormat->setCurrentIndex(settings.value("studio/export/filetype", 0).toInt());
linPrefix->setText(settings.value(QSL("studio/export/file_prefix"), QSL("bcs_")).toString());
cmbFileName->setCurrentIndex(settings.value(QSL("studio/export/name_format"), 0).toInt());
cmbFileFormat->setCurrentIndex(settings.value(QSL("studio/export/filetype"), 0).toInt());
connect(btnCancel, SIGNAL( clicked( bool )), SLOT(quit_now()));
QIcon closeIcon(QIcon::fromTheme(QSL("window-close"), QIcon(QSL(":res/x.svg"))));
btnCancel->setIcon(closeIcon);
connect(btnCancel, SIGNAL( clicked( bool )), SLOT(close()));
connect(btnOK, SIGNAL( clicked( bool )), SLOT(process()));
connect(btnDestPath, SIGNAL( clicked( bool )), SLOT(get_directory()));
}
@ -51,16 +61,12 @@ ExportWindow::~ExportWindow()
#if QT_VERSION < 0x60000
settings.setIniCodec("UTF-8");
#endif
settings.setValue(QSL("studio/export/window_geometry"), saveGeometry());
settings.setValue("studio/export/destination", linDestPath->text());
settings.setValue("studio/export/file_prefix", linPrefix->text());
settings.setValue("studio/export/name_format", cmbFileName->currentIndex());
settings.setValue("studio/export/filetype", cmbFileFormat->currentIndex());
}
void ExportWindow::quit_now()
{
close();
settings.setValue(QSL("studio/export/destination"), linDestPath->text());
settings.setValue(QSL("studio/export/file_prefix"), linPrefix->text());
settings.setValue(QSL("studio/export/name_format"), cmbFileName->currentIndex());
settings.setValue(QSL("studio/export/filetype"), cmbFileFormat->currentIndex());
}
void ExportWindow::get_directory()
@ -73,116 +79,148 @@ void ExportWindow::get_directory()
QFileDialog fdialog;
fdialog.setFileMode(QFileDialog::Directory);
fdialog.setDirectory(settings.value("studio/default_dir", QDir::toNativeSeparators(QDir::homePath())).toString());
fdialog.setDirectory(settings.value(QSL("studio/default_dir"),
QDir::toNativeSeparators(QDir::homePath())).toString());
if(fdialog.exec()) {
if (fdialog.exec()) {
directory = fdialog.selectedFiles().at(0);
} else {
return;
}
linDestPath->setText(QDir::toNativeSeparators(directory));
settings.setValue("studio/default_dir", directory);
settings.setValue(QSL("studio/default_dir"), directory);
}
void ExportWindow::process()
{
QString fileName;
QString dataString;
const QRegularExpression urlRE(QSL("[\\/:*?\"<>|%]"));
txtFeedback->setPlainText(tr("Processing..."));
txtFeedback->moveCursor(QTextCursor::End, QTextCursor::MoveAnchor);
QApplication::processEvents(QEventLoop::ExcludeUserInputEvents);
QStringList dataList = m_output_data.split('\n');
int lines = dataList.size();
if (lines && dataList[lines - 1].isEmpty()) {
lines--;
}
QString biggest;
bool needUrlEscape = false;
const int fileNameIdx = cmbFileName->currentIndex();
if (fileNameIdx == 1) {
biggest = QString::number(lines + 1);
} else {
needUrlEscape = m_output_data.contains(urlRE);
}
QString suffix;
QString Feedback;
int lines, i, j, inputpos;
lines = output_data.count(QChar('\n'), Qt::CaseInsensitive);
inputpos = 0;
switch(cmbFileFormat->currentIndex()) {
switch (cmbFileFormat->currentIndex()) {
#ifdef NO_PNG
case 0: suffix = ".eps"; break;
case 1: suffix = ".gif"; break;
case 2: suffix = ".svg"; break;
case 3: suffix = ".bmp"; break;
case 4: suffix = ".pcx"; break;
case 5: suffix = ".emf"; break;
case 6: suffix = ".tif"; break;
case 0: suffix = QSL(".eps"); break;
case 1: suffix = QSL(".gif"); break;
case 2: suffix = QSL(".svg"); break;
case 3: suffix = QSL(".bmp"); break;
case 4: suffix = QSL(".pcx"); break;
case 5: suffix = QSL(".emf"); break;
case 6: suffix = QSL(".tif"); break;
#else
case 0: suffix = ".png"; break;
case 1: suffix = ".eps"; break;
case 2: suffix = ".gif"; break;
case 3: suffix = ".svg"; break;
case 4: suffix = ".bmp"; break;
case 5: suffix = ".pcx"; break;
case 6: suffix = ".emf"; break;
case 7: suffix = ".tif"; break;
case 0: suffix = QSL(".png"); break;
case 1: suffix = QSL(".eps"); break;
case 2: suffix = QSL(".gif"); break;
case 3: suffix = QSL(".svg"); break;
case 4: suffix = QSL(".bmp"); break;
case 5: suffix = QSL(".pcx"); break;
case 6: suffix = QSL(".emf"); break;
case 7: suffix = QSL(".tif"); break;
#endif
}
txtFeedback->clear();
Feedback = "";
for(i = 0; i < lines; i++) {
int datalen = 0;
for(j = inputpos; ((j < output_data.length()) && (output_data[j] != '\n') ); j++) {
datalen++;
}
dataString = output_data.mid(inputpos, datalen);
switch(cmbFileName->currentIndex()) {
case 0: { /* Same as Data (URL Escaped) */
QString filePathPrefix = linDestPath->text() % QDir::separator() % linPrefix->text();
QStringList Feedback;
int successCount = 0, errorCount = 0;
for (int i = 0; i < lines; i++) {
const QString &dataString = dataList[i];
QString fileName;
switch (fileNameIdx) {
case 0: /* Same as Data (URL Escaped) */
if (needUrlEscape) {
QString url_escaped;
int m;
QChar name_qchar;
for(m = 0; m < dataString.length(); m++) {
name_qchar = dataString[m];
for (int m = 0; m < dataString.length(); m++) {
QChar name_qchar = dataString[m];
char name_char = name_qchar.toLatin1();
switch(name_char) {
case '\\': url_escaped += "%5C"; break;
case '/': url_escaped += "%2F"; break;
case ':': url_escaped += "%3A"; break;
case '*': url_escaped += "%2A"; break;
case '?': url_escaped += "%3F"; break;
case '"': url_escaped += "%22"; break;
case '<': url_escaped += "%3C"; break;
case '>': url_escaped += "%3E"; break;
case '|': url_escaped += "%7C"; break;
case '%': url_escaped += "%25"; break;
switch (name_char) {
case '\\': url_escaped += QSL("%5C"); break;
case '/': url_escaped += QSL("%2F"); break;
case ':': url_escaped += QSL("%3A"); break;
case '*': url_escaped += QSL("%2A"); break;
case '?': url_escaped += QSL("%3F"); break;
case '"': url_escaped += QSL("%22"); break;
case '<': url_escaped += QSL("%3C"); break;
case '>': url_escaped += QSL("%3E"); break;
case '|': url_escaped += QSL("%7C"); break;
case '%': url_escaped += QSL("%25"); break;
default: url_escaped += name_qchar; break;
}
}
fileName = linDestPath->text() + QDir::separator() + linPrefix->text() + url_escaped + suffix;
fileName = filePathPrefix % url_escaped % suffix;
} else {
fileName = filePathPrefix % dataString % suffix;
}
break;
case 1: { /* Formatted Serial Number */
QString biggest, this_val, outnumber;
int number_size, val_size, m;
QString this_val, pad;
biggest = QString::number(lines + 1);
number_size = biggest.length();
this_val = QString::number(i + 1);
val_size = this_val.length();
for(m = 0; m < (number_size - val_size); m++) {
outnumber += QChar('0');
}
pad.fill('0', biggest.length() - this_val.length());
outnumber += this_val;
fileName = linDestPath->text() + QDir::separator() + linPrefix->text() + outnumber + suffix;
fileName = filePathPrefix % pad % this_val % suffix;
}
break;
}
barcode->bc.setText(dataString.toLatin1().data());
barcode->bc.save_to_file(fileName.toLatin1().data());
Feedback += "Line ";
Feedback += QString::number(i + 1);
Feedback += ": ";
if (barcode->bc.hasErrors()) {
Feedback += barcode->bc.error_message();
Feedback += "\n";
m_bc->bc.setText(dataString);
m_bc->bc.save_to_file(fileName);
if (m_bc->bc.hasErrors()) {
/*: %1 is line number, %2 is error message */
Feedback << tr("Line %1: %2").arg(i + 1).arg(m_bc->bc.error_message());
errorCount++;
} else {
Feedback += "Success\n";
/*: %1 is line number */
Feedback << tr("Line %1: Success").arg(i + 1);
successCount++;
}
if (i && (i % 100 == 0)) {
txtFeedback->appendPlainText(Feedback.join('\n'));
txtFeedback->moveCursor(QTextCursor::End, QTextCursor::MoveAnchor);
QApplication::processEvents(QEventLoop::ExcludeUserInputEvents);
Feedback.clear();
}
txtFeedback->document()->setPlainText(Feedback);
inputpos += datalen + 1;
}
QString summary;
if (errorCount && successCount) {
/*: %1 is total no. of items processed, %2 is no. of failures, %3 is no. of successes */
summary = tr("Total %1, %2 failed, %3 succeeded.").arg(errorCount + successCount).arg(errorCount)
.arg(successCount);
} else if (errorCount) {
/*: %1 is no. of failures */
summary = tr("All %1 failed.").arg(errorCount);
} else if (successCount) {
/*: %1 is no. of successes */
summary = tr("All %1 succeeded.").arg(successCount);
} else {
summary = tr("No items.");
}
if (Feedback.size()) {
txtFeedback->appendPlainText(Feedback.join('\n') + '\n' + summary + '\n');
} else {
txtFeedback->appendPlainText(summary + '\n');
}
txtFeedback->moveCursor(QTextCursor::End, QTextCursor::MoveAnchor);
}

View File

@ -1,6 +1,6 @@
/*
Zint Barcode Generator - the open source barcode generator
Copyright (C) 2009-2017 Robin Stuart <rstuart114@gmail.com>
Copyright (C) 2009-2021 Robin Stuart <rstuart114@gmail.com>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@ -16,6 +16,7 @@
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
/* vim: set ts=4 sw=4 et : */
#ifndef EXPORTWINDOW_H
#define EXPORTWINDOW_H
@ -25,18 +26,19 @@
class ExportWindow : public QDialog, private Ui::ExportDialog
{
Q_OBJECT
Q_OBJECT
public:
ExportWindow();
~ExportWindow();
BarcodeItem *barcode;
QString output_data;
ExportWindow(BarcodeItem *bc, const QString& output_data);
~ExportWindow();
private slots:
void quit_now();
void process();
void get_directory();
void process();
void get_directory();
protected:
BarcodeItem *m_bc;
QString m_output_data;
};
#endif
#endif

162
frontend_qt/extCLI.ui Normal file
View File

@ -0,0 +1,162 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>CLIDialog</class>
<widget class="QDialog" name="CLIDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>429</width>
<height>333</height>
</rect>
</property>
<property name="windowTitle">
<string>CLI Equivalent</string>
</property>
<property name="windowIcon">
<iconset resource="resources.qrc">
<normaloff>:res/zint-qt.ico</normaloff>:res/zint-qt.ico</iconset>
</property>
<property name="modal">
<bool>true</bool>
</property>
<layout class="QVBoxLayout" name="verticalLayoutCLI">
<item>
<widget class="QLabel" name="lblCLICmd">
<property name="text">
<string>Command Line &amp;Equivalent</string>
</property>
<property name="toolTip">
<string>Current GUI settings as CLI equivalent</string>
</property>
<property name="buddy">
<cstring>txtCLICmd</cstring>
</property>
</widget>
</item>
<item>
<widget class="QPlainTextEdit" name="txtCLICmd">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBoxCLIUnixWin">
<property name="title">
<string>Escape Method</string>
</property>
<property name="toolTip">
<string>How to escape data</string>
</property>
<layout class="QGridLayout" name="gridLayoutCLIUnixWin">
<property name="sizeConstraint">
<enum>QLayout::SetMinimumSize</enum>
</property>
<item row="0" column="0">
<widget class="QRadioButton" name="radCLIUnix">
<property name="text">
<string>&amp;Unix</string>
</property>
<property name="toolTip">
<string>Escape for Unix shell</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QRadioButton" name="radCLIWin">
<property name="text">
<string>&amp;Windows</string>
</property>
<property name="toolTip">
<string>Escape for Windows command prompt</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horzLayoutCLIChks">
<item>
<widget class="QCheckBox" name="chkCLILongOpts">
<property name="text">
<string>&amp;Long Options Only</string>
</property>
<property name="toolTip">
<string>Only use long option names, not short ones</string>
</property>
<property name="checked">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="chkCLIBarcodeName">
<property name="text">
<string>&amp;Barcode Name</string>
</property>
<property name="toolTip">
<string>Use name of barcode, not number</string>
</property>
<property name="checked">
<bool>false</bool>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horzLayoutCLIBtns">
<property name="sizeConstraint">
<enum>QLayout::SetDefaultConstraint</enum>
</property>
<item>
<widget class="QStatusBar" name="statusBarCLI">
<property name="sizeGripEnabled">
<bool>false</bool>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="btnCLICopy">
<property name="toolTip">
<string>Copy to clipboard</string>
</property>
<property name="text">
<string> C&amp;opy</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="btnCLIClose">
<property name="text">
<string>&amp;Close</string>
</property>
<property name="toolTip">
<string>Close window</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

View File

@ -27,8 +27,8 @@
<string>&amp;Data</string>
</property>
<property name="toolTip">
<string>Input data. Newlines (Line Feeds (0xA0))
will be converted to spaces</string>
<string>Input data. Line Feeds (0xA0) will
be converted to spaces</string>
</property>
<property name="buddy">
<cstring>txtDataInput</cstring>
@ -70,14 +70,14 @@ will be converted to spaces</string>
&lt;tr&gt;&lt;td&gt;Record Separator (0x1E)&lt;/td&gt;&lt;td&gt;&amp;nbsp;\R&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Backslash (0x5C)&lt;/td&gt;&lt;td&gt;&amp;nbsp;\\&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;
Note that newlines (Line Feeds (0x0A)) are &lt;br/&gt;not included</string>
Note that Line Feed (0x0A) is not included</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="btnReset">
<widget class="QPushButton" name="btnDataClear">
<property name="text">
<string>&amp;Reset</string>
<string> C&amp;lear</string>
</property>
<property name="toolTip">
<string>Clear data window</string>
@ -100,7 +100,7 @@ Note that newlines (Line Feeds (0x0A)) are &lt;br/&gt;not included</string>
<item>
<widget class="QPushButton" name="btnOK">
<property name="text">
<string>&amp;OK</string>
<string> &amp;OK</string>
</property>
<property name="toolTip">
<string>Close window and update input data</string>

View File

@ -10,24 +10,6 @@
<height>505</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>450</width>
<height>505</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>450</width>
<height>505</height>
</size>
</property>
<property name="windowTitle">
<string>Export Barcodes</string>
</property>
@ -35,258 +17,214 @@
<iconset resource="resources.qrc">
<normaloff>:res/zint-qt.ico</normaloff>:res/zint-qt.ico</iconset>
</property>
<widget class="QLineEdit" name="linDestPath">
<property name="geometry">
<rect>
<x>140</x>
<y>10</y>
<width>261</width>
<height>22</height>
</rect>
</property>
<property name="toolTip">
<string>Destination folder</string>
</property>
</widget>
<widget class="QLineEdit" name="linPrefix">
<property name="geometry">
<rect>
<x>140</x>
<y>40</y>
<width>301</width>
<height>22</height>
</rect>
</property>
<property name="toolTip">
<string>The first part of the filenames</string>
</property>
<property name="text">
<string>bcs_</string>
</property>
</widget>
<widget class="QComboBox" name="cmbFileName">
<property name="geometry">
<rect>
<x>140</x>
<y>70</y>
<width>301</width>
<height>22</height>
</rect>
</property>
<property name="toolTip">
<string>Set the naming convention used by the files</string>
</property>
<layout class="QVBoxLayout" name="verticalLayoutExp">
<item>
<property name="text">
<string>Same as Data</string>
</property>
<layout class="QGridLayout" name="gridLayoutExpFile">
<item row="0" column="0">
<widget class="QLabel" name="lblDestPath">
<property name="text">
<string>&amp;Destination Path:</string>
</property>
<property name="toolTip">
<string>Destination folder</string>
</property>
<property name="buddy">
<cstring>linDestPath</cstring>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="linDestPath">
<property name="geometry">
<rect>
<x>140</x>
<y>10</y>
<width>261</width>
<height>22</height>
</rect>
</property>
<property name="toolTip">
<string>Destination folder</string>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QToolButton" name="btnDestPath">
<property name="toolTip">
<string>Find a destination for your files</string>
</property>
<property name="text">
<string>&amp;...</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="lblPrefix">
<property name="text">
<string>File Name &amp;Prefix:</string>
</property>
<property name="toolTip">
<string>The first part of the filenames</string>
</property>
<property name="buddy">
<cstring>linPrefix</cstring>
</property>
</widget>
</item>
<item row="1" column="1" colspan="2">
<widget class="QLineEdit" name="linPrefix">
<property name="toolTip">
<string>The first part of the filenames</string>
</property>
<property name="text">
<string>bcs_</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="lblFileName">
<property name="text">
<string>File &amp;Name:</string>
</property>
<property name="toolTip">
<string>Set the naming convention used by the files</string>
</property>
<property name="buddy">
<cstring>cmbFileName</cstring>
</property>
</widget>
</item>
<item row="2" column="1" colspan="2">
<widget class="QComboBox" name="cmbFileName">
<property name="toolTip">
<string>Set the naming convention used by the files</string>
</property>
<item>
<property name="text">
<string>Same as Data</string>
</property>
</item>
<item>
<property name="text">
<string>Serial Number</string>
</property>
</item>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="lblFileFormat">
<property name="text">
<string>File &amp;Format:</string>
</property>
<property name="toolTip">
<string>The type of file which you want to create</string>
</property>
<property name="buddy">
<cstring>cmbFileFormat</cstring>
</property>
</widget>
</item>
<item row="3" column="1" colspan="2">
<widget class="QComboBox" name="cmbFileFormat">
<property name="toolTip">
<string>The type of file which you want to create</string>
</property>
<item>
<property name="text">
<string>Portable Network Graphic (*.png)</string>
</property>
</item>
<item>
<property name="text">
<string>Encapsulated Post Script (*.eps)</string>
</property>
</item>
<item>
<property name="text">
<string>Graphics Interchange Format (*.gif)</string>
</property>
</item>
<item>
<property name="text">
<string>Scalable Vector Graphic (*.svg)</string>
</property>
</item>
<item>
<property name="text">
<string>Windows Bitmap (*.bmp)</string>
</property>
</item>
<item>
<property name="text">
<string>ZSoft PC Painter Image (*.pcx)</string>
</property>
</item>
<item>
<property name="text">
<string>Extended Metafile (*.emf)</string>
</property>
</item>
<item>
<property name="text">
<string>Tagged Image File Format (*.tif)</string>
</property>
</item>
</widget>
</item>
</layout>
</item>
<item>
<property name="text">
<string>Serial Number</string>
</property>
</item>
</widget>
<widget class="QComboBox" name="cmbFileFormat">
<property name="geometry">
<rect>
<x>140</x>
<y>100</y>
<width>301</width>
<height>22</height>
</rect>
</property>
<property name="toolTip">
<string>The type of file which you want to create</string>
</property>
<item>
<property name="text">
<string>Portable Network Graphic (*.png)</string>
</property>
<layout class="QHBoxLayout" name="horzLayoutExpBtns">
<item>
<spacer name="horzSpacerExpBtns">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="btnOK">
<property name="text">
<string>&amp;Export</string>
</property>
<property name="toolTip">
<string>Create files</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="btnCancel">
<property name="text">
<string>&amp;Close</string>
</property>
<property name="toolTip">
<string>Close window</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<property name="text">
<string>Encapsulated Post Script (*.eps)</string>
</property>
<widget class="QLabel" name="lblFeedback">
<property name="text">
<string>Export Results:</string>
</property>
</widget>
</item>
<item>
<property name="text">
<string>Graphics Interchange Format (*.gif)</string>
</property>
<widget class="QPlainTextEdit" name="txtFeedback">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<property name="text">
<string>Scalable Vector Graphic (*.svg)</string>
</property>
</item>
<item>
<property name="text">
<string>Windows Bitmap (*.bmp)</string>
</property>
</item>
<item>
<property name="text">
<string>ZSoft PC Painter Image (*.pcx)</string>
</property>
</item>
<item>
<property name="text">
<string>Extended Metafile (*.emf)</string>
</property>
</item>
<item>
<property name="text">
<string>Tagged Image File Format (*.tif)</string>
</property>
</item>
</widget>
<widget class="QToolButton" name="btnDestPath">
<property name="geometry">
<rect>
<x>410</x>
<y>10</y>
<width>30</width>
<height>25</height>
</rect>
</property>
<property name="toolTip">
<string>Find a destination for your files</string>
</property>
<property name="text">
<string>&amp;...</string>
</property>
</widget>
<widget class="QLabel" name="label">
<property name="geometry">
<rect>
<x>10</x>
<y>10</y>
<width>121</width>
<height>16</height>
</rect>
</property>
<property name="text">
<string>&amp;Destination Path:</string>
</property>
<property name="toolTip">
<string>Destination folder</string>
</property>
<property name="buddy">
<cstring>linDestPath</cstring>
</property>
</widget>
<widget class="QLabel" name="label_2">
<property name="geometry">
<rect>
<x>10</x>
<y>40</y>
<width>111</width>
<height>16</height>
</rect>
</property>
<property name="text">
<string>File Name &amp;Prefix:</string>
</property>
<property name="toolTip">
<string>The first part of the filenames</string>
</property>
<property name="buddy">
<cstring>linPrefix</cstring>
</property>
</widget>
<widget class="QLabel" name="label_3">
<property name="geometry">
<rect>
<x>10</x>
<y>70</y>
<width>111</width>
<height>16</height>
</rect>
</property>
<property name="text">
<string>File &amp;Name:</string>
</property>
<property name="toolTip">
<string>Set the naming convention used by the files</string>
</property>
<property name="buddy">
<cstring>cmbFileName</cstring>
</property>
</widget>
<widget class="QLabel" name="label_4">
<property name="geometry">
<rect>
<x>10</x>
<y>100</y>
<width>111</width>
<height>16</height>
</rect>
</property>
<property name="text">
<string>File &amp;Format:</string>
</property>
<property name="toolTip">
<string>The type of file which you want to create</string>
</property>
<property name="buddy">
<cstring>cmbFileFormat</cstring>
</property>
</widget>
<widget class="QPushButton" name="btnCancel">
<property name="geometry">
<rect>
<x>360</x>
<y>130</y>
<width>80</width>
<height>26</height>
</rect>
</property>
<property name="text">
<string>&amp;Close</string>
</property>
<property name="toolTip">
<string>Close window</string>
</property>
</widget>
<widget class="QPushButton" name="btnOK">
<property name="geometry">
<rect>
<x>270</x>
<y>130</y>
<width>80</width>
<height>26</height>
</rect>
</property>
<property name="text">
<string>&amp;Export</string>
</property>
<property name="toolTip">
<string>Create files</string>
</property>
</widget>
<widget class="QPlainTextEdit" name="txtFeedback">
<property name="geometry">
<rect>
<x>10</x>
<y>180</y>
<width>430</width>
<height>315</height>
</rect>
</property>
</widget>
<widget class="QLabel" name="lblFeedback">
<property name="geometry">
<rect>
<x>10</x>
<y>160</y>
<width>101</width>
<height>17</height>
</rect>
</property>
<property name="text">
<string>Export Results:</string>
</property>
</widget>
</layout>
</widget>
<resources/>
<connections/>

View File

@ -14,17 +14,17 @@
<string>Sequence Export</string>
</property>
<property name="windowIcon">
<iconset resource="resources.qrc">
<iconset>
<normaloff>:res/zint-qt.ico</normaloff>:res/zint-qt.ico</iconset>
</property>
<property name="modal">
<bool>true</bool>
</property>
<layout class="QVBoxLayout" name="verticalLayout_6">
<layout class="QVBoxLayout" name="vertLayoutSeq">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_9">
<layout class="QHBoxLayout" name="horzLayoutSeq">
<item>
<widget class="QGroupBox" name="groupBox">
<widget class="QGroupBox" name="groupBoxSeqCreate">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
@ -34,155 +34,158 @@
<property name="title">
<string>Create Sequence</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_5">
<layout class="QVBoxLayout" name="vertLayoutSeqCreate">
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<layout class="QHBoxLayout" name="horzLayoutSeqCreate">
<item>
<layout class="QVBoxLayout" name="verticalLayout">
<layout class="QVBoxLayout" name="vertLayoutSeqCreateLbls">
<item>
<widget class="QLabel" name="label">
<widget class="QLabel" name="lblSeqStartVal">
<property name="toolTip">
<string>Start sequence at this value</string>
</property>
<property name="text">
<string>&amp;Start Value:</string>
</property>
<property name="buddy">
<cstring>linStartVal</cstring>
</property>
<property name="toolTip">
<string>Start sequence at this value</string>
<cstring>spnSeqStartVal</cstring>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_2">
<widget class="QLabel" name="lblSeqEndVal">
<property name="toolTip">
<string>End sequence at this value</string>
</property>
<property name="text">
<string>End &amp;Value:</string>
</property>
<property name="buddy">
<cstring>linEndVal</cstring>
</property>
<property name="toolTip">
<string>End sequence at this value</string>
<cstring>spnSeqEndVal</cstring>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="lblIncrement">
<widget class="QLabel" name="lblSeqIncVal">
<property name="toolTip">
<string>Go from start to end in steps of this amount</string>
</property>
<property name="text">
<string>Increment &amp;By:</string>
</property>
<property name="buddy">
<cstring>linIncVal</cstring>
</property>
<property name="toolTip">
<string>Go from start to end in steps of this amount</string>
<cstring>spnSeqIncVal</cstring>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_4">
<widget class="QLabel" name="lblSeqFormat">
<property name="toolTip">
<string>Format sequence using special characters&lt;table cellspacing=&quot;3&quot;&gt;
&lt;tr&gt;&lt;td&gt;#&lt;/td&gt;&lt;td&gt;Number or space&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;$&lt;/td&gt;&lt;td&gt;Number or '0'&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;*&lt;/td&gt;&lt;td&gt;Number or '*'&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Other&lt;/td&gt;&lt;td&gt;Insert literally&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</string>
</property>
<property name="text">
<string>&amp;Format:</string>
</property>
<property name="buddy">
<cstring>linFormat</cstring>
</property>
<property name="toolTip">
<string>Format sequence using special characters&lt;table cellspacing=&quot;3&quot;&gt;
&lt;tr&gt;&lt;td&gt;#&lt;/td&gt;&lt;td&gt;Number or space&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;$&lt;/td&gt;&lt;td&gt;Number or &apos;0&apos;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;*&lt;/td&gt;&lt;td&gt;Number or &apos;*&apos;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Other&lt;/td&gt;&lt;td&gt;Insert literally&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</string>
<cstring>linSeqFormat</cstring>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_5">
<property name="text">
<string>Sequence:</string>
</property>
<widget class="QLabel" name="lblSeqCreate">
<property name="toolTip">
<string>Create a data sequence</string>
</property>
<property name="text">
<string>Sequence:</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_6">
<property name="text">
<string>Sequence File:</string>
</property>
<widget class="QLabel" name="lblSeqImport">
<property name="toolTip">
<string>Get a data sequence from a file</string>
</property>
<property name="text">
<string>Sequence File:</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="lblExport">
<property name="text">
<string>Generate Bar Codes:</string>
</property>
<widget class="QLabel" name="lblSeqExport">
<property name="enabled">
<bool>false</bool>
</property>
<property name="toolTip">
<string>Save the symbols to files</string>
</property>
<property name="text">
<string>Generate Bar Codes:</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_2">
<layout class="QVBoxLayout" name="vertLayoutSeqCreateVals">
<item>
<widget class="QLineEdit" name="linStartVal">
<property name="text">
<string>1</string>
<widget class="QSpinBox" name="spnSeqStartVal">
<property name="toolTip">
<string>Start sequence at this value</string>
</property>
<property name="frame">
<bool>true</bool>
</property>
<property name="toolTip">
<string>Start sequence at this value</string>
<property name="maximum">
<number>999999999</number>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="linEndVal">
<property name="text">
<string>10</string>
</property>
<widget class="QSpinBox" name="spnSeqEndVal">
<property name="toolTip">
<string>End sequence at this value</string>
</property>
<property name="maximum">
<number>999999999</number>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="linIncVal">
<property name="text">
<string>1</string>
</property>
<widget class="QSpinBox" name="spnSeqIncVal">
<property name="toolTip">
<string>Go from start to end in steps of this amount</string>
</property>
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>999999999</number>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="linFormat">
<property name="text">
<string>$$$$$$</string>
</property>
<widget class="QLineEdit" name="linSeqFormat">
<property name="toolTip">
<string>Format sequence using special characters&lt;table cellspacing=&quot;3&quot;&gt;
&lt;tr&gt;&lt;td&gt;#&lt;/td&gt;&lt;td&gt;Number or space&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;$&lt;/td&gt;&lt;td&gt;Number or &apos;0&apos;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;*&lt;/td&gt;&lt;td&gt;Number or &apos;*&apos;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;$&lt;/td&gt;&lt;td&gt;Number or '0'&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;*&lt;/td&gt;&lt;td&gt;Number or '*'&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Other&lt;/td&gt;&lt;td&gt;Insert literally&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</string>
</property>
<property name="text">
<string>$$$$$$</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="btnCreate">
<widget class="QPushButton" name="btnSeqCreate">
<property name="toolTip">
<string>Create a data sequence</string>
</property>
@ -192,7 +195,7 @@
</widget>
</item>
<item>
<widget class="QPushButton" name="btnImport">
<widget class="QPushButton" name="btnSeqImport">
<property name="toolTip">
<string>Get a data sequence from a file</string>
</property>
@ -202,7 +205,7 @@
</widget>
</item>
<item>
<widget class="QPushButton" name="btnExport">
<widget class="QPushButton" name="btnSeqExport">
<property name="enabled">
<bool>false</bool>
</property>
@ -222,33 +225,29 @@
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_2">
<widget class="QGroupBox" name="groupBoxSeqPreview">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="title">
<string>Sequence &amp;Data</string>
</property>
<property name="toolTip">
<string>The data to be encoded, one line per symbol</string>
</property>
<property name="title">
<string>Sequence &amp;Data</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
<layout class="QVBoxLayout" name="verticalLayout_4">
<layout class="QVBoxLayout" name="vertLayoutSeqPreview">
<item>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="QPlainTextEdit" name="txtPreview">
<property name="toolTip">
<string>The data to be encoded, one line per symbol</string>
</property>
</widget>
</item>
</layout>
<widget class="QPlainTextEdit" name="txtSeqPreview">
<property name="toolTip">
<string>The data to be encoded, one line per symbol</string>
</property>
</widget>
</item>
</layout>
</widget>
@ -256,9 +255,9 @@
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_10">
<layout class="QHBoxLayout" name="horzLayoutSeqBtns">
<item>
<spacer name="horizontalSpacer_2">
<spacer name="horzSpacerSeqBtns">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
@ -271,23 +270,23 @@
</spacer>
</item>
<item>
<widget class="QPushButton" name="btnReset">
<property name="text">
<string>&amp;Reset</string>
</property>
<widget class="QPushButton" name="btnSeqClear">
<property name="toolTip">
<string>Clear the sequence data</string>
</property>
<property name="text">
<string> C&amp;lear</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="btnClose">
<property name="text">
<string>&amp;Close</string>
</property>
<widget class="QPushButton" name="btnSeqClose">
<property name="toolTip">
<string>Close window</string>
</property>
<property name="text">
<string>&amp;Close</string>
</property>
</widget>
</item>
</layout>

View File

@ -15,12 +15,14 @@ QT += uitools
# Input
HEADERS += barcodeitem.h \
cliwindow.h \
datawindow.h \
exportwindow.h \
mainwindow.h \
sequencewindow.h
FORMS += extData.ui \
FORMS += extCLI.ui \
extData.ui \
extExport.ui \
extSequence.ui \
grpAztec.ui \
@ -55,12 +57,13 @@ FORMS += extData.ui \
mainWindow.ui
SOURCES += barcodeitem.cpp \
cliwindow.cpp \
datawindow.cpp \
exportwindow.cpp \
main.cpp \
mainwindow.cpp \
sequencewindow.cpp
TRANSLATIONS = frontend_de.ts
RESOURCES += resources.qrc

View File

@ -5,12 +5,14 @@ QT += widgets
# Input
HEADERS += barcodeitem.h \
cliwindow.h \
datawindow.h \
exportwindow.h \
mainwindow.h \
sequencewindow.h
FORMS += extData.ui \
FORMS += extCLI.ui \
extData.ui \
extExport.ui \
extSequence.ui \
grpAztec.ui \
@ -45,6 +47,7 @@ FORMS += extData.ui \
mainWindow.ui
SOURCES += barcodeitem.cpp \
cliwindow.cpp \
datawindow.cpp \
exportwindow.cpp \
main.cpp \

View File

@ -6,20 +6,23 @@ CONFIG += warn_on \
uitools
FORMS = mainWindow.ui \
extSequence.ui \
extCLI.ui \
extSequence.ui \
extExport.ui \
extData.ui
HEADERS = mainwindow.h \
barcodeitem.h \
cliwindow.h \
datawindow.h \
exportwindow.h \
sequencewindow.h \
qzint.h
SOURCES = main.cpp \
SOURCES = main.cpp \
mainwindow.cpp \
barcodeitem.cpp \
cliwindow.cpp \
datawindow.cpp \
exportwindow.cpp \
sequencewindow.cpp
@ -30,5 +33,5 @@ RESOURCES = resources.qrc
INCLUDEPATH += ../backend
RC_FILE = ./res/qtZint.rc
LIBS = QtZint2.lib

View File

@ -34,14 +34,14 @@
#include <QAction>
#include "mainwindow.h"
#include "cliwindow.h"
#include "datawindow.h"
#include "sequencewindow.h"
#include <stdio.h>
// Shorthand
#define QSL QStringLiteral
static const int statusBarTimeout = 0; // Don't timeout
static const int tempMessageTimeout = 2000;
static const QKeySequence quitKeySeq(Qt::CTRL | Qt::Key_Q); // Use on Windows also (i.e. not using QKeySequence::Quit)
@ -430,11 +430,11 @@ bool MainWindow::save()
QString dirname = pathname.mid(0, lastSeparator);
if (dirname.isEmpty()) {
/*: %1 is path saved to */
statusBar->showMessage(tr("Saved as \"%1\"").arg(pathname), statusBarTimeout);
statusBar->showMessage(tr("Saved as \"%1\"").arg(pathname), 0 /*No timeout*/);
} else {
QString filename = pathname.right(pathname.length() - (lastSeparator + 1));
/*: %1 is base filename saved to, %2 is directory saved in */
statusBar->showMessage(tr("Saved as \"%1\" in \"%2\"").arg(filename).arg(dirname), statusBarTimeout);
statusBar->showMessage(tr("Saved as \"%1\" in \"%2\"").arg(filename).arg(dirname), 0 /*No timeout*/);
}
settings.setValue(QSL("studio/default_dir"), dirname);
@ -476,21 +476,35 @@ void MainWindow::help()
QDesktopServices::openUrl(QSL("https://zint.org.uk/manual")); // TODO: manual.md
}
int MainWindow::open_data_dialog()
void MainWindow::open_data_dialog()
{
int retval;
DataWindow dlg(txtData->text());
retval = dlg.exec();
if (dlg.Valid == 1)
(void) dlg.exec();
if (dlg.Valid) {
const bool updated = txtData->text() != dlg.DataOutput;
txtData->setText(dlg.DataOutput);
return retval;
if (updated) {
statusBar->showMessage(tr("Updated data"), tempMessageTimeout);
}
}
}
int MainWindow::open_sequence_dialog()
void MainWindow::open_sequence_dialog()
{
SequenceWindow dlg;
dlg.barcode = &m_bc;
return dlg.exec();
SequenceWindow dlg(&m_bc);
(void) dlg.exec();
#ifdef _WIN32
// Windows causes BarcodeItem to paint on closing dialog so need to re-paint with our (non-Export) values
update_preview();
#endif
}
void MainWindow::open_cli_dialog()
{
CLIWindow dlg(&m_bc, chkAutoHeight->isEnabled() && chkAutoHeight->isChecked(),
m_spnHeightPerRow && m_spnHeightPerRow->isEnabled() ? m_spnHeightPerRow->value() : 0.0);
(void) dlg.exec();
}
void MainWindow::on_fgcolor_clicked()
@ -527,7 +541,7 @@ void MainWindow::autoheight_ui_set()
if (enabled && m_spnHeightPerRow->value()) {
lblHeight->setEnabled(!enabled);
heightb->setEnabled(!enabled);
statusBar->showMessage(tr("Using \"Row Height\""), statusBarTimeout);
statusBar->showMessage(tr("Using \"Row Height\""), 0 /*No timeout*/);
} else {
statusBar->clearMessage();
}
@ -650,6 +664,9 @@ void MainWindow::structapp_ui_set()
void MainWindow::on_encoded()
{
if (QApplication::activeModalWidget() != nullptr) { // Protect against encode in popup dialog
return;
}
this->setMinimumHeight(m_bc.bc.getError() ? 455 : 435);
enableActions(true);
errtxtBar_set(false /*isError*/);
@ -663,6 +680,9 @@ void MainWindow::on_encoded()
void MainWindow::on_errored()
{
if (QApplication::activeModalWidget() != nullptr) { // Protect against error in popup dialog (Sequence Export)
return;
}
this->setMinimumHeight(455);
enableActions(false);
errtxtBar_set(true /*isError*/);
@ -795,7 +815,7 @@ void MainWindow::copy_to_clipboard_errtxt()
QMimeData *mdata = new QMimeData;
mdata->setText(m_bc.bc.lastError());
clipboard->setMimeData(mdata, QClipboard::Clipboard);
statusBar->showMessage(tr("Copied message to clipboard"), statusBarTimeout);
statusBar->showMessage(tr("Copied message to clipboard"), 0 /*No timeout*/);
}
}
@ -879,6 +899,8 @@ void MainWindow::view_context_menu(const QPoint &pos)
menu.addAction(m_copySVGAct);
menu.addAction(m_copyTIFAct);
menu.addSeparator();
menu.addAction(m_CLIAct);
menu.addSeparator();
menu.addAction(m_saveAsAct);
menu.exec(get_context_menu_pos(pos, view));
@ -1698,6 +1720,7 @@ void MainWindow::update_preview()
m_bc.bc.setGSSep(false);
m_bc.bc.setNoQuietZones(false);
m_bc.bc.setDotSize(0.4f / 0.5f);
m_bc.bc.setGuardDescent(5.0f);
m_bc.bc.clearStructApp();
switch (symbology) {
@ -2253,6 +2276,7 @@ void MainWindow::createActions()
// MIT license - see site and "frontend_qt/res/LICENSE_feathericons"
QIcon menuIcon(QSL(":res/menu.svg"));
QIcon copyIcon(QIcon::fromTheme(QSL("edit-copy"), QIcon(QSL(":res/copy.svg"))));
QIcon cliIcon(QSL(":res/zint_black.ico"));
QIcon saveIcon(QIcon::fromTheme(QSL("document-save"), QIcon(QSL(":res/download.svg"))));
QIcon aboutIcon(QSL(":res/zint-qt.ico"));
QIcon helpIcon(QIcon::fromTheme(QSL("help-contents"), QIcon(QSL(":res/help-circle.svg"))));
@ -2302,6 +2326,10 @@ void MainWindow::createActions()
m_copyTIFAct->setStatusTip(tr("Copy to clipboard as TIF"));
connect(m_copyTIFAct, SIGNAL(triggered()), this, SLOT(copy_to_clipboard_tif()));
m_CLIAct = new QAction(cliIcon, tr("C&LI equivalent..."), this);
m_CLIAct->setStatusTip(tr("Generate CLI equivalent"));
connect(m_CLIAct, SIGNAL(triggered()), this, SLOT(open_cli_dialog()));
m_saveAsAct = new QAction(saveIcon, tr("&Save As..."), this);
m_saveAsAct->setStatusTip(tr("Output image to file"));
m_saveAsAct->setShortcut(QKeySequence::Save);
@ -2346,6 +2374,8 @@ void MainWindow::createMenu()
m_menu->addAction(m_copyTIFAct);
m_menu->addSeparator();
m_menu->addAction(m_CLIAct);
m_menu->addSeparator();
m_menu->addAction(m_saveAsAct);
m_menu->addSeparator();
m_menu->addAction(m_helpAct);
@ -2374,6 +2404,7 @@ void MainWindow::enableActions(bool enabled)
#endif
m_copySVGAct->setEnabled(enabled);
m_copyTIFAct->setEnabled(enabled);
m_CLIAct->setEnabled(enabled);
m_saveAsAct->setEnabled(enabled);
m_saveAsShortcut->setEnabled(enabled);
@ -2397,13 +2428,13 @@ void MainWindow::copy_to_clipboard(const QString &filename, const QString& name,
file.close();
clipboard->setMimeData(mdata, QClipboard::Clipboard);
/*: %1 is format (BMP/EMF etc) */
statusBar->showMessage(tr("Copied to clipboard as %1").arg(name), statusBarTimeout);
statusBar->showMessage(tr("Copied to clipboard as %1").arg(name), 0 /*No timeout*/);
}
} else {
mdata->setImageData(QImage(filename));
clipboard->setMimeData(mdata, QClipboard::Clipboard);
/*: %1 is format (BMP/EMF etc) */
statusBar->showMessage(tr("Copied to clipboard as %1").arg(name), statusBarTimeout);
statusBar->showMessage(tr("Copied to clipboard as %1").arg(name), 0 /*No timeout*/);
}
QFile::remove(filename);
@ -2456,172 +2487,59 @@ QWidget *MainWindow::get_widget(const QString &name)
}
/* Return settings subsection name for a symbol */
const QString &MainWindow::get_setting_name(int symbology)
QString MainWindow::get_setting_name(int symbology)
{
struct item {
const QString name;
int define;
int val;
};
static const struct item ndata[] = {
{ QSL(""), -1, 0 },
{ QSL("code11"), BARCODE_CODE11, 1 },
{ QSL("c25standard"), BARCODE_C25STANDARD, 2 },
{ QSL("c25inter"), BARCODE_C25INTER, 3 },
{ QSL("c25iata"), BARCODE_C25IATA, 4 },
{ QSL(""), -1, 5 },
{ QSL("c25logic"), BARCODE_C25LOGIC, 6 },
{ QSL("c25ind"), BARCODE_C25IND, 7 },
{ QSL("code39"), BARCODE_CODE39, 8 },
{ QSL("excode39"), BARCODE_EXCODE39, 9 },
{ QSL(""), -1, 10 },
{ QSL(""), -1, 11 },
{ QSL(""), -1, 12 },
{ QSL("eanx"), BARCODE_EANX, 13 },
{ QSL("eanx"), BARCODE_EANX_CHK, 14 },
{ QSL(""), -1, 15 },
{ QSL("code128"), BARCODE_GS1_128, 16 },
{ QSL(""), -1, 17 },
{ QSL("codabar"), BARCODE_CODABAR, 18 },
{ QSL(""), -1, 19 },
{ QSL("code128"), BARCODE_CODE128, 20 },
{ QSL("dpleit"), BARCODE_DPLEIT, 21 },
{ QSL("dpident"), BARCODE_DPIDENT, 22 },
{ QSL("code16k"), BARCODE_CODE16K, 23 },
{ QSL("code49"), BARCODE_CODE49, 24 },
{ QSL("code93"), BARCODE_CODE93, 25 },
{ QSL(""), -1, 26 },
{ QSL(""), -1, 27 },
{ QSL("flat"), BARCODE_FLAT, 28 },
{ QSL("dbar_omn"), BARCODE_DBAR_OMN, 29 },
{ QSL("dbar_ltd"), BARCODE_DBAR_LTD, 30 },
{ QSL("dbar_exp"), BARCODE_DBAR_EXP, 31 },
{ QSL("telepen"), BARCODE_TELEPEN, 32 },
{ QSL(""), -1, 33 },
{ QSL("upca"), BARCODE_UPCA, 34 },
{ QSL("upca"), BARCODE_UPCA_CHK, 35 },
{ QSL(""), -1, 36 },
{ QSL("upce"), BARCODE_UPCE, 37 },
{ QSL("upce"), BARCODE_UPCE_CHK, 38 },
{ QSL(""), -1, 39 },
{ QSL("postnet"), BARCODE_POSTNET, 40 },
{ QSL(""), -1, 41 },
{ QSL(""), -1, 42 },
{ QSL(""), -1, 43 },
{ QSL(""), -1, 44 },
{ QSL(""), -1, 45 },
{ QSL(""), -1, 46 },
{ QSL("msi_plessey"), BARCODE_MSI_PLESSEY, 47 },
{ QSL(""), -1, 48 },
{ QSL("fim"), BARCODE_FIM, 49 },
{ QSL("logmars"), BARCODE_LOGMARS, 50 },
{ QSL("pharma"), BARCODE_PHARMA, 51 },
{ QSL("pzn"), BARCODE_PZN, 52 },
{ QSL("pharma_two"), BARCODE_PHARMA_TWO, 53 },
{ QSL(""), -1, 54 },
{ QSL("pdf417"), BARCODE_PDF417, 55 },
{ QSL("pdf417"), BARCODE_PDF417COMP, 56 },
{ QSL("maxicode"), BARCODE_MAXICODE, 57 },
{ QSL("qrcode"), BARCODE_QRCODE, 58 },
{ QSL(""), -1, 59 },
{ QSL("code128"), BARCODE_CODE128B, 60 },
{ QSL(""), -1, 61 },
{ QSL(""), -1, 62 },
{ QSL("auspost"), BARCODE_AUSPOST, 63 },
{ QSL(""), -1, 64 },
{ QSL(""), -1, 65 },
{ QSL("ausreply"), BARCODE_AUSREPLY, 66 },
{ QSL("ausroute"), BARCODE_AUSROUTE, 67 },
{ QSL("ausredirect"), BARCODE_AUSREDIRECT, 68 },
{ QSL("isbnx"), BARCODE_ISBNX, 69 },
{ QSL("rm4scc"), BARCODE_RM4SCC, 70 },
{ QSL("datamatrix"), BARCODE_DATAMATRIX, 71 },
{ QSL("ean14"), BARCODE_EAN14, 72 },
{ QSL("vin"), BARCODE_VIN, 73 },
{ QSL("codablockf"), BARCODE_CODABLOCKF, 74 },
{ QSL("nve18"), BARCODE_NVE18, 75 },
{ QSL("japanpost"), BARCODE_JAPANPOST, 76 },
{ QSL("koreapost"), BARCODE_KOREAPOST, 77 },
{ QSL(""), -1, 78 },
{ QSL("dbar_stk"), BARCODE_DBAR_STK, 79 },
{ QSL("dbar_omnstk"), BARCODE_DBAR_OMNSTK, 80 },
{ QSL("dbar_expstk"), BARCODE_DBAR_EXPSTK, 81 },
{ QSL("planet"), BARCODE_PLANET, 82 },
{ QSL(""), -1, 83 },
{ QSL("micropdf417"), BARCODE_MICROPDF417, 84 },
{ QSL("usps_imail"), BARCODE_USPS_IMAIL, 85 },
{ QSL("plessey"), BARCODE_PLESSEY, 86 },
{ QSL("telepen_num"), BARCODE_TELEPEN_NUM, 87 },
{ QSL(""), -1, 88 },
{ QSL("itf14"), BARCODE_ITF14, 89 },
{ QSL("kix"), BARCODE_KIX, 90 },
{ QSL(""), -1, 91 },
{ QSL("aztec"), BARCODE_AZTEC, 92 },
{ QSL("daft"), BARCODE_DAFT, 93 },
{ QSL(""), -1, 94 },
{ QSL(""), -1, 95 },
{ QSL("dpd"), BARCODE_DPD, 96 },
{ QSL("microqr"), BARCODE_MICROQR, 97 },
{ QSL("code128"), BARCODE_HIBC_128, 98 },
{ QSL("code39"), BARCODE_HIBC_39, 99 },
{ QSL(""), -1, 100 },
{ QSL(""), -1, 101 },
{ QSL("datamatrix"), BARCODE_HIBC_DM, 102 },
{ QSL(""), -1, 103 },
{ QSL("qrcode"), BARCODE_HIBC_QR, 104 },
{ QSL(""), -1, 105 },
{ QSL("pdf417"), BARCODE_HIBC_PDF, 106 },
{ QSL(""), -1, 107 },
{ QSL("micropdf417"), BARCODE_HIBC_MICPDF, 108 },
{ QSL(""), -1, 109 },
{ QSL("codablockf"), BARCODE_HIBC_BLOCKF, 110 },
{ QSL(""), -1, 111 },
{ QSL("aztec"), BARCODE_HIBC_AZTEC, 112 },
{ QSL(""), -1, 113 },
{ QSL(""), -1, 114 },
{ QSL("dotcode"), BARCODE_DOTCODE, 115 },
{ QSL("hanxin"), BARCODE_HANXIN, 116 },
{ QSL(""), -1, 117 },
{ QSL(""), -1, 118 },
{ QSL(""), -1, 119 },
{ QSL(""), -1, 120 },
{ QSL("mailmark"), BARCODE_MAILMARK, 121 },
{ QSL(""), -1, 122 },
{ QSL(""), -1, 123 },
{ QSL(""), -1, 124 },
{ QSL(""), -1, 125 },
{ QSL(""), -1, 126 },
{ QSL(""), -1, 127 },
{ QSL("azrune"), BARCODE_AZRUNE, 128 },
{ QSL("code32"), BARCODE_CODE32, 129 },
{ QSL("eanx"), BARCODE_EANX_CC, 130 },
{ QSL("code128"), BARCODE_GS1_128_CC, 131 },
{ QSL("dbar_omn"), BARCODE_DBAR_OMN_CC, 132 },
{ QSL("dbar_ltd"), BARCODE_DBAR_LTD_CC, 133 },
{ QSL("dbar_exp"), BARCODE_DBAR_EXP_CC, 134 },
{ QSL("upca"), BARCODE_UPCA_CC, 135 },
{ QSL("upce"), BARCODE_UPCE_CC, 136 },
{ QSL("dbar_stk"), BARCODE_DBAR_STK_CC, 137 },
{ QSL("dbar_omnstk"), BARCODE_DBAR_OMNSTK_CC, 138 },
{ QSL("dbar_expstk"), BARCODE_DBAR_EXPSTK_CC, 139 },
{ QSL("channel"), BARCODE_CHANNEL, 140 },
{ QSL("codeone"), BARCODE_CODEONE, 141 },
{ QSL("gridmatrix"), BARCODE_GRIDMATRIX, 142 },
{ QSL("upnqr"), BARCODE_UPNQR, 143 },
{ QSL("ultra"), BARCODE_ULTRA, 144 },
{ QSL("rmqr"), BARCODE_RMQR, 145 },
};
static const int data_size = sizeof(ndata) / sizeof(struct item);
if (symbology < 0 || symbology >= data_size) {
return ndata[0].name; // ""
char name_buf[32];
switch (symbology) {
case BARCODE_CODE128B:
case BARCODE_GS1_128:
case BARCODE_GS1_128_CC:
case BARCODE_HIBC_128:
symbology = BARCODE_CODE128;
break;
case BARCODE_PDF417COMP:
case BARCODE_HIBC_PDF:
symbology = BARCODE_PDF417;
break;
case BARCODE_HIBC_MICPDF:
symbology = BARCODE_MICROPDF417;
break;
case BARCODE_HIBC_AZTEC:
symbology = BARCODE_AZTEC;
break;
case BARCODE_HIBC_39:
symbology = BARCODE_CODE39;
break;
case BARCODE_HIBC_BLOCKF:
symbology = BARCODE_CODABLOCKF;
break;
case BARCODE_HIBC_DM:
symbology = BARCODE_DATAMATRIX;
break;
case BARCODE_HIBC_QR:
symbology = BARCODE_QRCODE;
break;
case BARCODE_DBAR_EXPSTK_CC:
symbology = BARCODE_DBAR_EXPSTK;
break;
case BARCODE_UPCA_CHK:
case BARCODE_UPCA_CC:
symbology = BARCODE_UPCA;
break;
case BARCODE_EANX_CHK:
case BARCODE_EANX_CC:
symbology = BARCODE_EANX;
break;
case BARCODE_UPCE_CHK:
case BARCODE_UPCE_CC:
symbology = BARCODE_UPCE;
break;
}
if (ndata[symbology].val != symbology ||
(ndata[symbology].define != -1 && ndata[symbology].define != symbology)) { // Self-check
fprintf(stderr, "MainWindow::get_setting_name: ndata table out of sync (%d)\n", symbology);
return ndata[0].name; // ""
if (ZBarcode_BarcodeName(symbology, name_buf) != 0) {
return QSL("");
}
return ndata[symbology].name;
QString name(name_buf + 8); // Strip "BARCODE_" prefix
return name.toLower();
}
/* Helper to return index of selected radio button in group, checking for NULL */
@ -2752,7 +2670,7 @@ void MainWindow::set_spn_from_setting(QSettings &settings, const QString &settin
/* Save settings for an individual symbol */
void MainWindow::save_sub_settings(QSettings &settings, int symbology)
{
const QString &name = get_setting_name(symbology);
QString name = get_setting_name(symbology);
if (!name.isEmpty()) {
settings.setValue(QSL("studio/bc/%1/data").arg(name), txtData->text());
if (!grpComposite->isHidden()) {
@ -3020,6 +2938,10 @@ void MainWindow::save_sub_settings(QSettings &settings, int symbology)
settings.setValue(QSL("studio/bc/maxicode/structapp_index"), get_cmb_index(QSL("cmbMaxiStructAppIndex")));
break;
case BARCODE_CHANNEL:
settings.setValue(QSL("studio/bc/channel/channel"), get_cmb_index(QSL("cmbChannel")));
break;
case BARCODE_CODEONE:
settings.setValue(QSL("studio/bc/codeone/size"), get_cmb_index(QSL("cmbC1Size")));
settings.setValue(QSL("studio/bc/codeone/encoding_mode"), get_rad_grp_index(
@ -3105,7 +3027,7 @@ void MainWindow::save_sub_settings(QSettings &settings, int symbology)
/* Load settings for an individual symbol */
void MainWindow::load_sub_settings(QSettings &settings, int symbology)
{
const QString &name = get_setting_name(symbology);
QString name = get_setting_name(symbology);
if (!name.isEmpty()) {
const QString &tdata = settings.value(QSL("studio/bc/%1/data").arg(name), QSL("")).toString();
if (!tdata.isEmpty()) {
@ -3391,6 +3313,10 @@ void MainWindow::load_sub_settings(QSettings &settings, int symbology)
set_cmb_from_setting(settings, QSL("studio/bc/maxicode/structapp_index"), QSL("cmbMaxiStructAppIndex"));
break;
case BARCODE_CHANNEL:
set_cmb_from_setting(settings, QSL("studio/bc/channel/channel"), QSL("cmbChannel"));
break;
case BARCODE_CODEONE:
set_cmb_from_setting(settings, QSL("studio/bc/codeone/size"), QSL("cmbC1Size"));
set_rad_from_setting(settings, QSL("studio/bc/codeone/encoding_mode"),

View File

@ -69,8 +69,9 @@ public slots:
void menu();
void reset_colours();
int open_data_dialog();
int open_sequence_dialog();
void open_data_dialog();
void open_sequence_dialog();
void open_cli_dialog();
void copy_to_clipboard_bmp();
void copy_to_clipboard_emf();
@ -118,7 +119,7 @@ protected:
QWidget *get_widget(const QString &name);
const QString &get_setting_name(int symbology);
static QString get_setting_name(int symbology);
int get_rad_grp_index(const QStringList &names);
void set_rad_from_setting(QSettings &settings, const QString &setting, const QStringList &names,
@ -161,6 +162,7 @@ private:
QAction *m_copyPNGAct;
QAction *m_copySVGAct;
QAction *m_copyTIFAct;
QAction *m_CLIAct;
QAction *m_saveAsAct;
QAction *m_aboutAct;
QAction *m_helpAct;

View File

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-check"><polyline points="20 6 9 17 4 12"></polyline></svg>

After

Width:  |  Height:  |  Size: 262 B

View File

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-delete"><path d="M21 4H8l-7 8 7 8h13a2 2 0 0 0 2-2V6a2 2 0 0 0-2-2z"></path><line x1="18" y1="9" x2="12" y2="15"></line><line x1="12" y1="9" x2="18" y2="15"></line></svg>

After

Width:  |  Height:  |  Size: 374 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

View File

@ -32,7 +32,10 @@
<file>grpUPCEAN.ui</file>
<file>grpVIN.ui</file>
<file>res/zint-qt.ico</file>
<file>res/zint_black.ico</file>
<file>res/check.svg</file>
<file>res/copy.svg</file>
<file>res/delete.svg</file>
<file>res/download.svg</file>
<file>res/help-circle.svg</file>
<file>res/menu.svg</file>

View File

@ -28,29 +28,36 @@
#include "sequencewindow.h"
#include "exportwindow.h"
SequenceWindow::SequenceWindow()
// Shorthand
#define QSL QStringLiteral
SequenceWindow::SequenceWindow(BarcodeItem *bc) : m_bc(bc)
{
setupUi(this);
QSettings settings;
#if QT_VERSION < 0x60000
settings.setIniCodec("UTF-8");
#endif
QValidator *intvalid = new QIntValidator(this);
linStartVal->setText(settings.value("studio/sequence/start_value", "1").toString());
linEndVal->setText(settings.value("studio/sequence/end_value", "10").toString());
linIncVal->setText(settings.value("studio/sequence/increment", "1").toString());
linFormat->setText(settings.value("studio/sequence/format", "$$$$$$").toString());
QByteArray geometry = settings.value(QSL("studio/sequence/window_geometry")).toByteArray();
restoreGeometry(geometry);
linStartVal->setValidator(intvalid);
linEndVal->setValidator(intvalid);
linIncVal->setValidator(intvalid);
connect(btnClose, SIGNAL( clicked( bool )), SLOT(quit_now()));
connect(btnReset, SIGNAL( clicked( bool )), SLOT(reset_preview()));
connect(btnCreate, SIGNAL( clicked( bool )), SLOT(create_sequence()));
connect(txtPreview, SIGNAL( textChanged()), SLOT(check_generate()));
connect(btnImport, SIGNAL( clicked( bool )), SLOT(import()));
connect(btnExport, SIGNAL( clicked( bool )), SLOT(generate_sequence()));
spnSeqStartVal->setValue(settings.value(QSL("studio/sequence/start_value"), 1).toInt());
spnSeqEndVal->setValue(settings.value(QSL("studio/sequence/end_value"), 10).toInt());
spnSeqIncVal->setValue(settings.value(QSL("studio/sequence/increment"), 1).toInt());
linSeqFormat->setText(settings.value(QSL("studio/sequence/format"), QSL("$$$$$$")).toString());
QIcon closeIcon(QIcon::fromTheme(QSL("window-close"), QIcon(QSL(":res/x.svg"))));
QIcon clearIcon(QIcon::fromTheme(QSL("edit-clear"), QIcon(QSL(":res/delete.svg"))));
btnSeqClose->setIcon(closeIcon);
btnSeqClear->setIcon(clearIcon);
connect(btnSeqClose, SIGNAL( clicked( bool )), SLOT(close()));
connect(btnSeqClear, SIGNAL( clicked( bool )), SLOT(clear_preview()));
connect(btnSeqCreate, SIGNAL( clicked( bool )), SLOT(create_sequence()));
connect(txtSeqPreview, SIGNAL( textChanged()), SLOT(check_generate()));
connect(btnSeqImport, SIGNAL( clicked( bool )), SLOT(import()));
connect(btnSeqExport, SIGNAL( clicked( bool )), SLOT(generate_sequence()));
}
SequenceWindow::~SequenceWindow()
@ -59,40 +66,36 @@ SequenceWindow::~SequenceWindow()
#if QT_VERSION < 0x60000
settings.setIniCodec("UTF-8");
#endif
settings.setValue(QSL("studio/sequence/window_geometry"), saveGeometry());
settings.setValue("studio/sequence/start_value", linStartVal->text());
settings.setValue("studio/sequence/end_value", linEndVal->text());
settings.setValue("studio/sequence/increment", linIncVal->text());
settings.setValue("studio/sequence/format", linFormat->text());
settings.setValue(QSL("studio/sequence/start_value"), spnSeqStartVal->value());
settings.setValue(QSL("studio/sequence/end_value"), spnSeqEndVal->value());
settings.setValue(QSL("studio/sequence/increment"), spnSeqIncVal->value());
settings.setValue(QSL("studio/sequence/format"), linSeqFormat->text());
}
void SequenceWindow::quit_now()
void SequenceWindow::clear_preview()
{
close();
txtSeqPreview->clear();
}
void SequenceWindow::reset_preview()
{
txtPreview->clear();
}
QString SequenceWindow::apply_format(QString raw_number)
QString SequenceWindow::apply_format(const QString& raw_number)
{
QString adjusted, reversed;
QString format;
int format_len, input_len, i, inpos;
QChar format_qchar;
format = linFormat->text();
format = linSeqFormat->text();
input_len = raw_number.length();
format_len = format.length();
inpos = input_len;
for(i = format_len; i > 0; i--) {
for (i = format_len; i > 0; i--) {
format_qchar = format[i - 1];
char format_char = format_qchar.toLatin1();
switch(format_char) {
switch (format_char) {
case '#':
if (inpos > 0) {
adjusted += raw_number[inpos - 1];
@ -132,42 +135,41 @@ QString SequenceWindow::apply_format(QString raw_number)
void SequenceWindow::create_sequence()
{
QString startval, endval, incval, part, outputtext;
QStringList outputtext;
int start, stop, step, i;
bool ok;
startval = linStartVal->text();
endval = linEndVal->text();
incval = linIncVal->text();
start = startval.toInt(&ok, 10);
stop = endval.toInt(&ok, 10);
step = incval.toInt(&ok, 10);
start = spnSeqStartVal->value();
stop = spnSeqEndVal->value();
step = spnSeqIncVal->value();
if((stop <= start) || (step <= 0)) {
QMessageBox::critical(this, tr("Sequence Error"), tr("One or more of the input values is incorrect."));
if (stop < start) {
QMessageBox::critical(this, tr("Sequence Error"),
tr("End Value must be greater than or equal to Start Value."));
return;
}
if ((stop - start) / step > 10000) {
QMessageBox::critical(this, tr("Sequence Error"), tr("The maximum sequence allowed is 10,000 items."));
return;
}
for(i = start; i <= stop; i += step) {
part = apply_format(QString::number(i, 10));
part += '\n';
outputtext += part;
for (i = start; i <= stop; i += step) {
outputtext << apply_format(QString::number(i, 10));
}
txtPreview->setPlainText(outputtext);
txtSeqPreview->setPlainText(outputtext.join('\n'));
}
void SequenceWindow::check_generate()
{
QString preview_copy;
preview_copy = txtPreview->toPlainText();
if(preview_copy.isEmpty()) {
btnExport->setEnabled(false);
lblExport->setEnabled(false);
preview_copy = txtSeqPreview->toPlainText();
if (preview_copy.isEmpty()) {
btnSeqExport->setEnabled(false);
lblSeqExport->setEnabled(false);
} else {
btnExport->setEnabled(true);
lblExport->setEnabled(true);
btnSeqExport->setEnabled(true);
lblSeqExport->setEnabled(true);
}
}
@ -182,8 +184,8 @@ void SequenceWindow::import()
QFile file;
QByteArray outstream;
import_dialog.setWindowTitle("Import File");
import_dialog.setDirectory(settings.value("studio/default_dir",
import_dialog.setWindowTitle(tr("Import File"));
import_dialog.setDirectory(settings.value(QSL("studio/default_dir"),
QDir::toNativeSeparators(QDir::homePath())).toString());
if (import_dialog.exec()) {
@ -193,23 +195,21 @@ void SequenceWindow::import()
}
file.setFileName(filename);
if(!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
QMessageBox::critical(this, tr("Open Error"), tr("Could not open selected file."));
return;
}
outstream = file.readAll();
txtPreview->setPlainText(QString(outstream));
txtSeqPreview->setPlainText(QString(outstream));
file.close();
settings.setValue("studio/default_dir", filename.mid(0, filename.lastIndexOf(QDir::separator())));
settings.setValue(QSL("studio/default_dir"), filename.mid(0, filename.lastIndexOf(QDir::separator())));
}
void SequenceWindow::generate_sequence()
{
ExportWindow dlg;
dlg.barcode = barcode;
dlg.output_data = txtPreview->toPlainText();
ExportWindow dlg(m_bc, txtSeqPreview->toPlainText());
dlg.exec();
}

View File

@ -1,6 +1,6 @@
/*
Zint Barcode Generator - the open source barcode generator
Copyright (C) 2009-2017 Robin Stuart <rstuart114@gmail.com>
Copyright (C) 2009-2021 Robin Stuart <rstuart114@gmail.com>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@ -16,6 +16,7 @@
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
/* vim: set ts=4 sw=4 et : */
#ifndef SEQUENCEWINDOW_H
#define SEQUENCEWINDOW_H
@ -25,23 +26,24 @@
class SequenceWindow : public QDialog, private Ui::SequenceDialog
{
Q_OBJECT
Q_OBJECT
public:
SequenceWindow();
~SequenceWindow();
BarcodeItem *barcode;
SequenceWindow(BarcodeItem *bc);
~SequenceWindow();
private:
QString apply_format(QString raw_number);
QString apply_format(const QString &raw_number);
private slots:
void quit_now();
void reset_preview();
void create_sequence();
void check_generate();
void import();
void generate_sequence();
void clear_preview();
void create_sequence();
void check_generate();
void import();
void generate_sequence();
protected:
BarcodeItem *m_bc;
};
#endif