2021-11-23 22:12:48 +03:00
/*
Zint Barcode Generator - the open source barcode generator
2024-01-06 01:55:57 +03:00
Copyright ( C ) 2021 - 2024 Robin Stuart < rstuart114 @ gmail . com >
2021-11-23 22:12:48 +03:00
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 .
*/
- API: add new zint_symbol `dpmm` field for output resolution (BMP/
EMF/PCX/PNG/TIF only, i.e. excluding EPS, GIF & SVG)
- Add support for specifying scale by X-dimension and resolution
with new option `--scalexdimdp` for CLI/Tcl & new API function
`ZBarcode_Scale_From_XdimDp()` (+ `ZBarcode_XdimDp_From_Scale()`
& `ZBarcode_Default_Xdim()`) and new GUI popup; manual: document
- BMP/EMF/PCX/PNG/TIF: use new `dpmm` resolution field (for EMF
following Inkscape)
- backend_qt: add `dpmm()`, `vectorWidth()`, `vectorHeight()`,
`noPng()`, `getVersion()`, `takesGS1AIData()`, & `XdimDp` stuff
incl. new `QZintXdimDp` struct for passing around scale vars &
use in `getAsCLI()`; add comments
- Raise `scale` limit to 200 (from 100) to allow for large dpmm
- output: create directories & subdirectories as necessary for
output path using new function `out_fopen()` and use in BMP/EMF/
EPS/GIF/PCX/PNG/SVG/TIF
- DPLEIT/DPIDENT: format HRT according to (incomplete)
documentation, and set default height to 72X (from 50X)
- CODE128B renamed to CODE128AB as can use subsets A and/or B
- CODABAR: fix minimum height calc
- EMF: fix indexing of handles (zero-based not 1-based)
- GUI: fix symbology zap (previous technique of clearing and
re-loading settings without doing a sync no longer works);
fix UPCEAN guard descent enable
- MAILMARK: better error message if input < 14 characters
- GUI: add "Default" button for DAFT tracker ratio & enable/disable
various default buttons; use new `takesGS1AIData()` to
enable/disable GS1-specific checkboxes
- CLI: use new `validate_float()` to parse float options (7
significant digits allowed only, no scientific notation)
- DATAMATRIX/GRIDMATRIX/PDF417/QR/ULTRA: micro-optimize structapp
ID parse
- library/CLI: fiddle with static asserts (make CHAR_BIT sensitive,
supposedly)
- win32/README: update building libpng (assembly removed)
- README.linux: document incompatibility of Qt6 >= 6.3
- manual: expand Barcode Studio waffle
- test suite: change range separator to hyphen and allow multiple
excludes
2022-12-03 00:39:01 +03:00
/* SPDX-License-Identifier: GPL-3.0-or-later */
2021-11-23 22:12:48 +03:00
//#include <QDebug>
# include <QClipboard>
# include <QMimeData>
2024-01-06 01:55:57 +03:00
# include <QSettings>
2021-11-23 22:12:48 +03:00
# include "cliwindow.h"
// Shorthand
2024-01-06 01:55:57 +03:00
# define QSL QStringLiteral
# define QSEmpty QLatin1String("")
2021-11-23 22:12:48 +03:00
static const int tempMessageTimeout = 2000 ;
- API: add new zint_symbol `dpmm` field for output resolution (BMP/
EMF/PCX/PNG/TIF only, i.e. excluding EPS, GIF & SVG)
- Add support for specifying scale by X-dimension and resolution
with new option `--scalexdimdp` for CLI/Tcl & new API function
`ZBarcode_Scale_From_XdimDp()` (+ `ZBarcode_XdimDp_From_Scale()`
& `ZBarcode_Default_Xdim()`) and new GUI popup; manual: document
- BMP/EMF/PCX/PNG/TIF: use new `dpmm` resolution field (for EMF
following Inkscape)
- backend_qt: add `dpmm()`, `vectorWidth()`, `vectorHeight()`,
`noPng()`, `getVersion()`, `takesGS1AIData()`, & `XdimDp` stuff
incl. new `QZintXdimDp` struct for passing around scale vars &
use in `getAsCLI()`; add comments
- Raise `scale` limit to 200 (from 100) to allow for large dpmm
- output: create directories & subdirectories as necessary for
output path using new function `out_fopen()` and use in BMP/EMF/
EPS/GIF/PCX/PNG/SVG/TIF
- DPLEIT/DPIDENT: format HRT according to (incomplete)
documentation, and set default height to 72X (from 50X)
- CODE128B renamed to CODE128AB as can use subsets A and/or B
- CODABAR: fix minimum height calc
- EMF: fix indexing of handles (zero-based not 1-based)
- GUI: fix symbology zap (previous technique of clearing and
re-loading settings without doing a sync no longer works);
fix UPCEAN guard descent enable
- MAILMARK: better error message if input < 14 characters
- GUI: add "Default" button for DAFT tracker ratio & enable/disable
various default buttons; use new `takesGS1AIData()` to
enable/disable GS1-specific checkboxes
- CLI: use new `validate_float()` to parse float options (7
significant digits allowed only, no scientific notation)
- DATAMATRIX/GRIDMATRIX/PDF417/QR/ULTRA: micro-optimize structapp
ID parse
- library/CLI: fiddle with static asserts (make CHAR_BIT sensitive,
supposedly)
- win32/README: update building libpng (assembly removed)
- README.linux: document incompatibility of Qt6 >= 6.3
- manual: expand Barcode Studio waffle
- test suite: change range separator to hyphen and allow multiple
excludes
2022-12-03 00:39:01 +03:00
CLIWindow : : CLIWindow ( BarcodeItem * bc , const bool autoHeight , const double heightPerRow ,
const struct Zint : : QZintXdimDpVars * xdimdpVars )
: m_bc ( bc ) , m_autoHeight ( autoHeight ) , m_heightPerRow ( heightPerRow ) , m_xdimdpVars ( xdimdpVars )
2021-11-23 22:12:48 +03:00
{
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 ) ;
2022-05-12 22:35:06 +03:00
chkCLINoEXE - > setEnabled ( true ) ;
2021-11-23 22:12:48 +03:00
} else {
radCLIUnix - > setChecked ( true ) ;
2022-05-12 22:35:06 +03:00
chkCLINoEXE - > setEnabled ( false ) ;
2021-11-23 22:12:48 +03:00
}
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 ) ;
2022-05-12 22:35:06 +03:00
chkCLINoEXE - > setChecked ( settings . value ( QSL ( " studio/cli/chk_no_exe " ) , 0 ) . toInt ( ) ? true : false ) ;
2021-11-23 22:12:48 +03:00
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 ) ;
2024-01-06 01:55:57 +03:00
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 ( ) ) ) ;
connect ( chkCLINoEXE , SIGNAL ( toggled ( bool ) ) , SLOT ( generate_cli ( ) ) ) ;
2021-11-23 22:12:48 +03:00
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 ) ;
2022-05-12 22:35:06 +03:00
settings . setValue ( QSL ( " studio/cli/chk_no_exe " ) , chkCLINoEXE - > isChecked ( ) ? 1 : 0 ) ;
2021-11-23 22:12:48 +03:00
}
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 ( )
{
2022-05-12 22:35:06 +03:00
bool noEXE = false ;
if ( radCLIWin - > isChecked ( ) ) {
noEXE = chkCLINoEXE - > isChecked ( ) ;
chkCLINoEXE - > setEnabled ( true ) ;
} else {
chkCLINoEXE - > setEnabled ( false ) ;
}
2021-11-23 22:12:48 +03:00
QString cmd = m_bc - > bc . getAsCLI ( radCLIWin - > isChecked ( ) , chkCLILongOpts - > isChecked ( ) ,
2024-01-06 01:55:57 +03:00
chkCLIBarcodeName - > isChecked ( ) , noEXE , m_autoHeight , m_heightPerRow , QSEmpty /*outfile*/ ,
- API: add new zint_symbol `dpmm` field for output resolution (BMP/
EMF/PCX/PNG/TIF only, i.e. excluding EPS, GIF & SVG)
- Add support for specifying scale by X-dimension and resolution
with new option `--scalexdimdp` for CLI/Tcl & new API function
`ZBarcode_Scale_From_XdimDp()` (+ `ZBarcode_XdimDp_From_Scale()`
& `ZBarcode_Default_Xdim()`) and new GUI popup; manual: document
- BMP/EMF/PCX/PNG/TIF: use new `dpmm` resolution field (for EMF
following Inkscape)
- backend_qt: add `dpmm()`, `vectorWidth()`, `vectorHeight()`,
`noPng()`, `getVersion()`, `takesGS1AIData()`, & `XdimDp` stuff
incl. new `QZintXdimDp` struct for passing around scale vars &
use in `getAsCLI()`; add comments
- Raise `scale` limit to 200 (from 100) to allow for large dpmm
- output: create directories & subdirectories as necessary for
output path using new function `out_fopen()` and use in BMP/EMF/
EPS/GIF/PCX/PNG/SVG/TIF
- DPLEIT/DPIDENT: format HRT according to (incomplete)
documentation, and set default height to 72X (from 50X)
- CODE128B renamed to CODE128AB as can use subsets A and/or B
- CODABAR: fix minimum height calc
- EMF: fix indexing of handles (zero-based not 1-based)
- GUI: fix symbology zap (previous technique of clearing and
re-loading settings without doing a sync no longer works);
fix UPCEAN guard descent enable
- MAILMARK: better error message if input < 14 characters
- GUI: add "Default" button for DAFT tracker ratio & enable/disable
various default buttons; use new `takesGS1AIData()` to
enable/disable GS1-specific checkboxes
- CLI: use new `validate_float()` to parse float options (7
significant digits allowed only, no scientific notation)
- DATAMATRIX/GRIDMATRIX/PDF417/QR/ULTRA: micro-optimize structapp
ID parse
- library/CLI: fiddle with static asserts (make CHAR_BIT sensitive,
supposedly)
- win32/README: update building libpng (assembly removed)
- README.linux: document incompatibility of Qt6 >= 6.3
- manual: expand Barcode Studio waffle
- test suite: change range separator to hyphen and allow multiple
excludes
2022-12-03 00:39:01 +03:00
m_xdimdpVars ) ;
2021-11-23 22:12:48 +03:00
txtCLICmd - > setPlainText ( cmd ) ;
statusBarCLI - > clearMessage ( ) ;
}
2022-05-12 22:35:06 +03:00
/* vim: set ts=4 sw=4 et : */