mirror of
https://git.code.sf.net/p/zint/code
synced 2025-06-03 00:19:51 -04:00
- Add special symbology-specific escape sequences (Code 128 only)
for manual Code Set switching via `input_mode` flag `EXTRA_ESCAPE_MODE` (CLI `--extraesc`) (ticket #204) - GUI: disable "Reset" colour if default; add "Unset" to Printing Scale dialog (allows unsetting of X-dim/resolution settings without having to zap) - library: guard against out-of-bounds rows (negative) - test suite: fix some clang-tidy warnings; slight coverage improvements
This commit is contained in:
parent
5669addf01
commit
6f7cdd660c
30 changed files with 649 additions and 285 deletions
|
@ -302,6 +302,20 @@
|
|||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horzLayoutScaleBtns">
|
||||
<item>
|
||||
<widget class="QPushButton" name="btnScaleUnset">
|
||||
<property name="autoDefault">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string> &Unset</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Reset the scale to the original value and
|
||||
mark the settings as unset</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horzSpacerScaleBtns">
|
||||
<property name="orientation">
|
||||
|
|
|
@ -37,15 +37,26 @@
|
|||
<item row="0" column="1">
|
||||
<widget class="QRadioButton" name="radC128CSup">
|
||||
<property name="text">
|
||||
<string>Subset &C Suppression</string>
|
||||
<string>Code Set &C Suppression</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Do not use Subset C mode
|
||||
<string>Do not use Code Set C
|
||||
(numeric compression)</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<item row="1" column="0" colspan="2">
|
||||
<widget class="QRadioButton" name="radC128ExtraEsc">
|
||||
<property name="text">
|
||||
<string>&Manual Code Sets (Extra Escape Mode)</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Process special escape sequences "\^A", "\^B" and
|
||||
"\^C" allowing manual Code Set selection</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QRadioButton" name="radC128EAN">
|
||||
<property name="text">
|
||||
<string>GS&1-128</string>
|
||||
|
@ -56,7 +67,7 @@ formatted with Application Identifiers (AIs)</string>
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<item row="2" column="1">
|
||||
<widget class="QRadioButton" name="radC128HIBC">
|
||||
<property name="text">
|
||||
<string>H&IBC</string>
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/***************************************************************************
|
||||
* Copyright (C) 2008 by BogDan Vatra <bogdan@licentia.eu> *
|
||||
* Copyright (C) 2009-2022 by Robin Stuart <rstuart114@gmail.com> *
|
||||
* Copyright (C) 2009-2023 by 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 *
|
||||
|
@ -59,6 +59,9 @@ static const QKeySequence factoryResetSeq(Qt::SHIFT | Qt::CTRL | Qt::Key_R);
|
|||
|
||||
static const QRegularExpression colorRE(QSL("^[0-9A-Fa-f]{6}([0-9A-Fa-f]{2})?$"));
|
||||
|
||||
static const QColor fgcolorDefault(0, 0, 0, 0xff);
|
||||
static const QColor bgcolorDefault(0xff, 0xff, 0xff, 0xff);
|
||||
|
||||
struct bstyle_item {
|
||||
const QString text;
|
||||
int symbology;
|
||||
|
@ -561,8 +564,8 @@ bool MainWindow::eventFilter(QObject *watched, QEvent *event)
|
|||
|
||||
void MainWindow::reset_colours()
|
||||
{
|
||||
m_fgcolor.setRgb(0, 0, 0, 0xff);
|
||||
m_bgcolor.setRgb(0xff, 0xff, 0xff, 0xff);
|
||||
m_fgcolor = fgcolorDefault;
|
||||
m_bgcolor = bgcolorDefault;
|
||||
setColorTxtBtn(m_fgcolor, txt_fgcolor, fgcolor);
|
||||
setColorTxtBtn(m_bgcolor, txt_bgcolor, bgcolor);
|
||||
update_preview();
|
||||
|
@ -733,7 +736,7 @@ void MainWindow::about()
|
|||
"<p>A free barcode generator</p>"
|
||||
"<p>Instruction manual is available at the project homepage:<br>"
|
||||
"<a href=\"http://www.zint.org.uk\">http://www.zint.org.uk</a>.</p>"
|
||||
"<p>Copyright © 2006-2022 Robin Stuart and others.<br>"
|
||||
"<p>Copyright © 2006-2023 Robin Stuart and others.<br>"
|
||||
"Qt backend by BogDan Vatra.<br>"
|
||||
"Released under GNU GPL 3.0 or later.</p>"
|
||||
"<p>Qt version %2</p>"
|
||||
|
@ -972,7 +975,7 @@ void MainWindow::open_scale_dialog()
|
|||
{
|
||||
double originalScale = spnScale->value();
|
||||
QString originalSizeMsg = lblSizeMsg->text();
|
||||
ScaleWindow dlg(&m_bc, &m_xdimdpVars);
|
||||
ScaleWindow dlg(&m_bc, &m_xdimdpVars, originalScale);
|
||||
m_scaleWindow = &dlg;
|
||||
connect(&dlg, SIGNAL(scaleChanged(double)), this, SLOT(on_scaleChanged(double)));
|
||||
(void) dlg.exec();
|
||||
|
@ -1558,6 +1561,7 @@ void MainWindow::change_options()
|
|||
connect(get_widget(QSL("radC128EAN")), SIGNAL(toggled( bool )), SLOT(composite_ean_check()));
|
||||
connect(get_widget(QSL("radC128EAN")), SIGNAL(toggled( bool )), SLOT(update_preview()));
|
||||
connect(get_widget(QSL("radC128HIBC")), SIGNAL(toggled( bool )), SLOT(update_preview()));
|
||||
connect(get_widget(QSL("radC128ExtraEsc")), SIGNAL(toggled( bool )), SLOT(update_preview()));
|
||||
|
||||
} else if (symbology == BARCODE_PDF417) {
|
||||
QFile file(QSL(":/grpPDF417.ui"));
|
||||
|
@ -2502,6 +2506,7 @@ void MainWindow::update_preview()
|
|||
m_bc.bc.setText(txtData->text());
|
||||
}
|
||||
}
|
||||
btnReset->setEnabled(m_fgcolor != fgcolorDefault || m_bgcolor != bgcolorDefault);
|
||||
m_bc.bc.setOption1(-1);
|
||||
m_bc.bc.setOption2(0);
|
||||
m_bc.bc.setOption3(0);
|
||||
|
@ -2524,14 +2529,18 @@ void MainWindow::update_preview()
|
|||
switch (symbology) {
|
||||
|
||||
case BARCODE_CODE128:
|
||||
if (get_rad_val(QSL("radC128CSup")))
|
||||
if (get_rad_val(QSL("radC128CSup"))) {
|
||||
m_bc.bc.setSymbol(BARCODE_CODE128AB);
|
||||
else if (get_rad_val(QSL("radC128EAN")))
|
||||
} else if (get_rad_val(QSL("radC128EAN"))) {
|
||||
m_bc.bc.setSymbol(chkComposite->isChecked() ? BARCODE_GS1_128_CC : BARCODE_GS1_128);
|
||||
else if (get_rad_val(QSL("radC128HIBC")))
|
||||
} else if (get_rad_val(QSL("radC128HIBC"))) {
|
||||
m_bc.bc.setSymbol(BARCODE_HIBC_128);
|
||||
else
|
||||
} else if (get_rad_val(QSL("radC128ExtraEsc"))) {
|
||||
m_bc.bc.setSymbol(BARCODE_CODE128);
|
||||
m_bc.bc.setInputMode(m_bc.bc.inputMode() | EXTRA_ESCAPE_MODE);
|
||||
} else {
|
||||
m_bc.bc.setSymbol(BARCODE_CODE128);
|
||||
}
|
||||
break;
|
||||
|
||||
case BARCODE_EANX:
|
||||
|
@ -3927,7 +3936,7 @@ void MainWindow::save_sub_settings(QSettings &settings, int symbology)
|
|||
case BARCODE_HIBC_128:
|
||||
settings.setValue(QSL("studio/bc/code128/encoding_mode"), get_rad_grp_index(
|
||||
QStringList() << QSL("radC128Stand") << QSL("radC128EAN") << QSL("radC128CSup")
|
||||
<< QSL("radC128HIBC")));
|
||||
<< QSL("radC128HIBC") << QSL("radC128ExtraEsc")));
|
||||
break;
|
||||
|
||||
case BARCODE_PDF417:
|
||||
|
@ -4334,7 +4343,7 @@ void MainWindow::load_sub_settings(QSettings &settings, int symbology)
|
|||
case BARCODE_HIBC_128:
|
||||
set_rad_from_setting(settings, QSL("studio/bc/code128/encoding_mode"),
|
||||
QStringList() << QSL("radC128Stand") << QSL("radC128EAN") << QSL("radC128CSup")
|
||||
<< QSL("radC128HIBC"));
|
||||
<< QSL("radC128HIBC") << QSL("radC128ExtraEsc"));
|
||||
break;
|
||||
|
||||
case BARCODE_PDF417:
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Zint Barcode Generator - the open source barcode generator
|
||||
Copyright (C) 2022 Robin Stuart <rstuart114@gmail.com>
|
||||
Copyright (C) 2022-2023 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
|
||||
|
@ -44,8 +44,8 @@ static int resolution_standard(int inch, int val)
|
|||
return 0;
|
||||
}
|
||||
|
||||
ScaleWindow::ScaleWindow(BarcodeItem *bc, Zint::QZintXdimDpVars *vars)
|
||||
: m_bc(bc), Valid(false), m_vars(*vars)
|
||||
ScaleWindow::ScaleWindow(BarcodeItem *bc, Zint::QZintXdimDpVars *vars, double originalScale)
|
||||
: m_bc(bc), Valid(false), m_vars(*vars), m_originalScale(originalScale), m_unset(false)
|
||||
{
|
||||
setupUi(this);
|
||||
|
||||
|
@ -90,11 +90,15 @@ ScaleWindow::ScaleWindow(BarcodeItem *bc, Zint::QZintXdimDpVars *vars)
|
|||
size_msg_ui_set();
|
||||
|
||||
QIcon closeIcon(QIcon::fromTheme(QSL("window-close"), QIcon(QSL(":res/x.svg"))));
|
||||
QIcon unsetIcon(QSL(":res/delete.svg"));
|
||||
QIcon okIcon(QIcon(QSL(":res/check.svg")));
|
||||
btnCancel->setIcon(closeIcon);
|
||||
btnScaleUnset->setIcon(unsetIcon);
|
||||
btnScaleUnset->setEnabled(m_vars.set);
|
||||
btnOK->setIcon(okIcon);
|
||||
|
||||
connect(btnCancel, SIGNAL(clicked( bool )), SLOT(close()));
|
||||
connect(btnScaleUnset, SIGNAL( clicked( bool )), SLOT(unset_scale()));
|
||||
connect(btnOK, SIGNAL(clicked( bool )), SLOT(okay()));
|
||||
connect(spnXdim, SIGNAL(valueChanged( double )), SLOT(update_scale()));
|
||||
connect(cmbXdimUnits, SIGNAL(currentIndexChanged( int )), SLOT(x_dim_units_change()));
|
||||
|
@ -143,11 +147,25 @@ void ScaleWindow::size_msg_ui_set()
|
|||
}
|
||||
}
|
||||
|
||||
void ScaleWindow::unset_scale()
|
||||
{
|
||||
m_vars.x_dim = m_bc->bc.getXdimDpFromScale(m_originalScale, get_dpmm(), getFileType());
|
||||
m_vars.set = 0;
|
||||
|
||||
if (cmbXdimUnits->currentIndex() == 1) { // Inches
|
||||
spnXdim->setValue(m_vars.x_dim / 25.4);
|
||||
} else {
|
||||
spnXdim->setValue(m_vars.x_dim);
|
||||
}
|
||||
m_unset = true;
|
||||
btnScaleUnset->setEnabled(false);
|
||||
}
|
||||
|
||||
void ScaleWindow::okay()
|
||||
{
|
||||
if (update_vars()) {
|
||||
Valid = true;
|
||||
m_vars.set = 1;
|
||||
m_vars.set = m_unset ? 0 : 1;
|
||||
}
|
||||
close();
|
||||
}
|
||||
|
@ -159,6 +177,8 @@ void ScaleWindow::update_scale()
|
|||
// Need up-to-date `vectorWidth()` and `vectorHeight()` to estimate size including borders, whitespace & text,
|
||||
// so tell main window to encode and it will update UI here via `size_msg_ui_set()`
|
||||
emit scaleChanged(scale);
|
||||
m_unset = false;
|
||||
btnScaleUnset->setEnabled(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Zint Barcode Generator - the open source barcode generator
|
||||
Copyright (C) 2022 Robin Stuart <rstuart114@gmail.com>
|
||||
Copyright (C) 2022-2023 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
|
||||
|
@ -32,7 +32,7 @@ private:
|
|||
BarcodeItem *m_bc;
|
||||
|
||||
public:
|
||||
ScaleWindow(BarcodeItem *bc, struct Zint::QZintXdimDpVars *vars);
|
||||
ScaleWindow(BarcodeItem *bc, struct Zint::QZintXdimDpVars *vars, double originalScale);
|
||||
~ScaleWindow();
|
||||
|
||||
bool Valid;
|
||||
|
@ -45,6 +45,7 @@ signals:
|
|||
public slots:
|
||||
void size_msg_ui_set();
|
||||
private slots:
|
||||
void unset_scale();
|
||||
void okay();
|
||||
void update_scale();
|
||||
void x_dim_units_change();
|
||||
|
@ -57,6 +58,8 @@ private:
|
|||
float get_dpmm() const;
|
||||
const char *getFileType() const;
|
||||
double update_vars();
|
||||
double m_originalScale;
|
||||
bool m_unset;
|
||||
};
|
||||
|
||||
/* vim: set ts=4 sw=4 et : */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue