comparison mupdf-source/thirdparty/zint/frontend_qt/mainwindow.cpp @ 2:b50eed0cc0ef upstream

ADD: MuPDF v1.26.7: the MuPDF source as downloaded by a default build of PyMuPDF 1.26.4. The directory name has changed: no version number in the expanded directory now.
author Franz Glasner <fzglas.hg@dom66.de>
date Mon, 15 Sep 2025 11:43:07 +0200
parents
children
comparison
equal deleted inserted replaced
1:1d09e1dec1d9 2:b50eed0cc0ef
1 /***************************************************************************
2 * Copyright (C) 2008 by BogDan Vatra <bogdan@licentia.eu> *
3 * Copyright (C) 2009-2024 by Robin Stuart <rstuart114@gmail.com> *
4 * *
5 * This program is free software: you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation, either version 3 of the License, or *
8 * (at your option) any later version. *
9 * This program is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 * GNU General Public License for more details. *
13 * You should have received a copy of the GNU General Public License *
14 * along with this program. If not, see <http://www.gnu.org/licenses/>. *
15 ***************************************************************************/
16 /* SPDX-License-Identifier: GPL-3.0-or-later */
17
18 //#include <QDebug>
19 #include <QAction>
20 #include <QClipboard>
21 #include <QColor>
22 #include <QColorDialog>
23 #include <QDesktopServices>
24 #include <QFile>
25 #include <QFileDialog>
26 #include <QGraphicsScene>
27 #include <QImage>
28 #include <QListView>
29 #include <QMenu>
30 #include <QMessageBox>
31 #include <QMimeData>
32 #include <QRadioButton>
33 #include <QScreen>
34 #include <QSettings>
35 #include <QShortcut>
36 #include <QStandardItemModel>
37 #include <QTextStream>
38 #include <QUiLoader>
39
40 #include <math.h>
41 #include "mainwindow.h"
42 #include "cliwindow.h"
43 #include "datawindow.h"
44 #include "scalewindow.h"
45 #include "sequencewindow.h"
46
47 // Shorthand
48 #define QSL QStringLiteral
49 #define QSEmpty QLatin1String("")
50
51 static const int tempMessageTimeout = 2000;
52
53 // Use on Windows also (i.e. not using QKeySequence::Quit)
54 Q_GLOBAL_STATIC_WITH_ARGS(QKeySequence, quitKeySeq, (Qt::CTRL | Qt::Key_Q))
55
56 Q_GLOBAL_STATIC_WITH_ARGS(QKeySequence, openCLISeq, (Qt::SHIFT | Qt::CTRL | Qt::Key_C))
57
58 Q_GLOBAL_STATIC_WITH_ARGS(QKeySequence, copyBMPSeq, (Qt::SHIFT | Qt::CTRL | Qt::Key_B))
59 Q_GLOBAL_STATIC_WITH_ARGS(QKeySequence, copyEMFSeq, (Qt::SHIFT | Qt::CTRL | Qt::Key_E))
60 Q_GLOBAL_STATIC_WITH_ARGS(QKeySequence, copyGIFSeq, (Qt::SHIFT | Qt::CTRL | Qt::Key_G))
61 Q_GLOBAL_STATIC_WITH_ARGS(QKeySequence, copyPNGSeq, (Qt::SHIFT | Qt::CTRL | Qt::Key_P))
62 Q_GLOBAL_STATIC_WITH_ARGS(QKeySequence, copySVGSeq, (Qt::SHIFT | Qt::CTRL | Qt::Key_S))
63 Q_GLOBAL_STATIC_WITH_ARGS(QKeySequence, copyTIFSeq, (Qt::SHIFT | Qt::CTRL | Qt::Key_T))
64
65 Q_GLOBAL_STATIC_WITH_ARGS(QKeySequence, factoryResetSeq, (Qt::SHIFT | Qt::CTRL | Qt::Key_R))
66
67 // RGB hexadecimal 6 or 8 in length or CMYK comma-separated decimal percentages "C,M,Y,K"
68 static const QString colorREstr(QSL("^([0-9A-Fa-f]{6}([0-9A-Fa-f]{2})?)|(((100|[0-9]{0,2}),){3}(100|[0-9]{0,2}))$"));
69 Q_GLOBAL_STATIC_WITH_ARGS(QRegularExpression, colorRE, (colorREstr))
70
71 static const QString fgDefault(QSL("000000"));
72 static const QString bgDefault(QSL("FFFFFF"));
73 static const QString fgDefaultAlpha(QSL("000000FF"));
74 static const QString bgDefaultAlpha(QSL("FFFFFFFF"));
75
76 static QString qcolor_to_str(const QColor &color)
77 {
78 if (color.alpha() == 0xFF) {
79 return QString::asprintf("%02X%02X%02X", color.red(), color.green(), color.blue());
80 }
81 return QString::asprintf("%02X%02X%02X%02X", color.red(), color.green(), color.blue(), color.alpha());
82 }
83
84 static QColor str_to_qcolor(const QString &str)
85 {
86 QColor color;
87 int r, g, b, a;
88 if (str.contains(',')) {
89 int comma1 = str.indexOf(',');
90 int comma2 = str.indexOf(',', comma1 + 1);
91 int comma3 = str.indexOf(',', comma2 + 1);
92 int black = 100 - str.mid(comma3 + 1).toInt();
93 int val = 100 - str.mid(0, comma1).toInt();
94 r = (int) roundf((0xFF * val * black) / 10000.0f);
95 val = 100 - str.mid(comma1 + 1, comma2 - comma1 - 1).toInt();
96 g = (int) roundf((0xFF * val * black) / 10000.0f);
97 val = 100 - str.mid(comma2 + 1, comma3 - comma2 - 1).toInt();
98 b = (int) roundf((0xFF * val * black) / 10000.0f);
99 a = 0xFF;
100 } else {
101 r = str.mid(0, 2).toInt(nullptr, 16);
102 g = str.mid(2, 2).toInt(nullptr, 16);
103 b = str.mid(4, 2).toInt(nullptr, 16);
104 a = str.length() == 8 ? str.mid(6, 2).toInt(nullptr, 16) : 0xFF;
105 }
106 color.setRgb(r, g, b, a);
107 return color;
108 }
109
110 struct bstyle_item {
111 const QString text;
112 int symbology;
113 };
114
115 static const struct bstyle_item bstyle_items[] = {
116 { QSL("Australia Post Redirect Code"), BARCODE_AUSREDIRECT },
117 { QSL("Australia Post Reply-Paid"), BARCODE_AUSREPLY },
118 { QSL("Australia Post Routing Code"), BARCODE_AUSROUTE },
119 { QSL("Australia Post Standard Customer"), BARCODE_AUSPOST },
120 { QSL("Aztec Code (ISO 24778) (and HIBC)"), BARCODE_AZTEC },
121 { QSL("Aztec Runes (ISO 24778)"), BARCODE_AZRUNE },
122 { QSL("BC412 (SEMI T1-95)"), BARCODE_BC412 },
123 { QSL("Brazilian Postal Code (CEPNet)"), BARCODE_CEPNET },
124 { QSL("Channel Code"), BARCODE_CHANNEL },
125 { QSL("Codabar (EN 798)"), BARCODE_CODABAR },
126 { QSL("Codablock-F (and HIBC)"), BARCODE_CODABLOCKF },
127 { QSL("Code 11"), BARCODE_CODE11 },
128 { QSL("Code 128 (ISO 15417) (and GS1-128 and HIBC)"), BARCODE_CODE128 },
129 { QSL("Code 16K (EN 12323)"), BARCODE_CODE16K },
130 { QSL("Code 2 of 5 Data Logic"), BARCODE_C25LOGIC },
131 { QSL("Code 2 of 5 IATA"), BARCODE_C25IATA },
132 { QSL("Code 2 of 5 Industrial"), BARCODE_C25IND },
133 { QSL("Code 2 of 5 Interleaved (ISO 16390)"), BARCODE_C25INTER },
134 { QSL("Code 2 of 5 Standard (Matrix)"), BARCODE_C25STANDARD },
135 { QSL("Code 32 (Italian Pharmacode)"), BARCODE_CODE32 },
136 { QSL("Code 39 (ISO 16388) (and HIBC)"), BARCODE_CODE39 },
137 { QSL("Code 39 Extended"), BARCODE_EXCODE39 },
138 { QSL("Code 49"), BARCODE_CODE49 },
139 { QSL("Code 93"), BARCODE_CODE93 },
140 { QSL("Code One"), BARCODE_CODEONE },
141 { QSL("DAFT Code"), BARCODE_DAFT },
142 { QSL("Data Matrix (ISO 16022) (and HIBC)"), BARCODE_DATAMATRIX },
143 { QSL("Deutsche Post Identcode"), BARCODE_DPIDENT },
144 { QSL("Deutsche Post Leitcode"), BARCODE_DPLEIT },
145 { QSL("DotCode"), BARCODE_DOTCODE },
146 { QSL("DPD Code"), BARCODE_DPD },
147 { QSL("Dutch Post KIX"), BARCODE_KIX },
148 { QSL("DX Film Edge"), BARCODE_DXFILMEDGE },
149 { QSL("EAN (EAN-2, EAN-5, EAN-8 and EAN-13) (ISO 15420)"), BARCODE_EANX },
150 { QSL("EAN-14"), BARCODE_EAN14 },
151 { QSL("FIM (Facing Identification Mark)"), BARCODE_FIM },
152 { QSL("Flattermarken"), BARCODE_FLAT },
153 { QSL("Grid Matrix"), BARCODE_GRIDMATRIX },
154 { QSL("GS1 DataBar Expanded (ISO 24724)"), BARCODE_DBAR_EXP },
155 { QSL("GS1 DataBar Expanded Stacked (ISO 24724)"), BARCODE_DBAR_EXPSTK },
156 { QSL("GS1 DataBar Limited (ISO 24724)"), BARCODE_DBAR_LTD },
157 { QSL("GS1 DataBar Omnidirectional (and Truncated) (ISO 24724)"), BARCODE_DBAR_OMN },
158 { QSL("GS1 DataBar Stacked (ISO 24724)"), BARCODE_DBAR_STK },
159 { QSL("GS1 DataBar Stacked Omnidirectional (ISO 24724)"), BARCODE_DBAR_OMNSTK },
160 { QSL("Han Xin (Chinese Sensible) Code (ISO 20830)"), BARCODE_HANXIN },
161 { QSL("ISBN (International Standard Book Number)"), BARCODE_ISBNX },
162 { QSL("ITF-14"), BARCODE_ITF14 },
163 { QSL("Japanese Postal Barcode"), BARCODE_JAPANPOST },
164 { QSL("Korean Postal Barcode"), BARCODE_KOREAPOST },
165 { QSL("LOGMARS"), BARCODE_LOGMARS },
166 { QSL("MaxiCode (ISO 16023)"), BARCODE_MAXICODE },
167 { QSL("MicroPDF417 (ISO 24728) (and HIBC)"), BARCODE_MICROPDF417 },
168 { QSL("Micro QR Code (ISO 18004)"), BARCODE_MICROQR },
169 { QSL("MSI Plessey"), BARCODE_MSI_PLESSEY },
170 { QSL("NVE-18 (SSCC-18)"), BARCODE_NVE18 },
171 { QSL("PDF417 (ISO 15438) (and Compact and HIBC)"), BARCODE_PDF417 },
172 { QSL("Pharmacode"), BARCODE_PHARMA },
173 { QSL("Pharmacode 2-track"), BARCODE_PHARMA_TWO },
174 { QSL("Pharma Zentralnummer (PZN)"), BARCODE_PZN },
175 { QSL("PLANET"), BARCODE_PLANET },
176 { QSL("POSTNET"), BARCODE_POSTNET },
177 { QSL("QR Code (ISO 18004) (and HIBC)"), BARCODE_QRCODE },
178 { QSL("Rectangular Micro QR (rMQR) (ISO 23941)"), BARCODE_RMQR },
179 { QSL("Royal Mail 2D Mailmark (CMDM) (Data Matrix)"), BARCODE_MAILMARK_2D },
180 { QSL("Royal Mail 4-state Customer Code (RM4SCC)"), BARCODE_RM4SCC },
181 { QSL("Royal Mail 4-state Mailmark"), BARCODE_MAILMARK_4S },
182 { QSL("Telepen"), BARCODE_TELEPEN },
183 { QSL("Telepen Numeric"), BARCODE_TELEPEN_NUM },
184 { QSL("UK Plessey"), BARCODE_PLESSEY },
185 { QSL("Ultracode"), BARCODE_ULTRA },
186 { QSL("UPC-A (ISO 15420)"), BARCODE_UPCA },
187 { QSL("UPC-E (ISO 15420)"), BARCODE_UPCE },
188 { QSL("UPNQR"), BARCODE_UPNQR },
189 { QSL("UPU S10"), BARCODE_UPU_S10 },
190 { QSL("USPS Intelligent Mail (OneCode)"), BARCODE_USPS_IMAIL },
191 { QSL("VIN (Vehicle Identification Number)"), BARCODE_VIN },
192 };
193
194 #ifdef Q_OS_MACOS
195
196 /* Helper to make data tab vertical layouts look ok on macOS */
197 void MainWindow::mac_hack_vLayouts(QWidget *win)
198 {
199 QList<QVBoxLayout *> vlayouts = win->findChildren<QVBoxLayout *>();
200 for (int i = 0, cnt = vlayouts.size(); i < cnt; i++) {
201 if (vlayouts[i]->objectName() == "vLayoutData" || vlayouts[i]->objectName() == "vLayoutComposite"
202 || vlayouts[i]->objectName() == "vLayoutSegs") {
203 vlayouts[i]->setSpacing(2);
204 // If set spacing on QVBoxLayout then it seems its QHBoxLayout children inherit this so undo
205 QList<QHBoxLayout *> hlayouts = vlayouts[i]->findChildren<QHBoxLayout *>();
206 for (int j = 0, cnt = hlayouts.size(); j < cnt; j++) {
207 hlayouts[j]->setSpacing(8);
208 }
209 }
210 }
211 }
212
213 /* Helper to make status bars look ok on macOS */
214 void MainWindow::mac_hack_statusBars(QWidget *win, const char* name)
215 {
216 QList<QStatusBar *> sbars = name ? win->findChildren<QStatusBar *>(name) : win->findChildren<QStatusBar *>();
217 QColor bgColor = QGuiApplication::palette().window().color();
218 QString sbarSS = QSL("QStatusBar {background-color:") + bgColor.name() + QSL(";}");
219 for (int i = 0, cnt = sbars.size(); i < cnt; i++) {
220 sbars[i]->setStyleSheet(sbarSS);
221 }
222 }
223 #endif
224
225 MainWindow::MainWindow(QWidget *parent, Qt::WindowFlags fl)
226 : QWidget(parent, fl), m_previewBgColor(0xF4, 0xF4, 0xF4), m_optionWidget(nullptr), m_symbology(0),
227 m_menu(nullptr),
228 m_lblHeightPerRow(nullptr), m_spnHeightPerRow(nullptr),
229 m_btnHeightPerRowDisable(nullptr), m_btnHeightPerRowDefault(nullptr),
230 m_scaleWindow(nullptr)
231 {
232 // Undocumented command line debug flag
233 m_bc.bc.setDebug(QCoreApplication::arguments().contains(QSL("--verbose")));
234
235 QCoreApplication::setOrganizationName(QSL("zint"));
236 QCoreApplication::setOrganizationDomain(QSL("zint.org.uk"));
237 QCoreApplication::setApplicationName(QSL("Barcode Studio"));
238
239 QSettings settings;
240 #if QT_VERSION < 0x60000
241 settings.setIniCodec("UTF-8");
242 #endif
243
244 scene = new QGraphicsScene(this);
245
246 setupUi(this);
247 view->setScene(scene);
248
249 QVariant saved_geometry = settings.value(QSL("studio/window_geometry"));
250
251 #ifdef Q_OS_MACOS
252 // Standard width 360 too narrow
253 if (saved_geometry.isNull()) {
254 // Seems this is necessary on macOS to get a reasonable initial height
255 setMinimumSize(QSize(460, (int) (QApplication::primaryScreen()->availableSize().height() * 0.9f)));
256 } else {
257 setMinimumSize(QSize(460, 0));
258 }
259 mac_hack_vLayouts(this);
260 mac_hack_statusBars(this, "statusBar");
261 vLayoutTabData->setContentsMargins(QMargins(20, 0, 20, 0));
262 tabMain->setMinimumSize(QSize(0, 380));
263 tabMain->setMaximumSize(QSize(16777215, 380));
264 #endif
265 #ifdef _WIN32
266 tabMain->setMinimumSize(QSize(0, 316));
267 tabMain->setMaximumSize(QSize(16777215, 316));
268 #endif
269
270 restoreGeometry(saved_geometry.toByteArray());
271
272 m_fgcolor_geometry = settings.value(QSL("studio/fgcolor_geometry")).toByteArray();
273 m_bgcolor_geometry = settings.value(QSL("studio/bgcolor_geometry")).toByteArray();
274 m_previewbgcolor_geometry = settings.value(QSL("studio/previewbgcolor_geometry")).toByteArray();
275
276 btnScale->setIcon(QIcon(QSL(":res/scaling.svg")));
277 fgcolor->setIcon(QIcon(QSL(":res/black-eye.svg")));
278 bgcolor->setIcon(QIcon(QSL(":res/white-eye.svg")));
279 btnReverse->setIcon(QIcon(QSL(":res/shuffle.svg")));
280
281 QRegularExpressionValidator *colorValidator = new QRegularExpressionValidator(*colorRE, this);
282 txt_fgcolor->setValidator(colorValidator);
283 txt_bgcolor->setValidator(colorValidator);
284
285 connect(txt_fgcolor, SIGNAL(textEdited(QString)), this, SLOT(fgcolor_edited()));
286 connect(txt_bgcolor, SIGNAL(textEdited(QString)), this, SLOT(bgcolor_edited()));
287
288 const int cnt = (int) (sizeof(bstyle_items) / sizeof(bstyle_items[0]));
289 for (int i = 0; i < cnt; i++) {
290 bstyle->addItem(bstyle_items[i].text);
291 }
292 #ifdef _WIN32
293 bstyle->setMaxVisibleItems(cnt); /* Apart from increasing combo size, seems to be needed for filter to work */
294 #endif
295 #if QT_VERSION < 0x50A00
296 /* Prior to Qt 5.10 comboboxes have display issues when filtered (scrollers not accounted for), so disable */
297 filter_bstyle->hide();
298 #endif
299 bstyle->setCurrentIndex(settings.value(QSL("studio/symbology"), 12).toInt());
300
301 load_settings(settings);
302
303 // Set background of preview - allows whitespace and quiet zones to be more easily seen
304 m_bc.setColor(m_previewBgColor);
305
306 QIcon clearIcon(QSL(":res/delete.svg"));
307 btnClearData->setIcon(clearIcon);
308 btnClearDataSeg1->setIcon(clearIcon);
309 btnClearDataSeg2->setIcon(clearIcon);
310 btnClearDataSeg3->setIcon(clearIcon);
311 btnClearComposite->setIcon(clearIcon);
312 btnClearTextGap->setIcon(clearIcon);
313 btnZap->setIcon(QIcon(QSL(":res/zap.svg")));
314
315 change_options();
316
317 scene->addItem(&m_bc);
318
319 connect(bstyle, SIGNAL(currentIndexChanged(int)), SLOT(change_options()));
320 connect(bstyle, SIGNAL(currentIndexChanged(int)), SLOT(update_preview()));
321 connect(filter_bstyle, SIGNAL(textChanged(QString)), SLOT(filter_symbologies()));
322 connect(heightb, SIGNAL(valueChanged(double)), SLOT(update_preview()));
323 connect(bwidth, SIGNAL(valueChanged(int)), SLOT(update_preview()));
324 connect(btype, SIGNAL(currentIndexChanged(int)), SLOT(update_preview()));
325 connect(cmbFontSetting, SIGNAL(currentIndexChanged(int)), SLOT(update_preview()));
326 connect(spnTextGap, SIGNAL(valueChanged(double)), SLOT(text_gap_ui_set()));
327 connect(spnTextGap, SIGNAL(valueChanged(double)), SLOT(update_preview()));
328 connect(btnClearTextGap, SIGNAL(clicked(bool)), SLOT(clear_text_gap()));
329 connect(txtData, SIGNAL(textChanged(QString)), SLOT(data_ui_set()));
330 connect(txtData, SIGNAL(textChanged(QString)), SLOT(upcae_no_quiet_zones_ui_set()));
331 connect(txtData, SIGNAL(textChanged(QString)), SLOT(update_preview()));
332 connect(txtDataSeg1, SIGNAL(textChanged(QString)), SLOT(data_ui_set()));
333 connect(txtDataSeg1, SIGNAL(textChanged(QString)), SLOT(update_preview()));
334 connect(txtDataSeg2, SIGNAL(textChanged(QString)), SLOT(data_ui_set()));
335 connect(txtDataSeg2, SIGNAL(textChanged(QString)), SLOT(update_preview()));
336 connect(txtDataSeg3, SIGNAL(textChanged(QString)), SLOT(data_ui_set()));
337 connect(txtDataSeg3, SIGNAL(textChanged(QString)), SLOT(update_preview()));
338 connect(txtComposite, SIGNAL(textChanged()), SLOT(update_preview()));
339 connect(chkComposite, SIGNAL(toggled(bool)), SLOT(composite_ui_set()));
340 connect(chkComposite, SIGNAL(toggled(bool)), SLOT(update_preview()));
341 connect(cmbCompType, SIGNAL(currentIndexChanged(int)), SLOT(update_preview()));
342 connect(btnClearComposite, SIGNAL(clicked(bool)), SLOT(clear_composite()));
343 connect(cmbECI, SIGNAL(currentIndexChanged(int)), SLOT(update_preview()));
344 connect(cmbECISeg1, SIGNAL(currentIndexChanged(int)), SLOT(update_preview()));
345 connect(cmbECISeg2, SIGNAL(currentIndexChanged(int)), SLOT(update_preview()));
346 connect(cmbECISeg3, SIGNAL(currentIndexChanged(int)), SLOT(update_preview()));
347 connect(chkEscape, SIGNAL(toggled(bool)), SLOT(update_preview()));
348 connect(chkData, SIGNAL(toggled(bool)), SLOT(update_preview()));
349 connect(chkRInit, SIGNAL(toggled(bool)), SLOT(update_preview()));
350 connect(chkGS1Parens, SIGNAL(toggled(bool)), SLOT(update_preview()));
351 connect(chkGS1NoCheck, SIGNAL(toggled(bool)), SLOT(update_preview()));
352 connect(spnWhitespace, SIGNAL(valueChanged(int)), SLOT(update_preview()));
353 connect(spnVWhitespace, SIGNAL(valueChanged(int)), SLOT(update_preview()));
354 connect(btnMenu, SIGNAL(clicked(bool)), SLOT(menu()));
355 connect(btnSave, SIGNAL(clicked(bool)), SLOT(save()));
356 connect(spnScale, SIGNAL(valueChanged(double)), SLOT(update_preview()));
357 connect(btnExit, SIGNAL(clicked(bool)), SLOT(quit_now()));
358 connect(fgcolor, SIGNAL(clicked(bool)), SLOT(fgcolor_clicked()));
359 connect(bgcolor, SIGNAL(clicked(bool)), SLOT(bgcolor_clicked()));
360 connect(btnReset, SIGNAL(clicked(bool)), SLOT(reset_colours()));
361 connect(btnReverse, SIGNAL(clicked(bool)), SLOT(reverse_colours()));
362 connect(btnMoreData, SIGNAL(clicked(bool)), SLOT(open_data_dialog()));
363 connect(btnMoreDataSeg1, SIGNAL(clicked(bool)), SLOT(open_data_dialog_seg1()));
364 connect(btnMoreDataSeg2, SIGNAL(clicked(bool)), SLOT(open_data_dialog_seg2()));
365 connect(btnMoreDataSeg3, SIGNAL(clicked(bool)), SLOT(open_data_dialog_seg3()));
366 connect(btnClearData, SIGNAL(clicked(bool)), SLOT(clear_data()));
367 connect(btnClearDataSeg1, SIGNAL(clicked(bool)), SLOT(clear_data_seg1()));
368 connect(btnClearDataSeg2, SIGNAL(clicked(bool)), SLOT(clear_data_seg2()));
369 connect(btnClearDataSeg3, SIGNAL(clicked(bool)), SLOT(clear_data_seg3()));
370 connect(btnSequence, SIGNAL(clicked(bool)), SLOT(open_sequence_dialog()));
371 connect(btnZap, SIGNAL(clicked(bool)), SLOT(zap()));
372 connect(chkAutoHeight, SIGNAL(toggled(bool)), SLOT(autoheight_ui_set()));
373 connect(chkAutoHeight, SIGNAL(toggled(bool)), SLOT(update_preview()));
374 connect(chkCompliantHeight, SIGNAL(toggled(bool)), SLOT(update_preview()));
375 connect(btnScale, SIGNAL(clicked(bool)), SLOT(open_scale_dialog()));
376 connect(chkHRTShow, SIGNAL(toggled(bool)), SLOT(HRTShow_ui_set()));
377 connect(chkHRTShow, SIGNAL(toggled(bool)), SLOT(update_preview()));
378 connect(chkCMYK, SIGNAL(toggled(bool)), SLOT(change_cmyk()));
379 connect(chkQuietZones, SIGNAL(toggled(bool)), SLOT(update_preview()));
380 connect(cmbRotate, SIGNAL(currentIndexChanged(int)), SLOT(update_preview()));
381 connect(chkDotty, SIGNAL(toggled(bool)), SLOT(dotty_ui_set()));
382 connect(chkDotty, SIGNAL(toggled(bool)), SLOT(update_preview()));
383 connect(spnDotSize, SIGNAL(valueChanged(double)), SLOT(update_preview()));
384 connect(btnCopySVG, SIGNAL(clicked(bool)), SLOT(copy_to_clipboard_svg()));
385 connect(btnCopyBMP, SIGNAL(clicked(bool)), SLOT(copy_to_clipboard_bmp()));
386
387 connect(&m_bc.bc, SIGNAL(encoded()), SLOT(on_encoded()));
388 connect(&m_bc.bc, SIGNAL(errored()), SLOT(on_errored()));
389
390 connect(view, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(view_context_menu(QPoint)));
391 connect(errtxtBar, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(errtxtBar_context_menu(QPoint)));
392
393 // Will enable/disable these on error
394 m_saveAsShortcut = new QShortcut(QKeySequence::Save, this);
395 connect(m_saveAsShortcut, SIGNAL(activated()), SLOT(save()));
396 m_openCLIShortcut = new QShortcut(*openCLISeq, this);
397 connect(m_openCLIShortcut, SIGNAL(activated()), SLOT(open_cli_dialog()));
398 m_copyBMPShortcut = new QShortcut(*copyBMPSeq, this);
399 connect(m_copyBMPShortcut, SIGNAL(activated()), SLOT(copy_to_clipboard_bmp()));
400 m_copyEMFShortcut = new QShortcut(*copyEMFSeq, this);
401 connect(m_copyEMFShortcut, SIGNAL(activated()), SLOT(copy_to_clipboard_emf()));
402 m_copyGIFShortcut = new QShortcut(*copyGIFSeq, this);
403 connect(m_copyGIFShortcut, SIGNAL(activated()), SLOT(copy_to_clipboard_gif()));
404 if (!m_bc.bc.noPng()) {
405 m_copyPNGShortcut = new QShortcut(*copyPNGSeq, this);
406 connect(m_copyPNGShortcut, SIGNAL(activated()), SLOT(copy_to_clipboard_png()));
407 }
408 m_copySVGShortcut = new QShortcut(*copySVGSeq, this);
409 connect(m_copySVGShortcut, SIGNAL(activated()), SLOT(copy_to_clipboard_svg()));
410 m_copyTIFShortcut = new QShortcut(*copyTIFSeq, this);
411 connect(m_copyTIFShortcut, SIGNAL(activated()), SLOT(copy_to_clipboard_tif()));
412
413 m_factoryResetShortcut = new QShortcut(*factoryResetSeq, this);
414 connect(m_factoryResetShortcut, SIGNAL(activated()), SLOT(factory_reset()));
415
416 QShortcut *helpShortcut = new QShortcut(QKeySequence::HelpContents, this);
417 connect(helpShortcut, SIGNAL(activated()), SLOT(help()));
418 QShortcut *quitShortcut = new QShortcut(*quitKeySeq, this);
419 connect(quitShortcut, SIGNAL(activated()), SLOT(quit_now()));
420
421 createActions();
422 createMenu();
423 bstyle->setFocus();
424
425 tabMain->installEventFilter(this);
426 txt_fgcolor->installEventFilter(this);
427 txt_bgcolor->installEventFilter(this);
428 }
429
430 MainWindow::~MainWindow()
431 {
432 QSettings settings;
433 #if QT_VERSION < 0x60000
434 settings.setIniCodec("UTF-8");
435 #endif
436
437 settings.setValue(QSL("studio/window_geometry"), saveGeometry());
438 settings.setValue(QSL("studio/fgcolor_geometry"), m_fgcolor_geometry);
439 settings.setValue(QSL("studio/bgcolor_geometry"), m_bgcolor_geometry);
440 settings.setValue(QSL("studio/previewbgcolor_geometry"), m_previewbgcolor_geometry);
441 settings.setValue(QSL("studio/tab_index"), tabMain->currentIndex());
442 settings.setValue(QSL("studio/symbology"), bstyle->currentIndex());
443 settings.setValue(QSL("studio/ink/text"), m_fgstr);
444 settings.setValue(QSL("studio/paper/text"), m_bgstr);
445 if (m_previewBgColor.isValid()) {
446 settings.setValue(QSL("studio/preview_bg_color"), m_previewBgColor.name());
447 }
448 settings.setValue(QSL("studio/data"), txtData->text());
449 /* Seg data not saved so don't restore */
450 settings.setValue(QSL("studio/composite_text"), txtComposite->toPlainText());
451 settings.setValue(QSL("studio/chk_composite"), chkComposite->isChecked() ? 1 : 0);
452 settings.setValue(QSL("studio/comp_type"), cmbCompType->currentIndex());
453 settings.setValue(QSL("studio/eci"), cmbECI->currentIndex());
454 /* Seg ECIs not saved so don't restore */
455 settings.setValue(QSL("studio/chk_escape"), chkEscape->isChecked() ? 1 : 0);
456 settings.setValue(QSL("studio/chk_data"), chkData->isChecked() ? 1 : 0);
457 settings.setValue(QSL("studio/chk_rinit"), chkRInit->isChecked() ? 1 : 0);
458 settings.setValue(QSL("studio/chk_gs1parens"), chkGS1Parens->isChecked() ? 1 : 0);
459 settings.setValue(QSL("studio/chk_gs1nocheck"), chkGS1NoCheck->isChecked() ? 1 : 0);
460 settings.setValue(QSL("studio/appearance/autoheight"), chkAutoHeight->isChecked() ? 1 : 0);
461 settings.setValue(QSL("studio/appearance/compliantheight"), chkCompliantHeight->isChecked() ? 1 : 0);
462 settings.setValue(QSL("studio/appearance/height"), heightb->value());
463 settings.setValue(QSL("studio/appearance/border"), bwidth->value());
464 settings.setValue(QSL("studio/appearance/whitespace"), spnWhitespace->value());
465 settings.setValue(QSL("studio/appearance/vwhitespace"), spnVWhitespace->value());
466 settings.setValue(QSL("studio/appearance/scale"), spnScale->value());
467 settings.setValue(QSL("studio/appearance/border_type"), btype->currentIndex());
468 settings.setValue(QSL("studio/appearance/font_setting"), cmbFontSetting->currentIndex());
469 settings.setValue(QSL("studio/appearance/text_gap"), spnTextGap->value());
470 settings.setValue(QSL("studio/appearance/chk_hrt_show"), chkHRTShow->isChecked() ? 1 : 0);
471 settings.setValue(QSL("studio/appearance/chk_cmyk"), chkCMYK->isChecked() ? 1 : 0);
472 settings.setValue(QSL("studio/appearance/chk_quiet_zones"), chkQuietZones->isChecked() ? 1 : 0);
473 settings.setValue(QSL("studio/appearance/rotate"), cmbRotate->currentIndex());
474 settings.setValue(QSL("studio/appearance/chk_embed_vector_font"), chkEmbedVectorFont->isChecked() ? 1 : 0);
475 settings.setValue(QSL("studio/appearance/chk_dotty"), chkDotty->isChecked() ? 1 : 0);
476 settings.setValue(QSL("studio/appearance/dot_size"), spnDotSize->value());
477 // These are "system-wide"
478 settings.setValue(QSL("studio/xdimdpvars/resolution"), m_xdimdpVars.resolution);
479 settings.setValue(QSL("studio/xdimdpvars/resolution_units"), m_xdimdpVars.resolution_units);
480 settings.setValue(QSL("studio/xdimdpvars/filetype"), m_xdimdpVars.filetype);
481 settings.setValue(QSL("studio/xdimdpvars/filetype_maxicode"), m_xdimdpVars.filetype_maxicode);
482
483 save_sub_settings(settings, m_bc.bc.symbol());
484 }
485
486 void MainWindow::load_settings(QSettings &settings)
487 {
488 bool initial_load = m_symbology == 0;
489 QString initialData(initial_load ? tr("Your Data Here!") : "");
490
491 m_fgstr = settings.value(QSL("studio/ink/text"), QSEmpty).toString();
492 if (m_fgstr.isEmpty()) {
493 QColor color(settings.value(QSL("studio/ink/red"), 0).toInt(),
494 settings.value(QSL("studio/ink/green"), 0).toInt(),
495 settings.value(QSL("studio/ink/blue"), 0).toInt(),
496 settings.value(QSL("studio/ink/alpha"), 0xff).toInt());
497 m_fgstr = qcolor_to_str(color);
498 }
499 if (m_fgstr.indexOf(*colorRE) != 0) {
500 m_fgstr = fgDefault;
501 }
502 m_bgstr = settings.value(QSL("studio/paper/text"), QSEmpty).toString();
503 if (m_bgstr.isEmpty()) {
504 QColor color(settings.value(QSL("studio/paper/red"), 0).toInt(),
505 settings.value(QSL("studio/paper/green"), 0).toInt(),
506 settings.value(QSL("studio/paper/blue"), 0).toInt(),
507 settings.value(QSL("studio/paper/alpha"), 0xff).toInt());
508 m_bgstr = qcolor_to_str(color);
509 }
510 if (m_bgstr.indexOf(*colorRE) != 0) {
511 m_bgstr = bgDefault;
512 }
513
514 m_previewBgColor = QColor(settings.value(QSL("studio/preview_bg_color"), QSL("#F4F4F4")).toString());
515 if (!m_previewBgColor.isValid()) {
516 m_previewBgColor = QColor(0xF4, 0xF4, 0xF4);
517 }
518
519 txtData->setText(settings.value(QSL("studio/data"), initialData).toString());
520 /* Don't save seg data */
521 txtComposite->setText(settings.value(QSL("studio/composite_text"), initialData).toString());
522 chkComposite->setChecked(settings.value(QSL("studio/chk_composite")).toInt() ? true : false);
523 cmbCompType->setCurrentIndex(settings.value(QSL("studio/comp_type"), 0).toInt());
524 cmbECI->setCurrentIndex(settings.value(QSL("studio/eci"), 0).toInt());
525 /* Don't save seg ECIs */
526 chkEscape->setChecked(settings.value(QSL("studio/chk_escape")).toInt() ? true : false);
527 chkData->setChecked(settings.value(QSL("studio/chk_data")).toInt() ? true : false);
528 chkRInit->setChecked(settings.value(QSL("studio/chk_rinit")).toInt() ? true : false);
529 chkGS1Parens->setChecked(settings.value(QSL("studio/chk_gs1parens")).toInt() ? true : false);
530 chkGS1NoCheck->setChecked(settings.value(QSL("studio/chk_gs1nocheck")).toInt() ? true : false);
531 chkAutoHeight->setChecked(settings.value(QSL("studio/appearance/autoheight"), 1).toInt() ? true : false);
532 chkCompliantHeight->setChecked(
533 settings.value(QSL("studio/appearance/compliantheight"), 1).toInt() ? true : false);
534 heightb->setValue(settings.value(QSL("studio/appearance/height"), 50.0f).toFloat());
535 bwidth->setValue(settings.value(QSL("studio/appearance/border"), 0).toInt());
536 spnWhitespace->setValue(settings.value(QSL("studio/appearance/whitespace"), 0).toInt());
537 spnVWhitespace->setValue(settings.value(QSL("studio/appearance/vwhitespace"), 0).toInt());
538 spnScale->setValue(settings.value(QSL("studio/appearance/scale"), 1.0).toFloat());
539 btype->setCurrentIndex(settings.value(QSL("studio/appearance/border_type"), 0).toInt());
540 cmbFontSetting->setCurrentIndex(settings.value(QSL("studio/appearance/font_setting"), 0).toInt());
541 spnTextGap->setValue(settings.value(QSL("studio/appearance/text_gap"), 1.0).toFloat());
542 chkHRTShow->setChecked(settings.value(QSL("studio/appearance/chk_hrt_show"), 1).toInt() ? true : false);
543 chkCMYK->setChecked(settings.value(QSL("studio/appearance/chk_cmyk"), 0).toInt() ? true : false);
544 chkQuietZones->setChecked(settings.value(QSL("studio/appearance/chk_quiet_zones"), 0).toInt() ? true : false);
545 cmbRotate->setCurrentIndex(settings.value(QSL("studio/appearance/rotate"), 0).toInt());
546 chkEmbedVectorFont->setChecked(settings.value(QSL("studio/appearance/chk_embed_vector_font"), 0).toInt()
547 ? true : false);
548 chkDotty->setChecked(settings.value(QSL("studio/appearance/chk_dotty"), 0).toInt() ? true : false);
549 spnDotSize->setValue(settings.value(QSL("studio/appearance/dot_size"), 4.0 / 5.0).toFloat());
550 // These are "system-wide"
551 m_xdimdpVars.resolution_units = std::max(std::min(settings.value(QSL("studio/xdimdpvars/resolution_units"),
552 0).toInt(), 1), 0);
553 const int defaultResolution = m_xdimdpVars.resolution_units == 1 ? 300 : 12; // 300dpi or 12dpmm
554 const int maxRes = m_xdimdpVars.resolution_units == 1 ? 25400 : 1000;
555 m_xdimdpVars.resolution = std::max(std::min(settings.value(QSL("studio/xdimdpvars/resolution"),
556 defaultResolution).toInt(), maxRes), 1);
557 m_xdimdpVars.filetype = std::max(std::min(settings.value(QSL("studio/xdimdpvars/filetype"), 0).toInt(), 1), 0);
558 m_xdimdpVars.filetype_maxicode = std::max(std::min(settings.value(QSL("studio/xdimdpvars/filetype_maxicode"),
559 0).toInt(), 2), 0);
560 }
561
562 QString MainWindow::get_zint_version(void)
563 {
564 QString zint_version;
565
566 int lib_version = Zint::QZint::getVersion();
567 int version_major = lib_version / 10000;
568 int version_minor = (lib_version % 10000) / 100;
569 int version_release = lib_version % 100;
570 int version_build;
571
572 if (version_release >= 9) {
573 /* This is a test release */
574 version_release = version_release / 10;
575 version_build = lib_version % 10;
576 QTextStream(&zint_version) << version_major << '.' << version_minor << '.' << version_release
577 << '.' << version_build << QSL(" (dev)");
578 } else {
579 /* This is a stable release */
580 QTextStream(&zint_version) << version_major << '.' << version_minor << '.' << version_release;
581 }
582
583 return zint_version;
584 }
585
586 void MainWindow::resizeEvent(QResizeEvent *event)
587 {
588 QWidget::resizeEvent(event);
589 update_preview();
590 }
591
592 bool MainWindow::event(QEvent *event)
593 {
594 switch (event->type()) {
595 case QEvent::StatusTip:
596 statusBar->showMessage(static_cast<QStatusTipEvent*>(event)->tip());
597 break;
598 default:
599 break;
600 }
601
602 return QWidget::event(event);
603 }
604
605 bool MainWindow::eventFilter(QObject *watched, QEvent *event)
606 {
607 if (event->type() == QEvent::ShortcutOverride) {
608 QKeyEvent *keyEvent = static_cast<QKeyEvent *>(event);
609 if (keyEvent->modifiers().testFlag(Qt::AltModifier) && keyEvent->key() == 'O') {
610 event->ignore();
611 txtData->setFocus();
612 return true;
613 }
614 }
615
616 if ((watched == txt_fgcolor || watched == txt_bgcolor) && event->type() == QEvent::FocusOut) {
617 // Exclude right-click context menu pop-up (Undo/Redo/Cut/Copy/Paste etc.)
618 QFocusEvent *focusEvent = static_cast<QFocusEvent *>(event);
619 if (focusEvent->reason() != Qt::PopupFocusReason) {
620 if (watched == txt_fgcolor) {
621 setColorTxtBtn(m_fgstr, txt_fgcolor, fgcolor);
622 } else {
623 setColorTxtBtn(m_bgstr, txt_bgcolor, bgcolor);
624 }
625 }
626 }
627
628 return QWidget::eventFilter(watched, event);
629 }
630
631 void MainWindow::reset_colours()
632 {
633 m_fgstr = fgDefault;
634 m_bgstr = bgDefault;
635 setColorTxtBtn(m_fgstr, txt_fgcolor, fgcolor);
636 setColorTxtBtn(m_bgstr, txt_bgcolor, bgcolor);
637 update_preview();
638 }
639
640 void MainWindow::reverse_colours()
641 {
642 QString temp = m_fgstr;
643 m_fgstr = m_bgstr;
644 m_bgstr = temp;
645 setColorTxtBtn(m_fgstr, txt_fgcolor, fgcolor);
646 setColorTxtBtn(m_bgstr, txt_bgcolor, bgcolor);
647 update_preview();
648 }
649
650 void MainWindow::setColorTxtBtn(const QString &colorStr, QLineEdit *txt, QToolButton* btn) {
651 if (colorStr != txt->text()) {
652 int cursorPos = txt->cursorPosition();
653 txt->setText(colorStr);
654 txt->setCursorPosition(cursorPos);
655 }
656 btn->setStyleSheet(QSL("QToolButton {background-color:") + str_to_qcolor(colorStr).name() + QSL(";}"));
657 }
658
659 bool MainWindow::save()
660 {
661 QSettings settings;
662 #if QT_VERSION < 0x60000
663 settings.setIniCodec("UTF-8");
664 #endif
665 QFileDialog save_dialog;
666 QString pathname;
667 QString suffix;
668 QStringList suffixes;
669
670 save_dialog.setAcceptMode(QFileDialog::AcceptSave);
671 save_dialog.setWindowTitle(tr("Save Barcode Image"));
672 save_dialog.setDirectory(settings.value(QSL("studio/default_dir"),
673 QDir::toNativeSeparators(QDir::homePath())).toString());
674
675 suffixes << QSL("eps") << QSL("gif") << QSL("svg") << QSL("bmp") << QSL("pcx") << QSL("emf") << QSL("tif");
676 if (m_bc.bc.noPng()) {
677 suffix = settings.value(QSL("studio/default_suffix"), QSL("gif")).toString();
678 save_dialog.setNameFilter(tr(
679 "Encapsulated PostScript (*.eps);;Graphics Interchange Format (*.gif)"
680 ";;Scalable Vector Graphic (*.svg);;Windows Bitmap (*.bmp);;ZSoft PC Painter Image (*.pcx)"
681 ";;Enhanced Metafile (*.emf);;Tagged Image File Format (*.tif)"));
682 } else {
683 suffix = settings.value(QSL("studio/default_suffix"), QSL("png")).toString();
684 save_dialog.setNameFilter(tr(
685 "Portable Network Graphic (*.png);;Encapsulated PostScript (*.eps);;Graphics Interchange Format (*.gif)"
686 ";;Scalable Vector Graphic (*.svg);;Windows Bitmap (*.bmp);;ZSoft PC Painter Image (*.pcx)"
687 ";;Enhanced Metafile (*.emf);;Tagged Image File Format (*.tif)"));
688 suffixes << QSL("png");
689 }
690
691 if (QString::compare(suffix, QSL("png"), Qt::CaseInsensitive) == 0)
692 save_dialog.selectNameFilter(tr("Portable Network Graphic (*.png)"));
693 else if (QString::compare(suffix, QSL("eps"), Qt::CaseInsensitive) == 0)
694 save_dialog.selectNameFilter(tr("Encapsulated PostScript (*.eps)"));
695 else if (QString::compare(suffix, QSL("gif"), Qt::CaseInsensitive) == 0)
696 save_dialog.selectNameFilter(tr("Graphics Interchange Format (*.gif)"));
697 else if (QString::compare(suffix, QSL("svg"), Qt::CaseInsensitive) == 0)
698 save_dialog.selectNameFilter(tr("Scalable Vector Graphic (*.svg)"));
699 else if (QString::compare(suffix, QSL("bmp"), Qt::CaseInsensitive) == 0)
700 save_dialog.selectNameFilter(tr("Windows Bitmap (*.bmp)"));
701 else if (QString::compare(suffix, QSL("pcx"), Qt::CaseInsensitive) == 0)
702 save_dialog.selectNameFilter(tr("ZSoft PC Painter Image (*.pcx)"));
703 else if (QString::compare(suffix, QSL("emf"), Qt::CaseInsensitive) == 0)
704 save_dialog.selectNameFilter(tr("Enhanced Metafile (*.emf)"));
705 else if (QString::compare(suffix, QSL("tif"), Qt::CaseInsensitive) == 0)
706 save_dialog.selectNameFilter(tr("Tagged Image File Format (*.tif)"));
707
708 if (save_dialog.exec()) {
709 pathname = save_dialog.selectedFiles().at(0);
710 if ((pathname.lastIndexOf('.') == -1) || (pathname.lastIndexOf('.') < (pathname.length() - 5))) {
711 suffix = save_dialog.selectedNameFilter();
712 suffix = suffix.mid((suffix.lastIndexOf('.') + 1), 3);
713 pathname.append('.');
714 pathname.append(suffix);
715 } else {
716 suffix = pathname.right(pathname.length() - (pathname.lastIndexOf('.') + 1));
717 if (!suffixes.contains(suffix, Qt::CaseInsensitive)) {
718 /*: %1 is suffix of filename */
719 QMessageBox::critical(this, tr("Save Error"), tr("Unknown output format \"%1\"").arg(suffix));
720 return false;
721 }
722 }
723 } else {
724 return false;
725 }
726
727 if (m_bc.bc.save_to_file(pathname) == false) {
728 if (m_bc.bc.getError() >= ZINT_ERROR) {
729 QMessageBox::critical(this, tr("Save Error"), m_bc.bc.error_message());
730 return false;
731 }
732 QMessageBox::warning(this, tr("Save Warning"), m_bc.bc.error_message());
733 }
734
735 QString nativePathname = QDir::toNativeSeparators(pathname);
736 int lastSeparator = nativePathname.lastIndexOf(QDir::separator());
737 QString dirname = nativePathname.mid(0, lastSeparator);
738 if (dirname.isEmpty()) {
739 /*: %1 is path saved to */
740 statusBar->showMessage(tr("Saved as \"%1\"").arg(nativePathname), 0 /*No timeout*/);
741 } else {
742 QString filename = nativePathname.right(nativePathname.length() - (lastSeparator + 1));
743 /*: %1 is base filename saved to, %2 is directory saved in */
744 statusBar->showMessage(tr("Saved as \"%1\" in \"%2\"").arg(filename, dirname), 0 /*No timeout*/);
745 }
746
747 settings.setValue(QSL("studio/default_dir"), dirname);
748 settings.setValue(QSL("studio/default_suffix"), suffix);
749 return true;
750 }
751
752 void MainWindow::factory_reset()
753 {
754 QMessageBox msgBox(QMessageBox::Question, tr("Factory Reset"),
755 tr("This will clear all saved data and reset all settings for all symbologies to defaults."),
756 QMessageBox::Yes | QMessageBox::No, this);
757 msgBox.setInformativeText(tr("Do you wish to continue?"));
758 msgBox.setDefaultButton(QMessageBox::Yes);
759 if (msgBox.exec() == QMessageBox::No) {
760 return;
761 }
762
763 QSettings settings;
764 #if QT_VERSION < 0x60000
765 settings.setIniCodec("UTF-8");
766 #endif
767 settings.clear();
768
769 int symbology = bstyle_items[bstyle->currentIndex()].symbology;
770
771 load_settings(settings);
772
773 load_sub_settings(settings, symbology);
774
775 settings.sync();
776
777 setColorTxtBtn(m_fgstr, txt_fgcolor, fgcolor);
778 setColorTxtBtn(m_bgstr, txt_bgcolor, bgcolor);
779
780 m_previewBgColor = QColor(0xF4, 0xF4, 0xF4);
781 m_bc.setColor(m_previewBgColor);
782
783 txtData->setFocus(Qt::OtherFocusReason);
784 update_preview();
785 }
786
787 void MainWindow::about()
788 {
789 QString zint_version = get_zint_version();
790 QSettings settings;
791
792 QMessageBox::about(this, tr("About Zint"),
793 /*: %1 is Zint version, %2 is Qt version, %3 is QSettings file/registry path */
794 tr(
795 #ifdef Q_OS_MACOS
796 "<style>h2, p { font-size:11px; font-weight:normal; }</style>"
797 #endif
798 "<h2>Zint Barcode Studio %1</h2>"
799 "<p>A free barcode generator</p>"
800 "<p>Instruction manual is available at the project homepage:<br>"
801 "<a href=\"http://www.zint.org.uk\">http://www.zint.org.uk</a>.</p>"
802 "<p>Copyright &copy; 2006-2024 Robin Stuart and others.<br>"
803 "Qt backend by BogDan Vatra.<br>"
804 "Released under GNU GPL 3.0 or later.</p>"
805 "<p>Qt version %2<br>%3</p>"
806 "<p>\"Mailmark\" is a Registered Trademark of Royal Mail.<br>"
807 "\"QR Code\" is a Registered Trademark of Denso Corp.<br>"
808 "\"Telepen\" is a Registered Trademark of SB Electronics.</p>"
809 "<p>With thanks to Harald Oehlmann, Norbert Szab&oacute;, Robert Elliott, Milton Neal, "
810 "Git Lost, Alonso Schaich, Andre Maute and many others at "
811 "<a href=\"https://sourceforge.net/projects/zint/\">SourceForge</a>.</p>"
812 ).arg(zint_version, QT_VERSION_STR, settings.fileName()));
813 }
814
815 void MainWindow::help()
816 {
817 QDesktopServices::openUrl(QSL("https://zint.org.uk/manual")); // TODO: manual.md
818 }
819
820 void MainWindow::preview_bg()
821 {
822 QColorDialog color_dialog(nullptr /*parent*/);
823 color_dialog.setWindowTitle(tr("Set preview background colour"));
824 color_dialog.setOptions(QColorDialog::DontUseNativeDialog);
825 color_dialog.setCurrentColor(m_previewBgColor);
826 color_dialog.restoreGeometry(m_previewbgcolor_geometry);
827 connect(&color_dialog, SIGNAL(currentColorChanged(QColor)), this, SLOT(previewbgcolor_changed(QColor)));
828 if (color_dialog.exec() && color_dialog.selectedColor().isValid()) {
829 m_previewBgColor = color_dialog.selectedColor();
830 }
831 m_previewbgcolor_geometry = color_dialog.saveGeometry();
832 disconnect(&color_dialog, SIGNAL(currentColorChanged(QColor)), this, SLOT(previewbgcolor_changed(QColor)));
833
834 m_bc.setColor(m_previewBgColor);
835 update_preview();
836 }
837
838 void MainWindow::previewbgcolor_changed(const QColor& color)
839 {
840 if (color.isValid()) {
841 m_bc.setColor(color);
842 update_preview();
843 }
844 }
845
846 QLineEdit *MainWindow::get_seg_textbox(int seg_no)
847 {
848 static QLineEdit *textboxes[4] = {
849 txtData, txtDataSeg1, txtDataSeg2, txtDataSeg3
850 };
851 return textboxes[seg_no];
852 }
853
854 QComboBox *MainWindow::get_seg_eci(int seg_no)
855 {
856 static QComboBox *ecis[4] = {
857 cmbECI, cmbECISeg1, cmbECISeg2, cmbECISeg3
858 };
859 return ecis[seg_no];
860 }
861
862 void MainWindow::clear_data()
863 {
864 if (clear_data_eci_seg(0)) {
865 update_preview();
866 }
867 }
868
869 void MainWindow::clear_data_seg1()
870 {
871 if (clear_data_eci_seg(1)) {
872 update_preview();
873 }
874 }
875
876 void MainWindow::clear_data_seg2()
877 {
878 if (clear_data_eci_seg(2)) {
879 update_preview();
880 }
881 }
882
883 void MainWindow::clear_data_seg3()
884 {
885 if (clear_data_eci_seg(3)) {
886 update_preview();
887 }
888 }
889
890 bool MainWindow::clear_data_eci_seg(int seg_no)
891 {
892 QLineEdit *txt = get_seg_textbox(seg_no);
893 QComboBox *cmb = get_seg_eci(seg_no);
894 if (!txt->text().isEmpty() || cmb->currentIndex() != 0) {
895 txt->clear();
896 cmb->setCurrentIndex(0);
897 txt->setFocus(Qt::OtherFocusReason);
898 return true;
899 }
900 return false;
901 }
902
903 void MainWindow::clear_composite()
904 {
905 if (!txtComposite->toPlainText().isEmpty()) {
906 txtComposite->clear();
907 update_preview();
908 }
909 }
910
911 void MainWindow::open_data_dialog_seg(const int seg_no)
912 {
913 if (seg_no < 0 || seg_no > 3) {
914 return;
915 }
916 QLineEdit *seg_textbox = get_seg_textbox(seg_no);
917 QString originalText = seg_textbox->text();
918 bool originalChkEscape = chkEscape->isChecked();
919 DataWindow dlg(originalText, originalChkEscape, seg_no);
920
921 #ifdef Q_OS_MACOS
922 mac_hack_statusBars(&dlg);
923 #endif
924
925 connect(&dlg, SIGNAL(dataChanged(QString,bool,int)), this, SLOT(on_dataChanged(QString,bool,int)));
926 (void) dlg.exec();
927 if (dlg.Valid) {
928 const bool updated = originalText != dlg.DataOutput;
929 seg_textbox->setText(dlg.DataOutput);
930 if (updated) {
931 static const QString updatedEscTxts[4] = {
932 tr("Set \"Parse Escapes\", updated data"),
933 tr("Set \"Parse Escapes\", updated segment 1 data"),
934 tr("Set \"Parse Escapes\", updated segment 2 data"),
935 tr("Set \"Parse Escapes\", updated segment 3 data"),
936 };
937 static const QString updatedTxts[4] = {
938 tr("Updated data"),
939 tr("Updated segment 1 data"),
940 tr("Updated segment 2 data"),
941 tr("Updated segment 3 data"),
942 };
943 if (dlg.Escaped && !originalChkEscape) {
944 chkEscape->setChecked(true);
945 statusBar->showMessage(updatedEscTxts[seg_no], tempMessageTimeout);
946 } else {
947 chkEscape->setChecked(originalChkEscape);
948 statusBar->showMessage(updatedTxts[seg_no], tempMessageTimeout);
949 }
950 }
951 } else {
952 seg_textbox->setText(originalText); // Restore
953 chkEscape->setChecked(originalChkEscape);
954 }
955 disconnect(&dlg, SIGNAL(dataChanged(QString,bool,int)), this, SLOT(on_dataChanged(QString,bool,int)));
956 }
957
958 void MainWindow::open_data_dialog()
959 {
960 open_data_dialog_seg(0);
961 }
962
963 void MainWindow::open_data_dialog_seg1()
964 {
965 open_data_dialog_seg(1);
966 }
967
968 void MainWindow::open_data_dialog_seg2()
969 {
970 open_data_dialog_seg(2);
971 }
972
973 void MainWindow::open_data_dialog_seg3()
974 {
975 open_data_dialog_seg(3);
976 }
977
978 void MainWindow::open_sequence_dialog()
979 {
980 SequenceWindow dlg(&m_bc);
981 (void) dlg.exec();
982 #ifdef _WIN32
983 // Windows causes BarcodeItem to paint on closing dialog so need to re-paint with our (non-Export) values
984 update_preview();
985 #endif
986 }
987
988 void MainWindow::zap()
989 {
990 QSettings settings;
991 #if QT_VERSION < 0x60000
992 settings.setIniCodec("UTF-8");
993 #endif
994
995 int symbology = bstyle_items[bstyle->currentIndex()].symbology;
996 QString name = get_setting_name(symbology);
997 settings.remove(QSL("studio/bc/%1").arg(name));
998 settings.remove(QSL("studio/data"));
999 settings.remove(QSL("studio/eci"));
1000
1001 load_settings(settings);
1002
1003 m_xdimdpVars.x_dim = 0.0f;
1004 m_xdimdpVars.x_dim_units = 0;
1005 m_xdimdpVars.set = 0;
1006
1007 load_sub_settings(settings, symbology);
1008
1009 setColorTxtBtn(m_fgstr, txt_fgcolor, fgcolor);
1010 setColorTxtBtn(m_bgstr, txt_bgcolor, bgcolor);
1011
1012 txtData->setFocus(Qt::OtherFocusReason);
1013 update_preview();
1014 }
1015
1016 void MainWindow::on_dataChanged(const QString& text, bool escaped, int seg_no)
1017 {
1018 QLineEdit *seg_textbox = get_seg_textbox(seg_no);
1019
1020 chkEscape->setChecked(escaped);
1021 seg_textbox->setText(text);
1022 update_preview();
1023 }
1024
1025 void MainWindow::on_scaleChanged(double scale)
1026 {
1027 spnScale->setValue(scale);
1028 size_msg_ui_set();
1029 }
1030
1031 void MainWindow::open_cli_dialog()
1032 {
1033 CLIWindow dlg(&m_bc, chkAutoHeight->isEnabled() && chkAutoHeight->isChecked(),
1034 m_spnHeightPerRow && m_spnHeightPerRow->isEnabled() ? m_spnHeightPerRow->value() : 0.0,
1035 &m_xdimdpVars);
1036
1037 #ifdef Q_OS_MACOS
1038 mac_hack_statusBars(&dlg);
1039 #endif
1040
1041 (void) dlg.exec();
1042 }
1043
1044 void MainWindow::open_scale_dialog()
1045 {
1046 double originalScale = spnScale->value();
1047 QString originalSizeMsg = lblSizeMsg->text();
1048 ScaleWindow dlg(&m_bc, &m_xdimdpVars, originalScale);
1049 m_scaleWindow = &dlg;
1050 connect(&dlg, SIGNAL(scaleChanged(double)), this, SLOT(on_scaleChanged(double)));
1051 (void) dlg.exec();
1052 disconnect(&dlg, SIGNAL(scaleChanged(double)), this, SLOT(on_scaleChanged(double)));
1053 if (dlg.Valid) {
1054 m_xdimdpVars = dlg.m_vars;
1055 update_preview();
1056 } else { // Restore
1057 spnScale->setValue(originalScale);
1058 lblSizeMsg->setText(originalSizeMsg);
1059 }
1060 m_scaleWindow = nullptr;
1061 }
1062
1063 void MainWindow::fgcolor_clicked()
1064 {
1065 color_clicked(m_fgstr, txt_fgcolor, fgcolor, tr("Set foreground colour"), m_fgcolor_geometry,
1066 SLOT(fgcolor_changed(const QColor&)));
1067 }
1068
1069 void MainWindow::bgcolor_clicked()
1070 {
1071 color_clicked(m_bgstr, txt_bgcolor, bgcolor, tr("Set background colour"), m_bgcolor_geometry,
1072 SLOT(bgcolor_changed(const QColor&)));
1073 }
1074
1075 void MainWindow::color_clicked(QString &colorStr, QLineEdit *txt, QToolButton *btn, const QString& title,
1076 QByteArray& geometry, const char *color_changed)
1077 {
1078 QString original = colorStr;
1079
1080 QColorDialog color_dialog(nullptr /*parent*/);
1081 color_dialog.setWindowTitle(title);
1082 color_dialog.setOptions(QColorDialog::DontUseNativeDialog | QColorDialog::ShowAlphaChannel);
1083 color_dialog.setCurrentColor(str_to_qcolor(colorStr));
1084 color_dialog.restoreGeometry(geometry);
1085 connect(&color_dialog, SIGNAL(currentColorChanged(QColor)), this, color_changed);
1086
1087 if (color_dialog.exec() && color_dialog.selectedColor().isValid()) {
1088 colorStr = qcolor_to_str(color_dialog.selectedColor());
1089 } else {
1090 colorStr = original;
1091 }
1092 geometry = color_dialog.saveGeometry();
1093 disconnect(&color_dialog, SIGNAL(currentColorChanged(QColor)), this, color_changed);
1094
1095 setColorTxtBtn(colorStr, txt, btn);
1096 update_preview();
1097 }
1098
1099 void MainWindow::fgcolor_changed(const QColor& color)
1100 {
1101 if (color.isValid()) {
1102 m_fgstr = qcolor_to_str(color);
1103 setColorTxtBtn(m_fgstr, txt_fgcolor, fgcolor);
1104 update_preview();
1105 }
1106 }
1107
1108 void MainWindow::bgcolor_changed(const QColor& color)
1109 {
1110 if (color.isValid()) {
1111 m_bgstr = qcolor_to_str(color);
1112 setColorTxtBtn(m_bgstr, txt_bgcolor, bgcolor);
1113 update_preview();
1114 }
1115 }
1116
1117 void MainWindow::fgcolor_edited()
1118 {
1119 color_edited(m_fgstr, txt_fgcolor, fgcolor);
1120 }
1121
1122 void MainWindow::bgcolor_edited()
1123 {
1124 color_edited(m_bgstr, txt_bgcolor, bgcolor);
1125 }
1126
1127 void MainWindow::color_edited(QString &colorStr, QLineEdit *txt, QToolButton *btn)
1128 {
1129 QString new_str = txt->text().trimmed();
1130 if (new_str.indexOf(*colorRE) != 0) {
1131 return;
1132 }
1133 colorStr = new_str;
1134 setColorTxtBtn(colorStr, txt, btn);
1135 update_preview();
1136 }
1137
1138 void MainWindow::autoheight_ui_set()
1139 {
1140 bool enabled = chkAutoHeight->isEnabled() && !chkAutoHeight->isChecked();
1141 lblHeight->setEnabled(enabled);
1142 heightb->setEnabled(enabled);
1143
1144 if (m_lblHeightPerRow && m_spnHeightPerRow) {
1145 m_lblHeightPerRow->setEnabled(enabled);
1146 m_spnHeightPerRow->setEnabled(enabled);
1147 if (enabled && m_spnHeightPerRow->value()) {
1148 lblHeight->setEnabled(!enabled);
1149 heightb->setEnabled(!enabled);
1150 statusBar->showMessage(tr("Using \"Row Height\""), 0 /*No timeout*/);
1151 } else {
1152 statusBar->clearMessage();
1153 }
1154 if (m_btnHeightPerRowDisable) {
1155 m_btnHeightPerRowDisable->setEnabled(enabled && m_spnHeightPerRow->value());
1156 }
1157 if (m_btnHeightPerRowDefault) {
1158 if (enabled && m_spnHeightPerRow->value() == get_height_per_row_default()) {
1159 enabled = false;
1160 }
1161 m_btnHeightPerRowDefault->setEnabled(enabled);
1162 }
1163 }
1164 }
1165
1166 void MainWindow::HRTShow_ui_set()
1167 {
1168 bool enabled = chkHRTShow->isEnabled() && chkHRTShow->isChecked();
1169 lblFontSetting->setEnabled(enabled);
1170 cmbFontSetting->setEnabled(enabled);
1171 lblTextGap->setEnabled(enabled);
1172 spnTextGap->setEnabled(enabled);
1173 chkEmbedVectorFont->setEnabled(enabled);
1174 text_gap_ui_set();
1175 upcean_no_quiet_zones_ui_set();
1176 upcae_no_quiet_zones_ui_set();
1177 }
1178
1179 void MainWindow::text_gap_ui_set()
1180 {
1181 bool hrtEnabled = chkHRTShow->isEnabled() && chkHRTShow->isChecked();
1182 btnClearTextGap->setEnabled(hrtEnabled && spnTextGap->value() != 1.0);
1183 }
1184
1185 void MainWindow::dotty_ui_set()
1186 {
1187 int symbology = bstyle_items[bstyle->currentIndex()].symbology;
1188
1189 if (symbology == BARCODE_DOTCODE) {
1190 chkDotty->setEnabled(false);
1191 lblDotSize->setEnabled(true);
1192 spnDotSize->setEnabled(true);
1193 } else {
1194 bool enabled = chkDotty->isEnabled() && chkDotty->isChecked();
1195 lblDotSize->setEnabled(enabled);
1196 spnDotSize->setEnabled(enabled);
1197 }
1198 }
1199
1200 void MainWindow::codeone_ui_set()
1201 {
1202 int symbology = bstyle_items[bstyle->currentIndex()].symbology;
1203 if (symbology != BARCODE_CODEONE)
1204 return;
1205
1206 QGroupBox *groupBox = m_optionWidget->findChild<QGroupBox*>(QSL("groupBoxC1StructApp"));
1207 if (groupBox) {
1208 bool enabled = get_cmb_index(QSL("cmbC1Size")) != 9; // Not Version S
1209 groupBox->setEnabled(enabled);
1210 }
1211 }
1212
1213 void MainWindow::upcean_no_quiet_zones_ui_set()
1214 {
1215 int symbology = bstyle_items[bstyle->currentIndex()].symbology;
1216 if (!m_bc.bc.isEANUPC(symbology) || symbology == BARCODE_UPCA || symbology == BARCODE_UPCA_CHK
1217 || symbology == BARCODE_UPCA_CC)
1218 return;
1219
1220 bool showHRT = chkHRTShow->isEnabled() && chkHRTShow->isChecked();
1221 QCheckBox *noQZs, *guardWS;
1222 noQZs = m_optionWidget ? m_optionWidget->findChild<QCheckBox*>(QSL("chkUPCEANNoQuietZones")) : nullptr;
1223 guardWS = m_optionWidget ? m_optionWidget->findChild<QCheckBox*>(QSL("chkUPCEANGuardWhitespace")) : nullptr;
1224
1225 if (noQZs && guardWS) {
1226 guardWS->setEnabled(!noQZs->isChecked() && showHRT);
1227 }
1228 }
1229
1230 void MainWindow::upcae_no_quiet_zones_ui_set()
1231 {
1232 const int symbology = bstyle_items[bstyle->currentIndex()].symbology;
1233 const bool is_upca = symbology == BARCODE_UPCA || symbology == BARCODE_UPCA_CHK || symbology == BARCODE_UPCA_CC;
1234 const bool is_upce = symbology == BARCODE_UPCE || symbology == BARCODE_UPCE_CHK || symbology == BARCODE_UPCE_CC;
1235 if (!is_upca && !is_upce)
1236 return;
1237
1238 bool showHRT = chkHRTShow->isEnabled() && chkHRTShow->isChecked();
1239 QCheckBox *noQZs, *guardWS;
1240 if (is_upca) {
1241 noQZs = m_optionWidget ? m_optionWidget->findChild<QCheckBox*>(QSL("chkUPCANoQuietZones")) : nullptr;
1242 guardWS = m_optionWidget ? m_optionWidget->findChild<QCheckBox*>(QSL("chkUPCAGuardWhitespace")) : nullptr;
1243 } else {
1244 noQZs = m_optionWidget ? m_optionWidget->findChild<QCheckBox*>(QSL("chkUPCEANNoQuietZones")) : nullptr;
1245 guardWS = m_optionWidget ? m_optionWidget->findChild<QCheckBox*>(QSL("chkUPCEANGuardWhitespace")) : nullptr;
1246 }
1247
1248 if (noQZs && guardWS) {
1249 if (have_addon()) {
1250 noQZs->setEnabled(true);
1251 guardWS->setEnabled(!noQZs->isChecked() && showHRT);
1252 } else {
1253 noQZs->setEnabled(!showHRT);
1254 guardWS->setEnabled(false);
1255 }
1256 }
1257 }
1258
1259 void MainWindow::structapp_ui_set()
1260 {
1261 int symbology = bstyle_items[bstyle->currentIndex()].symbology;
1262 QString name;
1263 bool enabled = false;
1264 QWidget *widgetCount = nullptr, *widgetIndex = nullptr;
1265 QLabel *lblID2 = nullptr;
1266 QWidget *widgetID = nullptr, *widgetID2 = nullptr;
1267
1268 if (symbology == BARCODE_AZTEC) {
1269 name = QSL("Aztec");
1270 widgetID = get_widget(QSL("txt") + name + QSL("StructAppID"));
1271 } else if (symbology == BARCODE_CODEONE) {
1272 name = QSL("C1");
1273 QSpinBox *spnCount = m_optionWidget->findChild<QSpinBox*>(QSL("spn") + name + QSL("StructAppCount"));
1274 enabled = spnCount ? spnCount->value() > 1 : false;
1275 widgetCount = spnCount;
1276 widgetIndex = get_widget(QSL("spn") + name + QSL("StructAppIndex"));
1277 } else if (symbology == BARCODE_DATAMATRIX) {
1278 name = QSL("DM");
1279 widgetID = get_widget(QSL("spn") + name + QSL("StructAppID"));
1280 widgetID2 = get_widget(QSL("spn") + name + QSL("StructAppID2"));
1281 } else if (symbology == BARCODE_DOTCODE) {
1282 name = QSL("Dot");
1283 } else if (symbology == BARCODE_MAXICODE) {
1284 name = QSL("Maxi");
1285 } else if (symbology == BARCODE_PDF417 || symbology == BARCODE_MICROPDF417) {
1286 name = symbology == BARCODE_PDF417 ? QSL("PDF") : QSL("MPDF");
1287 QSpinBox *spnCount = m_optionWidget->findChild<QSpinBox*>(QSL("spn") + name + QSL("StructAppCount"));
1288 enabled = spnCount ? spnCount->value() > 1 : false;
1289 widgetCount = spnCount;
1290 widgetIndex = get_widget(QSL("spn") + name + QSL("StructAppIndex"));
1291 widgetID = get_widget(QSL("txt") + name + QSL("StructAppID"));
1292 } else if (symbology == BARCODE_QRCODE) {
1293 name = QSL("QR");
1294 widgetID = get_widget(QSL("spn") + name + QSL("StructAppID"));
1295 } else if (symbology == BARCODE_GRIDMATRIX) {
1296 name = QSL("Grid");
1297 widgetID = get_widget(QSL("spn") + name + QSL("StructAppID"));
1298 } else if (symbology == BARCODE_ULTRA) {
1299 name = QSL("Ultra");
1300 widgetID = get_widget(QSL("spn") + name + QSL("StructAppID"));
1301 }
1302 if (!name.isEmpty()) {
1303 QLabel *lblIndex = m_optionWidget->findChild<QLabel*>(QSL("lbl") + name + QSL("StructAppIndex"));
1304 if (!widgetCount) {
1305 QComboBox *cmbCount = m_optionWidget->findChild<QComboBox*>(QSL("cmb") + name + QSL("StructAppCount"));
1306 enabled = cmbCount ? cmbCount->currentIndex() != 0 : false;
1307 widgetCount = cmbCount;
1308 }
1309 if (!widgetIndex) {
1310 widgetIndex = get_widget(QSL("cmb") + name + QSL("StructAppIndex"));
1311 }
1312 if (lblIndex && widgetCount && widgetIndex) {
1313 lblIndex->setEnabled(enabled);
1314 widgetIndex->setEnabled(enabled);
1315 QLabel *lblID = m_optionWidget->findChild<QLabel*>(QSL("lbl") + name + QSL("StructAppID"));
1316 if (lblID) {
1317 lblID->setEnabled(enabled);
1318 if (lblID2) {
1319 lblID2->setEnabled(enabled);
1320 }
1321 }
1322 if (widgetID) {
1323 widgetID->setEnabled(enabled);
1324 if (widgetID2) {
1325 widgetID2->setEnabled(enabled);
1326 }
1327 }
1328 }
1329 }
1330 }
1331
1332 void MainWindow::clear_text_gap()
1333 {
1334 spnTextGap->setValue(1.0);
1335 spnTextGap->setFocus();
1336 update_preview();
1337 }
1338
1339 void MainWindow::on_encoded()
1340 {
1341 // Protect against encode in Sequence Export popup dialog
1342 QWidget *activeModalWidget = QApplication::activeModalWidget();
1343 if (activeModalWidget != nullptr && activeModalWidget->objectName() == "ExportDialog") {
1344 return;
1345 }
1346 enableActions();
1347 errtxtBar_set();
1348
1349 if (!chkAutoHeight->isEnabled() || chkAutoHeight->isChecked() || !heightb->isEnabled()) {
1350 /* setValue() rounds up/down to precision (decimals 3), we want round up only */
1351 float height = (float) (ceil(m_bc.bc.height() * 1000.0f) / 1000.0f);
1352 heightb->setValue(height); // This can cause a double-encode unfortunately
1353 }
1354 size_msg_ui_set();
1355
1356 if (m_optionWidget) {
1357 automatic_info_set();
1358 }
1359 }
1360
1361 void MainWindow::on_errored()
1362 {
1363 // Protect against error in Sequence Export popup dialog
1364 QWidget *activeModalWidget = QApplication::activeModalWidget();
1365 if (activeModalWidget != nullptr && activeModalWidget->objectName() == "ExportDialog") {
1366 return;
1367 }
1368 enableActions();
1369 errtxtBar_set();
1370 size_msg_ui_set();
1371 if (m_optionWidget) {
1372 automatic_info_set();
1373 }
1374 }
1375
1376 void MainWindow::filter_symbologies()
1377 {
1378 // `simplified()` trims and reduces inner whitespace to a single space - nice!
1379 QString filter = filter_bstyle->text().simplified();
1380 QListView *lview = qobject_cast<QListView *>(bstyle->view());
1381 QStandardItemModel *model = qobject_cast<QStandardItemModel*>(bstyle->model());
1382 QStandardItem *item;
1383
1384 if (!lview || !model) {
1385 return;
1386 }
1387
1388 /* QString::split() only introduced Qt 5.14, so too new for us to use */
1389 QStringList filter_list;
1390 if (!filter.isEmpty()) {
1391 int i, j;
1392 for (i = 0; (j = filter.indexOf(' ', i)) != -1; i = j + 1) {
1393 filter_list << filter.mid(i, j - i);
1394 }
1395 filter_list << filter.mid(i);
1396 }
1397 int filter_cnt = filter_list.size();
1398 int cnt = (int) (sizeof(bstyle_items) / sizeof(bstyle_items[0]));
1399
1400 if (filter_cnt) {
1401 for (int i = 0; i < cnt; i++) {
1402 bool hidden = lview->isRowHidden(i);
1403 bool hide = true;
1404 for (int j = 0; j < filter_cnt; j++) {
1405 if (bstyle->itemText(i).contains(filter_list[j], Qt::CaseInsensitive)) {
1406 hide = false;
1407 break;
1408 }
1409 }
1410 if ((hide && !hidden) || (!hide && hidden)) {
1411 // https://stackoverflow.com/questions/25172220
1412 // /how-to-hide-qcombobox-items-instead-of-clearing-them-out
1413 item = model->item(i);
1414 item->setFlags(hide ? item->flags() & ~Qt::ItemIsEnabled : item->flags() | Qt::ItemIsEnabled);
1415 lview->setRowHidden(i, hide);
1416 }
1417 }
1418 } else {
1419 for (int i = 0; i < cnt; i++) {
1420 if (lview->isRowHidden(i)) {
1421 item = model->item(i);
1422 item->setFlags(item->flags() | Qt::ItemIsEnabled);
1423 lview->setRowHidden(i, false);
1424 }
1425 }
1426 }
1427 }
1428
1429 void MainWindow::size_msg_ui_set()
1430 {
1431 if (m_bc.bc.getError() < ZINT_ERROR) {
1432 float scale = (float) spnScale->value();
1433 struct Zint::QZintXdimDpVars *vars = m_scaleWindow ? &m_scaleWindow->m_vars : &m_xdimdpVars;
1434 if (vars->x_dim == 0.0) {
1435 vars->x_dim_units = 0;
1436 vars->x_dim = std::min(m_bc.bc.getXdimDpFromScale(scale, get_dpmm(vars), getFileType(vars)), 10.0f);
1437 } else {
1438 // Scale trumps stored X-dimension
1439 double x_dim_mm = vars->x_dim_units == 1 ? vars->x_dim * 25.4 : vars->x_dim;
1440 if (m_bc.bc.getScaleFromXdimDp((float) x_dim_mm, get_dpmm(vars), getFileType(vars)) != scale) {
1441 x_dim_mm = std::min(m_bc.bc.getXdimDpFromScale(scale, get_dpmm(vars), getFileType(vars)), 10.0f);
1442 vars->x_dim = vars->x_dim_units == 1 ? x_dim_mm / 25.4 : x_dim_mm;
1443 }
1444 }
1445 float width_x_dim, height_x_dim;
1446 if (m_bc.bc.getWidthHeightXdim((float) vars->x_dim, width_x_dim, height_x_dim)) {
1447 const char *fmt = vars->x_dim_units == 1 ? "%.3f x %.3f in @ %d %s (%s)" : "%.2f x %.2f mm @ %d %s (%s)";
1448 const char *resolution_units_str = vars->resolution_units == 1 ? "dpi" : "dpmm";
1449 lblSizeMsg->setText(QString::asprintf(fmt, width_x_dim, height_x_dim, vars->resolution,
1450 resolution_units_str, getFileType(vars, true /*msg*/)));
1451 } else {
1452 lblSizeMsg->clear();
1453 }
1454 } else {
1455 lblSizeMsg->clear();
1456 }
1457 if (m_scaleWindow) {
1458 m_scaleWindow->size_msg_ui_set();
1459 }
1460 }
1461
1462 void MainWindow::change_cmyk()
1463 {
1464 /* This value is only used when printing (saving) to file */
1465 m_bc.bc.setCMYK(chkCMYK->isChecked());
1466 }
1467
1468 void MainWindow::quit_now()
1469 {
1470 close();
1471 }
1472
1473 void MainWindow::menu()
1474 {
1475 QSize size = m_menu->sizeHint();
1476 m_menu->exec(btnMenu->mapToGlobal(QPoint(0, -size.height())));
1477 }
1478
1479 void MainWindow::copy_to_clipboard_bmp()
1480 {
1481 copy_to_clipboard(QSL(".zint.bmp"), QSL("BMP"));
1482 }
1483
1484 void MainWindow::copy_to_clipboard_emf()
1485 {
1486 copy_to_clipboard(QSL(".zint.emf"), QSL("EMF"), "image/x-emf");
1487 }
1488
1489 void MainWindow::copy_to_clipboard_eps()
1490 {
1491 // TODO: try other possibles application/eps, application/x-eps, image/eps, image/x-eps
1492 copy_to_clipboard(QSL(".zint.eps"), QSL("EPS"), "application/postscript");
1493 }
1494
1495 void MainWindow::copy_to_clipboard_gif()
1496 {
1497 copy_to_clipboard(QSL(".zint.gif"), QSL("GIF"));
1498 }
1499
1500 void MainWindow::copy_to_clipboard_pcx()
1501 {
1502 // TODO: try other mime types in various apps
1503 copy_to_clipboard(QSL(".zint.pcx"), QSL("PCX"), "image/x-pcx");
1504 }
1505
1506 void MainWindow::copy_to_clipboard_png()
1507 {
1508 if (!m_bc.bc.noPng()) {
1509 copy_to_clipboard(QSL(".zint.png"), QSL("PNG"));
1510 }
1511 }
1512
1513 void MainWindow::copy_to_clipboard_svg()
1514 {
1515 copy_to_clipboard(QSL(".zint.svg"), QSL("SVG"));
1516 }
1517
1518 void MainWindow::copy_to_clipboard_tif()
1519 {
1520 copy_to_clipboard(QSL(".zint.tif"), QSL("TIF"));
1521 }
1522
1523 void MainWindow::copy_to_clipboard_errtxt()
1524 {
1525 if (m_bc.bc.hasErrors()) {
1526 QClipboard *clipboard = QGuiApplication::clipboard();
1527 QMimeData *mdata = new QMimeData;
1528 mdata->setText(m_bc.bc.lastError());
1529 clipboard->setMimeData(mdata, QClipboard::Clipboard);
1530 statusBar->showMessage(tr("Copied message to clipboard"), 0 /*No timeout*/);
1531 }
1532 }
1533
1534 void MainWindow::height_per_row_disable()
1535 {
1536 if (m_spnHeightPerRow) {
1537 m_spnHeightPerRow->setValue(0.0);
1538 }
1539 }
1540
1541 double MainWindow::get_height_per_row_default()
1542 {
1543 const QString &name = m_btnHeightPerRowDefault->objectName();
1544 double val = 0.0;
1545 if (name == QSL("btnPDFHeightPerRowDefault")) {
1546 val = 3.0;
1547 } else if (name == QSL("btnMPDFHeightPerRowDefault")) {
1548 val = 2.0;
1549 } else if (name == QSL("btnC16kHeightPerRowDefault")) {
1550 if (chkCompliantHeight->isEnabled() && chkCompliantHeight->isChecked()) {
1551 const int rows = m_bc.bc.encodedRows();
1552 val = 10.0 + (double)((rows - 1) * (get_cmb_index(QSL("cmbC16kRowSepHeight")) + 1)) / rows;
1553 } else {
1554 val = 10.0;
1555 }
1556 } else if (name == QSL("btnCbfHeightPerRowDefault")) {
1557 // Depends on no. of data cols
1558 const int cols = (m_bc.bc.encodedWidth() - 57) / 11; // 57 = 4 * 11 (start/subset/checks) + 13 (stop char)
1559 val = 0.55 * cols + 3;
1560 if (val < 10.0) {
1561 val = 10.0;
1562 }
1563 } else if (name == QSL("btnC49HeightPerRowDefault")) {
1564 if (chkCompliantHeight->isEnabled() && chkCompliantHeight->isChecked()) {
1565 const int rows = m_bc.bc.encodedRows();
1566 val = 10.0 + (double)((rows - 1) * (get_cmb_index(QSL("cmbC49RowSepHeight")) + 1)) / rows;
1567 } else {
1568 val = 10.0;
1569 }
1570 } else if (name == QSL("btnDBESHeightPerRowDefault")) {
1571 val = 34.0;
1572 }
1573 return val;
1574 }
1575
1576 void MainWindow::height_per_row_default()
1577 {
1578 if (m_spnHeightPerRow && m_btnHeightPerRowDefault) {
1579 double val = get_height_per_row_default();
1580 if (val) {
1581 m_spnHeightPerRow->setValue(val);
1582 }
1583 }
1584 }
1585
1586 bool MainWindow::have_addon()
1587 {
1588 const QRegularExpression addonRE(QSL("^[0-9X]+[+][0-9]+$"));
1589 return txtData->text().contains(addonRE);
1590 }
1591
1592 void MainWindow::guard_default_upcean()
1593 {
1594 guard_default(QSL("spnUPCEANGuardDescent"));
1595 }
1596
1597 void MainWindow::guard_default_upca()
1598 {
1599 guard_default(QSL("spnUPCAGuardDescent"));
1600 }
1601
1602 void MainWindow::view_context_menu(const QPoint &pos)
1603 {
1604 QMenu menu(tr("View Menu"), view);
1605
1606 if (m_bc.bc.getError() >= ZINT_ERROR) {
1607 menu.addAction(m_copyErrtxtAct);
1608
1609 menu.exec(get_context_menu_pos(pos, view));
1610 } else {
1611 menu.addAction(m_copyBMPAct);
1612 menu.addAction(m_copyEMFAct);
1613 #ifdef MAINWINDOW_COPY_EPS
1614 menu.addAction(m_copyEPSAct);
1615 #endif
1616 menu.addAction(m_copyGIFAct);
1617 #ifdef MAINWINDOW_COPY_PCX
1618 menu.addAction(m_copyPCXAct);
1619 #endif
1620 if (!m_bc.bc.noPng()) {
1621 menu.addAction(m_copyPNGAct);
1622 }
1623 menu.addAction(m_copySVGAct);
1624 menu.addAction(m_copyTIFAct);
1625 menu.addSeparator();
1626 menu.addAction(m_openCLIAct);
1627 menu.addSeparator();
1628 menu.addAction(m_saveAsAct);
1629 menu.addSeparator();
1630 menu.addAction(m_previewBgColorAct);
1631
1632 menu.exec(get_context_menu_pos(pos, view));
1633 }
1634 }
1635
1636 void MainWindow::errtxtBar_context_menu(const QPoint &pos)
1637 {
1638 QMenu menu(tr("Message Menu"), errtxtBar);
1639
1640 menu.addAction(m_copyErrtxtAct);
1641
1642 menu.exec(get_context_menu_pos(pos, errtxtBar));
1643 }
1644
1645 void MainWindow::change_options()
1646 {
1647 QUiLoader uiload;
1648 QSettings settings;
1649 #if QT_VERSION < 0x60000
1650 settings.setIniCodec("UTF-8");
1651 #endif
1652
1653 bool initial_load = m_symbology == 0;
1654 int original_tab_count = tabMain->count();
1655 int original_tab_index = tabMain->currentIndex();
1656 int symbology = bstyle_items[bstyle->currentIndex()].symbology;
1657
1658 if (m_symbology) {
1659 save_sub_settings(settings, m_symbology);
1660 }
1661 statusBar->clearMessage();
1662
1663 grpSpecific->hide();
1664 if (m_optionWidget) {
1665 if (tabMain->count() == 3) {
1666 tabMain->removeTab(1);
1667 } else {
1668 vLayoutSpecific->removeWidget(m_optionWidget);
1669 }
1670 delete m_optionWidget;
1671 m_optionWidget = nullptr;
1672 }
1673 chkComposite->setText(tr("Add &2D Component"));
1674 combobox_item_enabled(cmbCompType, 3, false); // CC-C
1675 btype->setItemText(0, tr("No border"));
1676 combobox_item_enabled(cmbFontSetting, 1, true); // Reset bold options
1677 combobox_item_enabled(cmbFontSetting, 3, true);
1678 m_lblHeightPerRow = nullptr;
1679 m_spnHeightPerRow = nullptr;
1680 m_btnHeightPerRowDisable = nullptr;
1681 m_btnHeightPerRowDefault = nullptr;
1682
1683 setColorTxtBtn(m_fgstr, txt_fgcolor, fgcolor);
1684 setColorTxtBtn(m_bgstr, txt_bgcolor, bgcolor);
1685
1686 m_xdimdpVars.x_dim = 0.0f;
1687 m_xdimdpVars.x_dim_units = 0;
1688 m_xdimdpVars.set = 0;
1689
1690 if (symbology == BARCODE_CODE128) {
1691 QFile file(QSL(":/grpC128.ui"));
1692 if (!file.open(QIODevice::ReadOnly))
1693 return;
1694 m_optionWidget = uiload.load(&file);
1695 file.close();
1696 load_sub_settings(settings, symbology);
1697 tabMain->insertTab(1, m_optionWidget, tr("Cod&e 128"));
1698 chkComposite->setText(tr("Add &2D Component (GS1-128 only)"));
1699 combobox_item_enabled(cmbCompType, 3, true); // CC-C
1700 set_smaller_font(QSL("noteC128CompositeEAN"));
1701 connect(get_widget(QSL("radC128Stand")), SIGNAL(toggled(bool)), SLOT(update_preview()));
1702 connect(get_widget(QSL("radC128CSup")), SIGNAL(toggled(bool)), SLOT(update_preview()));
1703 connect(get_widget(QSL("radC128EAN")), SIGNAL(toggled(bool)), SLOT(composite_ean_check()));
1704 connect(get_widget(QSL("radC128EAN")), SIGNAL(toggled(bool)), SLOT(update_preview()));
1705 connect(get_widget(QSL("radC128HIBC")), SIGNAL(toggled(bool)), SLOT(update_preview()));
1706 connect(get_widget(QSL("radC128ExtraEsc")), SIGNAL(toggled(bool)), SLOT(update_preview()));
1707
1708 } else if (symbology == BARCODE_PDF417) {
1709 QFile file(QSL(":/grpPDF417.ui"));
1710 if (!file.open(QIODevice::ReadOnly))
1711 return;
1712 m_optionWidget = uiload.load(&file);
1713 file.close();
1714 load_sub_settings(settings, symbology);
1715 structapp_ui_set();
1716 tabMain->insertTab(1, m_optionWidget, tr("PDF41&7"));
1717 connect(get_widget(QSL("cmbPDFECC")), SIGNAL(currentIndexChanged(int)), SLOT(update_preview()));
1718 connect(get_widget(QSL("cmbPDFCols")), SIGNAL(currentIndexChanged(int)), SLOT(update_preview()));
1719 connect(get_widget(QSL("cmbPDFRows")), SIGNAL(currentIndexChanged(int)), SLOT(update_preview()));
1720 m_lblHeightPerRow = m_optionWidget->findChild<QLabel*>(QSL("lblPDFHeightPerRow"));
1721 m_spnHeightPerRow = m_optionWidget->findChild<QDoubleSpinBox*>(QSL("spnPDFHeightPerRow"));
1722 connect(m_spnHeightPerRow, SIGNAL(valueChanged(double)), SLOT(autoheight_ui_set()));
1723 connect(m_spnHeightPerRow, SIGNAL(valueChanged(double)), SLOT(update_preview()));
1724 m_btnHeightPerRowDisable = m_optionWidget->findChild<QPushButton*>(QSL("btnPDFHeightPerRowDisable"));
1725 m_btnHeightPerRowDefault = m_optionWidget->findChild<QPushButton*>(QSL("btnPDFHeightPerRowDefault"));
1726 connect(m_btnHeightPerRowDisable, SIGNAL(clicked(bool)), SLOT(height_per_row_disable()));
1727 connect(m_btnHeightPerRowDefault, SIGNAL(clicked(bool)), SLOT(height_per_row_default()));
1728 connect(get_widget(QSL("radPDFTruncated")), SIGNAL(toggled(bool)), SLOT(update_preview()));
1729 connect(get_widget(QSL("radPDFStand")), SIGNAL(toggled(bool)), SLOT(update_preview()));
1730 connect(get_widget(QSL("radPDFHIBC")), SIGNAL(toggled(bool)), SLOT(update_preview()));
1731 connect(get_widget(QSL("chkPDFFast")), SIGNAL(toggled(bool)), SLOT(update_preview()));
1732 connect(get_widget(QSL("spnPDFStructAppCount")), SIGNAL(valueChanged(int)), SLOT(update_preview()));
1733 connect(get_widget(QSL("spnPDFStructAppCount")), SIGNAL(valueChanged(int)), SLOT(structapp_ui_set()));
1734 connect(get_widget(QSL("spnPDFStructAppIndex")), SIGNAL(valueChanged(int)), SLOT(update_preview()));
1735 connect(get_widget(QSL("txtPDFStructAppID")), SIGNAL(textChanged(QString)), SLOT(update_preview()));
1736
1737 } else if (symbology == BARCODE_MICROPDF417) {
1738 QFile file(QSL(":/grpMicroPDF.ui"));
1739 if (!file.open(QIODevice::ReadOnly))
1740 return;
1741 m_optionWidget = uiload.load(&file);
1742 file.close();
1743 load_sub_settings(settings, symbology);
1744 structapp_ui_set();
1745 tabMain->insertTab(1, m_optionWidget, tr("Micro PDF41&7"));
1746 connect(get_widget(QSL("cmbMPDFCols")), SIGNAL(currentIndexChanged(int)), SLOT(update_preview()));
1747 m_lblHeightPerRow = m_optionWidget->findChild<QLabel*>(QSL("lblMPDFHeightPerRow"));
1748 m_spnHeightPerRow = m_optionWidget->findChild<QDoubleSpinBox*>(QSL("spnMPDFHeightPerRow"));
1749 connect(m_spnHeightPerRow, SIGNAL(valueChanged(double)), SLOT(autoheight_ui_set()));
1750 connect(m_spnHeightPerRow, SIGNAL(valueChanged(double)), SLOT(update_preview()));
1751 m_btnHeightPerRowDisable = m_optionWidget->findChild<QPushButton*>(QSL("btnMPDFHeightPerRowDisable"));
1752 m_btnHeightPerRowDefault = m_optionWidget->findChild<QPushButton*>(QSL("btnMPDFHeightPerRowDefault"));
1753 connect(m_btnHeightPerRowDisable, SIGNAL(clicked(bool)), SLOT(height_per_row_disable()));
1754 connect(m_btnHeightPerRowDefault, SIGNAL(clicked(bool)), SLOT(height_per_row_default()));
1755 connect(get_widget(QSL("radMPDFStand")), SIGNAL(toggled(bool)), SLOT(update_preview()));
1756 connect(get_widget(QSL("chkMPDFFast")), SIGNAL(toggled(bool)), SLOT(update_preview()));
1757 connect(get_widget(QSL("spnMPDFStructAppCount")), SIGNAL(valueChanged(int)), SLOT(update_preview()));
1758 connect(get_widget(QSL("spnMPDFStructAppCount")), SIGNAL(valueChanged(int)), SLOT(structapp_ui_set()));
1759 connect(get_widget(QSL("spnMPDFStructAppIndex")), SIGNAL(valueChanged(int)), SLOT(update_preview()));
1760 connect(get_widget(QSL("txtMPDFStructAppID")), SIGNAL(textChanged(QString)), SLOT(update_preview()));
1761
1762 } else if (symbology == BARCODE_DOTCODE) {
1763 QFile file(QSL(":/grpDotCode.ui"));
1764 if (!file.open(QIODevice::ReadOnly))
1765 return;
1766 m_optionWidget = uiload.load(&file);
1767 file.close();
1768 load_sub_settings(settings, symbology);
1769 structapp_ui_set();
1770 tabMain->insertTab(1, m_optionWidget, tr("DotCod&e"));
1771 connect(get_widget(QSL("cmbDotCols")), SIGNAL(currentIndexChanged(int)), SLOT(update_preview()));
1772 connect(get_widget(QSL("cmbDotMask")), SIGNAL(currentIndexChanged(int)), SLOT(update_preview()));
1773 connect(get_widget(QSL("radDotStand")), SIGNAL(toggled(bool)), SLOT(update_preview()));
1774 connect(get_widget(QSL("radDotGS1")), SIGNAL(toggled(bool)), SLOT(update_preview()));
1775 connect(get_widget(QSL("cmbDotStructAppCount")), SIGNAL(currentIndexChanged(int)), SLOT(update_preview()));
1776 connect(get_widget(QSL("cmbDotStructAppCount")), SIGNAL(currentIndexChanged(int)), SLOT(structapp_ui_set()));
1777 connect(get_widget(QSL("cmbDotStructAppIndex")), SIGNAL(currentIndexChanged(int)), SLOT(update_preview()));
1778
1779 } else if (symbology == BARCODE_AZTEC) {
1780 QFile file(QSL(":/grpAztec.ui"));
1781 if (!file.open(QIODevice::ReadOnly))
1782 return;
1783 m_optionWidget = uiload.load(&file);
1784 file.close();
1785 load_sub_settings(settings, symbology);
1786 structapp_ui_set();
1787 tabMain->insertTab(1, m_optionWidget, tr("Aztec Cod&e"));
1788 connect(get_widget(QSL("radAztecAuto")), SIGNAL(toggled(bool)), SLOT(update_preview()));
1789 connect(get_widget(QSL("radAztecSize")), SIGNAL(toggled(bool)), SLOT(update_preview()));
1790 connect(get_widget(QSL("radAztecECC")), SIGNAL(toggled(bool)), SLOT(update_preview()));
1791 connect(get_widget(QSL("cmbAztecSize")), SIGNAL(currentIndexChanged(int)), SLOT(update_preview()));
1792 connect(get_widget(QSL("cmbAztecECC")), SIGNAL(currentIndexChanged(int)), SLOT(update_preview()));
1793 connect(get_widget(QSL("radAztecStand")), SIGNAL(toggled(bool)), SLOT(update_preview()));
1794 connect(get_widget(QSL("radAztecGS1")), SIGNAL(toggled(bool)), SLOT(update_preview()));
1795 connect(get_widget(QSL("radAztecHIBC")), SIGNAL(toggled(bool)), SLOT(update_preview()));
1796 connect(get_widget(QSL("cmbAztecStructAppCount")), SIGNAL(currentIndexChanged(int)), SLOT(update_preview()));
1797 connect(get_widget(QSL("cmbAztecStructAppCount")), SIGNAL(currentIndexChanged(int)),
1798 SLOT(structapp_ui_set()));
1799 connect(get_widget(QSL("cmbAztecStructAppIndex")), SIGNAL(currentIndexChanged(int)), SLOT(update_preview()));
1800 connect(get_widget(QSL("txtAztecStructAppID")), SIGNAL(textChanged(QString)), SLOT(update_preview()));
1801
1802 } else if (symbology == BARCODE_MSI_PLESSEY) {
1803 QFile file(QSL(":/grpMSICheck.ui"));
1804 if (!file.open(QIODevice::ReadOnly))
1805 return;
1806 m_optionWidget = uiload.load(&file);
1807 file.close();
1808 load_sub_settings(settings, symbology);
1809 vLayoutSpecific->addWidget(m_optionWidget);
1810 grpSpecific->show();
1811 connect(get_widget(QSL("cmbMSICheck")), SIGNAL(currentIndexChanged(int)), SLOT(update_preview()));
1812 connect(get_widget(QSL("cmbMSICheck")), SIGNAL(currentIndexChanged(int)), SLOT(msi_plessey_ui_set()));
1813 connect(get_widget(QSL("chkMSICheckText")), SIGNAL(toggled(bool)), SLOT(update_preview()));
1814
1815 } else if (symbology == BARCODE_CODE11) {
1816 QFile file(QSL(":/grpC11.ui"));
1817 if (!file.open(QIODevice::ReadOnly))
1818 return;
1819 m_optionWidget = uiload.load(&file);
1820 file.close();
1821 load_sub_settings(settings, symbology);
1822 vLayoutSpecific->addWidget(m_optionWidget);
1823 grpSpecific->show();
1824 connect(get_widget(QSL("radC11TwoCheckDigits")), SIGNAL(toggled(bool)), SLOT(update_preview()));
1825 connect(get_widget(QSL("radC11OneCheckDigit")), SIGNAL(toggled(bool)), SLOT(update_preview()));
1826 connect(get_widget(QSL("radC11NoCheckDigits")), SIGNAL(toggled(bool)), SLOT(update_preview()));
1827
1828 } else if (symbology == BARCODE_C25STANDARD || symbology == BARCODE_C25INTER || symbology == BARCODE_C25IATA
1829 || symbology == BARCODE_C25LOGIC || symbology == BARCODE_C25IND) {
1830 QFile file(QSL(":/grpC25.ui"));
1831 if (file.open(QIODevice::ReadOnly)) {
1832 m_optionWidget = uiload.load(&file);
1833 file.close();
1834 load_sub_settings(settings, symbology);
1835 vLayoutSpecific->addWidget(m_optionWidget);
1836 grpSpecific->show();
1837 connect(get_widget(QSL("radC25Stand")), SIGNAL(toggled(bool)), SLOT(update_preview()));
1838 connect(get_widget(QSL("radC25Check")), SIGNAL(toggled(bool)), SLOT(update_preview()));
1839 connect(get_widget(QSL("radC25CheckHide")), SIGNAL(toggled(bool)), SLOT(update_preview()));
1840 }
1841
1842 } else if (symbology == BARCODE_CODE39 || symbology == BARCODE_EXCODE39 || symbology == BARCODE_LOGMARS) {
1843 QFile file(QSL(":/grpC39.ui"));
1844 if (!file.open(QIODevice::ReadOnly))
1845 return;
1846 m_optionWidget = uiload.load(&file);
1847 file.close();
1848 load_sub_settings(settings, symbology);
1849 vLayoutSpecific->addWidget(m_optionWidget);
1850 grpSpecific->show();
1851 connect(get_widget(QSL("radC39Stand")), SIGNAL(toggled(bool)), SLOT(update_preview()));
1852 connect(get_widget(QSL("radC39Check")), SIGNAL(toggled(bool)), SLOT(update_preview()));
1853 connect(get_widget(QSL("radC39CheckHide")), SIGNAL(toggled(bool)), SLOT(update_preview()));
1854 QRadioButton *radC39HIBC = m_optionWidget->findChild<QRadioButton*>(QSL("radC39HIBC"));
1855 if (symbology == BARCODE_EXCODE39 || symbology == BARCODE_LOGMARS) {
1856 if (radC39HIBC->isChecked()) {
1857 radC39HIBC->setChecked(false);
1858 m_optionWidget->findChild<QRadioButton*>(QSL("radC39Stand"))->setChecked(true);
1859 }
1860 radC39HIBC->setEnabled(false);
1861 radC39HIBC->hide();
1862 } else {
1863 connect(get_widget(QSL("radC39HIBC")), SIGNAL(toggled(bool)), SLOT(update_preview()));
1864 radC39HIBC->setEnabled(true);
1865 radC39HIBC->show();
1866 }
1867
1868 } else if (symbology == BARCODE_CODE16K) {
1869 QFile file(QSL(":/grpC16k.ui"));
1870 if (!file.open(QIODevice::ReadOnly))
1871 return;
1872 m_optionWidget = uiload.load(&file);
1873 file.close();
1874 load_sub_settings(settings, symbology);
1875 tabMain->insertTab(1, m_optionWidget, tr("Cod&e 16K"));
1876 btype->setItemText(0, tr("Default (bind)"));
1877 connect(get_widget(QSL("cmbC16kRows")), SIGNAL(currentIndexChanged(int)), SLOT(update_preview()));
1878 m_lblHeightPerRow = m_optionWidget->findChild<QLabel*>(QSL("lblC16kHeightPerRow"));
1879 m_spnHeightPerRow = m_optionWidget->findChild<QDoubleSpinBox*>(QSL("spnC16kHeightPerRow"));
1880 connect(m_spnHeightPerRow, SIGNAL(valueChanged(double)), SLOT(autoheight_ui_set()));
1881 connect(m_spnHeightPerRow, SIGNAL(valueChanged(double)), SLOT(update_preview()));
1882 m_btnHeightPerRowDisable = m_optionWidget->findChild<QPushButton*>(QSL("btnC16kHeightPerRowDisable"));
1883 m_btnHeightPerRowDefault = m_optionWidget->findChild<QPushButton*>(QSL("btnC16kHeightPerRowDefault"));
1884 connect(m_btnHeightPerRowDisable, SIGNAL(clicked(bool)), SLOT(height_per_row_disable()));
1885 connect(m_btnHeightPerRowDefault, SIGNAL(clicked(bool)), SLOT(height_per_row_default()));
1886 connect(get_widget(QSL("cmbC16kRowSepHeight")), SIGNAL(currentIndexChanged(int)), SLOT(update_preview()));
1887 connect(get_widget(QSL("radC16kStand")), SIGNAL(toggled(bool)), SLOT(update_preview()));
1888 connect(get_widget(QSL("chkC16kNoQuietZones")), SIGNAL(toggled(bool)), SLOT(update_preview()));
1889
1890 } else if (symbology == BARCODE_CODABAR) {
1891 QFile file(QSL(":/grpCodabar.ui"));
1892 if (!file.open(QIODevice::ReadOnly))
1893 return;
1894 m_optionWidget = uiload.load(&file);
1895 file.close();
1896 load_sub_settings(settings, symbology);
1897 vLayoutSpecific->addWidget(m_optionWidget);
1898 grpSpecific->show();
1899 connect(get_widget(QSL("radCodabarStand")), SIGNAL(toggled(bool)), SLOT(update_preview()));
1900 connect(get_widget(QSL("radCodabarCheckHide")), SIGNAL(toggled(bool)), SLOT(update_preview()));
1901 connect(get_widget(QSL("radCodabarCheck")), SIGNAL(toggled(bool)), SLOT(update_preview()));
1902
1903 } else if (symbology == BARCODE_CODABLOCKF) {
1904 QFile file (QSL(":/grpCodablockF.ui"));
1905 if (!file.open(QIODevice::ReadOnly))
1906 return;
1907 m_optionWidget = uiload.load(&file);
1908 file.close();
1909 load_sub_settings(settings, symbology);
1910 tabMain->insertTab(1, m_optionWidget, tr("Codablock&-F"));
1911 btype->setItemText(0, tr("Default (bind)"));
1912 connect(get_widget(QSL("cmbCbfWidth")), SIGNAL(currentIndexChanged(int)), SLOT(update_preview()));
1913 connect(get_widget(QSL("cmbCbfHeight")), SIGNAL(currentIndexChanged(int)), SLOT(update_preview()));
1914 m_lblHeightPerRow = m_optionWidget->findChild<QLabel*>(QSL("lblCbfHeightPerRow"));
1915 m_spnHeightPerRow = m_optionWidget->findChild<QDoubleSpinBox*>(QSL("spnCbfHeightPerRow"));
1916 connect(m_spnHeightPerRow, SIGNAL(valueChanged(double)), SLOT(autoheight_ui_set()));
1917 connect(m_spnHeightPerRow, SIGNAL(valueChanged(double)), SLOT(update_preview()));
1918 m_btnHeightPerRowDisable = m_optionWidget->findChild<QPushButton*>(QSL("btnCbfHeightPerRowDisable"));
1919 m_btnHeightPerRowDefault = m_optionWidget->findChild<QPushButton*>(QSL("btnCbfHeightPerRowDefault"));
1920 connect(m_btnHeightPerRowDisable, SIGNAL(clicked(bool)), SLOT(height_per_row_disable()));
1921 connect(m_btnHeightPerRowDefault, SIGNAL(clicked(bool)), SLOT(height_per_row_default()));
1922 connect(get_widget(QSL("cmbCbfRowSepHeight")), SIGNAL(currentIndexChanged(int)), SLOT(update_preview()));
1923 connect(get_widget(QSL("radCbfStand")), SIGNAL(toggled(bool)), SLOT(update_preview()));
1924 connect(get_widget(QSL("radCbfHIBC")), SIGNAL(toggled(bool)), SLOT(update_preview()));
1925 connect(get_widget(QSL("chkCbfNoQuietZones")), SIGNAL(toggled(bool)), SLOT(update_preview()));
1926
1927 } else if (symbology == BARCODE_DAFT) {
1928 QFile file(QSL(":/grpDAFT.ui"));
1929 if (file.open(QIODevice::ReadOnly)) {
1930 m_optionWidget = uiload.load(&file);
1931 file.close();
1932 load_sub_settings(settings, symbology);
1933 vLayoutSpecific->addWidget(m_optionWidget);
1934 grpSpecific->show();
1935 set_smaller_font(QSL("noteDAFTTrackerRatios"));
1936 connect(get_widget(QSL("spnDAFTTrackerRatio")), SIGNAL(valueChanged(double)), SLOT(daft_ui_set()));
1937 connect(get_widget(QSL("spnDAFTTrackerRatio")), SIGNAL(valueChanged(double)), SLOT(update_preview()));
1938 connect(get_widget(QSL("btnDAFTTrackerDefault")), SIGNAL(clicked(bool)), SLOT(daft_tracker_default()));
1939 daft_ui_set();
1940 }
1941
1942 } else if (symbology == BARCODE_DPD) {
1943 btype->setItemText(0, tr("Default (bind top, 3X width)"));
1944 QFile file(QSL(":/grpDPD.ui"));
1945 if (file.open(QIODevice::ReadOnly)) {
1946 m_optionWidget = uiload.load(&file);
1947 file.close();
1948 load_sub_settings(settings, symbology);
1949 vLayoutSpecific->addWidget(m_optionWidget);
1950 grpSpecific->show();
1951 connect(get_widget(QSL("chkDPDRelabel")), SIGNAL(toggled(bool)), SLOT(update_preview()));
1952 }
1953
1954 } else if (symbology == BARCODE_DATAMATRIX) {
1955 QFile file(QSL(":/grpDM.ui"));
1956 if (!file.open(QIODevice::ReadOnly))
1957 return;
1958 m_optionWidget = uiload.load(&file);
1959 file.close();
1960 load_sub_settings(settings, symbology);
1961 structapp_ui_set();
1962 tabMain->insertTab(1, m_optionWidget, tr("D&ata Matrix"));
1963 connect(get_widget(QSL("radDM200Stand")), SIGNAL(toggled(bool)), SLOT(update_preview()));
1964 connect(get_widget(QSL("radDM200GS1")), SIGNAL(toggled(bool)), SLOT(update_preview()));
1965 connect(get_widget(QSL("radDM200HIBC")), SIGNAL(toggled(bool)), SLOT(update_preview()));
1966 connect(get_widget(QSL("cmbDM200Size")), SIGNAL(currentIndexChanged(int)), SLOT(update_preview()));
1967 connect(get_widget(QSL("chkDMRectangle")), SIGNAL(toggled(bool)), SLOT(update_preview()));
1968 connect(get_widget(QSL("chkDMRE")), SIGNAL(toggled(bool)), SLOT(update_preview()));
1969 connect(get_widget(QSL("chkDMGSSep")), SIGNAL(toggled(bool)), SLOT(update_preview()));
1970 connect(get_widget(QSL("chkDMISO144")), SIGNAL(toggled(bool)), SLOT(update_preview()));
1971 connect(get_widget(QSL("chkDMFast")), SIGNAL(toggled(bool)), SLOT(update_preview()));
1972 connect(get_widget(QSL("cmbDMStructAppCount")), SIGNAL(currentIndexChanged(int)), SLOT(update_preview()));
1973 connect(get_widget(QSL("cmbDMStructAppCount")), SIGNAL(currentIndexChanged(int)), SLOT(structapp_ui_set()));
1974 connect(get_widget(QSL("cmbDMStructAppIndex")), SIGNAL(currentIndexChanged(int)), SLOT(update_preview()));
1975 connect(get_widget(QSL("spnDMStructAppID")), SIGNAL(valueChanged(int)), SLOT(update_preview()));
1976 connect(get_widget(QSL("spnDMStructAppID2")), SIGNAL(valueChanged(int)), SLOT(update_preview()));
1977
1978 } else if (symbology == BARCODE_MAILMARK_2D) {
1979 QFile file(QSL(":/grpMailmark2D.ui"));
1980 if (file.open(QIODevice::ReadOnly)) {
1981 m_optionWidget = uiload.load(&file);
1982 file.close();
1983 load_sub_settings(settings, symbology);
1984 vLayoutSpecific->addWidget(m_optionWidget);
1985 grpSpecific->show();
1986 connect(get_widget(QSL("cmbMailmark2DSize")), SIGNAL(currentIndexChanged(int)), SLOT(update_preview()));
1987 connect(get_widget(QSL("chkMailmark2DRectangle")), SIGNAL(toggled(bool)), SLOT(update_preview()));
1988 }
1989
1990 } else if (symbology == BARCODE_ITF14) {
1991 btype->setItemText(0, tr("Default (box, 5X width)"));
1992 QFile file(QSL(":/grpITF14.ui"));
1993 if (file.open(QIODevice::ReadOnly)) {
1994 m_optionWidget = uiload.load(&file);
1995 file.close();
1996 load_sub_settings(settings, symbology);
1997 vLayoutSpecific->addWidget(m_optionWidget);
1998 grpSpecific->show();
1999 connect(get_widget(QSL("chkITF14NoQuietZones")), SIGNAL(toggled(bool)), SLOT(update_preview()));
2000 }
2001
2002 } else if (symbology == BARCODE_PZN) {
2003 QFile file(QSL(":/grpPZN.ui"));
2004 if (file.open(QIODevice::ReadOnly)) {
2005 m_optionWidget = uiload.load(&file);
2006 file.close();
2007 load_sub_settings(settings, symbology);
2008 vLayoutSpecific->addWidget(m_optionWidget);
2009 grpSpecific->show();
2010 connect(get_widget(QSL("chkPZN7")), SIGNAL(toggled(bool)), SLOT(update_preview()));
2011 }
2012
2013 } else if (symbology == BARCODE_QRCODE) {
2014 QFile file(QSL(":/grpQR.ui"));
2015 if (!file.open(QIODevice::ReadOnly))
2016 return;
2017 m_optionWidget = uiload.load(&file);
2018 file.close();
2019 load_sub_settings(settings, symbology);
2020 structapp_ui_set();
2021 tabMain->insertTab(1, m_optionWidget, tr("QR Cod&e"));
2022 connect(get_widget(QSL("cmbQRSize")), SIGNAL(currentIndexChanged(int)), SLOT(update_preview()));
2023 connect(get_widget(QSL("cmbQRECC")), SIGNAL(currentIndexChanged(int)), SLOT(update_preview()));
2024 connect(get_widget(QSL("cmbQRMask")), SIGNAL(currentIndexChanged(int)), SLOT(update_preview()));
2025 connect(get_widget(QSL("radQRStand")), SIGNAL(toggled(bool)), SLOT(update_preview()));
2026 connect(get_widget(QSL("radQRGS1")), SIGNAL(toggled(bool)), SLOT(update_preview()));
2027 connect(get_widget(QSL("radQRHIBC")), SIGNAL(toggled(bool)), SLOT(update_preview()));
2028 connect(get_widget(QSL("chkQRFullMultibyte")), SIGNAL(toggled(bool)), SLOT(update_preview()));
2029 connect(get_widget(QSL("chkQRFast")), SIGNAL(toggled(bool)), SLOT(update_preview()));
2030 connect(get_widget(QSL("cmbQRStructAppCount")), SIGNAL(currentIndexChanged(int)), SLOT(update_preview()));
2031 connect(get_widget(QSL("cmbQRStructAppCount")), SIGNAL(currentIndexChanged(int)), SLOT(structapp_ui_set()));
2032 connect(get_widget(QSL("cmbQRStructAppIndex")), SIGNAL(currentIndexChanged(int)), SLOT(update_preview()));
2033 connect(get_widget(QSL("spnQRStructAppID")), SIGNAL(valueChanged(int)), SLOT(update_preview()));
2034
2035 } else if (symbology == BARCODE_UPNQR) {
2036 QFile file(QSL(":/grpUPNQR.ui"));
2037 if (file.open(QIODevice::ReadOnly)) {
2038 m_optionWidget = uiload.load(&file);
2039 file.close();
2040 load_sub_settings(settings, symbology);
2041 vLayoutSpecific->addWidget(m_optionWidget);
2042 grpSpecific->show();
2043 connect(get_widget(QSL("cmbUPNQRMask")), SIGNAL(currentIndexChanged(int)), SLOT(update_preview()));
2044 connect(get_widget(QSL("chkUPNQRFast")), SIGNAL(toggled(bool)), SLOT(update_preview()));
2045 }
2046
2047 } else if (symbology == BARCODE_RMQR) {
2048 QFile file(QSL(":/grpRMQR.ui"));
2049 if (!file.open(QIODevice::ReadOnly))
2050 return;
2051 m_optionWidget = uiload.load(&file);
2052 file.close();
2053 load_sub_settings(settings, symbology);
2054 tabMain->insertTab(1, m_optionWidget, tr("rMQR Cod&e"));
2055 connect(get_widget(QSL("cmbRMQRSize")), SIGNAL(currentIndexChanged(int)), SLOT(update_preview()));
2056 connect(get_widget(QSL("cmbRMQRECC")), SIGNAL(currentIndexChanged(int)), SLOT(update_preview()));
2057 connect(get_widget(QSL("radRMQRStand")), SIGNAL(toggled(bool)), SLOT(update_preview()));
2058 connect(get_widget(QSL("radRMQRGS1")), SIGNAL(toggled(bool)), SLOT(update_preview()));
2059 connect(get_widget(QSL("chkRMQRFullMultibyte")), SIGNAL(toggled(bool)), SLOT(update_preview()));
2060
2061 } else if (symbology == BARCODE_HANXIN) {
2062 QFile file(QSL(":/grpHX.ui"));
2063 if (!file.open(QIODevice::ReadOnly))
2064 return;
2065 m_optionWidget = uiload.load(&file);
2066 file.close();
2067 load_sub_settings(settings, symbology);
2068 tabMain->insertTab(1, m_optionWidget, tr("Han Xin Cod&e"));
2069 connect(get_widget(QSL("cmbHXSize")), SIGNAL(currentIndexChanged(int)), SLOT(update_preview()));
2070 connect(get_widget(QSL("cmbHXECC")), SIGNAL(currentIndexChanged(int)), SLOT(update_preview()));
2071 connect(get_widget(QSL("cmbHXMask")), SIGNAL(currentIndexChanged(int)), SLOT(update_preview()));
2072 connect(get_widget(QSL("chkHXFullMultibyte")), SIGNAL(toggled(bool)), SLOT(update_preview()));
2073
2074 } else if (symbology == BARCODE_MICROQR) {
2075 QFile file(QSL(":/grpMQR.ui"));
2076 if (!file.open(QIODevice::ReadOnly))
2077 return;
2078 m_optionWidget = uiload.load(&file);
2079 file.close();
2080 load_sub_settings(settings, symbology);
2081 tabMain->insertTab(1, m_optionWidget, tr("Micro QR Cod&e"));
2082 connect(get_widget(QSL("cmbMQRSize")), SIGNAL(currentIndexChanged(int)), SLOT(update_preview()));
2083 connect(get_widget(QSL("cmbMQRECC")), SIGNAL(currentIndexChanged(int)), SLOT(update_preview()));
2084 connect(get_widget(QSL("cmbMQRMask")), SIGNAL(currentIndexChanged(int)), SLOT(update_preview()));
2085 connect(get_widget(QSL("chkMQRFullMultibyte")), SIGNAL(toggled(bool)), SLOT(update_preview()));
2086
2087 } else if (symbology == BARCODE_GRIDMATRIX) {
2088 QFile file(QSL(":/grpGrid.ui"));
2089 if (!file.open(QIODevice::ReadOnly))
2090 return;
2091 m_optionWidget = uiload.load(&file);
2092 file.close();
2093 load_sub_settings(settings, symbology);
2094 structapp_ui_set();
2095 tabMain->insertTab(1, m_optionWidget, tr("Grid M&atrix"));
2096 set_smaller_font(QSL("noteGridECC"));
2097 connect(get_widget(QSL("cmbGridSize")), SIGNAL(currentIndexChanged(int)), SLOT(update_preview()));
2098 connect(get_widget(QSL("cmbGridECC")), SIGNAL(currentIndexChanged(int)), SLOT(update_preview()));
2099 connect(get_widget(QSL("chkGridFullMultibyte")), SIGNAL(toggled(bool)), SLOT(update_preview()));
2100 connect(get_widget(QSL("cmbGridStructAppCount")), SIGNAL(currentIndexChanged(int)), SLOT(update_preview()));
2101 connect(get_widget(QSL("cmbGridStructAppCount")), SIGNAL(currentIndexChanged(int)), SLOT(structapp_ui_set()));
2102 connect(get_widget(QSL("cmbGridStructAppIndex")), SIGNAL(currentIndexChanged(int)), SLOT(update_preview()));
2103 connect(get_widget(QSL("spnGridStructAppID")), SIGNAL(valueChanged(int)), SLOT(update_preview()));
2104
2105 } else if (symbology == BARCODE_MAXICODE) {
2106 QFile file(QSL(":/grpMaxicode.ui"));
2107 if (!file.open(QIODevice::ReadOnly))
2108 return;
2109 m_optionWidget = uiload.load(&file);
2110 file.close();
2111 load_sub_settings(settings, symbology);
2112 structapp_ui_set();
2113 tabMain->insertTab(1, m_optionWidget, tr("MaxiCod&e"));
2114 connect(get_widget(QSL("cmbMaxiMode")), SIGNAL(currentIndexChanged(int)), SLOT(update_preview()));
2115 connect(get_widget(QSL("cmbMaxiMode")), SIGNAL(currentIndexChanged(int)), SLOT(maxi_scm_ui_set()));
2116 connect(get_widget(QSL("txtMaxiSCMPostcode")), SIGNAL(textChanged(QString)), SLOT(update_preview()));
2117 connect(get_widget(QSL("spnMaxiSCMCountry")), SIGNAL(valueChanged(int)), SLOT(update_preview()));
2118 connect(get_widget(QSL("spnMaxiSCMService")), SIGNAL(valueChanged(int)), SLOT(update_preview()));
2119 connect(get_widget(QSL("chkMaxiSCMVV")), SIGNAL(toggled(bool)), SLOT(update_preview()));
2120 connect(get_widget(QSL("chkMaxiSCMVV")), SIGNAL(toggled(bool)), SLOT(maxi_scm_ui_set()));
2121 connect(get_widget(QSL("spnMaxiSCMVV")), SIGNAL(valueChanged(int)), SLOT(update_preview()));
2122 connect(get_widget(QSL("cmbMaxiStructAppCount")), SIGNAL(currentIndexChanged(int)), SLOT(update_preview()));
2123 connect(get_widget(QSL("cmbMaxiStructAppCount")), SIGNAL(currentIndexChanged(int)), SLOT(structapp_ui_set()));
2124 connect(get_widget(QSL("cmbMaxiStructAppIndex")), SIGNAL(currentIndexChanged(int)), SLOT(update_preview()));
2125 maxi_scm_ui_set();
2126
2127 } else if (symbology == BARCODE_CHANNEL) {
2128 QFile file(QSL(":/grpChannel.ui"));
2129 if (!file.open(QIODevice::ReadOnly))
2130 return;
2131 m_optionWidget = uiload.load(&file);
2132 file.close();
2133 load_sub_settings(settings, symbology);
2134 vLayoutSpecific->addWidget(m_optionWidget);
2135 grpSpecific->show();
2136 connect(get_widget(QSL("cmbChannel")), SIGNAL(currentIndexChanged(int)), SLOT(update_preview()));
2137
2138 } else if (symbology == BARCODE_CODEONE) {
2139 QFile file(QSL(":/grpCodeOne.ui"));
2140 if (!file.open(QIODevice::ReadOnly))
2141 return;
2142 m_optionWidget = uiload.load(&file);
2143 file.close();
2144 load_sub_settings(settings, symbology);
2145 codeone_ui_set();
2146 structapp_ui_set();
2147 tabMain->insertTab(1, m_optionWidget, tr("Code On&e"));
2148 connect(get_widget(QSL("cmbC1Size")), SIGNAL(currentIndexChanged(int)), SLOT(codeone_ui_set()));
2149 connect(get_widget(QSL("cmbC1Size")), SIGNAL(currentIndexChanged(int)), SLOT(update_preview()));
2150 connect(get_widget(QSL("radC1GS1")), SIGNAL(toggled(bool)), SLOT(update_preview()));
2151 connect(get_widget(QSL("spnC1StructAppCount")), SIGNAL(valueChanged(int)), SLOT(update_preview()));
2152 connect(get_widget(QSL("spnC1StructAppCount")), SIGNAL(valueChanged(int)), SLOT(structapp_ui_set()));
2153 connect(get_widget(QSL("spnC1StructAppIndex")), SIGNAL(valueChanged(int)), SLOT(update_preview()));
2154
2155 } else if (symbology == BARCODE_CODE49) {
2156 QFile file(QSL(":/grpC49.ui"));
2157 if (!file.open(QIODevice::ReadOnly))
2158 return;
2159 m_optionWidget = uiload.load(&file);
2160 file.close();
2161 load_sub_settings(settings, symbology);
2162 tabMain->insertTab(1, m_optionWidget, tr("Cod&e 49"));
2163 btype->setItemText(0, tr("Default (bind)"));
2164 connect(get_widget(QSL("cmbC49Rows")), SIGNAL(currentIndexChanged(int)), SLOT(update_preview()));
2165 m_lblHeightPerRow = m_optionWidget->findChild<QLabel*>(QSL("lblC49HeightPerRow"));
2166 m_spnHeightPerRow = m_optionWidget->findChild<QDoubleSpinBox*>(QSL("spnC49HeightPerRow"));
2167 connect(m_spnHeightPerRow, SIGNAL(valueChanged(double)), SLOT(autoheight_ui_set()));
2168 connect(m_spnHeightPerRow, SIGNAL(valueChanged(double)), SLOT(update_preview()));
2169 m_btnHeightPerRowDisable = m_optionWidget->findChild<QPushButton*>(QSL("btnC49HeightPerRowDisable"));
2170 m_btnHeightPerRowDefault = m_optionWidget->findChild<QPushButton*>(QSL("btnC49HeightPerRowDefault"));
2171 connect(m_btnHeightPerRowDisable, SIGNAL(clicked(bool)), SLOT(height_per_row_disable()));
2172 connect(m_btnHeightPerRowDefault, SIGNAL(clicked(bool)), SLOT(height_per_row_default()));
2173 connect(get_widget(QSL("cmbC49RowSepHeight")), SIGNAL(currentIndexChanged(int)), SLOT(update_preview()));
2174 connect(get_widget(QSL("radC49GS1")), SIGNAL(toggled(bool)), SLOT(update_preview()));
2175 connect(get_widget(QSL("chkC49NoQuietZones")), SIGNAL(toggled(bool)), SLOT(update_preview()));
2176
2177 } else if (symbology == BARCODE_CODE93) {
2178 QFile file(QSL(":/grpC93.ui"));
2179 if (file.open(QIODevice::ReadOnly)) {
2180 m_optionWidget = uiload.load(&file);
2181 file.close();
2182 load_sub_settings(settings, symbology);
2183 vLayoutSpecific->addWidget(m_optionWidget);
2184 grpSpecific->show();
2185 connect(get_widget(QSL("chkC93ShowChecks")), SIGNAL(toggled(bool)), SLOT(update_preview()));
2186 }
2187
2188 } else if (symbology == BARCODE_DBAR_EXPSTK) {
2189 QFile file(QSL(":/grpDBExtend.ui"));
2190 if (!file.open(QIODevice::ReadOnly))
2191 return;
2192 m_optionWidget = uiload.load(&file);
2193 file.close();
2194 load_sub_settings(settings, symbology);
2195 tabMain->insertTab(1, m_optionWidget, tr("GS1 D&ataBar Exp Stack"));
2196 connect(get_widget(QSL("radDBESCols")), SIGNAL(toggled(bool)), SLOT(update_preview()));
2197 connect(get_widget(QSL("radDBESRows")), SIGNAL(toggled(bool)), SLOT(update_preview()));
2198 connect(get_widget(QSL("cmbDBESCols")), SIGNAL(currentIndexChanged(int)), SLOT(update_preview()));
2199 connect(get_widget(QSL("cmbDBESRows")), SIGNAL(currentIndexChanged(int)), SLOT(update_preview()));
2200 m_lblHeightPerRow = m_optionWidget->findChild<QLabel*>(QSL("lblDBESHeightPerRow"));
2201 m_spnHeightPerRow = m_optionWidget->findChild<QDoubleSpinBox*>(QSL("spnDBESHeightPerRow"));
2202 connect(m_spnHeightPerRow, SIGNAL(valueChanged(double)), SLOT(autoheight_ui_set()));
2203 connect(m_spnHeightPerRow, SIGNAL(valueChanged(double)), SLOT(update_preview()));
2204 m_btnHeightPerRowDisable = m_optionWidget->findChild<QPushButton*>(QSL("btnDBESHeightPerRowDisable"));
2205 m_btnHeightPerRowDefault = m_optionWidget->findChild<QPushButton*>(QSL("btnDBESHeightPerRowDefault"));
2206 connect(m_btnHeightPerRowDisable, SIGNAL(clicked(bool)), SLOT(height_per_row_disable()));
2207 connect(m_btnHeightPerRowDefault, SIGNAL(clicked(bool)), SLOT(height_per_row_default()));
2208
2209 } else if (symbology == BARCODE_ULTRA) {
2210 QFile file(QSL(":/grpUltra.ui"));
2211 if (!file.open(QIODevice::ReadOnly))
2212 return;
2213 m_optionWidget = uiload.load(&file);
2214 file.close();
2215 load_sub_settings(settings, symbology);
2216 structapp_ui_set();
2217 tabMain->insertTab(1, m_optionWidget, tr("Ultracod&e"));
2218 connect(get_widget(QSL("radUltraAuto")), SIGNAL(toggled(bool)), SLOT(update_preview()));
2219 connect(get_widget(QSL("radUltraEcc")), SIGNAL(toggled(bool)), SLOT(update_preview()));
2220 connect(get_widget(QSL("cmbUltraEcc")), SIGNAL(currentIndexChanged(int)), SLOT(update_preview()));
2221 connect(get_widget(QSL("cmbUltraRevision")), SIGNAL(currentIndexChanged(int)), SLOT(update_preview()));
2222 connect(get_widget(QSL("radUltraStand")), SIGNAL(toggled(bool)), SLOT(update_preview()));
2223 connect(get_widget(QSL("radUltraGS1")), SIGNAL(toggled(bool)), SLOT(update_preview()));
2224 connect(get_widget(QSL("cmbUltraStructAppCount")), SIGNAL(currentIndexChanged(int)), SLOT(update_preview()));
2225 connect(get_widget(QSL("cmbUltraStructAppCount")), SIGNAL(currentIndexChanged(int)),
2226 SLOT(structapp_ui_set()));
2227 connect(get_widget(QSL("cmbUltraStructAppIndex")), SIGNAL(currentIndexChanged(int)), SLOT(update_preview()));
2228 connect(get_widget(QSL("spnUltraStructAppID")), SIGNAL(valueChanged(int)), SLOT(update_preview()));
2229
2230 } else if (symbology == BARCODE_UPCA || symbology == BARCODE_UPCA_CHK || symbology == BARCODE_UPCA_CC) {
2231 QFile file(QSL(":/grpUPCA.ui"));
2232 if (!file.open(QIODevice::ReadOnly))
2233 return;
2234 m_optionWidget = uiload.load(&file);
2235 file.close();
2236 load_sub_settings(settings, symbology);
2237 upcae_no_quiet_zones_ui_set();
2238 tabMain->insertTab(1, m_optionWidget, tr("UPC-&A"));
2239 combobox_item_enabled(cmbFontSetting, 1, false); // Disable bold options
2240 combobox_item_enabled(cmbFontSetting, 3, false);
2241 if (cmbFontSetting->currentIndex() == 1 || cmbFontSetting->currentIndex() == 3) {
2242 cmbFontSetting->setCurrentIndex(cmbFontSetting->currentIndex() - 1);
2243 }
2244 connect(get_widget(QSL("cmbUPCAAddonGap")), SIGNAL(currentIndexChanged(int)), SLOT(update_preview()));
2245 connect(get_widget(QSL("spnUPCAGuardDescent")), SIGNAL(valueChanged(double)), SLOT(update_preview()));
2246 connect(get_widget(QSL("btnUPCAGuardDefault")), SIGNAL(clicked(bool)), SLOT(guard_default_upca()));
2247 connect(get_widget(QSL("chkUPCANoQuietZones")), SIGNAL(toggled(bool)), SLOT(upcae_no_quiet_zones_ui_set()));
2248 connect(get_widget(QSL("chkUPCANoQuietZones")), SIGNAL(toggled(bool)), SLOT(update_preview()));
2249 connect(get_widget(QSL("chkUPCAGuardWhitespace")), SIGNAL(toggled(bool)), SLOT(update_preview()));
2250
2251 } else if (symbology == BARCODE_EANX || symbology == BARCODE_EANX_CHK || symbology == BARCODE_EANX_CC
2252 || symbology == BARCODE_UPCE || symbology == BARCODE_UPCE_CHK || symbology == BARCODE_UPCE_CC
2253 || symbology == BARCODE_ISBNX) {
2254 QFile file(QSL(":/grpUPCEAN.ui"));
2255 if (!file.open(QIODevice::ReadOnly))
2256 return;
2257 m_optionWidget = uiload.load(&file);
2258 file.close();
2259 load_sub_settings(settings, symbology);
2260 const bool is_upce = symbology == BARCODE_UPCE || symbology == BARCODE_UPCE_CHK
2261 || symbology == BARCODE_UPCE_CC;
2262 if (is_upce) {
2263 tabMain->insertTab(1, m_optionWidget, tr("UPC-&E"));
2264 upcae_no_quiet_zones_ui_set();
2265 } else if (symbology == BARCODE_ISBNX) {
2266 tabMain->insertTab(1, m_optionWidget, tr("ISBN"));
2267 upcean_no_quiet_zones_ui_set();
2268 } else {
2269 tabMain->insertTab(1, m_optionWidget, tr("&EAN"));
2270 upcean_no_quiet_zones_ui_set();
2271 }
2272 combobox_item_enabled(cmbFontSetting, 1, false); // Disable bold options
2273 combobox_item_enabled(cmbFontSetting, 3, false);
2274 if (cmbFontSetting->currentIndex() == 1 || cmbFontSetting->currentIndex() == 3) {
2275 cmbFontSetting->setCurrentIndex(cmbFontSetting->currentIndex() - 1);
2276 }
2277 connect(get_widget(QSL("cmbUPCEANAddonGap")), SIGNAL(currentIndexChanged(int)), SLOT(update_preview()));
2278 connect(get_widget(QSL("spnUPCEANGuardDescent")), SIGNAL(valueChanged(double)), SLOT(update_preview()));
2279 connect(get_widget(QSL("btnUPCEANGuardDefault")), SIGNAL(clicked(bool)), SLOT(guard_default_upcean()));
2280 if (is_upce) {
2281 connect(get_widget(QSL("chkUPCEANNoQuietZones")), SIGNAL(toggled(bool)),
2282 SLOT(upcae_no_quiet_zones_ui_set()));
2283 } else {
2284 connect(get_widget(QSL("chkUPCEANNoQuietZones")), SIGNAL(toggled(bool)),
2285 SLOT(upcean_no_quiet_zones_ui_set()));
2286 }
2287 connect(get_widget(QSL("chkUPCEANNoQuietZones")), SIGNAL(toggled(bool)), SLOT(update_preview()));
2288 connect(get_widget(QSL("chkUPCEANGuardWhitespace")), SIGNAL(toggled(bool)), SLOT(update_preview()));
2289
2290 } else if (symbology == BARCODE_VIN) {
2291 QFile file(QSL(":/grpVIN.ui"));
2292 if (!file.open(QIODevice::ReadOnly))
2293 return;
2294 m_optionWidget = uiload.load(&file);
2295 file.close();
2296 load_sub_settings(settings, symbology);
2297 vLayoutSpecific->addWidget(m_optionWidget);
2298 grpSpecific->show();
2299 connect(get_widget(QSL("chkVINImportChar")), SIGNAL(toggled(bool)), SLOT(update_preview()));
2300
2301 } else {
2302 m_optionWidget = nullptr;
2303 load_sub_settings(settings, symbology);
2304 }
2305
2306 switch (symbology) {
2307 case BARCODE_CODE128:
2308 case BARCODE_EANX:
2309 case BARCODE_UPCA:
2310 case BARCODE_UPCE:
2311 case BARCODE_DBAR_OMN:
2312 case BARCODE_DBAR_LTD:
2313 case BARCODE_DBAR_EXP:
2314 case BARCODE_DBAR_STK:
2315 case BARCODE_DBAR_OMNSTK:
2316 case BARCODE_DBAR_EXPSTK:
2317 grpComposite->show();
2318 grpSegs->hide();
2319 break;
2320 case BARCODE_AZTEC:
2321 case BARCODE_DATAMATRIX:
2322 case BARCODE_MAXICODE:
2323 case BARCODE_MICROPDF417:
2324 case BARCODE_PDF417:
2325 case BARCODE_PDF417COMP:
2326 case BARCODE_QRCODE:
2327 case BARCODE_DOTCODE:
2328 case BARCODE_CODEONE:
2329 case BARCODE_GRIDMATRIX:
2330 case BARCODE_HANXIN:
2331 case BARCODE_ULTRA:
2332 case BARCODE_RMQR:
2333 grpComposite->hide();
2334 grpSegs->show();
2335 break;
2336 default:
2337 grpComposite->hide();
2338 grpSegs->hide();
2339 break;
2340 }
2341
2342 // ECI, GS1Parens, GS1NoCheck, RInit, CompliantHeight will be checked in update_preview() as
2343 // encoding mode dependent (HIBC and/or GS1)
2344 chkAutoHeight->setEnabled(!m_bc.bc.isFixedRatio(symbology));
2345 chkHRTShow->setEnabled(m_bc.bc.hasHRT(symbology));
2346 chkQuietZones->setEnabled(!m_bc.bc.hasDefaultQuietZones(symbology));
2347 chkDotty->setEnabled(m_bc.bc.isDotty(symbology));
2348
2349 setColorTxtBtn(m_fgstr, txt_fgcolor, fgcolor);
2350 setColorTxtBtn(m_bgstr, txt_bgcolor, bgcolor);
2351
2352 data_ui_set();
2353 composite_ui_set();
2354 autoheight_ui_set();
2355 HRTShow_ui_set();
2356 dotty_ui_set();
2357
2358 if (initial_load) {
2359 tabMain->setCurrentIndex(settings.value(QSL("studio/tab_index"), 0).toInt());
2360 } else if (original_tab_count == tabMain->count()) {
2361 tabMain->setCurrentIndex(original_tab_index);
2362 } else if (original_tab_count > tabMain->count()) {
2363 tabMain->setCurrentIndex(original_tab_index == 2 ? 1 : 0);
2364 } else {
2365 tabMain->setCurrentIndex(original_tab_index == 1 ? 2 : 0);
2366 }
2367 }
2368
2369 void MainWindow::data_ui_set()
2370 {
2371 if (grpSegs->isHidden()) {
2372 return;
2373 }
2374
2375 if (txtData->text().isEmpty()) {
2376 lblSeg1->setEnabled(false);
2377 cmbECISeg1->setEnabled(false);
2378 txtDataSeg1->setEnabled(false);
2379 btnMoreDataSeg1->setEnabled(false);
2380 btnClearDataSeg1->setEnabled(false);
2381
2382 lblSeg2->setEnabled(false);
2383 cmbECISeg2->setEnabled(false);
2384 txtDataSeg2->setEnabled(false);
2385 btnMoreDataSeg2->setEnabled(false);
2386 btnClearDataSeg2->setEnabled(false);
2387
2388 lblSeg3->setEnabled(false);
2389 cmbECISeg3->setEnabled(false);
2390 txtDataSeg3->setEnabled(false);
2391 btnMoreDataSeg3->setEnabled(false);
2392 btnClearDataSeg3->setEnabled(false);
2393 return;
2394 }
2395
2396 lblSeg1->setEnabled(true);
2397 txtDataSeg1->setEnabled(true);
2398 btnMoreDataSeg1->setEnabled(true);
2399 if (txtDataSeg1->text().isEmpty()) {
2400 cmbECISeg1->setEnabled(false);
2401 btnClearDataSeg1->setEnabled(false);
2402
2403 lblSeg2->setEnabled(false);
2404 cmbECISeg2->setEnabled(false);
2405 txtDataSeg2->setEnabled(false);
2406 btnMoreDataSeg2->setEnabled(false);
2407 btnClearDataSeg2->setEnabled(false);
2408
2409 lblSeg3->setEnabled(false);
2410 cmbECISeg3->setEnabled(false);
2411 txtDataSeg3->setEnabled(false);
2412 btnMoreDataSeg3->setEnabled(false);
2413 btnClearDataSeg3->setEnabled(false);
2414 } else {
2415 cmbECISeg1->setEnabled(true);
2416 btnClearDataSeg1->setEnabled(true);
2417
2418 lblSeg2->setEnabled(true);
2419 txtDataSeg2->setEnabled(true);
2420 btnMoreDataSeg2->setEnabled(true);
2421 if (txtDataSeg2->text().isEmpty()) {
2422 cmbECISeg2->setEnabled(false);
2423 btnClearDataSeg2->setEnabled(false);
2424
2425 lblSeg3->setEnabled(false);
2426 cmbECISeg3->setEnabled(false);
2427 txtDataSeg3->setEnabled(false);
2428 btnMoreDataSeg3->setEnabled(false);
2429 btnClearDataSeg3->setEnabled(false);
2430 } else {
2431 cmbECISeg2->setEnabled(true);
2432 btnClearDataSeg2->setEnabled(true);
2433
2434 bool data_seg3_empty = txtDataSeg3->text().isEmpty();
2435 lblSeg3->setEnabled(true);
2436 cmbECISeg3->setEnabled(!data_seg3_empty);
2437 txtDataSeg3->setEnabled(true);
2438 btnMoreDataSeg3->setEnabled(true);
2439 btnClearDataSeg3->setEnabled(!data_seg3_empty);
2440 }
2441 }
2442 }
2443
2444 void MainWindow::composite_ui_set()
2445 {
2446 bool enabled = !grpComposite->isHidden() && chkComposite->isChecked();
2447
2448 lblCompType->setEnabled(enabled);
2449 cmbCompType->setEnabled(enabled);
2450 lblComposite->setEnabled(enabled);
2451 btnClearComposite->setEnabled(enabled);
2452 txtComposite->setEnabled(enabled);
2453
2454 if (enabled) {
2455 if (bstyle_items[bstyle->currentIndex()].symbology == BARCODE_CODE128) {
2456 QRadioButton *radioButton = m_optionWidget->findChild<QRadioButton*>(QSL("radC128EAN"));
2457 if (radioButton) {
2458 radioButton->setChecked(true);
2459 }
2460 }
2461 }
2462 }
2463
2464 void MainWindow::composite_ean_check()
2465 {
2466 if (bstyle_items[bstyle->currentIndex()].symbology != BARCODE_CODE128)
2467 return;
2468 QRadioButton *radioButton = m_optionWidget->findChild<QRadioButton*>(QSL("radC128EAN"));
2469 if (radioButton && !radioButton->isChecked())
2470 chkComposite->setChecked(false);
2471 }
2472
2473 void MainWindow::maxi_scm_ui_set()
2474 {
2475 if (bstyle_items[bstyle->currentIndex()].symbology != BARCODE_MAXICODE)
2476 return;
2477 QCheckBox *chkMaxiSCMVV = m_optionWidget ? m_optionWidget->findChild<QCheckBox*>(QSL("chkMaxiSCMVV")) : nullptr;
2478 if (!chkMaxiSCMVV)
2479 return;
2480
2481 bool isMode2or3 = get_cmb_index(QSL("cmbMaxiMode")) == 0;
2482
2483 m_optionWidget->findChild<QLabel*>(QSL("lblMaxiSCMPostcode"))->setEnabled(isMode2or3);
2484 m_optionWidget->findChild<QLineEdit*>(QSL("txtMaxiSCMPostcode"))->setEnabled(isMode2or3);
2485 m_optionWidget->findChild<QLabel*>(QSL("lblMaxiSCMCountry"))->setEnabled(isMode2or3);
2486 m_optionWidget->findChild<QSpinBox*>(QSL("spnMaxiSCMCountry"))->setEnabled(isMode2or3);
2487 m_optionWidget->findChild<QLabel*>(QSL("lblMaxiSCMService"))->setEnabled(isMode2or3);
2488 m_optionWidget->findChild<QSpinBox*>(QSL("spnMaxiSCMService"))->setEnabled(isMode2or3);
2489 chkMaxiSCMVV->setEnabled(isMode2or3);
2490 m_optionWidget->findChild<QLabel*>(QSL("lblMaxiSCMVV"))->setEnabled(isMode2or3 && chkMaxiSCMVV->isChecked());
2491 m_optionWidget->findChild<QSpinBox*>(QSL("spnMaxiSCMVV"))->setEnabled(isMode2or3 && chkMaxiSCMVV->isChecked());
2492 }
2493
2494 void MainWindow::msi_plessey_ui_set()
2495 {
2496 if (bstyle_items[bstyle->currentIndex()].symbology != BARCODE_MSI_PLESSEY)
2497 return;
2498 QCheckBox *checkBox = m_optionWidget ? m_optionWidget->findChild<QCheckBox*>(QSL("chkMSICheckText")) : nullptr;
2499 if (checkBox) {
2500 checkBox->setEnabled(get_cmb_index(QSL("cmbMSICheck")) > 0);
2501 }
2502 }
2503
2504 // Taken from https://stackoverflow.com/questions/38915001/disable-specific-items-in-qcombobox
2505 void MainWindow::combobox_item_enabled(QComboBox *comboBox, int index, bool enabled)
2506 {
2507 QStandardItemModel *model = qobject_cast<QStandardItemModel*>(comboBox->model());
2508 if (model) {
2509 QStandardItem *item = model->item(index);
2510 if (item) {
2511 item->setEnabled(enabled);
2512 }
2513 }
2514 }
2515
2516 bool MainWindow::upcean_addon_gap(const QString &comboBoxName, const QString &labelName, int base)
2517 {
2518 QComboBox *comboBox = m_optionWidget->findChild<QComboBox*>(comboBoxName);
2519 QLabel *label = m_optionWidget->findChild<QLabel*>(labelName);
2520
2521 bool enabled = have_addon();
2522 if (comboBox) {
2523 comboBox->setEnabled(enabled);
2524 }
2525 if (label) {
2526 label->setEnabled(enabled);
2527 }
2528 if (enabled && comboBox) {
2529 int item_val = comboBox->currentIndex();
2530 if (item_val) {
2531 m_bc.bc.setOption2(item_val + base);
2532 }
2533 }
2534 return enabled;
2535 }
2536
2537 void MainWindow::upcean_guard_descent(const QString &spnBoxName, const QString &labelName,
2538 const QString &btnDefaultName, bool enabled)
2539 {
2540 QDoubleSpinBox *spnBox = m_optionWidget->findChild<QDoubleSpinBox*>(spnBoxName);
2541 QLabel *label = m_optionWidget->findChild<QLabel*>(labelName);
2542 QPushButton *btnDefault = m_optionWidget->findChild<QPushButton*>(btnDefaultName);
2543
2544 if (spnBox) {
2545 spnBox->setEnabled(enabled);
2546 }
2547 if (label) {
2548 label->setEnabled(enabled);
2549 }
2550 if (btnDefault) {
2551 btnDefault->setEnabled(enabled);
2552 }
2553 if (enabled && spnBox) {
2554 m_bc.bc.setGuardDescent(spnBox->value());
2555 if (btnDefault && spnBox->value() == 5.0) {
2556 QWidget *focus = QApplication::focusWidget();
2557 btnDefault->setEnabled(false);
2558 if (focus == btnDefault) {
2559 spnBox->setFocus();
2560 }
2561 }
2562 }
2563 }
2564
2565 void MainWindow::guard_default(const QString &spnBoxName)
2566 {
2567 QDoubleSpinBox *spnBox = m_optionWidget->findChild<QDoubleSpinBox*>(spnBoxName);
2568 if (spnBox && spnBox->value() != 5.0) {
2569 spnBox->setValue(5.0);
2570 update_preview();
2571 }
2572 }
2573
2574 void MainWindow::daft_ui_set()
2575 {
2576 QDoubleSpinBox *spnBox = m_optionWidget->findChild<QDoubleSpinBox*>(QSL("spnDAFTTrackerRatio"));
2577 QPushButton *btnDefault = m_optionWidget->findChild<QPushButton*>(QSL("btnDAFTTrackerDefault"));
2578 if (spnBox && spnBox->value() == 25.0) {
2579 if (btnDefault) {
2580 QWidget *focus = QApplication::focusWidget();
2581 btnDefault->setEnabled(false);
2582 if (focus == btnDefault) {
2583 spnBox->setFocus();
2584 }
2585 }
2586 } else if (btnDefault && !btnDefault->isEnabled()) {
2587 btnDefault->setEnabled(true);
2588 }
2589 }
2590
2591 void MainWindow::daft_tracker_default()
2592 {
2593 QDoubleSpinBox *spnBox = m_optionWidget->findChild<QDoubleSpinBox*>(QSL("spnDAFTTrackerRatio"));
2594 if (spnBox && spnBox->value() != 25.0) {
2595 spnBox->setValue(25.0);
2596 update_preview();
2597 }
2598 }
2599
2600 void MainWindow::set_gs1_mode(bool gs1_mode)
2601 {
2602 if (gs1_mode) {
2603 m_bc.bc.setInputMode(GS1_MODE | (m_bc.bc.inputMode() & ~0x07)); // Keep upper bits
2604 chkData->setEnabled(false);
2605 } else {
2606 chkData->setEnabled(true);
2607 }
2608 }
2609
2610 void MainWindow::set_smaller_font(const QString &labelName)
2611 {
2612 QLabel *label = m_optionWidget ? m_optionWidget->findChild<QLabel*>(labelName) : nullptr;
2613 if (label) {
2614 const QFont &appFont = QApplication::font();
2615 qreal pointSize = appFont.pointSizeF();
2616 if (pointSize != -1.0) {
2617 QFont font = label->font();
2618 pointSize *= 0.9;
2619 font.setPointSizeF(pointSize);
2620 label->setFont(font);
2621 } else {
2622 int pixelSize = appFont.pixelSize();
2623 if (pixelSize > 1) {
2624 QFont font = label->font();
2625 font.setPixelSize(pixelSize - 1);
2626 label->setFont(font);
2627 }
2628 }
2629 }
2630 }
2631
2632 void MainWindow::update_preview()
2633 {
2634 int symbology = bstyle_items[bstyle->currentIndex()].symbology;
2635 int eci_not_set = true;
2636 int width = view->geometry().width();
2637 int height = view->geometry().height();
2638 int item_val;
2639 QCheckBox *checkBox;
2640
2641 if (!grpComposite->isHidden() && chkComposite->isChecked()) {
2642 m_bc.bc.setPrimaryMessage(txtData->text());
2643 m_bc.bc.setText(txtComposite->toPlainText());
2644 btnClearComposite->setEnabled(!txtComposite->toPlainText().isEmpty());
2645 } else {
2646 btnClearComposite->setEnabled(false);
2647 if (!grpSegs->isHidden() && !txtDataSeg1->text().isEmpty()) {
2648 std::vector<Zint::QZintSeg> segs;
2649 segs.push_back(Zint::QZintSeg(txtData->text(), cmbECI->currentIndex()));
2650 segs.push_back(Zint::QZintSeg(txtDataSeg1->text(), cmbECISeg1->currentIndex()));
2651 if (!txtDataSeg2->text().isEmpty()) {
2652 segs.push_back(Zint::QZintSeg(txtDataSeg2->text(), cmbECISeg2->currentIndex()));
2653 if (!txtDataSeg3->text().isEmpty()) {
2654 segs.push_back(Zint::QZintSeg(txtDataSeg3->text(), cmbECISeg3->currentIndex()));
2655 }
2656 }
2657 m_bc.bc.setSegs(segs);
2658 } else {
2659 m_bc.bc.setText(txtData->text());
2660 }
2661 }
2662 btnReset->setEnabled((m_fgstr != fgDefault && m_fgstr != fgDefaultAlpha)
2663 || (m_bgstr != bgDefault && m_bgstr != bgDefaultAlpha));
2664 m_bc.bc.setOption1(-1);
2665 m_bc.bc.setOption2(0);
2666 m_bc.bc.setOption3(0);
2667 m_bc.bc.setDPMM(m_xdimdpVars.set ? get_dpmm(&m_xdimdpVars) : 0.0f);
2668 chkData->setEnabled(true);
2669 if (chkData->isChecked()) {
2670 m_bc.bc.setInputMode(DATA_MODE);
2671 } else {
2672 m_bc.bc.setInputMode(UNICODE_MODE);
2673 }
2674 if (chkEscape->isChecked()) {
2675 m_bc.bc.setInputMode(m_bc.bc.inputMode() | ESCAPE_MODE);
2676 }
2677 m_bc.bc.setGSSep(false);
2678 m_bc.bc.setNoQuietZones(false);
2679 m_bc.bc.setGuardWhitespace(false);
2680 m_bc.bc.setDotSize(0.4f / 0.5f);
2681 m_bc.bc.setGuardDescent(5.0f);
2682 m_bc.bc.setTextGap(1.0f);
2683 m_bc.bc.clearStructApp();
2684
2685 switch (symbology) {
2686
2687 case BARCODE_CODE128:
2688 if (get_rad_val(QSL("radC128CSup"))) {
2689 m_bc.bc.setSymbol(BARCODE_CODE128AB);
2690 } else if (get_rad_val(QSL("radC128EAN"))) {
2691 m_bc.bc.setSymbol(chkComposite->isChecked() ? BARCODE_GS1_128_CC : BARCODE_GS1_128);
2692 } else if (get_rad_val(QSL("radC128HIBC"))) {
2693 m_bc.bc.setSymbol(BARCODE_HIBC_128);
2694 } else if (get_rad_val(QSL("radC128ExtraEsc"))) {
2695 m_bc.bc.setSymbol(BARCODE_CODE128);
2696 m_bc.bc.setInputMode(m_bc.bc.inputMode() | EXTRA_ESCAPE_MODE);
2697 } else {
2698 m_bc.bc.setSymbol(BARCODE_CODE128);
2699 }
2700 break;
2701
2702 case BARCODE_EANX:
2703 m_bc.bc.setSymbol(chkComposite->isChecked() ? BARCODE_EANX_CC : BARCODE_EANX);
2704 {
2705 bool have_addon = upcean_addon_gap(QSL("cmbUPCEANAddonGap"), QSL("lblUPCEANAddonGap"), 7 /*base*/);
2706 bool enable_guard = have_addon || txtData->text().length() > 5;
2707 upcean_guard_descent(QSL("spnUPCEANGuardDescent"), QSL("lblUPCEANGuardDescent"),
2708 QSL("btnUPCEANGuardDefault"), enable_guard);
2709 }
2710 if (get_chk_val(QSL("chkUPCEANNoQuietZones"))) {
2711 m_bc.bc.setNoQuietZones(true);
2712 } else if (get_chk_val(QSL("chkUPCEANGuardWhitespace"))) {
2713 m_bc.bc.setGuardWhitespace(true);
2714 }
2715 break;
2716
2717 case BARCODE_ISBNX:
2718 m_bc.bc.setSymbol(symbology);
2719 upcean_addon_gap(QSL("cmbUPCEANAddonGap"), QSL("lblUPCEANAddonGap"), 7 /*base*/);
2720 upcean_guard_descent(QSL("spnUPCEANGuardDescent"), QSL("lblUPCEANGuardDescent"),
2721 QSL("btnUPCEANGuardDefault"));
2722 if (get_chk_val(QSL("chkUPCEANNoQuietZones"))) {
2723 m_bc.bc.setNoQuietZones(true);
2724 } else if (get_chk_val(QSL("chkUPCEANGuardWhitespace"))) {
2725 m_bc.bc.setGuardWhitespace(true);
2726 }
2727 break;
2728
2729 case BARCODE_UPCA:
2730 m_bc.bc.setSymbol(chkComposite->isChecked() ? BARCODE_UPCA_CC : BARCODE_UPCA);
2731 upcean_addon_gap(QSL("cmbUPCAAddonGap"), QSL("lblUPCAAddonGap"), 9 /*base*/);
2732 upcean_guard_descent(QSL("spnUPCAGuardDescent"), QSL("lblUPCAGuardDescent"), QSL("btnUPCAGuardDefault"));
2733 if (get_chk_val(QSL("chkUPCANoQuietZones"))) {
2734 m_bc.bc.setNoQuietZones(true);
2735 } else if (get_chk_val(QSL("chkUPCAGuardWhitespace"))) {
2736 m_bc.bc.setGuardWhitespace(true);
2737 }
2738 break;
2739
2740 case BARCODE_UPCE:
2741 m_bc.bc.setSymbol(chkComposite->isChecked() ? BARCODE_UPCE_CC : BARCODE_UPCE);
2742 upcean_addon_gap(QSL("cmbUPCEANAddonGap"), QSL("lblUPCEANAddonGap"), 7 /*base*/);
2743 upcean_guard_descent(QSL("spnUPCEANGuardDescent"), QSL("lblUPCEANGuardDescent"),
2744 QSL("btnUPCEANGuardDefault"));
2745 if (get_chk_val(QSL("chkUPCEANNoQuietZones"))) {
2746 m_bc.bc.setNoQuietZones(true);
2747 } else if (get_chk_val(QSL("chkUPCEANGuardWhitespace"))) {
2748 m_bc.bc.setGuardWhitespace(true);
2749 }
2750 break;
2751
2752 case BARCODE_DBAR_OMN:
2753 m_bc.bc.setSymbol(chkComposite->isChecked() ? BARCODE_DBAR_OMN_CC : BARCODE_DBAR_OMN);
2754 break;
2755 case BARCODE_DBAR_LTD:
2756 m_bc.bc.setSymbol(chkComposite->isChecked() ? BARCODE_DBAR_LTD_CC : BARCODE_DBAR_LTD);
2757 break;
2758 case BARCODE_DBAR_EXP:
2759 m_bc.bc.setSymbol(chkComposite->isChecked() ? BARCODE_DBAR_EXP_CC : BARCODE_DBAR_EXP);
2760 break;
2761 case BARCODE_DBAR_STK:
2762 m_bc.bc.setSymbol(chkComposite->isChecked() ? BARCODE_DBAR_STK_CC : BARCODE_DBAR_STK);
2763 break;
2764 case BARCODE_DBAR_OMNSTK:
2765 m_bc.bc.setSymbol(chkComposite->isChecked() ? BARCODE_DBAR_OMNSTK_CC : BARCODE_DBAR_OMNSTK);
2766 break;
2767 case BARCODE_DBAR_EXPSTK:
2768 m_bc.bc.setSymbol(chkComposite->isChecked() ? BARCODE_DBAR_EXPSTK_CC : BARCODE_DBAR_EXPSTK);
2769 if (get_rad_val(QSL("radDBESCols"))) {
2770 if ((item_val = get_cmb_index(QSL("cmbDBESCols"))) != 0) {
2771 m_bc.bc.setOption2(item_val);
2772 }
2773 } else if (get_rad_val(QSL("radDBESRows"))) {
2774 if ((item_val = get_cmb_index(QSL("cmbDBESRows"))) != 0) {
2775 m_bc.bc.setOption3(item_val + 1); // Begins at 2
2776 }
2777 }
2778 break;
2779
2780 case BARCODE_PDF417:
2781 if (get_rad_val(QSL("radPDFTruncated")))
2782 m_bc.bc.setSymbol(BARCODE_PDF417COMP);
2783 else if (get_rad_val(QSL("radPDFHIBC")))
2784 m_bc.bc.setSymbol(BARCODE_HIBC_PDF);
2785 else
2786 m_bc.bc.setSymbol(BARCODE_PDF417);
2787
2788 m_bc.bc.setOption2(get_cmb_index(QSL("cmbPDFCols")));
2789 if ((item_val = get_cmb_index(QSL("cmbPDFRows"))) != 0) {
2790 m_bc.bc.setOption3(item_val + 2); // Starts at 3 rows
2791 }
2792 m_bc.bc.setOption1(get_cmb_index(QSL("cmbPDFECC")) - 1);
2793
2794 if (get_chk_val(QSL("chkPDFFast"))) {
2795 m_bc.bc.setInputMode(FAST_MODE | m_bc.bc.inputMode());
2796 }
2797
2798 if ((item_val = get_spn_val(QSL("spnPDFStructAppCount"))) > 1) {
2799 m_bc.bc.setStructApp(item_val, get_spn_val(QSL("spnPDFStructAppIndex")),
2800 get_txt_val(QSL("txtPDFStructAppID")));
2801 }
2802 break;
2803
2804 case BARCODE_MICROPDF417:
2805 if (get_rad_val(QSL("radMPDFHIBC")))
2806 m_bc.bc.setSymbol(BARCODE_HIBC_MICPDF);
2807 else
2808 m_bc.bc.setSymbol(BARCODE_MICROPDF417);
2809
2810 m_bc.bc.setOption2(get_cmb_index(QSL("cmbMPDFCols")));
2811
2812 if (get_chk_val(QSL("chkMPDFFast"))) {
2813 m_bc.bc.setInputMode(FAST_MODE | m_bc.bc.inputMode());
2814 }
2815
2816 if ((item_val = get_spn_val(QSL("spnMPDFStructAppCount"))) > 1) {
2817 m_bc.bc.setStructApp(item_val, get_spn_val(QSL("spnMPDFStructAppIndex")),
2818 get_txt_val(QSL("txtMPDFStructAppID")));
2819 }
2820 break;
2821
2822 case BARCODE_DOTCODE:
2823 m_bc.bc.setSymbol(BARCODE_DOTCODE);
2824 if ((item_val = get_cmb_index(QSL("cmbDotCols"))) != 0) {
2825 m_bc.bc.setOption2(item_val + 4); // Cols 1-4 not listed
2826 }
2827 if ((item_val = get_cmb_index(QSL("cmbDotMask"))) != 0) {
2828 m_bc.bc.setOption3((item_val << 8) | m_bc.bc.option3());
2829 }
2830 set_gs1_mode(get_rad_val(QSL("radDotGS1")));
2831
2832 if ((item_val = get_cmb_index(QSL("cmbDotStructAppCount"))) != 0) {
2833 QString id; // Dummy ID
2834 m_bc.bc.setStructApp(item_val + 1, get_cmb_index(QSL("cmbDotStructAppIndex")) + 1, id);
2835 }
2836 break;
2837
2838 case BARCODE_AZTEC:
2839 if (get_rad_val(QSL("radAztecHIBC")))
2840 m_bc.bc.setSymbol(BARCODE_HIBC_AZTEC);
2841 else
2842 m_bc.bc.setSymbol(BARCODE_AZTEC);
2843
2844 if (get_rad_val(QSL("radAztecSize")))
2845 m_bc.bc.setOption2(get_cmb_index(QSL("cmbAztecSize")) + 1);
2846
2847 if (get_rad_val(QSL("radAztecECC")))
2848 m_bc.bc.setOption1(get_cmb_index(QSL("cmbAztecECC")) + 1);
2849
2850 set_gs1_mode(get_rad_val(QSL("radAztecGS1")));
2851
2852 if ((item_val = get_cmb_index(QSL("cmbAztecStructAppCount"))) != 0) {
2853 m_bc.bc.setStructApp(item_val + 1, get_cmb_index(QSL("cmbAztecStructAppIndex")) + 1,
2854 get_txt_val(QSL("txtAztecStructAppID")));
2855 }
2856 break;
2857
2858 case BARCODE_MSI_PLESSEY:
2859 m_bc.bc.setSymbol(BARCODE_MSI_PLESSEY);
2860 item_val = get_cmb_index(QSL("cmbMSICheck"));
2861 if (item_val && get_chk_val(QSL("chkMSICheckText"))) {
2862 item_val += 10;
2863 }
2864 m_bc.bc.setOption2(item_val);
2865 break;
2866
2867 case BARCODE_CODE11:
2868 m_bc.bc.setSymbol(BARCODE_CODE11);
2869 if (get_rad_val(QSL("radC11OneCheckDigit"))) {
2870 m_bc.bc.setOption2(1);
2871 } else if (get_rad_val(QSL("radC11NoCheckDigits"))) {
2872 m_bc.bc.setOption2(2);
2873 }
2874 break;
2875
2876 case BARCODE_C25STANDARD:
2877 case BARCODE_C25INTER:
2878 case BARCODE_C25IATA:
2879 case BARCODE_C25LOGIC:
2880 case BARCODE_C25IND:
2881 m_bc.bc.setSymbol(symbology);
2882 m_bc.bc.setOption2(get_rad_grp_index(
2883 QStringList() << QSL("radC25Stand") << QSL("radC25Check") << QSL("radC25CheckHide")));
2884 break;
2885
2886 case BARCODE_CODE39:
2887 if (get_rad_val(QSL("radC39HIBC"))) {
2888 m_bc.bc.setSymbol(BARCODE_HIBC_39);
2889 } else {
2890 m_bc.bc.setSymbol(BARCODE_CODE39);
2891 if (get_rad_val(QSL("radC39Check"))) {
2892 m_bc.bc.setOption2(1);
2893 } else if (get_rad_val(QSL("radC39CheckHide"))) {
2894 m_bc.bc.setOption2(2);
2895 }
2896 }
2897 break;
2898 case BARCODE_EXCODE39:
2899 m_bc.bc.setSymbol(BARCODE_EXCODE39);
2900 if (get_rad_val(QSL("radC39Check"))) {
2901 m_bc.bc.setOption2(1);
2902 } else if (get_rad_val(QSL("radC39CheckHide"))) {
2903 m_bc.bc.setOption2(2);
2904 }
2905 break;
2906 case BARCODE_LOGMARS:
2907 m_bc.bc.setSymbol(BARCODE_LOGMARS);
2908 if (get_rad_val(QSL("radC39Check"))) {
2909 m_bc.bc.setOption2(1);
2910 } else if (get_rad_val(QSL("radC39CheckHide"))) {
2911 m_bc.bc.setOption2(2);
2912 }
2913 break;
2914
2915 case BARCODE_CODE16K:
2916 m_bc.bc.setSymbol(BARCODE_CODE16K);
2917 set_gs1_mode(get_rad_val(QSL("radC16kGS1")));
2918 if ((item_val = get_cmb_index(QSL("cmbC16kRows"))) != 0) {
2919 m_bc.bc.setOption1(item_val + 2); // Starts at 3
2920 }
2921 // Row separator height selection uses option 3 in zint_symbol
2922 if ((item_val = get_cmb_index(QSL("cmbC16kRowSepHeight"))) != 0) {
2923 m_bc.bc.setOption3(item_val + 1); // Zero-based
2924 }
2925 if (get_chk_val(QSL("chkC16kNoQuietZones"))) {
2926 m_bc.bc.setNoQuietZones(true);
2927 }
2928 break;
2929
2930 case BARCODE_CODABAR:
2931 m_bc.bc.setSymbol(BARCODE_CODABAR);
2932 m_bc.bc.setOption2(get_rad_grp_index(
2933 QStringList() << QSL("radCodabarStand") << QSL("radCodabarCheckHide") << QSL("radCodabarCheck")));
2934 break;
2935
2936 case BARCODE_CODABLOCKF:
2937 if (get_rad_val(QSL("radCbfHIBC"))) {
2938 m_bc.bc.setSymbol(BARCODE_HIBC_BLOCKF);
2939 } else {
2940 m_bc.bc.setSymbol(BARCODE_CODABLOCKF);
2941 }
2942 if ((item_val = get_cmb_index(QSL("cmbCbfWidth"))) != 0) {
2943 m_bc.bc.setOption2(item_val - 1 + 9);
2944 }
2945 // Height selection uses option 1 in zint_symbol
2946 if ((item_val = get_cmb_index(QSL("cmbCbfHeight"))) != 0) {
2947 m_bc.bc.setOption1(item_val);
2948 }
2949 // Row separator height selection uses option 3 in zint_symbol
2950 if ((item_val = get_cmb_index(QSL("cmbCbfRowSepHeight"))) != 0) {
2951 m_bc.bc.setOption3(item_val + 1); // Zero-based
2952 }
2953 if (get_chk_val(QSL("chkCbfNoQuietZones"))) {
2954 m_bc.bc.setNoQuietZones(true);
2955 }
2956 break;
2957
2958 case BARCODE_DAFT:
2959 m_bc.bc.setSymbol(BARCODE_DAFT);
2960 // Kept as percentage, convert to thousandths
2961 m_bc.bc.setOption2((int) (get_dspn_val(QSL("spnDAFTTrackerRatio")) * 10));
2962 break;
2963
2964 case BARCODE_DPD:
2965 m_bc.bc.setSymbol(BARCODE_DPD);
2966 if (get_chk_val(QSL("chkDPDRelabel"))) {
2967 m_bc.bc.setOption2(1);
2968 }
2969 break;
2970
2971 case BARCODE_DATAMATRIX:
2972 if (get_rad_val(QSL("radDM200HIBC")))
2973 m_bc.bc.setSymbol(BARCODE_HIBC_DM);
2974 else
2975 m_bc.bc.setSymbol(BARCODE_DATAMATRIX);
2976
2977 checkBox = m_optionWidget->findChild<QCheckBox*>(QSL("chkDMGSSep"));
2978 if (get_rad_val(QSL("radDM200GS1"))) {
2979 set_gs1_mode(true);
2980 checkBox->setEnabled(true);
2981 if (checkBox->isChecked()) {
2982 m_bc.bc.setGSSep(true);
2983 }
2984 } else {
2985 set_gs1_mode(false);
2986 checkBox->setEnabled(false);
2987 }
2988
2989 m_bc.bc.setOption2(get_cmb_index(QSL("cmbDM200Size")));
2990
2991 if (get_cmb_index(QSL("cmbDM200Size")) == 0) {
2992 // Suppressing rectangles or allowing DMRE only makes sense if in automatic size mode
2993 m_optionWidget->findChild<QLabel*>(QSL("lblDMAutoSize"))->setEnabled(true);
2994 m_optionWidget->findChild<QCheckBox*>(QSL("chkDMRectangle"))->setEnabled(true);
2995 if (m_optionWidget->findChild<QCheckBox*>(QSL("chkDMRectangle"))->isChecked()) {
2996 m_bc.bc.setOption3(DM_SQUARE);
2997 m_optionWidget->findChild<QCheckBox*>(QSL("chkDMRE"))->setEnabled(false);
2998 } else {
2999 m_optionWidget->findChild<QCheckBox*>(QSL("chkDMRE"))->setEnabled(true);
3000 if (m_optionWidget->findChild<QCheckBox*>(QSL("chkDMRE"))->isChecked())
3001 m_bc.bc.setOption3(DM_DMRE);
3002 else
3003 m_bc.bc.setOption3(0);
3004 }
3005 } else {
3006 m_optionWidget->findChild<QLabel*>(QSL("lblDMAutoSize"))->setEnabled(false);
3007 m_optionWidget->findChild<QCheckBox*>(QSL("chkDMRectangle"))->setEnabled(false);
3008 m_optionWidget->findChild<QCheckBox*>(QSL("chkDMRE"))->setEnabled(false);
3009 m_bc.bc.setOption3(0);
3010 }
3011
3012 if (get_chk_val(QSL("chkDMISO144"))) {
3013 m_bc.bc.setOption3(m_bc.bc.option3() | DM_ISO_144);
3014 }
3015
3016 if (get_chk_val(QSL("chkDMFast"))) {
3017 m_bc.bc.setInputMode(FAST_MODE | m_bc.bc.inputMode());
3018 }
3019
3020 if ((item_val = get_cmb_index(QSL("cmbDMStructAppCount"))) != 0) {
3021 QString id;
3022 int id1 = get_spn_val(QSL("spnDMStructAppID"));
3023 int id2 = get_spn_val(QSL("spnDMStructAppID2"));
3024 m_bc.bc.setStructApp(item_val + 1, get_cmb_index(QSL("cmbDMStructAppIndex")) + 1,
3025 id.setNum(id1 * 1000 + id2));
3026 }
3027 break;
3028
3029 case BARCODE_MAILMARK_2D:
3030 m_bc.bc.setSymbol(BARCODE_MAILMARK_2D);
3031
3032 if ((item_val = get_cmb_index(QSL("cmbMailmark2DSize")))) {
3033 m_bc.bc.setOption2(item_val == 1 ? 8 : item_val == 2 ? 10 : 30);
3034 }
3035
3036 if (!item_val) {
3037 // Suppressing rectangles only makes sense if in automatic size mode
3038 m_optionWidget->findChild<QLabel*>(QSL("lblMailmark2DAutoSize"))->setEnabled(true);
3039 m_optionWidget->findChild<QCheckBox*>(QSL("chkMailmark2DRectangle"))->setEnabled(true);
3040 if (m_optionWidget->findChild<QCheckBox*>(QSL("chkMailmark2DRectangle"))->isChecked()) {
3041 m_bc.bc.setOption3(DM_SQUARE);
3042 }
3043 } else {
3044 m_optionWidget->findChild<QLabel*>(QSL("lblMailmark2DAutoSize"))->setEnabled(false);
3045 m_optionWidget->findChild<QCheckBox*>(QSL("chkMailmark2DRectangle"))->setEnabled(false);
3046 m_bc.bc.setOption3(0);
3047 }
3048
3049 break;
3050
3051 case BARCODE_ITF14:
3052 m_bc.bc.setSymbol(BARCODE_ITF14);
3053 if (get_chk_val(QSL("chkITF14NoQuietZones"))) {
3054 m_bc.bc.setNoQuietZones(true);
3055 }
3056 break;
3057
3058 case BARCODE_PZN:
3059 m_bc.bc.setSymbol(BARCODE_PZN);
3060 if (get_chk_val(QSL("chkPZN7"))) {
3061 m_bc.bc.setOption2(1);
3062 }
3063 break;
3064
3065 case BARCODE_QRCODE:
3066 if (get_rad_val(QSL("radQRHIBC")))
3067 m_bc.bc.setSymbol(BARCODE_HIBC_QR);
3068 else
3069 m_bc.bc.setSymbol(BARCODE_QRCODE);
3070
3071 set_gs1_mode(get_rad_val(QSL("radQRGS1")));
3072
3073 if ((item_val = get_cmb_index(QSL("cmbQRSize"))) != 0) {
3074 m_bc.bc.setOption2(item_val);
3075 }
3076 if ((item_val = get_cmb_index(QSL("cmbQRECC"))) != 0) {
3077 m_bc.bc.setOption1(item_val);
3078 }
3079 if ((item_val = get_cmb_index(QSL("cmbQRMask"))) != 0) {
3080 m_bc.bc.setOption3((item_val << 8) | m_bc.bc.option3());
3081 }
3082 if (get_chk_val(QSL("chkQRFullMultibyte"))) {
3083 m_bc.bc.setOption3(ZINT_FULL_MULTIBYTE | m_bc.bc.option3());
3084 }
3085 if (get_chk_val(QSL("chkQRFast"))) {
3086 m_bc.bc.setInputMode(FAST_MODE | m_bc.bc.inputMode());
3087 }
3088 if ((item_val = get_cmb_index(QSL("cmbQRStructAppCount"))) != 0) {
3089 QString id;
3090 int id_val = get_spn_val(QSL("spnQRStructAppID"));
3091 m_bc.bc.setStructApp(item_val + 1, get_cmb_index(QSL("cmbQRStructAppIndex")) + 1, id.setNum(id_val));
3092 }
3093 break;
3094
3095 case BARCODE_MICROQR:
3096 m_bc.bc.setSymbol(BARCODE_MICROQR);
3097 if ((item_val = get_cmb_index(QSL("cmbMQRSize"))) != 0) {
3098 m_bc.bc.setOption2(item_val);
3099 }
3100 if ((item_val = get_cmb_index(QSL("cmbMQRECC"))) != 0) {
3101 m_bc.bc.setOption1(item_val);
3102 }
3103 if ((item_val = get_cmb_index(QSL("cmbMQRMask"))) != 0) {
3104 m_bc.bc.setOption3((item_val << 8) | m_bc.bc.option3());
3105 }
3106 if (get_chk_val(QSL("chkMQRFullMultibyte"))) {
3107 m_bc.bc.setOption3(ZINT_FULL_MULTIBYTE | m_bc.bc.option3());
3108 }
3109 break;
3110
3111 case BARCODE_UPNQR:
3112 m_bc.bc.setSymbol(BARCODE_UPNQR);
3113 cmbECI->setCurrentIndex(2 /*ECI 4*/);
3114 if ((item_val = get_cmb_index(QSL("cmbUPNQRMask"))) != 0) {
3115 m_bc.bc.setOption3((item_val << 8) | m_bc.bc.option3());
3116 }
3117 if (get_chk_val(QSL("chkUPNQRFast"))) {
3118 m_bc.bc.setInputMode(FAST_MODE | m_bc.bc.inputMode());
3119 }
3120 break;
3121
3122 case BARCODE_RMQR:
3123 m_bc.bc.setSymbol(BARCODE_RMQR);
3124
3125 set_gs1_mode(get_rad_val(QSL("radRMQRGS1")));
3126
3127 if ((item_val = get_cmb_index(QSL("cmbRMQRSize"))) != 0) {
3128 m_bc.bc.setOption2(item_val);
3129 }
3130 if ((item_val = get_cmb_index(QSL("cmbRMQRECC"))) != 0) {
3131 m_bc.bc.setOption1(item_val * 2); // Levels 2 (M) and 4 (H) only
3132 }
3133 if (get_chk_val(QSL("chkRMQRFullMultibyte"))) {
3134 m_bc.bc.setOption3(ZINT_FULL_MULTIBYTE);
3135 }
3136 break;
3137
3138 case BARCODE_GRIDMATRIX:
3139 m_bc.bc.setSymbol(BARCODE_GRIDMATRIX);
3140 if ((item_val = get_cmb_index(QSL("cmbGridSize"))) != 0) {
3141 m_bc.bc.setOption2(item_val);
3142 }
3143 if ((item_val = get_cmb_index(QSL("cmbGridECC"))) != 0) {
3144 m_bc.bc.setOption1(item_val);
3145 }
3146 if (get_chk_val(QSL("chkGridFullMultibyte"))) {
3147 m_bc.bc.setOption3(ZINT_FULL_MULTIBYTE);
3148 }
3149 if ((item_val = get_cmb_index(QSL("cmbGridStructAppCount"))) != 0) {
3150 QString id;
3151 int id_val = get_spn_val(QSL("spnGridStructAppID"));
3152 m_bc.bc.setStructApp(item_val + 1, get_cmb_index(QSL("cmbGridStructAppIndex")) + 1,
3153 id.setNum(id_val));
3154 }
3155 break;
3156
3157 case BARCODE_MAXICODE:
3158 m_bc.bc.setSymbol(BARCODE_MAXICODE);
3159 if (get_cmb_index(QSL("cmbMaxiMode")) == 0) {
3160 m_bc.bc.setOption1(0); // Auto-determine mode 2 or 3 from primary message (checks that it isn't empty)
3161 m_bc.bc.setPrimaryMessage(QString::asprintf("%s%03d%03d",
3162 get_txt_val(QSL("txtMaxiSCMPostcode")).toUtf8().constData(),
3163 get_spn_val(QSL("spnMaxiSCMCountry")), get_spn_val(QSL("spnMaxiSCMService"))));
3164 QCheckBox *chkMaxiSCMVV = m_optionWidget->findChild<QCheckBox*>(QSL("chkMaxiSCMVV"));
3165 if (chkMaxiSCMVV && chkMaxiSCMVV->isEnabled() && chkMaxiSCMVV->isChecked()) {
3166 m_bc.bc.setOption2(get_spn_val(QSL("spnMaxiSCMVV")) + 1);
3167 }
3168 } else {
3169 m_bc.bc.setOption1(get_cmb_index(QSL("cmbMaxiMode")) + 3);
3170 }
3171
3172 if ((item_val = get_cmb_index(QSL("cmbMaxiStructAppCount"))) != 0) {
3173 QString id; // Dummy ID
3174 m_bc.bc.setStructApp(item_val + 1, get_cmb_index(QSL("cmbMaxiStructAppIndex")) + 1, id);
3175 }
3176 break;
3177
3178 case BARCODE_CHANNEL:
3179 m_bc.bc.setSymbol(BARCODE_CHANNEL);
3180 if ((item_val = get_cmb_index(QSL("cmbChannel"))) == 0)
3181 m_bc.bc.setOption2(0);
3182 else
3183 m_bc.bc.setOption2(item_val + 2);
3184 break;
3185
3186 case BARCODE_CODEONE:
3187 m_bc.bc.setSymbol(BARCODE_CODEONE);
3188 m_bc.bc.setOption2(get_cmb_index(QSL("cmbC1Size")));
3189 if (m_bc.bc.option2() == 9) { // Version S
3190 eci_not_set = false;
3191 cmbECI->setEnabled(false);
3192 lblECI->setEnabled(false);
3193 m_optionWidget->findChild<QRadioButton*>(QSL("radC1GS1"))->setEnabled(false);
3194 } else {
3195 m_optionWidget->findChild<QRadioButton*>(QSL("radC1GS1"))->setEnabled(true);
3196 set_gs1_mode(get_rad_val(QSL("radC1GS1")));
3197 }
3198 if (get_cmb_index(QSL("cmbC1Size")) != 9 && (item_val = get_spn_val(QSL("spnC1StructAppCount"))) > 1) {
3199 QString id; // Dummy ID
3200 m_bc.bc.setStructApp(item_val, get_spn_val(QSL("spnC1StructAppIndex")), id);
3201 }
3202 break;
3203
3204 case BARCODE_CODE49:
3205 m_bc.bc.setSymbol(BARCODE_CODE49);
3206 set_gs1_mode(get_rad_val(QSL("radC49GS1")));
3207 if ((item_val = get_cmb_index(QSL("cmbC49Rows"))) != 0) {
3208 m_bc.bc.setOption1(item_val + 2); // Starts at 3
3209 }
3210 // Row separator height selection uses option 3 in zint_symbol
3211 if ((item_val = get_cmb_index(QSL("cmbC49RowSepHeight"))) != 0) {
3212 m_bc.bc.setOption3(item_val + 1); // Zero-based
3213 }
3214 if (get_chk_val(QSL("chkC49NoQuietZones"))) {
3215 m_bc.bc.setNoQuietZones(true);
3216 }
3217 break;
3218
3219 case BARCODE_CODE93:
3220 m_bc.bc.setSymbol(BARCODE_CODE93);
3221 if (get_chk_val(QSL("chkC93ShowChecks"))) {
3222 m_bc.bc.setOption2(1);
3223 }
3224 break;
3225
3226 case BARCODE_HANXIN:
3227 m_bc.bc.setSymbol(BARCODE_HANXIN);
3228 if ((item_val = get_cmb_index(QSL("cmbHXSize"))) != 0) {
3229 m_bc.bc.setOption2(item_val);
3230 }
3231 if ((item_val = get_cmb_index(QSL("cmbHXECC"))) != 0) {
3232 m_bc.bc.setOption1(item_val);
3233 }
3234 if ((item_val = get_cmb_index(QSL("cmbHXMask"))) != 0) {
3235 m_bc.bc.setOption3((item_val << 8) | m_bc.bc.option3());
3236 }
3237 if (get_chk_val(QSL("chkHXFullMultibyte"))) {
3238 m_bc.bc.setOption3(ZINT_FULL_MULTIBYTE | m_bc.bc.option3());
3239 }
3240 break;
3241
3242 case BARCODE_ULTRA:
3243 m_bc.bc.setSymbol(BARCODE_ULTRA);
3244 if (get_rad_val(QSL("radUltraEcc")))
3245 m_bc.bc.setOption1(get_cmb_index(QSL("cmbUltraEcc")) + 1);
3246
3247 set_gs1_mode(get_rad_val(QSL("radUltraGS1")));
3248
3249 if ((item_val = get_cmb_index(QSL("cmbUltraRevision"))) > 0) {
3250 m_bc.bc.setOption2(item_val + 1); // Combobox 0-based
3251 }
3252 if ((item_val = get_cmb_index(QSL("cmbUltraStructAppCount"))) != 0) {
3253 QString id;
3254 int id_val = get_spn_val(QSL("spnUltraStructAppID"));
3255 m_bc.bc.setStructApp(item_val + 1, get_cmb_index(QSL("cmbUltraStructAppIndex")) + 1,
3256 id.setNum(id_val));
3257 }
3258 break;
3259
3260 case BARCODE_VIN:
3261 m_bc.bc.setSymbol(BARCODE_VIN);
3262 if (get_chk_val(QSL("chkVINImportChar"))) {
3263 m_bc.bc.setOption2(m_bc.bc.option2() | 1); // Import character 'I' prefix
3264 }
3265 break;
3266
3267 default:
3268 m_bc.bc.setSymbol(symbology);
3269 break;
3270 }
3271 m_symbology = m_bc.bc.symbol();
3272
3273 if (eci_not_set) {
3274 cmbECI->setEnabled(m_bc.bc.supportsECI());
3275 lblECI->setEnabled(cmbECI->isEnabled());
3276 }
3277 btnClearData->setEnabled(!txtData->text().isEmpty());
3278 chkGS1Parens->setEnabled(m_bc.bc.takesGS1AIData(m_symbology) || (m_bc.bc.inputMode() & 0x07) == GS1_MODE);
3279 chkGS1NoCheck->setEnabled(chkGS1Parens->isEnabled());
3280 chkRInit->setEnabled(m_bc.bc.supportsReaderInit() && (m_bc.bc.inputMode() & 0x07) != GS1_MODE);
3281 chkCompliantHeight->setEnabled(m_bc.bc.hasCompliantHeight());
3282
3283 if (!grpComposite->isHidden() && chkComposite->isChecked())
3284 m_bc.bc.setOption1(cmbCompType->currentIndex());
3285
3286 if (!chkAutoHeight->isEnabled() || chkAutoHeight->isChecked()) {
3287 m_bc.bc.setHeight(0);
3288 } else {
3289 if (m_spnHeightPerRow && m_spnHeightPerRow->isEnabled() && m_spnHeightPerRow->value()) {
3290 // This causes a double-encode unfortunately, as heightb gets synced
3291 m_bc.bc.setInputMode(m_bc.bc.inputMode() | HEIGHTPERROW_MODE);
3292 m_bc.bc.setHeight(m_spnHeightPerRow->value());
3293 } else {
3294 m_bc.bc.setHeight(heightb->value());
3295 }
3296 }
3297 m_bc.bc.setCompliantHeight(chkCompliantHeight->isEnabled() && chkCompliantHeight->isChecked());
3298 m_bc.bc.setECI(cmbECI->isEnabled() ? cmbECI->currentIndex() : 0);
3299 m_bc.bc.setGS1Parens(chkGS1Parens->isEnabled() && chkGS1Parens->isChecked());
3300 m_bc.bc.setGS1NoCheck(chkGS1NoCheck->isEnabled() && chkGS1NoCheck->isChecked());
3301 m_bc.bc.setReaderInit(chkRInit->isEnabled() && chkRInit->isChecked());
3302 m_bc.bc.setShowText(chkHRTShow->isEnabled() && chkHRTShow->isChecked());
3303 m_bc.bc.setBorderType(btype->currentIndex());
3304 m_bc.bc.setBorderWidth(bwidth->value());
3305 m_bc.bc.setWhitespace(spnWhitespace->value());
3306 m_bc.bc.setVWhitespace(spnVWhitespace->value());
3307 m_bc.bc.setQuietZones(chkQuietZones->isEnabled() && chkQuietZones->isChecked());
3308 m_bc.bc.setFontSetting(cmbFontSetting->currentIndex());
3309 m_bc.bc.setTextGap(spnTextGap->value());
3310 m_bc.bc.setRotateAngle(cmbRotate->currentIndex());
3311 m_bc.bc.setEmbedVectorFont(chkEmbedVectorFont->isEnabled() && chkEmbedVectorFont->isChecked());
3312 m_bc.bc.setDotty(chkDotty->isEnabled() && chkDotty->isChecked());
3313 if (m_symbology == BARCODE_DOTCODE || (chkDotty->isEnabled() && chkDotty->isChecked())) {
3314 m_bc.bc.setDotSize(spnDotSize->value());
3315 }
3316 m_bc.bc.setFgStr(m_fgstr);
3317 m_bc.bc.setBgStr(m_bgstr);
3318 m_bc.bc.setScale((float) spnScale->value());
3319 change_cmyk();
3320 m_bc.setSize(width - 10, height - 10);
3321 m_bc.update();
3322 scene->setSceneRect(m_bc.boundingRect());
3323 scene->update();
3324 }
3325
3326 void MainWindow::createActions()
3327 {
3328 // SVG icons from https://github.com/feathericons/feather
3329 // MIT license - see site and "frontend_qt/res/LICENSE_feathericons"
3330 QIcon menuIcon(QSL(":res/menu.svg"));
3331 QIcon copyIcon(QIcon::fromTheme(QSL("edit-copy"), QIcon(QSL(":res/copy.svg"))));
3332 QIcon cliIcon(QSL(":res/zint_black.ico"));
3333 QIcon saveIcon(QIcon::fromTheme(QSL("document-save"), QIcon(QSL(":res/download.svg"))));
3334 QIcon zapIcon(QSL(":res/zap.svg"));
3335 QIcon aboutIcon(QSL(":res/zint-qt.ico"));
3336 QIcon helpIcon(QIcon::fromTheme(QSL("help-contents"), QIcon(QSL(":res/help-circle.svg"))));
3337 QIcon previewBgIcon(QSL(":res/monitor-bg.svg"));
3338 QIcon quitIcon(QIcon::fromTheme(QSL("window-close"), QIcon(QSL(":res/x.svg"))));
3339
3340 btnMenu->setIcon(menuIcon);
3341 btnCopyBMP->setIcon(copyIcon);
3342 btnCopySVG->setIcon(copyIcon);
3343 btnSave->setIcon(saveIcon); // Makes it (too) big but live with it for a while after "Save As..." -> "Save..."
3344 btnExit->setIcon(quitIcon);
3345
3346 m_copyBMPAct = new QAction(copyIcon, tr("Copy as &BMP"), this);
3347 m_copyBMPAct->setStatusTip(tr("Copy to clipboard as BMP"));
3348 m_copyBMPAct->setShortcut(*copyBMPSeq);
3349 connect(m_copyBMPAct, SIGNAL(triggered()), this, SLOT(copy_to_clipboard_bmp()));
3350
3351 m_copyEMFAct = new QAction(copyIcon, tr("Copy as E&MF"), this);
3352 m_copyEMFAct->setStatusTip(tr("Copy to clipboard as EMF"));
3353 m_copyEMFAct->setShortcut(*copyEMFSeq);
3354 connect(m_copyEMFAct, SIGNAL(triggered()), this, SLOT(copy_to_clipboard_emf()));
3355
3356 #ifdef MAINWINDOW_COPY_EPS /* TODO: see if can get this to work */
3357 m_copyEPSAct = new QAction(copyIcon, tr("Copy as &EPS"), this);
3358 m_copyEPSAct->setStatusTip(tr("Copy to clipboard as EPS"));
3359 connect(m_copyEPSAct, SIGNAL(triggered()), this, SLOT(copy_to_clipboard_eps()));
3360 #endif
3361
3362 m_copyGIFAct = new QAction(copyIcon, tr("Copy as &GIF"), this);
3363 m_copyGIFAct->setStatusTip(tr("Copy to clipboard as GIF"));
3364 m_copyGIFAct->setShortcut(*copyGIFSeq);
3365 connect(m_copyGIFAct, SIGNAL(triggered()), this, SLOT(copy_to_clipboard_gif()));
3366
3367 #ifdef MAINWINDOW_COPY_PCX /* TODO: see if can get this to work */
3368 m_copyPCXAct = new QAction(copyIcon, tr("Copy as P&CX"), this);
3369 m_copyPCXAct->setStatusTip(tr("Copy to clipboard as PCX"));
3370 connect(m_copyPCXAct, SIGNAL(triggered()), this, SLOT(copy_to_clipboard_pcx()));
3371 #endif
3372
3373 if (!m_bc.bc.noPng()) {
3374 m_copyPNGAct = new QAction(copyIcon, tr("Copy as &PNG"), this);
3375 m_copyPNGAct->setStatusTip(tr("Copy to clipboard as PNG"));
3376 m_copyPNGAct->setShortcut(*copyPNGSeq);
3377 connect(m_copyPNGAct, SIGNAL(triggered()), this, SLOT(copy_to_clipboard_png()));
3378 }
3379
3380 m_copySVGAct = new QAction(copyIcon, tr("Copy as S&VG"), this);
3381 m_copySVGAct->setStatusTip(tr("Copy to clipboard as SVG"));
3382 m_copySVGAct->setShortcut(*copySVGSeq);
3383 connect(m_copySVGAct, SIGNAL(triggered()), this, SLOT(copy_to_clipboard_svg()));
3384
3385 m_copyTIFAct = new QAction(copyIcon, tr("Copy as &TIF"), this);
3386 m_copyTIFAct->setStatusTip(tr("Copy to clipboard as TIF"));
3387 m_copyTIFAct->setShortcut(*copyTIFSeq);
3388 connect(m_copyTIFAct, SIGNAL(triggered()), this, SLOT(copy_to_clipboard_tif()));
3389
3390 m_openCLIAct = new QAction(cliIcon, tr("C&LI Equivalent..."), this);
3391 m_openCLIAct->setStatusTip(tr("Generate CLI equivalent"));
3392 m_openCLIAct->setShortcut(*openCLISeq);
3393 connect(m_openCLIAct, SIGNAL(triggered()), this, SLOT(open_cli_dialog()));
3394
3395 m_saveAsAct = new QAction(saveIcon, tr("&Save As..."), this);
3396 m_saveAsAct->setStatusTip(tr("Output image to file"));
3397 m_saveAsAct->setShortcut(QKeySequence::Save);
3398 connect(m_saveAsAct, SIGNAL(triggered()), this, SLOT(save()));
3399
3400 m_factoryResetAct = new QAction(zapIcon, tr("Factory &Reset..."), this);
3401 m_factoryResetAct->setStatusTip(tr("Clear all data & settings"));
3402 m_factoryResetAct->setShortcut(*factoryResetSeq);
3403 connect(m_factoryResetAct, SIGNAL(triggered()), this, SLOT(factory_reset()));
3404
3405 m_helpAct = new QAction(helpIcon, tr("&Help (online)"), this);
3406 m_helpAct->setStatusTip(tr("Online manual"));
3407 m_helpAct->setShortcut(QKeySequence::HelpContents);
3408 connect(m_helpAct, SIGNAL(triggered()), this, SLOT(help()));
3409
3410 m_previewBgColorAct = new QAction(previewBgIcon, tr("Set preview bac&kground..."), this);
3411 m_previewBgColorAct->setStatusTip(tr("Set preview background colour"));
3412 connect(m_previewBgColorAct, SIGNAL(triggered()), this, SLOT(preview_bg()));
3413
3414 m_aboutAct = new QAction(aboutIcon, tr("&About..."), this);
3415 m_aboutAct->setStatusTip(tr("About Zint Barcode Studio"));
3416 connect(m_aboutAct, SIGNAL(triggered()), this, SLOT(about()));
3417
3418 m_quitAct = new QAction(quitIcon, tr("&Quit"), this);
3419 m_quitAct->setStatusTip(tr("Exit Zint Barcode Studio"));
3420 m_quitAct->setShortcut(*quitKeySeq);
3421 connect(m_quitAct, SIGNAL(triggered()), this, SLOT(quit_now()));
3422
3423 m_copyErrtxtAct = new QAction(copyIcon, tr("&Copy"), this);
3424 m_copyErrtxtAct->setStatusTip(tr("Copy message to clipboard"));
3425 connect(m_copyErrtxtAct, SIGNAL(triggered()), this, SLOT(copy_to_clipboard_errtxt()));
3426 }
3427
3428 void MainWindow::createMenu()
3429 {
3430 m_menu = new QMenu(tr("Menu"), this);
3431
3432 m_menu->addAction(m_copyBMPAct);
3433 m_menu->addAction(m_copyEMFAct);
3434 #ifdef MAINWINDOW_COPY_EPS
3435 m_menu->addAction(m_copyEPSAct);
3436 #endif
3437 m_menu->addAction(m_copyGIFAct);
3438 #ifdef MAINWINDOW_COPY_PCX
3439 m_menu->addAction(m_copyPCXAct);
3440 #endif
3441 if (!m_bc.bc.noPng()) {
3442 m_menu->addAction(m_copyPNGAct);
3443 }
3444 m_menu->addAction(m_copySVGAct);
3445 m_menu->addAction(m_copyTIFAct);
3446 m_menu->addSeparator();
3447
3448 m_menu->addAction(m_openCLIAct);
3449 m_menu->addSeparator();
3450 m_menu->addAction(m_saveAsAct);
3451 m_menu->addSeparator();
3452 m_menu->addAction(m_factoryResetAct);
3453 m_menu->addSeparator();
3454 m_menu->addAction(m_helpAct);
3455 m_menu->addAction(m_aboutAct);
3456 m_menu->addSeparator();
3457 m_menu->addAction(m_quitAct);
3458 }
3459
3460 void MainWindow::enableActions()
3461 {
3462 const bool enabled = m_bc.bc.getError() < ZINT_ERROR;
3463 btnCopyBMP->setEnabled(enabled);
3464 btnCopySVG->setEnabled(enabled);
3465 btnSave->setEnabled(enabled);
3466
3467 m_copyBMPAct->setEnabled(enabled);
3468 m_copyEMFAct->setEnabled(enabled);
3469 #ifdef MAINWINDOW_COPY_EPS
3470 m_copyEPSAct->setEnabled(enabled);
3471 #endif
3472 m_copyGIFAct->setEnabled(enabled);
3473 #ifdef MAINWINDOW_COPY_PCX
3474 m_copyPCXAct->setEnabled(enabled);
3475 #endif
3476 if (!m_bc.bc.noPng()) {
3477 m_copyPNGAct->setEnabled(enabled);
3478 }
3479 m_copySVGAct->setEnabled(enabled);
3480 m_copyTIFAct->setEnabled(enabled);
3481 m_openCLIAct->setEnabled(enabled);
3482 m_saveAsAct->setEnabled(enabled);
3483
3484 m_saveAsShortcut->setEnabled(enabled);
3485 m_openCLIShortcut->setEnabled(enabled);
3486 m_copyBMPShortcut->setEnabled(enabled);
3487 m_copyEMFShortcut->setEnabled(enabled);
3488 m_copyGIFShortcut->setEnabled(enabled);
3489 if (!m_bc.bc.noPng()) {
3490 m_copyPNGShortcut->setEnabled(enabled);
3491 }
3492 m_copySVGShortcut->setEnabled(enabled);
3493 m_copyTIFShortcut->setEnabled(enabled);
3494 }
3495
3496 void MainWindow::copy_to_clipboard(const QString &filename, const QString& name, const char *mimeType)
3497 {
3498 QClipboard *clipboard = QGuiApplication::clipboard();
3499
3500 if (!m_bc.bc.save_to_file(filename)) {
3501 return;
3502 }
3503
3504 QMimeData *mdata = new QMimeData;
3505 if (mimeType) {
3506 QFile file(filename);
3507 if (!file.open(QIODevice::ReadOnly)) {
3508 delete mdata;
3509 } else {
3510 mdata->setData(mimeType, file.readAll());
3511 file.close();
3512 clipboard->setMimeData(mdata, QClipboard::Clipboard);
3513 /*: %1 is format (BMP/EMF etc) */
3514 statusBar->showMessage(tr("Copied to clipboard as %1").arg(name), 0 /*No timeout*/);
3515 }
3516 } else {
3517 mdata->setImageData(QImage(filename));
3518 clipboard->setMimeData(mdata, QClipboard::Clipboard);
3519 /*: %1 is format (BMP/EMF etc) */
3520 statusBar->showMessage(tr("Copied to clipboard as %1").arg(name), 0 /*No timeout*/);
3521 }
3522
3523 QFile::remove(filename);
3524 }
3525
3526 void MainWindow::errtxtBar_clear()
3527 {
3528 errtxtBar->clearMessage();
3529 if (!errtxtBarContainer->isHidden()) {
3530 errtxtBarContainer->hide();
3531 errtxtBarContainer->update();
3532 update_preview(); // This causes a double-encode unfortunately
3533 }
3534 }
3535
3536 void MainWindow::errtxtBar_set()
3537 {
3538 const bool isError = m_bc.bc.getError() >= ZINT_ERROR;
3539 if (!m_bc.bc.hasErrors()) {
3540 errtxtBar_clear();
3541 view->setMinimumSize(QSize(0, 35));
3542 } else {
3543 view->setMinimumSize(QSize(0, 5));
3544 errtxtBar->showMessage(m_bc.bc.lastError());
3545 errtxtBar->setStyleSheet(isError
3546 ? QSL("QStatusBar {background:white; color:#dd0000;}")
3547 : QSL("QStatusBar {background:white; color:#ff6f00;}"));
3548 if (errtxtBarContainer->isHidden()) {
3549 errtxtBarContainer->show();
3550 errtxtBarContainer->update();
3551 update_preview(); // This causes a double-encode unfortunately
3552 }
3553 }
3554 }
3555
3556 void MainWindow::automatic_info_set()
3557 {
3558 if (!m_optionWidget) {
3559 return;
3560 }
3561 const int symbology = bstyle_items[bstyle->currentIndex()].symbology;
3562 const bool isError = m_bc.bc.getError() >= ZINT_ERROR;
3563 QLineEdit *txt;
3564 QComboBox *cmb;
3565
3566 if (symbology == BARCODE_AZTEC || symbology == BARCODE_HIBC_AZTEC) {
3567 if ((txt = m_optionWidget->findChild<QLineEdit*>(QSL("txtAztecAutoInfo")))) {
3568 if (!isError && !get_rad_val(QSL("radAztecSize"))) {
3569 const int w = m_bc.bc.encodedWidth();
3570 if (w <= 27) { // Note Zint always favours Compact on automatic
3571 txt->setText(QString::asprintf("(%d X %d Compact)", w, w));
3572 } else {
3573 int layers;
3574 if (w <= 95) {
3575 layers = (w - 16 + (w <= 61)) / 4;
3576 } else {
3577 layers = (w - 20 + (w <= 125) * 2) / 4;
3578 }
3579 txt->setText(QString::asprintf("(%d X %d (%d Layers))", w, w, layers));
3580 }
3581 } else {
3582 txt->setText(QSEmpty);
3583 }
3584 }
3585
3586 } else if (symbology == BARCODE_CHANNEL) {
3587 if ((cmb = m_optionWidget->findChild<QComboBox*>(QSL("cmbChannel")))) {
3588 if (!isError && cmb->currentIndex() == 0) {
3589 const int channels = (m_bc.bc.encodedWidth() - 7) / 4;
3590 cmb->setItemText(0, QString::asprintf("Automatic (%d)", channels));
3591 } else {
3592 cmb->setItemText(0, QSL("Automatic"));
3593 }
3594 }
3595
3596 } else if (symbology == BARCODE_CODABLOCKF || symbology == BARCODE_HIBC_BLOCKF) {
3597 if ((cmb = m_optionWidget->findChild<QComboBox*>(QSL("cmbCbfWidth")))) {
3598 if (!isError && cmb->currentIndex() == 0) {
3599 const int data_w = (m_bc.bc.encodedWidth() - 57) / 11;
3600 cmb->setItemText(0, QString::asprintf("Automatic (%d (%d data))", data_w + 5, data_w));
3601 } else {
3602 cmb->setItemText(0, QSL("Automatic"));
3603 }
3604 }
3605 if ((cmb = m_optionWidget->findChild<QComboBox*>(QSL("cmbCbfHeight")))) {
3606 if (!isError && cmb->currentIndex() == 0) {
3607 cmb->setItemText(0, QString::asprintf("Automatic (%d)", m_bc.bc.encodedRows()));
3608 } else {
3609 cmb->setItemText(0, QSL("Automatic"));
3610 }
3611 }
3612
3613 } else if (symbology == BARCODE_CODE16K) {
3614 if ((cmb = m_optionWidget->findChild<QComboBox*>(QSL("cmbC16kRows")))) {
3615 if (!isError && cmb->currentIndex() == 0) {
3616 cmb->setItemText(0, QString::asprintf("Automatic (%d)", m_bc.bc.encodedRows()));
3617 } else {
3618 cmb->setItemText(0, QSL("Automatic"));
3619 }
3620 }
3621
3622 } else if (symbology == BARCODE_CODE49) {
3623 if ((cmb = m_optionWidget->findChild<QComboBox*>(QSL("cmbC49Rows")))) {
3624 if (!isError && cmb->currentIndex() == 0) {
3625 cmb->setItemText(0, QString::asprintf("Automatic (%d)", m_bc.bc.encodedRows()));
3626 } else {
3627 cmb->setItemText(0, QSL("Automatic"));
3628 }
3629 }
3630
3631 } else if (symbology == BARCODE_CODEONE) {
3632 if ((cmb = m_optionWidget->findChild<QComboBox*>(QSL("cmbC1Size")))) {
3633 if (!isError && cmb->currentIndex() == 0) {
3634 const int r = m_bc.bc.encodedRows();
3635 const int w = m_bc.bc.encodedWidth();
3636 // Note Versions S & T not used by Zint in automatic mode
3637 static const char vers[] = { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H' };
3638 int idx;
3639 if (r <= 40) {
3640 idx = (r == 22) + (r == 28) * 2 + (r == 40) * 3;
3641 } else {
3642 idx = (r == 70) + (r == 104) * 2 + (r == 148) * 3 + 4;
3643 }
3644 cmb->setItemText(0, QString::asprintf("Automatic (%d X %d (Version %c))", r, w, vers[idx]));
3645 } else {
3646 cmb->setItemText(0, QSL("Automatic"));
3647 }
3648 }
3649
3650 } else if (symbology == BARCODE_DATAMATRIX || symbology == BARCODE_HIBC_DM) {
3651 if ((cmb = m_optionWidget->findChild<QComboBox*>(QSL("cmbDM200Size")))) {
3652 if (!isError && cmb->currentIndex() == 0) {
3653 const int r = m_bc.bc.encodedRows();
3654 const int w = m_bc.bc.encodedWidth();
3655 int z = 0;
3656 if (r == w) {
3657 if (r <= 26) {
3658 z = (r - 8) / 2;
3659 } else if (r <= 52) {
3660 z = 10 + (r - 32) / 4;
3661 } else if (r <= 104) {
3662 z = 16 + (r - 64) / 8;
3663 } else {
3664 z = 22 + (r - 120) / 12;
3665 }
3666 cmb->setItemText(0, QString::asprintf("Automatic (%d x %d (Zint %d))", r, w, z));
3667 } else if ((r == 8 && (w == 18 || w == 32)) || (r == 12 && (w == 26 || w == 36))
3668 || (r == 16 && (w == 36 || w == 48))) {
3669 z = 25 + (w == 32) + (w == 26) * 2 + (r == 12 && w == 36) * 3
3670 + (r == 16 && w == 36) * 4 + (w == 48) * 5;
3671 cmb->setItemText(0, QString::asprintf("Automatic (%d x %d (Zint %d))", r, w, z));
3672 } else { // DMRE
3673 if (r == 8) {
3674 z = 31 + (w == 64) + (w == 80) * 2 + (w == 96) * 3 + (w == 120) * 4 + (w == 144) * 5;
3675 } else if (r == 12) {
3676 z = 37 + (w == 88);
3677 } else if (r == 16) {
3678 z = 39;
3679 } else if (r == 20) {
3680 z = 40 + (w == 44) + (w == 64) * 2;
3681 } else if (r == 22) {
3682 z = 43;
3683 } else if (r == 24) {
3684 z = 44 + (w == 64);
3685 } else { /* if (r == 26) */
3686 z = 46 + (w == 48) + (w == 64) * 2;
3687 }
3688 cmb->setItemText(0, QString::asprintf("Automatic (%d x %d (DMRE) (Zint %d))", r, w, z));
3689 }
3690 } else {
3691 cmb->setItemText(0, QSL("Automatic"));
3692 }
3693 }
3694
3695 } else if (symbology == BARCODE_MAILMARK_2D) {
3696 if ((cmb = m_optionWidget->findChild<QComboBox*>(QSL("cmbMailmark2DSize")))) {
3697 if (!isError && cmb->currentIndex() == 0) {
3698 const int r = m_bc.bc.encodedRows();
3699 const int w = m_bc.bc.encodedWidth();
3700 int z;
3701 if (r == w) {
3702 z = r <= 26 ? 8 : 10;
3703 cmb->setItemText(0, QString::asprintf("Automatic (%d x %d (Zint %d) - Type %d)", r, w, z, z - 1));
3704 } else {
3705 z = 30;
3706 cmb->setItemText(0, QString::asprintf("Automatic (%d x %d (Zint %d) - Type %d)", r, w, z, z - 1));
3707 }
3708 } else {
3709 cmb->setItemText(0, QSL("Automatic"));
3710 }
3711 }
3712
3713 } else if (symbology == BARCODE_DOTCODE) {
3714 if ((cmb = m_optionWidget->findChild<QComboBox*>(QSL("cmbDotCols")))) {
3715 if (!isError && cmb->currentIndex() == 0) {
3716 cmb->setItemText(0, QString::asprintf("Automatic (%d)", m_bc.bc.encodedWidth()));
3717 } else {
3718 cmb->setItemText(0, QSL("Automatic"));
3719 }
3720 }
3721
3722 } else if (symbology == BARCODE_GRIDMATRIX) {
3723 if ((cmb = m_optionWidget->findChild<QComboBox*>(QSL("cmbGridSize")))) {
3724 if (!isError && cmb->currentIndex() == 0) {
3725 const int r = m_bc.bc.encodedRows();
3726 cmb->setItemText(0, QString::asprintf("Automatic (%d x %d (Version %d))", r, r, (r - 6) / 12));
3727 } else {
3728 cmb->setItemText(0, QSL("Automatic"));
3729 }
3730 }
3731
3732 } else if (symbology == BARCODE_HANXIN) {
3733 if ((cmb = m_optionWidget->findChild<QComboBox*>(QSL("cmbHXSize")))) {
3734 if (!isError && cmb->currentIndex() == 0) {
3735 const int r = m_bc.bc.encodedRows();
3736 cmb->setItemText(0, QString::asprintf("Automatic (%d x %d (Version %d))", r, r, (r - 21) / 2));
3737 } else {
3738 cmb->setItemText(0, QSL("Automatic"));
3739 }
3740 }
3741
3742 } else if (symbology == BARCODE_MICROPDF417 || symbology == BARCODE_HIBC_MICPDF) {
3743 if ((cmb = m_optionWidget->findChild<QComboBox*>(QSL("cmbMPDFCols")))) {
3744 if (!isError && cmb->currentIndex() == 0) {
3745 const int w = m_bc.bc.encodedWidth();
3746 int cols;
3747 if (w == 38) {
3748 cols = 1;
3749 } else if (w == 55) {
3750 cols = 2;
3751 } else if (w == 82) {
3752 cols = 3;
3753 } else { /* if (w == 99) */
3754 cols = 4;
3755 }
3756 cmb->setItemText(0, QString::asprintf("Automatic (%d)", cols));
3757 } else {
3758 cmb->setItemText(0, QSL("Automatic"));
3759 }
3760 }
3761
3762 } else if (symbology == BARCODE_MICROQR) {
3763 if ((cmb = m_optionWidget->findChild<QComboBox*>(QSL("cmbMQRSize")))) {
3764 if (!isError && cmb->currentIndex() == 0) {
3765 const int r = m_bc.bc.encodedRows();
3766 cmb->setItemText(0, QString::asprintf("Automatic (%d x %d (Version M%d))", r, r, (r - 9) / 2));
3767 } else {
3768 cmb->setItemText(0, QSL("Automatic"));
3769 }
3770 }
3771
3772 } else if (symbology == BARCODE_PDF417 || symbology == BARCODE_PDF417COMP || symbology == BARCODE_HIBC_PDF) {
3773 if ((cmb = m_optionWidget->findChild<QComboBox*>(QSL("cmbPDFCols")))) {
3774 if (!isError && cmb->currentIndex() == 0) {
3775 const int w = m_bc.bc.encodedWidth();
3776 const int overhead = get_rad_val(QSL("radPDFTruncated")) || symbology == BARCODE_PDF417COMP ? 35 : 69;
3777 cmb->setItemText(0, QString::asprintf("Automatic (%d)", (w - overhead) / 17));
3778 } else {
3779 cmb->setItemText(0, QSL("Automatic"));
3780 }
3781 }
3782 if ((cmb = m_optionWidget->findChild<QComboBox*>(QSL("cmbPDFRows")))) {
3783 if (!isError && cmb->currentIndex() == 0) {
3784 const int r = m_bc.bc.encodedRows();
3785 cmb->setItemText(0, QString::asprintf("Automatic (%d)", r));
3786 } else {
3787 cmb->setItemText(0, QSL("Automatic"));
3788 }
3789 }
3790
3791 } else if (symbology == BARCODE_QRCODE || symbology == BARCODE_HIBC_QR) {
3792 if ((cmb = m_optionWidget->findChild<QComboBox*>(QSL("cmbQRSize")))) {
3793 if (!isError && cmb->currentIndex() == 0) {
3794 const int r = m_bc.bc.encodedRows();
3795 cmb->setItemText(0, QString::asprintf("Automatic (%d x %d (Version %d))", r, r, (r - 17) / 4));
3796 } else {
3797 cmb->setItemText(0, QSL("Automatic"));
3798 }
3799 }
3800
3801 } else if (symbology == BARCODE_RMQR) {
3802 if ((cmb = m_optionWidget->findChild<QComboBox*>(QSL("cmbRMQRSize")))) {
3803 if (!isError && cmb->currentIndex() == 0) {
3804 const int r = m_bc.bc.encodedRows();
3805 const int w = m_bc.bc.encodedWidth();
3806 int z;
3807 if (r == 11 || r == 13) {
3808 z = 11 + (r == 13) * 6 + (w == 43) + (w == 59) * 2 + (w == 77) * 3 + (w == 99) * 4
3809 + (w == 139) * 5;
3810 } else {
3811 z = (w == 59) + (w == 77) * 2 + (w == 99) * 3 + (w == 139) * 4;
3812 if (r == 7) {
3813 z += 1;
3814 } else if (r == 9) {
3815 z += 6;
3816 } else if (r == 15) {
3817 z += 23;
3818 } else { /* if (r == 17) */
3819 z += 28;
3820 }
3821 }
3822 cmb->setItemText(0, QString::asprintf("Automatic (R%dx%d (Zint %d))", r, w, z));
3823 } else {
3824 cmb->setItemText(0, QSL("Automatic"));
3825 }
3826 }
3827
3828 } else if (symbology == BARCODE_ULTRA) {
3829 if ((txt = m_optionWidget->findChild<QLineEdit*>(QSL("txtUltraAutoInfo")))) {
3830 if (!isError) {
3831 const int w = m_bc.bc.encodedWidth();
3832 const int r = m_bc.bc.encodedRows();
3833 txt->setText(QString::asprintf("(%d X %d)", w, r));
3834 } else {
3835 txt->setText(QSEmpty);
3836 }
3837 }
3838 }
3839 }
3840
3841 QPoint MainWindow::get_context_menu_pos(const QPoint &pos, QWidget *widget)
3842 {
3843 QPoint menuPos(pos);
3844 if (menuPos.x() == 0 && menuPos.y() == 0) { // May have been invoked by menu key
3845 QPoint mousePos(widget->mapFromGlobal(QCursor::pos()));
3846 if (widget->rect().contains(mousePos)) {
3847 menuPos = mousePos;
3848 }
3849 }
3850
3851 return widget->mapToGlobal(menuPos);
3852 }
3853
3854 /* Shorthand to find widget child as generic QWidget */
3855 QWidget *MainWindow::get_widget(const QString &name)
3856 {
3857 return m_optionWidget ? m_optionWidget->findChild<QWidget*>(name) : nullptr;
3858 }
3859
3860 /* Return settings subsection name for a symbol */
3861 QString MainWindow::get_setting_name(int symbology)
3862 {
3863 switch (symbology) {
3864 case BARCODE_CODE128AB:
3865 case BARCODE_GS1_128:
3866 case BARCODE_GS1_128_CC:
3867 case BARCODE_HIBC_128:
3868 symbology = BARCODE_CODE128;
3869 break;
3870 case BARCODE_PDF417COMP:
3871 case BARCODE_HIBC_PDF:
3872 symbology = BARCODE_PDF417;
3873 break;
3874 case BARCODE_HIBC_MICPDF:
3875 symbology = BARCODE_MICROPDF417;
3876 break;
3877 case BARCODE_HIBC_AZTEC:
3878 symbology = BARCODE_AZTEC;
3879 break;
3880 case BARCODE_HIBC_39:
3881 symbology = BARCODE_CODE39;
3882 break;
3883 case BARCODE_HIBC_BLOCKF:
3884 symbology = BARCODE_CODABLOCKF;
3885 break;
3886 case BARCODE_HIBC_DM:
3887 symbology = BARCODE_DATAMATRIX;
3888 break;
3889 case BARCODE_HIBC_QR:
3890 symbology = BARCODE_QRCODE;
3891 break;
3892 case BARCODE_DBAR_OMN_CC:
3893 symbology = BARCODE_DBAR_OMN;
3894 break;
3895 case BARCODE_DBAR_OMNSTK_CC:
3896 symbology = BARCODE_DBAR_OMNSTK;
3897 break;
3898 case BARCODE_DBAR_LTD_CC:
3899 symbology = BARCODE_DBAR_LTD;
3900 break;
3901 case BARCODE_DBAR_STK_CC:
3902 symbology = BARCODE_DBAR_STK;
3903 break;
3904 case BARCODE_DBAR_EXP_CC:
3905 symbology = BARCODE_DBAR_EXP;
3906 break;
3907 case BARCODE_DBAR_EXPSTK_CC:
3908 symbology = BARCODE_DBAR_EXPSTK;
3909 break;
3910 case BARCODE_UPCA_CHK:
3911 case BARCODE_UPCA_CC:
3912 symbology = BARCODE_UPCA;
3913 break;
3914 case BARCODE_EANX_CHK:
3915 case BARCODE_EANX_CC:
3916 symbology = BARCODE_EANX;
3917 break;
3918 case BARCODE_UPCE_CHK:
3919 case BARCODE_UPCE_CC:
3920 symbology = BARCODE_UPCE;
3921 break;
3922 }
3923 return Zint::QZint::barcodeName(symbology).mid(8).toLower(); // Strip "BARCODE_" prefix
3924 }
3925
3926 /* Helper to return index of selected radio button in group, checking for NULL */
3927 int MainWindow::get_rad_grp_index(const QStringList &names)
3928 {
3929 if (m_optionWidget) {
3930 QRadioButton *radioButton;
3931 for (int index = 0; index < names.size(); index++) {
3932 radioButton = m_optionWidget->findChild<QRadioButton*>(names[index]);
3933 if (radioButton && radioButton->isChecked()) {
3934 return index;
3935 }
3936 }
3937 }
3938 return 0;
3939 }
3940
3941 /* Helper to set radio button in group from index in settings, checking for NULL */
3942 void MainWindow::set_rad_from_setting(QSettings &settings, const QString &setting,
3943 const QStringList &names, int default_val)
3944 {
3945 if (m_optionWidget) {
3946 int index = settings.value(setting, default_val).toInt();
3947 QRadioButton *radioButton;
3948 if (index >= 0 && index < names.size()) {
3949 radioButton = m_optionWidget->findChild<QRadioButton*>(names[index]);
3950 } else {
3951 radioButton = m_optionWidget->findChild<QRadioButton*>(names[0]);
3952 }
3953 if (radioButton) {
3954 radioButton->setChecked(true);
3955 }
3956 }
3957 }
3958
3959 /* Helper to see if radio button checked, checking for NULL and whether enabled */
3960 bool MainWindow::get_rad_val(const QString &name)
3961 {
3962 QRadioButton *radioButton = m_optionWidget ? m_optionWidget->findChild<QRadioButton*>(name) : nullptr;
3963 return radioButton && radioButton->isEnabled() && radioButton->isChecked();
3964 }
3965
3966 /* Helper to return index of selected item in combobox, checking for NULL */
3967 int MainWindow::get_cmb_index(const QString &name)
3968 {
3969 QComboBox *comboBox = m_optionWidget ? m_optionWidget->findChild<QComboBox*>(name) : nullptr;
3970 return comboBox ? comboBox->currentIndex() : 0;
3971 }
3972
3973 /* Helper to set item in combobox from index in settings, checking for NULL */
3974 void MainWindow::set_cmb_from_setting(QSettings &settings, const QString &setting, const QString &name,
3975 int default_val)
3976 {
3977 QComboBox *comboBox = m_optionWidget ? m_optionWidget->findChild<QComboBox*>(name) : nullptr;
3978 if (comboBox) {
3979 comboBox->setCurrentIndex(settings.value(setting, default_val).toInt());
3980 }
3981 }
3982
3983 /* Helper to return if checkbox checked, checking for NULL */
3984 int MainWindow::get_chk_val(const QString &name)
3985 {
3986 QCheckBox *checkBox = m_optionWidget ? m_optionWidget->findChild<QCheckBox*>(name) : nullptr;
3987 return checkBox && checkBox->isChecked() ? 1 : 0;
3988 }
3989
3990 /* Helper to set checkbox from settings, checking for NULL */
3991 void MainWindow::set_chk_from_setting(QSettings &settings, const QString &setting, const QString &name,
3992 int default_val)
3993 {
3994 QCheckBox *checkBox = m_optionWidget ? m_optionWidget->findChild<QCheckBox*>(name) : nullptr;
3995 if (checkBox) {
3996 checkBox->setChecked(settings.value(setting, default_val).toInt() ? true : false);
3997 }
3998 }
3999
4000 /* Helper to return value of double spinner, checking for NULL */
4001 double MainWindow::get_dspn_val(const QString &name)
4002 {
4003 QDoubleSpinBox *spinBox = m_optionWidget->findChild<QDoubleSpinBox*>(name);
4004 return spinBox ? spinBox->value() : 0.0;
4005 }
4006
4007 /* Helper to set double spinner from settings, checking for NULL */
4008 void MainWindow::set_dspn_from_setting(QSettings &settings, const QString &setting, const QString &name,
4009 float default_val)
4010 {
4011 QDoubleSpinBox *spinBox = m_optionWidget->findChild<QDoubleSpinBox*>(name);
4012 if (spinBox) {
4013 spinBox->setValue(settings.value(setting, default_val).toFloat());
4014 }
4015 }
4016
4017 /* Helper to return text of line edit, checking for NULL */
4018 QString MainWindow::get_txt_val(const QString &name)
4019 {
4020 QLineEdit *lineEdit = m_optionWidget ? m_optionWidget->findChild<QLineEdit*>(name) : nullptr;
4021 return lineEdit ? lineEdit->text() : QSEmpty;
4022 }
4023
4024 /* Helper to set line edit from settings, checking for NULL */
4025 void MainWindow::set_txt_from_setting(QSettings &settings, const QString &setting, const QString &name,
4026 const QString &default_val)
4027 {
4028 QLineEdit *lineEdit = m_optionWidget ? m_optionWidget->findChild<QLineEdit*>(name) : nullptr;
4029 if (lineEdit) {
4030 lineEdit->setText(settings.value(setting, default_val).toString());
4031 }
4032 }
4033
4034 /* Helper to return value of spin box, checking for NULL */
4035 int MainWindow::get_spn_val(const QString &name)
4036 {
4037 QSpinBox *spinBox = m_optionWidget ? m_optionWidget->findChild<QSpinBox*>(name) : nullptr;
4038 return spinBox ? spinBox->value() : 0;
4039 }
4040
4041 /* Helper to set spin box from settings, checking for NULL */
4042 void MainWindow::set_spn_from_setting(QSettings &settings, const QString &setting, const QString &name,
4043 int default_val)
4044 {
4045 QSpinBox *spinBox = m_optionWidget ? m_optionWidget->findChild<QSpinBox*>(name) : nullptr;
4046 if (spinBox) {
4047 spinBox->setValue(settings.value(setting, default_val).toInt());
4048 }
4049 }
4050
4051 /* Save settings for an individual symbol */
4052 void MainWindow::save_sub_settings(QSettings &settings, int symbology)
4053 {
4054 QString name = get_setting_name(symbology);
4055 if (!name.isEmpty()) { // Should never be empty
4056 settings.setValue(QSL("studio/bc/%1/data").arg(name), txtData->text());
4057 if (!grpSegs->isHidden()) {
4058 settings.setValue(QSL("studio/bc/%1/data_seg1").arg(name), txtDataSeg1->text());
4059 settings.setValue(QSL("studio/bc/%1/data_seg2").arg(name), txtDataSeg2->text());
4060 settings.setValue(QSL("studio/bc/%1/data_seg3").arg(name), txtDataSeg3->text());
4061 }
4062 if (!grpComposite->isHidden()) {
4063 settings.setValue(QSL("studio/bc/%1/composite_text").arg(name), txtComposite->toPlainText());
4064 settings.setValue(QSL("studio/bc/%1/chk_composite").arg(name), chkComposite->isChecked() ? 1 : 0);
4065 settings.setValue(QSL("studio/bc/%1/comp_type").arg(name), cmbCompType->currentIndex());
4066 }
4067 if (cmbECI->isEnabled()) {
4068 settings.setValue(QSL("studio/bc/%1/eci").arg(name), cmbECI->currentIndex());
4069 settings.setValue(QSL("studio/bc/%1/eci_seg1").arg(name), cmbECISeg1->currentIndex());
4070 settings.setValue(QSL("studio/bc/%1/eci_seg2").arg(name), cmbECISeg2->currentIndex());
4071 settings.setValue(QSL("studio/bc/%1/eci_seg3").arg(name), cmbECISeg3->currentIndex());
4072 }
4073 settings.setValue(QSL("studio/bc/%1/chk_escape").arg(name), chkEscape->isChecked() ? 1 : 0);
4074 settings.setValue(QSL("studio/bc/%1/chk_data").arg(name), chkData->isChecked() ? 1 : 0);
4075 if (chkRInit->isEnabled()) {
4076 settings.setValue(QSL("studio/bc/%1/chk_rinit").arg(name), chkRInit->isChecked() ? 1 : 0);
4077 }
4078 settings.setValue(QSL("studio/bc/%1/chk_gs1parens").arg(name), chkGS1Parens->isChecked() ? 1 : 0);
4079 settings.setValue(QSL("studio/bc/%1/chk_gs1nocheck").arg(name), chkGS1NoCheck->isChecked() ? 1 : 0);
4080 if (chkAutoHeight->isEnabled()) {
4081 settings.setValue(
4082 QSL("studio/bc/%1/appearance/autoheight").arg(name), chkAutoHeight->isChecked() ? 1 : 0);
4083 settings.setValue(QSL("studio/bc/%1/appearance/height").arg(name), heightb->value());
4084 }
4085 if (chkCompliantHeight->isEnabled()) {
4086 settings.setValue(
4087 QSL("studio/bc/%1/appearance/compliantheight").arg(name), chkCompliantHeight->isChecked() ? 1 : 0);
4088 }
4089 settings.setValue(QSL("studio/bc/%1/appearance/border").arg(name), bwidth->value());
4090 settings.setValue(QSL("studio/bc/%1/appearance/whitespace").arg(name), spnWhitespace->value());
4091 settings.setValue(QSL("studio/bc/%1/appearance/vwhitespace").arg(name), spnVWhitespace->value());
4092 settings.setValue(QSL("studio/bc/%1/appearance/scale").arg(name), spnScale->value());
4093 settings.setValue(QSL("studio/bc/%1/appearance/border_type").arg(name), btype->currentIndex());
4094 if (chkHRTShow->isEnabled()) {
4095 settings.setValue(QSL("studio/bc/%1/appearance/font_setting").arg(name), cmbFontSetting->currentIndex());
4096 settings.setValue(QSL("studio/bc/%1/appearance/text_gap").arg(name), spnTextGap->value());
4097 settings.setValue(QSL("studio/bc/%1/appearance/chk_embed_vector_font").arg(name),
4098 chkEmbedVectorFont->isChecked() ? 1 : 0);
4099 settings.setValue(QSL("studio/bc/%1/appearance/chk_hrt_show").arg(name), chkHRTShow->isChecked() ? 1 : 0);
4100 }
4101 settings.setValue(QSL("studio/bc/%1/appearance/chk_cmyk").arg(name), chkCMYK->isChecked() ? 1 : 0);
4102 settings.setValue(
4103 QSL("studio/bc/%1/appearance/chk_quietzones").arg(name), chkQuietZones->isChecked() ? 1 : 0);
4104 settings.setValue(QSL("studio/bc/%1/appearance/rotate").arg(name), cmbRotate->currentIndex());
4105 if (symbology == BARCODE_DOTCODE || chkDotty->isEnabled()) {
4106 settings.setValue(QSL("studio/bc/%1/appearance/chk_dotty").arg(name), chkDotty->isChecked() ? 1 : 0);
4107 settings.setValue(QSL("studio/bc/%1/appearance/dot_size").arg(name), spnDotSize->value());
4108 }
4109 settings.setValue(QSL("studio/bc/%1/ink/text").arg(name), m_fgstr);
4110 settings.setValue(QSL("studio/bc/%1/paper/text").arg(name), m_bgstr);
4111 settings.setValue(QSL("studio/bc/%1/xdimdpvars/x_dim").arg(name), m_xdimdpVars.x_dim);
4112 settings.setValue(QSL("studio/bc/%1/xdimdpvars/x_dim_units").arg(name), m_xdimdpVars.x_dim_units);
4113 settings.setValue(QSL("studio/bc/%1/xdimdpvars/set").arg(name), m_xdimdpVars.set);
4114 }
4115
4116 switch (symbology) {
4117 case BARCODE_CODE128:
4118 case BARCODE_CODE128AB:
4119 case BARCODE_GS1_128:
4120 case BARCODE_GS1_128_CC:
4121 case BARCODE_HIBC_128:
4122 settings.setValue(QSL("studio/bc/code128/encoding_mode"), get_rad_grp_index(
4123 QStringList() << QSL("radC128Stand") << QSL("radC128EAN") << QSL("radC128CSup")
4124 << QSL("radC128HIBC") << QSL("radC128ExtraEsc")));
4125 break;
4126
4127 case BARCODE_PDF417:
4128 case BARCODE_PDF417COMP:
4129 case BARCODE_HIBC_PDF:
4130 settings.setValue(QSL("studio/bc/pdf417/cols"), get_cmb_index(QSL("cmbPDFCols")));
4131 settings.setValue(QSL("studio/bc/pdf417/rows"), get_cmb_index(QSL("cmbPDFRows")));
4132 settings.setValue(QSL("studio/bc/pdf417/height_per_row"), get_dspn_val(QSL("spnPDFHeightPerRow")));
4133 settings.setValue(QSL("studio/bc/pdf417/ecc"), get_cmb_index(QSL("cmbPDFECC")));
4134 settings.setValue(QSL("studio/bc/pdf417/encoding_mode"), get_rad_grp_index(
4135 QStringList() << QSL("radPDFStand") << QSL("radPDFTruncated") << QSL("radPDFHIBC")));
4136 settings.setValue(QSL("studio/bc/pdf417/chk_fast"), get_chk_val(QSL("chkPDFFast")));
4137 settings.setValue(QSL("studio/bc/pdf417/structapp_count"), get_spn_val(QSL("spnPDFStructAppCount")));
4138 settings.setValue(QSL("studio/bc/pdf417/structapp_index"), get_spn_val(QSL("spnPDFStructAppIndex")));
4139 settings.setValue(QSL("studio/bc/pdf417/structapp_id"), get_txt_val(QSL("txtPDFStructAppID")));
4140 break;
4141
4142 case BARCODE_MICROPDF417:
4143 case BARCODE_HIBC_MICPDF:
4144 settings.setValue(QSL("studio/bc/micropdf417/cols"), get_cmb_index(QSL("cmbMPDFCols")));
4145 settings.setValue(QSL("studio/bc/micropdf417/height_per_row"), get_dspn_val(QSL("spnMPDFHeightPerRow")));
4146 settings.setValue(QSL("studio/bc/micropdf417/encoding_mode"), get_rad_grp_index(
4147 QStringList() << QSL("radMPDFStand") << QSL("radMPDFHIBC")));
4148 settings.setValue(QSL("studio/bc/micropdf417/chk_fast"), get_chk_val(QSL("chkMPDFFast")));
4149 settings.setValue(QSL("studio/bc/micropdf417/structapp_count"),
4150 get_spn_val(QSL("spnMPDFStructAppCount")));
4151 settings.setValue(QSL("studio/bc/micropdf417/structapp_index"),
4152 get_spn_val(QSL("spnMPDFStructAppIndex")));
4153 settings.setValue(QSL("studio/bc/micropdf417/structapp_id"), get_txt_val(QSL("txtMPDFStructAppID")));
4154 break;
4155
4156 case BARCODE_DOTCODE:
4157 settings.setValue(QSL("studio/bc/dotcode/cols"), get_cmb_index(QSL("cmbDotCols")));
4158 settings.setValue(QSL("studio/bc/dotcode/mask"), get_cmb_index(QSL("cmbDotMask")));
4159 settings.setValue(QSL("studio/bc/dotcode/encoding_mode"), get_rad_grp_index(
4160 QStringList() << QSL("radDotStand") << QSL("radDotGS1")));
4161 settings.setValue(QSL("studio/bc/dotcode/structapp_count"), get_cmb_index(QSL("cmbDotStructAppCount")));
4162 settings.setValue(QSL("studio/bc/dotcode/structapp_index"), get_cmb_index(QSL("cmbDotStructAppIndex")));
4163 break;
4164
4165 case BARCODE_AZTEC:
4166 case BARCODE_HIBC_AZTEC:
4167 settings.setValue(QSL("studio/bc/aztec/autoresizing"), get_rad_grp_index(
4168 QStringList() << QSL("radAztecAuto") << QSL("radAztecSize") << QSL("radAztecECC")));
4169 settings.setValue(QSL("studio/bc/aztec/size"), get_cmb_index(QSL("cmbAztecSize")));
4170 settings.setValue(QSL("studio/bc/aztec/ecc"), get_cmb_index(QSL("cmbAztecECC")));
4171 settings.setValue(QSL("studio/bc/aztec/encoding_mode"), get_rad_grp_index(
4172 QStringList() << QSL("radAztecStand") << QSL("radAztecGS1") << QSL("radAztecHIBC")));
4173 settings.setValue(QSL("studio/bc/aztec/structapp_count"), get_cmb_index(QSL("cmbAztecStructAppCount")));
4174 settings.setValue(QSL("studio/bc/aztec/structapp_index"), get_cmb_index(QSL("cmbAztecStructAppIndex")));
4175 settings.setValue(QSL("studio/bc/aztec/structapp_id"), get_txt_val(QSL("txtAztecStructAppID")));
4176 break;
4177
4178 case BARCODE_MSI_PLESSEY:
4179 settings.setValue(QSL("studio/bc/msi_plessey/check_digit"), get_cmb_index(QSL("cmbMSICheck")));
4180 settings.setValue(QSL("studio/bc/msi_plessey/check_text"), get_chk_val(QSL("chkMSICheckText")));
4181 break;
4182
4183 case BARCODE_CODE11:
4184 settings.setValue(QSL("studio/bc/code11/check_digit"), get_rad_grp_index(
4185 QStringList() << QSL("radC11TwoCheckDigits") << QSL("radC11OneCheckDigit")
4186 << QSL("radC11NoCheckDigits")));
4187 break;
4188
4189 case BARCODE_C25STANDARD:
4190 settings.setValue(QSL("studio/bc/c25standard/check_digit"), get_rad_grp_index(
4191 QStringList() << QSL("radC25Stand") << QSL("radC25Check") << QSL("radC25CheckHide")));
4192 break;
4193 case BARCODE_C25INTER:
4194 settings.setValue(QSL("studio/bc/c25inter/check_digit"), get_rad_grp_index(
4195 QStringList() << QSL("radC25Stand") << QSL("radC25Check") << QSL("radC25CheckHide")));
4196 break;
4197 case BARCODE_C25IATA:
4198 settings.setValue(QSL("studio/bc/c25iata/check_digit"), get_rad_grp_index(
4199 QStringList() << QSL("radC25Stand") << QSL("radC25Check") << QSL("radC25CheckHide")));
4200 break;
4201 case BARCODE_C25LOGIC:
4202 settings.setValue(QSL("studio/bc/c25logic/check_digit"), get_rad_grp_index(
4203 QStringList() << QSL("radC25Stand") << QSL("radC25Check") << QSL("radC25CheckHide")));
4204 break;
4205 case BARCODE_C25IND:
4206 settings.setValue(QSL("studio/bc/c25ind/check_digit"), get_rad_grp_index(
4207 QStringList() << QSL("radC25Stand") << QSL("radC25Check") << QSL("radC25CheckHide")));
4208 break;
4209
4210 case BARCODE_CODE39:
4211 case BARCODE_HIBC_39:
4212 settings.setValue(QSL("studio/bc/code39/check_digit"), get_rad_grp_index(
4213 QStringList() << QSL("radC39Stand") << QSL("radC39Check") << QSL("radC39HIBC")
4214 << QSL("radC39CheckHide")));
4215 break;
4216
4217 case BARCODE_EXCODE39:
4218 settings.setValue(QSL("studio/bc/excode39/check_digit"), get_rad_grp_index(
4219 QStringList() << QSL("radC39Stand") << QSL("radC39Check") << QSL("radC39CheckHide")));
4220 break;
4221 case BARCODE_LOGMARS:
4222 settings.setValue(QSL("studio/bc/logmars/check_digit"), get_rad_grp_index(
4223 QStringList() << QSL("radC39Stand") << QSL("radC39Check") << QSL("radC39CheckHide")));
4224 break;
4225
4226 case BARCODE_CODE16K:
4227 settings.setValue(QSL("studio/bc/code16k/rows"), get_cmb_index(QSL("cmbC16kRows")));
4228 settings.setValue(QSL("studio/bc/code16k/height_per_row"), get_dspn_val(QSL("spnC16kHeightPerRow")));
4229 settings.setValue(QSL("studio/bc/code16k/row_sep_height"), get_cmb_index(QSL("cmbC16kRowSepHeight")));
4230 settings.setValue(QSL("studio/bc/code16k/encoding_mode"), get_rad_grp_index(
4231 QStringList() << QSL("radC16kStand") << QSL("radC16kGS1")));
4232 settings.setValue(QSL("studio/bc/code16k/chk_no_quiet_zones"), get_chk_val(QSL("chkC16kNoQuietZones")));
4233 break;
4234
4235 case BARCODE_CODABAR:
4236 settings.setValue(QSL("studio/bc/codabar/check_digit"), get_rad_grp_index(
4237 QStringList() << QSL("radCodabarStand") << QSL("radCodabarCheckHide") << QSL("radCodabarCheck")));
4238 break;
4239
4240 case BARCODE_CODABLOCKF:
4241 case BARCODE_HIBC_BLOCKF:
4242 settings.setValue(QSL("studio/bc/codablockf/width"), get_cmb_index(QSL("cmbCbfWidth")));
4243 settings.setValue(QSL("studio/bc/codablockf/height"), get_cmb_index(QSL("cmbCbfHeight")));
4244 settings.setValue(QSL("studio/bc/codablockf/height_per_row"), get_dspn_val(QSL("spnCbfHeightPerRow")));
4245 settings.setValue(QSL("studio/bc/codablockf/row_sep_height"), get_cmb_index(QSL("cmbCbfRowSepHeight")));
4246 settings.setValue(QSL("studio/bc/codablockf/encoding_mode"), get_rad_grp_index(
4247 QStringList() << QSL("radCbfStand") << QSL("radCbfHIBC")));
4248 settings.setValue(QSL("studio/bc/codablockf/chk_no_quiet_zones"), get_chk_val(QSL("chkCbfNoQuietZones")));
4249 break;
4250
4251 case BARCODE_DAFT:
4252 settings.setValue(QSL("studio/bc/daft/tracker_ratio"),
4253 QString::number(get_dspn_val(QSL("spnDAFTTrackerRatio")), 'f', 1 /*precision*/));
4254 break;
4255
4256 case BARCODE_DPD:
4257 settings.setValue(QSL("studio/bc/dpd/chk_relabel"), get_chk_val(QSL("chkDPDRelabel")));
4258 break;
4259
4260 case BARCODE_DATAMATRIX:
4261 case BARCODE_HIBC_DM:
4262 settings.setValue(QSL("studio/bc/datamatrix/size"), get_cmb_index(QSL("cmbDM200Size")));
4263 settings.setValue(QSL("studio/bc/datamatrix/encoding_mode"), get_rad_grp_index(
4264 QStringList() << QSL("radDM200Stand") << QSL("radDM200GS1") << QSL("radDM200HIBC")));
4265 settings.setValue(QSL("studio/bc/datamatrix/chk_suppress_rect"), get_chk_val(QSL("chkDMRectangle")));
4266 settings.setValue(QSL("studio/bc/datamatrix/chk_allow_dmre"), get_chk_val(QSL("chkDMRE")));
4267 settings.setValue(QSL("studio/bc/datamatrix/chk_gs_sep"), get_chk_val(QSL("chkDMGSSep")));
4268 settings.setValue(QSL("studio/bc/datamatrix/iso_144"), get_chk_val(QSL("chkDMISO144")));
4269 settings.setValue(QSL("studio/bc/datamatrix/chk_fast"), get_chk_val(QSL("chkDMFast")));
4270 settings.setValue(QSL("studio/bc/datamatrix/structapp_count"), get_cmb_index(QSL("cmbDMStructAppCount")));
4271 settings.setValue(QSL("studio/bc/datamatrix/structapp_index"), get_cmb_index(QSL("cmbDMStructAppIndex")));
4272 settings.setValue(QSL("studio/bc/datamatrix/structapp_id"), get_spn_val(QSL("spnDMStructAppID")));
4273 settings.setValue(QSL("studio/bc/datamatrix/structapp_id2"), get_spn_val(QSL("spnDMStructAppID2")));
4274 break;
4275
4276 case BARCODE_MAILMARK_2D:
4277 settings.setValue(QSL("studio/bc/mailmark2d/size"), get_cmb_index(QSL("cmbMailmark2DSize")));
4278 settings.setValue(
4279 QSL("studio/bc/mailmark2d/chk_suppress_rect"), get_chk_val(QSL("chkMailmark2DRectangle")));
4280 break;
4281
4282 case BARCODE_ITF14:
4283 settings.setValue(QSL("studio/bc/itf14/chk_no_quiet_zones"), get_chk_val(QSL("chkITF14NoQuietZones")));
4284 break;
4285
4286 case BARCODE_PZN:
4287 settings.setValue(QSL("studio/bc/pzn/chk_pzn7"), get_chk_val(QSL("chkPZN7")));
4288 break;
4289
4290 case BARCODE_QRCODE:
4291 case BARCODE_HIBC_QR:
4292 settings.setValue(QSL("studio/bc/qrcode/size"), get_cmb_index(QSL("cmbQRSize")));
4293 settings.setValue(QSL("studio/bc/qrcode/ecc"), get_cmb_index(QSL("cmbQRECC")));
4294 settings.setValue(QSL("studio/bc/qrcode/mask"), get_cmb_index(QSL("cmbQRMask")));
4295 settings.setValue(QSL("studio/bc/qrcode/encoding_mode"), get_rad_grp_index(
4296 QStringList() << QSL("radDM200Stand") << QSL("radQRGS1") << QSL("radQRHIBC")));
4297 settings.setValue(QSL("studio/bc/qrcode/chk_full_multibyte"), get_chk_val(QSL("chkQRFullMultibyte")));
4298 settings.setValue(QSL("studio/bc/qrcode/chk_fast_mode"), get_chk_val(QSL("chkQRFast")));
4299 settings.setValue(QSL("studio/bc/qrcode/structapp_count"), get_cmb_index(QSL("cmbQRStructAppCount")));
4300 settings.setValue(QSL("studio/bc/qrcode/structapp_index"), get_cmb_index(QSL("cmbQRStructAppIndex")));
4301 settings.setValue(QSL("studio/bc/qrcode/structapp_id"), get_spn_val(QSL("spnQRStructAppID")));
4302 break;
4303
4304 case BARCODE_UPNQR:
4305 settings.setValue(QSL("studio/bc/upnqr/mask"), get_cmb_index(QSL("cmbUPNQRMask")));
4306 settings.setValue(QSL("studio/bc/upnqr/chk_fast_mode"), get_chk_val(QSL("chkUPNQRFast")));
4307 break;
4308
4309 case BARCODE_RMQR:
4310 settings.setValue(QSL("studio/bc/rmqr/size"), get_cmb_index(QSL("cmbRMQRSize")));
4311 settings.setValue(QSL("studio/bc/rmqr/ecc"), get_cmb_index(QSL("cmbRMQRECC")));
4312 settings.setValue(QSL("studio/bc/rmqr/encoding_mode"), get_rad_grp_index(
4313 QStringList() << QSL("radQRStand") << QSL("radRMQRGS1")));
4314 settings.setValue(QSL("studio/bc/rmqr/chk_full_multibyte"), get_chk_val(QSL("chkRMQRFullMultibyte")));
4315 break;
4316
4317 case BARCODE_HANXIN:
4318 settings.setValue(QSL("studio/bc/hanxin/size"), get_cmb_index(QSL("cmbHXSize")));
4319 settings.setValue(QSL("studio/bc/hanxin/ecc"), get_cmb_index(QSL("cmbHXECC")));
4320 settings.setValue(QSL("studio/bc/hanxin/mask"), get_cmb_index(QSL("cmbHXMask")));
4321 settings.setValue(QSL("studio/bc/hanxin/chk_full_multibyte"), get_chk_val(QSL("chkHXFullMultibyte")));
4322 break;
4323
4324 case BARCODE_MICROQR:
4325 settings.setValue(QSL("studio/bc/microqr/size"), get_cmb_index(QSL("cmbMQRSize")));
4326 settings.setValue(QSL("studio/bc/microqr/ecc"), get_cmb_index(QSL("cmbMQRECC")));
4327 settings.setValue(QSL("studio/bc/microqr/mask"), get_cmb_index(QSL("cmbMQRMask")));
4328 settings.setValue(QSL("studio/bc/microqr/chk_full_multibyte"), get_chk_val(QSL("chkMQRFullMultibyte")));
4329 break;
4330
4331 case BARCODE_GRIDMATRIX:
4332 settings.setValue(QSL("studio/bc/gridmatrix/size"), get_cmb_index(QSL("cmbGridSize")));
4333 settings.setValue(QSL("studio/bc/gridmatrix/ecc"), get_cmb_index(QSL("cmbGridECC")));
4334 settings.setValue(QSL("studio/bc/gridmatrix/chk_full_multibyte"),
4335 get_chk_val(QSL("chkGridFullMultibyte")));
4336 settings.setValue(QSL("studio/bc/gridmatrix/structapp_count"),
4337 get_cmb_index(QSL("cmbGridStructAppCount")));
4338 settings.setValue(QSL("studio/bc/gridmatrix/structapp_index"),
4339 get_cmb_index(QSL("cmbGridStructAppIndex")));
4340 settings.setValue(QSL("studio/bc/gridmatrix/structapp_id"), get_spn_val(QSL("spnGridStructAppID")));
4341 break;
4342
4343 case BARCODE_MAXICODE:
4344 settings.setValue(QSL("studio/bc/maxicode/mode"), get_cmb_index(QSL("cmbMaxiMode")));
4345 settings.setValue(QSL("studio/bc/maxicode/scm_postcode"), get_txt_val(QSL("txtMaxiSCMPostcode")));
4346 settings.setValue(QSL("studio/bc/maxicode/scm_country"), get_spn_val(QSL("spnMaxiSCMCountry")));
4347 settings.setValue(QSL("studio/bc/maxicode/scm_service"), get_spn_val(QSL("spnMaxiSCMService")));
4348 settings.setValue(QSL("studio/bc/maxicode/chk_scm_vv"), get_chk_val(QSL("chkMaxiSCMVV")));
4349 settings.setValue(QSL("studio/bc/maxicode/spn_scm_vv"), get_spn_val(QSL("spnMaxiSCMVV")));
4350 settings.setValue(QSL("studio/bc/maxicode/structapp_count"), get_cmb_index(QSL("cmbMaxiStructAppCount")));
4351 settings.setValue(QSL("studio/bc/maxicode/structapp_index"), get_cmb_index(QSL("cmbMaxiStructAppIndex")));
4352 break;
4353
4354 case BARCODE_CHANNEL:
4355 settings.setValue(QSL("studio/bc/channel/channel"), get_cmb_index(QSL("cmbChannel")));
4356 break;
4357
4358 case BARCODE_CODEONE:
4359 settings.setValue(QSL("studio/bc/codeone/size"), get_cmb_index(QSL("cmbC1Size")));
4360 settings.setValue(QSL("studio/bc/codeone/encoding_mode"), get_rad_grp_index(
4361 QStringList() << QSL("radC1Stand") << QSL("radC1GS1")));
4362 settings.setValue(QSL("studio/bc/codeone/structapp_count"), get_spn_val(QSL("spnC1StructAppCount")));
4363 settings.setValue(QSL("studio/bc/codeone/structapp_index"), get_spn_val(QSL("spnC1StructAppIndex")));
4364 break;
4365
4366 case BARCODE_CODE49:
4367 settings.setValue(QSL("studio/bc/code49/rows"), get_cmb_index(QSL("cmbC49Rows")));
4368 settings.setValue(QSL("studio/bc/code49/height_per_row"), get_dspn_val(QSL("spnC49HeightPerRow")));
4369 settings.setValue(QSL("studio/bc/code49/row_sep_height"), get_cmb_index(QSL("cmbC49RowSepHeight")));
4370 settings.setValue(QSL("studio/bc/code49/encoding_mode"), get_rad_grp_index(
4371 QStringList() << QSL("radC49Stand") << QSL("radC49GS1")));
4372 settings.setValue(QSL("studio/bc/code49/chk_no_quiet_zones"), get_chk_val(QSL("chkC49NoQuietZones")));
4373 break;
4374
4375 case BARCODE_CODE93:
4376 settings.setValue(QSL("studio/bc/code93/chk_show_checks"), get_chk_val(QSL("chkC93ShowChecks")));
4377 break;
4378
4379 case BARCODE_DBAR_EXPSTK:
4380 case BARCODE_DBAR_EXPSTK_CC:
4381 settings.setValue(QSL("studio/bc/dbar_expstk/colsrows"), get_rad_grp_index(
4382 QStringList() << QSL("radDBESCols") << QSL("radDBESRows")));
4383 settings.setValue(QSL("studio/bc/dbar_expstk/cols"), get_cmb_index(QSL("cmbDBESCols")));
4384 settings.setValue(QSL("studio/bc/dbar_expstk/rows"), get_cmb_index(QSL("cmbDBESRows")));
4385 settings.setValue(QSL("studio/bc/dbar_expstk/height_per_row"), get_dspn_val(QSL("spnDBESHeightPerRow")));
4386 break;
4387
4388 case BARCODE_ULTRA:
4389 settings.setValue(QSL("studio/bc/ultra/autoresizing"), get_rad_grp_index(
4390 QStringList() << QSL("radUltraAuto") << QSL("radUltraEcc")));
4391 settings.setValue(QSL("studio/bc/ultra/ecc"), get_cmb_index(QSL("cmbUltraEcc")));
4392 settings.setValue(QSL("studio/bc/ultra/revision"), get_cmb_index(QSL("cmbUltraRevision")));
4393 settings.setValue(QSL("studio/bc/ultra/encoding_mode"), get_rad_grp_index(
4394 QStringList() << QSL("radUltraStand") << QSL("radUltraGS1")));
4395 settings.setValue(QSL("studio/bc/ultra/structapp_count"), get_cmb_index(QSL("cmbUltraStructAppCount")));
4396 settings.setValue(QSL("studio/bc/ultra/structapp_index"), get_cmb_index(QSL("cmbUltraStructAppIndex")));
4397 settings.setValue(QSL("studio/bc/ultra/structapp_id"), get_spn_val(QSL("spnUltraStructAppID")));
4398 break;
4399
4400 case BARCODE_UPCA:
4401 case BARCODE_UPCA_CHK:
4402 case BARCODE_UPCA_CC:
4403 settings.setValue(QSL("studio/bc/upca/addongap"), get_cmb_index(QSL("cmbUPCAAddonGap")));
4404 settings.setValue(QSL("studio/bc/upca/guard_descent"),
4405 QString::number(get_dspn_val(QSL("spnUPCAGuardDescent")), 'f', 3 /*precision*/));
4406 settings.setValue(QSL("studio/bc/upca/chk_no_quiet_zones"), get_chk_val(QSL("chkUPCANoQuietZones")));
4407 settings.setValue(QSL("studio/bc/upca/chk_guard_whitespace"), get_chk_val(QSL("chkUPCAGuardWhitespace")));
4408 break;
4409
4410 case BARCODE_EANX:
4411 case BARCODE_EANX_CHK:
4412 case BARCODE_EANX_CC:
4413 settings.setValue(QSL("studio/bc/eanx/addongap"), get_cmb_index(QSL("cmbUPCEANAddonGap")));
4414 settings.setValue(QSL("studio/bc/eanx/guard_descent"),
4415 QString::number(get_dspn_val(QSL("spnUPCEANGuardDescent")), 'f', 3 /*precision*/));
4416 settings.setValue(QSL("studio/bc/eanx/chk_no_quiet_zones"), get_chk_val(QSL("chkUPCEANNoQuietZones")));
4417 settings.setValue(QSL("studio/bc/eanx/chk_guard_whitespace"),
4418 get_chk_val(QSL("chkUPCEANGuardWhitespace")));
4419 break;
4420
4421 case BARCODE_UPCE:
4422 case BARCODE_UPCE_CHK:
4423 case BARCODE_UPCE_CC:
4424 settings.setValue(QSL("studio/bc/upce/addongap"), get_cmb_index(QSL("cmbUPCEANAddonGap")));
4425 settings.setValue(QSL("studio/bc/upce/guard_descent"),
4426 QString::number(get_dspn_val(QSL("spnUPCEANGuardDescent")), 'f', 3 /*precision*/));
4427 settings.setValue(QSL("studio/bc/upce/chk_no_quiet_zones"), get_chk_val(QSL("chkUPCEANNoQuietZones")));
4428 settings.setValue(QSL("studio/bc/upce/chk_guard_whitespace"),
4429 get_chk_val(QSL("chkUPCEANGuardWhitespace")));
4430 break;
4431
4432 case BARCODE_ISBNX:
4433 settings.setValue(QSL("studio/bc/isnbx/addongap"), get_cmb_index(QSL("cmbUPCEANAddonGap")));
4434 settings.setValue(QSL("studio/bc/isnbx/guard_descent"),
4435 QString::number(get_dspn_val(QSL("spnUPCEANGuardDescent")), 'f', 3 /*precision*/));
4436 settings.setValue(QSL("studio/bc/isnbx/chk_no_quiet_zones"), get_chk_val(QSL("chkUPCEANNoQuietZones")));
4437 settings.setValue(QSL("studio/bc/isnbx/chk_guard_whitespace"),
4438 get_chk_val(QSL("chkUPCEANGuardWhitespace")));
4439 break;
4440
4441 case BARCODE_VIN:
4442 settings.setValue(QSL("studio/bc/vin/chk_import_char_prefix"), get_chk_val(QSL("chkVINImportChar")));
4443 break;
4444 }
4445 }
4446
4447 /* Load settings for an individual symbol */
4448 void MainWindow::load_sub_settings(QSettings &settings, int symbology)
4449 {
4450 QString name = get_setting_name(symbology);
4451 if (!name.isEmpty()) { // Should never be empty
4452 const QString &tdata = settings.value(QSL("studio/bc/%1/data").arg(name), QSEmpty).toString();
4453 if (!tdata.isEmpty()) {
4454 txtData->setText(tdata);
4455 }
4456 if (!grpSegs->isHidden()) {
4457 txtDataSeg1->setText(settings.value(QSL("studio/bc/%1/data_seg1").arg(name), QSEmpty).toString());
4458 txtDataSeg2->setText(settings.value(QSL("studio/bc/%1/data_seg2").arg(name), QSEmpty).toString());
4459 txtDataSeg3->setText(settings.value(QSL("studio/bc/%1/data_seg3").arg(name), QSEmpty).toString());
4460 }
4461 if (!grpComposite->isHidden()) {
4462 const QString &composite_text = settings.value(
4463 QSL("studio/bc/%1/composite_text").arg(name), QSEmpty).toString();
4464 if (!composite_text.isEmpty()) {
4465 txtComposite->setText(composite_text);
4466 }
4467 chkComposite->setChecked(settings.value(
4468 QSL("studio/bc/%1/chk_composite").arg(name), 0).toInt() ? true : false);
4469 cmbCompType->setCurrentIndex(settings.value(QSL("studio/bc/%1/comp_type").arg(name), 0).toInt());
4470 }
4471 if (cmbECI->isEnabled()) {
4472 cmbECI->setCurrentIndex(settings.value(QSL("studio/bc/%1/eci").arg(name), 0).toInt());
4473 cmbECISeg1->setCurrentIndex(settings.value(QSL("studio/bc/%1/eci_seg1").arg(name), 0).toInt());
4474 cmbECISeg2->setCurrentIndex(settings.value(QSL("studio/bc/%1/eci_seg2").arg(name), 0).toInt());
4475 cmbECISeg3->setCurrentIndex(settings.value(QSL("studio/bc/%1/eci_seg3").arg(name), 0).toInt());
4476 }
4477 chkEscape->setChecked(settings.value(QSL("studio/bc/%1/chk_escape").arg(name)).toInt() ? true : false);
4478 chkData->setChecked(settings.value(QSL("studio/bc/%1/chk_data").arg(name)).toInt() ? true : false);
4479 if (chkRInit->isEnabled()) {
4480 chkRInit->setChecked(settings.value(QSL("studio/bc/%1/chk_rinit").arg(name)).toInt() ? true : false);
4481 }
4482 chkGS1Parens->setChecked(settings.value(QSL("studio/bc/%1/chk_gs1parens").arg(name)).toInt() ? true : false);
4483 chkGS1NoCheck->setChecked(settings.value(
4484 QSL("studio/bc/%1/chk_gs1nocheck").arg(name)).toInt() ? true : false);
4485 if (chkAutoHeight->isEnabled()) {
4486 chkAutoHeight->setChecked(settings.value(
4487 QSL("studio/bc/%1/appearance/autoheight").arg(name), 1).toInt() ? true : false);
4488 heightb->setValue(settings.value(QSL("studio/bc/%1/appearance/height").arg(name), 50.0f).toFloat());
4489 }
4490 if (chkCompliantHeight->isEnabled()) {
4491 chkCompliantHeight->setChecked(settings.value(
4492 QSL("studio/bc/%1/appearance/compliantheight").arg(name), 1).toInt() ? true : false);
4493 }
4494 bwidth->setValue(settings.value(QSL("studio/bc/%1/appearance/border").arg(name), 0).toInt());
4495 spnWhitespace->setValue(settings.value(QSL("studio/bc/%1/appearance/whitespace").arg(name), 0).toInt());
4496 spnVWhitespace->setValue(settings.value(QSL("studio/bc/%1/appearance/vwhitespace").arg(name), 0).toInt());
4497 spnScale->setValue(settings.value(QSL("studio/bc/%1/appearance/scale").arg(name), 1.0).toFloat());
4498 btype->setCurrentIndex(settings.value(QSL("studio/bc/%1/appearance/border_type").arg(name), 0).toInt());
4499 if (chkHRTShow->isEnabled()) {
4500 cmbFontSetting->setCurrentIndex(settings.value(
4501 QSL("studio/bc/%1/appearance/font_setting").arg(name), 0).toInt());
4502 spnTextGap->setValue(settings.value(QSL("studio/bc/%1/appearance/text_gap").arg(name), 1.0).toFloat());
4503 chkEmbedVectorFont->setChecked(settings.value(
4504 QSL("studio/bc/%1/appearance/chk_embed_vector_font").arg(name), 0).toInt() ? true : false);
4505 chkHRTShow->setChecked(settings.value(
4506 QSL("studio/bc/%1/appearance/chk_hrt_show").arg(name), 1).toInt() ? true : false);
4507 }
4508 chkCMYK->setChecked(settings.value(
4509 QSL("studio/bc/%1/appearance/chk_cmyk").arg(name), 0).toInt() ? true : false);
4510 chkQuietZones->setChecked(settings.value(
4511 QSL("studio/bc/%1/appearance/chk_quietzones").arg(name), 0).toInt() ? true : false);
4512 cmbRotate->setCurrentIndex(settings.value(QSL("studio/bc/%1/appearance/rotate").arg(name), 0).toInt());
4513 if (symbology == BARCODE_DOTCODE || chkDotty->isEnabled()) {
4514 chkDotty->setChecked(settings.value(
4515 QSL("studio/bc/%1/appearance/chk_dotty").arg(name), 0).toInt() ? true : false);
4516 spnDotSize->setValue(settings.value(
4517 QSL("studio/bc/%1/appearance/dot_size").arg(name), 0.4f / 0.5f).toFloat());
4518 }
4519 m_fgstr = settings.value(QSL("studio/bc/%1/ink/text").arg(name), QSEmpty).toString();
4520 if (m_fgstr.isEmpty()) {
4521 QColor color(settings.value(QSL("studio/bc/%1/ink/red").arg(name), 0).toInt(),
4522 settings.value(QSL("studio/bc/%1/ink/green").arg(name), 0).toInt(),
4523 settings.value(QSL("studio/bc/%1/ink/blue").arg(name), 0).toInt(),
4524 settings.value(QSL("studio/bc/%1/ink/alpha").arg(name), 0xff).toInt());
4525 m_fgstr = qcolor_to_str(color);
4526 }
4527 if (m_fgstr.indexOf(*colorRE) != 0) {
4528 m_fgstr = fgDefault;
4529 }
4530 m_bgstr = settings.value(QSL("studio/bc/%1/paper/text").arg(name), QSEmpty).toString();
4531 if (m_bgstr.isEmpty()) {
4532 QColor color(settings.value(QSL("studio/bc/%1/paper/red").arg(name), 0xff).toInt(),
4533 settings.value(QSL("studio/bc/%1/paper/green").arg(name), 0xff).toInt(),
4534 settings.value(QSL("studio/bc/%1/paper/blue").arg(name), 0xff).toInt(),
4535 settings.value(QSL("studio/bc/%1/paper/alpha").arg(name), 0xff).toInt());
4536 m_bgstr = qcolor_to_str(color);
4537 }
4538 if (m_bgstr.indexOf(*colorRE) != 0) {
4539 m_bgstr = bgDefault;
4540 }
4541 m_xdimdpVars.x_dim = settings.value(QSL("studio/bc/%1/xdimdpvars/x_dim").arg(name), 0.0).toFloat();
4542 m_xdimdpVars.x_dim_units = settings.value(QSL("studio/bc/%1/xdimdpvars/x_dim_units").arg(name), 0).toInt();
4543 m_xdimdpVars.set = settings.value(QSL("studio/bc/%1/xdimdpvars/set").arg(name), 0).toInt();
4544 } else {
4545 m_xdimdpVars.x_dim = 0.0;
4546 m_xdimdpVars.x_dim_units = 0;
4547 m_xdimdpVars.set = 0;
4548 }
4549
4550 switch (symbology) {
4551 case BARCODE_CODE128:
4552 case BARCODE_CODE128AB:
4553 case BARCODE_GS1_128:
4554 case BARCODE_GS1_128_CC:
4555 case BARCODE_HIBC_128:
4556 set_rad_from_setting(settings, QSL("studio/bc/code128/encoding_mode"),
4557 QStringList() << QSL("radC128Stand") << QSL("radC128EAN") << QSL("radC128CSup")
4558 << QSL("radC128HIBC") << QSL("radC128ExtraEsc"));
4559 break;
4560
4561 case BARCODE_PDF417:
4562 case BARCODE_PDF417COMP:
4563 case BARCODE_HIBC_PDF:
4564 set_cmb_from_setting(settings, QSL("studio/bc/pdf417/cols"), QSL("cmbPDFCols"));
4565 set_cmb_from_setting(settings, QSL("studio/bc/pdf417/rows"), QSL("cmbPDFRows"));
4566 set_dspn_from_setting(settings, QSL("studio/bc/pdf417/height_per_row"), QSL("spnPDFHeightPerRow"), 0.0f);
4567 set_cmb_from_setting(settings, QSL("studio/bc/pdf417/ecc"), QSL("cmbPDFECC"));
4568 set_rad_from_setting(settings, QSL("studio/bc/pdf417/encoding_mode"),
4569 QStringList() << QSL("radPDFStand") << QSL("radPDFTruncated") << QSL("radPDFHIBC"));
4570 set_chk_from_setting(settings, QSL("studio/bc/pdf417/chk_fast"), QSL("chkPDFFast"));
4571 set_spn_from_setting(settings, QSL("studio/bc/pdf417/structapp_count"), QSL("spnPDFStructAppCount"), 1);
4572 set_spn_from_setting(settings, QSL("studio/bc/pdf417/structapp_index"), QSL("spnPDFStructAppIndex"), 0);
4573 set_txt_from_setting(settings, QSL("studio/bc/pdf417/structapp_id"), QSL("txtPDFStructAppID"), QSEmpty);
4574 break;
4575
4576 case BARCODE_MICROPDF417:
4577 case BARCODE_HIBC_MICPDF:
4578 set_cmb_from_setting(settings, QSL("studio/bc/micropdf417/cols"), QSL("cmbMPDFCols"));
4579 set_dspn_from_setting(settings, QSL("studio/bc/micropdf417/height_per_row"), QSL("spnMPDFHeightPerRow"),
4580 0.0f);
4581 set_rad_from_setting(settings, QSL("studio/bc/micropdf417/encoding_mode"),
4582 QStringList() << QSL("radMPDFStand") << QSL("radMPDFHIBC"));
4583 set_chk_from_setting(settings, QSL("studio/bc/micropdf417/chk_fast"), QSL("chkMPDFFast"));
4584 set_spn_from_setting(settings, QSL("studio/bc/micropdf417/structapp_count"),
4585 QSL("spnMPDFStructAppCount"), 1);
4586 set_spn_from_setting(settings, QSL("studio/bc/micropdf417/structapp_index"),
4587 QSL("spnMPDFStructAppIndex"), 0);
4588 set_txt_from_setting(settings, QSL("studio/bc/micropdf417/structapp_id"), QSL("txtMPDFStructAppID"),
4589 QSEmpty);
4590 break;
4591
4592 case BARCODE_DOTCODE:
4593 set_cmb_from_setting(settings, QSL("studio/bc/dotcode/cols"), QSL("cmbDotCols"));
4594 set_cmb_from_setting(settings, QSL("studio/bc/dotcode/mask"), QSL("cmbDotMask"));
4595 set_rad_from_setting(settings, QSL("studio/bc/dotcode/encoding_mode"),
4596 QStringList() << QSL("radDotStand") << QSL("radDotGS1"));
4597 set_cmb_from_setting(settings, QSL("studio/bc/dotcode/structapp_count"), QSL("cmbDotStructAppCount"));
4598 set_cmb_from_setting(settings, QSL("studio/bc/dotcode/structapp_index"), QSL("cmbDotStructAppIndex"));
4599 break;
4600
4601 case BARCODE_AZTEC:
4602 case BARCODE_HIBC_AZTEC:
4603 set_rad_from_setting(settings, QSL("studio/bc/aztec/autoresizing"),
4604 QStringList() << QSL("radAztecAuto") << QSL("radAztecSize") << QSL("radAztecECC"));
4605 set_cmb_from_setting(settings, QSL("studio/bc/aztec/size"), QSL("cmbAztecSize"));
4606 set_cmb_from_setting(settings, QSL("studio/bc/aztec/ecc"), QSL("cmbAztecECC"));
4607 set_rad_from_setting(settings, QSL("studio/bc/aztec/encoding_mode"),
4608 QStringList() << QSL("radAztecStand") << QSL("radAztecGS1") << QSL("radAztecHIBC"));
4609 set_cmb_from_setting(settings, QSL("studio/bc/aztec/structapp_count"), QSL("cmbAztecStructAppCount"));
4610 set_cmb_from_setting(settings, QSL("studio/bc/aztec/structapp_index"), QSL("cmbAztecStructAppIndex"));
4611 set_txt_from_setting(settings, QSL("studio/bc/aztec/structapp_id"), QSL("txtAztecStructAppID"), QSEmpty);
4612 break;
4613
4614 case BARCODE_MSI_PLESSEY:
4615 set_cmb_from_setting(settings, QSL("studio/bc/msi_plessey/check_digit"), QSL("cmbMSICheck"));
4616 set_chk_from_setting(settings, QSL("studio/bc/msi_plessey/check_text"), QSL("chkMSICheckText"));
4617 msi_plessey_ui_set();
4618 break;
4619
4620 case BARCODE_CODE11:
4621 set_rad_from_setting(settings, QSL("studio/bc/code11/check_digit"),
4622 QStringList() << QSL("radC11TwoCheckDigits") << QSL("radC11OneCheckDigit")
4623 << QSL("radC11NoCheckDigits"));
4624 break;
4625
4626 case BARCODE_C25STANDARD:
4627 set_rad_from_setting(settings, QSL("studio/bc/c25standard/check_digit"),
4628 QStringList() << QSL("radC25Stand") << QSL("radC25Check") << QSL("radC25CheckHide"));
4629 break;
4630 case BARCODE_C25INTER:
4631 set_rad_from_setting(settings, QSL("studio/bc/c25inter/check_digit"),
4632 QStringList() << QSL("radC25Stand") << QSL("radC25Check") << QSL("radC25CheckHide"));
4633 break;
4634 case BARCODE_C25IATA:
4635 set_rad_from_setting(settings, QSL("studio/bc/c25iata/check_digit"),
4636 QStringList() << QSL("radC25Stand") << QSL("radC25Check") << QSL("radC25CheckHide"));
4637 break;
4638 case BARCODE_C25LOGIC:
4639 set_rad_from_setting(settings, QSL("studio/bc/c25logic/check_digit"),
4640 QStringList() << QSL("radC25Stand") << QSL("radC25Check") << QSL("radC25CheckHide"));
4641 break;
4642 case BARCODE_C25IND:
4643 set_rad_from_setting(settings, QSL("studio/bc/c25ind/check_digit"),
4644 QStringList() << QSL("radC25Stand") << QSL("radC25Check") << QSL("radC25CheckHide"));
4645 break;
4646
4647 case BARCODE_CODE39:
4648 case BARCODE_HIBC_39:
4649 set_rad_from_setting(settings, QSL("studio/bc/code39/check_digit"),
4650 QStringList() << QSL("radC39Stand") << QSL("radC39Check") << QSL("radC39HIBC")
4651 << QSL("radC39CheckHide"));
4652 break;
4653
4654 case BARCODE_EXCODE39:
4655 set_rad_from_setting(settings, QSL("studio/bc/excode39/check_digit"),
4656 QStringList() << QSL("radC39Stand") << QSL("radC39Check") << QSL("radC39CheckHide"));
4657 break;
4658 case BARCODE_LOGMARS:
4659 set_rad_from_setting(settings, QSL("studio/bc/logmars/check_digit"),
4660 QStringList() << QSL("radC39Stand") << QSL("radC39Check") << QSL("radC39CheckHide"));
4661 break;
4662
4663 case BARCODE_CODE16K:
4664 set_cmb_from_setting(settings, QSL("studio/bc/code16k/rows"), QSL("cmbC16kRows"));
4665 set_dspn_from_setting(settings, QSL("studio/bc/code16k/height_per_row"), QSL("spnC16kHeightPerRow"),
4666 0.0f);
4667 set_cmb_from_setting(settings, QSL("studio/bc/code16k/row_sep_height"), QSL("cmbC16kRowSepHeight"));
4668 set_rad_from_setting(settings, QSL("studio/bc/code16k/encoding_mode"),
4669 QStringList() << QSL("radC16kStand") << QSL("radC16kGS1"));
4670 set_chk_from_setting(settings, QSL("studio/bc/code16k/chk_no_quiet_zones"), QSL("chkC16kNoQuietZones"));
4671 break;
4672
4673 case BARCODE_CODABAR:
4674 set_rad_from_setting(settings, QSL("studio/bc/codabar/check_digit"),
4675 QStringList() << QSL("radCodabarStand") << QSL("radCodabarCheckHide") << QSL("radCodabarCheck"));
4676 break;
4677
4678 case BARCODE_CODABLOCKF:
4679 case BARCODE_HIBC_BLOCKF:
4680 set_cmb_from_setting(settings, QSL("studio/bc/codablockf/width"), QSL("cmbCbfWidth"));
4681 set_cmb_from_setting(settings, QSL("studio/bc/codablockf/height"), QSL("cmbCbfHeight"));
4682 set_dspn_from_setting(settings, QSL("studio/bc/codablockf/height_per_row"), QSL("spnCbfHeightPerRow"),
4683 0.0f);
4684 set_cmb_from_setting(settings, QSL("studio/bc/codablockf/row_sep_height"),
4685 QSL("cmbCbfRowSepHeight"));
4686 set_rad_from_setting(settings, QSL("studio/bc/codablockf/encoding_mode"),
4687 QStringList() << QSL("radCbfStand") << QSL("radCbfHIBC"));
4688 set_chk_from_setting(settings, QSL("studio/bc/codablockf/chk_no_quiet_zones"), QSL("chkCbfNoQuietZones"));
4689 break;
4690
4691 case BARCODE_DAFT:
4692 set_dspn_from_setting(settings, QSL("studio/bc/daft/tracker_ratio"), QSL("spnDAFTTrackerRatio"), 25.0f);
4693 break;
4694
4695 case BARCODE_DPD:
4696 set_chk_from_setting(settings, QSL("studio/bc/dpd/chk_relabel"), QSL("chkDPDRelabel"));
4697 break;
4698
4699 case BARCODE_DATAMATRIX:
4700 case BARCODE_HIBC_DM:
4701 set_cmb_from_setting(settings, QSL("studio/bc/datamatrix/size"), QSL("cmbDM200Size"));
4702 set_rad_from_setting(settings, QSL("studio/bc/datamatrix/encoding_mode"),
4703 QStringList() << QSL("radDM200Stand") << QSL("radDM200GS1") << QSL("radDM200HIBC"));
4704 set_chk_from_setting(settings, QSL("studio/bc/datamatrix/chk_suppress_rect"), QSL("chkDMRectangle"));
4705 set_chk_from_setting(settings, QSL("studio/bc/datamatrix/chk_allow_dmre"), QSL("chkDMRE"));
4706 set_chk_from_setting(settings, QSL("studio/bc/datamatrix/chk_gs_sep"), QSL("chkDMGSSep"));
4707 set_chk_from_setting(settings, QSL("studio/bc/datamatrix/iso_144"), QSL("chkDMISO144"));
4708 set_chk_from_setting(settings, QSL("studio/bc/datamatrix/chk_fast"), QSL("chkDMFast"));
4709 set_cmb_from_setting(settings, QSL("studio/bc/datamatrix/structapp_count"), QSL("cmbDMStructAppCount"));
4710 set_cmb_from_setting(settings, QSL("studio/bc/datamatrix/structapp_index"), QSL("cmbDMStructAppIndex"));
4711 set_spn_from_setting(settings, QSL("studio/bc/datamatrix/structapp_id"), QSL("spnDMStructAppID"), 1);
4712 set_spn_from_setting(settings, QSL("studio/bc/datamatrix/structapp_id2"), QSL("spnDMStructAppID2"), 1);
4713 break;
4714
4715 case BARCODE_MAILMARK_2D:
4716 set_cmb_from_setting(settings, QSL("studio/bc/mailmark2d/size"), QSL("cmbMailmark2DSize"));
4717 set_chk_from_setting(settings, QSL("studio/bc/mailmark2d/chk_suppress_rect"),
4718 QSL("chkMailmark2DRectangle"));
4719 break;
4720
4721 case BARCODE_ITF14:
4722 set_chk_from_setting(settings, QSL("studio/bc/itf14/chk_no_quiet_zones"), QSL("chkITF14NoQuietZones"));
4723 break;
4724
4725 case BARCODE_PZN:
4726 set_chk_from_setting(settings, QSL("studio/bc/pzn/chk_pzn7"), QSL("chkPZN7"));
4727 break;
4728
4729 case BARCODE_QRCODE:
4730 case BARCODE_HIBC_QR:
4731 set_cmb_from_setting(settings, QSL("studio/bc/qrcode/size"), QSL("cmbQRSize"));
4732 set_cmb_from_setting(settings, QSL("studio/bc/qrcode/ecc"), QSL("cmbQRECC"));
4733 set_cmb_from_setting(settings, QSL("studio/bc/qrcode/mask"), QSL("cmbQRMask"));
4734 set_rad_from_setting(settings, QSL("studio/bc/qrcode/encoding_mode"),
4735 QStringList() << QSL("radDM200Stand") << QSL("radQRGS1") << QSL("radQRHIBC"));
4736 set_chk_from_setting(settings, QSL("studio/bc/qrcode/chk_full_multibyte"), QSL("chkQRFullMultibyte"));
4737 set_chk_from_setting(settings, QSL("studio/bc/qrcode/chk_fast_mode"), QSL("chkQRFast"));
4738 set_cmb_from_setting(settings, QSL("studio/bc/qrcode/structapp_count"), QSL("cmbQRStructAppCount"));
4739 set_cmb_from_setting(settings, QSL("studio/bc/qrcode/structapp_index"), QSL("cmbQRStructAppIndex"));
4740 set_spn_from_setting(settings, QSL("studio/bc/qrcode/structapp_id"), QSL("spnQRStructAppID"), 0);
4741 break;
4742
4743 case BARCODE_UPNQR:
4744 set_cmb_from_setting(settings, QSL("studio/bc/upnqr/mask"), QSL("cmbUPNQRMask"));
4745 set_chk_from_setting(settings, QSL("studio/bc/upnqr/chk_fast_mode"), QSL("chkUPNQRFast"));
4746 break;
4747
4748 case BARCODE_RMQR:
4749 set_cmb_from_setting(settings, QSL("studio/bc/rmqr/size"), QSL("cmbRMQRSize"));
4750 set_cmb_from_setting(settings, QSL("studio/bc/rmqr/ecc"), QSL("cmbRMQRECC"));
4751 set_rad_from_setting(settings, QSL("studio/bc/rmqr/encoding_mode"),
4752 QStringList() << QSL("radQRStand") << QSL("radRMQRGS1"));
4753 set_chk_from_setting(settings, QSL("studio/bc/rmqr/chk_full_multibyte"), QSL("chkRMQRFullMultibyte"));
4754 break;
4755
4756 case BARCODE_HANXIN:
4757 set_cmb_from_setting(settings, QSL("studio/bc/hanxin/size"), QSL("cmbHXSize"));
4758 set_cmb_from_setting(settings, QSL("studio/bc/hanxin/ecc"), QSL("cmbHXECC"));
4759 set_cmb_from_setting(settings, QSL("studio/bc/hanxin/mask"), QSL("cmbHXMask"));
4760 set_chk_from_setting(settings, QSL("studio/bc/hanxin/chk_full_multibyte"), QSL("chkHXFullMultibyte"));
4761 break;
4762
4763 case BARCODE_MICROQR:
4764 set_cmb_from_setting(settings, QSL("studio/bc/microqr/size"), QSL("cmbMQRSize"));
4765 set_cmb_from_setting(settings, QSL("studio/bc/microqr/ecc"), QSL("cmbMQRECC"));
4766 set_cmb_from_setting(settings, QSL("studio/bc/microqr/mask"), QSL("cmbMQRMask"));
4767 set_chk_from_setting(settings, QSL("studio/bc/microqr/chk_full_multibyte"), QSL("chkMQRFullMultibyte"));
4768 break;
4769
4770 case BARCODE_GRIDMATRIX:
4771 set_cmb_from_setting(settings, QSL("studio/bc/gridmatrix/size"), QSL("cmbGridSize"));
4772 set_cmb_from_setting(settings, QSL("studio/bc/gridmatrix/ecc"), QSL("cmbGridECC"));
4773 set_chk_from_setting(settings, QSL("studio/bc/gridmatrix/chk_full_multibyte"),
4774 QSL("chkGridFullMultibyte"));
4775 set_cmb_from_setting(settings, QSL("studio/bc/gridmatrix/structapp_count"), QSL("cmbGridStructAppCount"));
4776 set_cmb_from_setting(settings, QSL("studio/bc/gridmatrix/structapp_index"), QSL("cmbGridStructAppIndex"));
4777 set_spn_from_setting(settings, QSL("studio/bc/gridmatrix/structapp_id"), QSL("spnGridStructAppID"), 0);
4778 break;
4779
4780 case BARCODE_MAXICODE:
4781 set_cmb_from_setting(settings, QSL("studio/bc/maxicode/mode"), QSL("cmbMaxiMode"), 1);
4782 set_txt_from_setting(settings, QSL("studio/bc/maxicode/scm_postcode"), QSL("txtMaxiSCMPostcode"),
4783 QSEmpty);
4784 set_spn_from_setting(settings, QSL("studio/bc/maxicode/scm_country"), QSL("spnMaxiSCMCountry"), 0);
4785 set_spn_from_setting(settings, QSL("studio/bc/maxicode/scm_service"), QSL("spnMaxiSCMService"), 0);
4786 set_chk_from_setting(settings, QSL("studio/bc/maxicode/chk_scm_vv"), QSL("chkMaxiSCMVV"));
4787 // 96 is ASC MH10/SC 8
4788 set_spn_from_setting(settings, QSL("studio/bc/maxicode/spn_scm_vv"), QSL("spnMaxiSCMVV"), 96);
4789 set_cmb_from_setting(settings, QSL("studio/bc/maxicode/structapp_count"), QSL("cmbMaxiStructAppCount"));
4790 set_cmb_from_setting(settings, QSL("studio/bc/maxicode/structapp_index"), QSL("cmbMaxiStructAppIndex"));
4791 break;
4792
4793 case BARCODE_CHANNEL:
4794 set_cmb_from_setting(settings, QSL("studio/bc/channel/channel"), QSL("cmbChannel"));
4795 break;
4796
4797 case BARCODE_CODEONE:
4798 set_cmb_from_setting(settings, QSL("studio/bc/codeone/size"), QSL("cmbC1Size"));
4799 set_rad_from_setting(settings, QSL("studio/bc/codeone/encoding_mode"),
4800 QStringList() << QSL("radC1Stand") << QSL("radC1GS1"));
4801 set_spn_from_setting(settings, QSL("studio/bc/codeone/structapp_count"), QSL("spnC1StructAppCount"), 1);
4802 set_spn_from_setting(settings, QSL("studio/bc/codeone/structapp_index"), QSL("spnC1StructAppIndex"), 0);
4803 break;
4804
4805 case BARCODE_CODE49:
4806 set_cmb_from_setting(settings, QSL("studio/bc/code49/rows"), QSL("cmbC49Rows"));
4807 set_dspn_from_setting(settings, QSL("studio/bc/code49/height_per_row"), QSL("spnC49HeightPerRow"), 0.0f);
4808 set_cmb_from_setting(settings, QSL("studio/bc/code49/row_sep_height"), QSL("cmbC49RowSepHeight"));
4809 set_rad_from_setting(settings, QSL("studio/bc/code49/encoding_mode"),
4810 QStringList() << QSL("radC49Stand") << QSL("radC49GS1"));
4811 set_chk_from_setting(settings, QSL("studio/bc/code49/chk_no_quiet_zones"), QSL("chkC49NoQuietZones"));
4812 break;
4813
4814 case BARCODE_CODE93:
4815 set_chk_from_setting(settings, QSL("studio/bc/code93/chk_show_checks"), QSL("chkC93ShowChecks"));
4816 break;
4817
4818 case BARCODE_DBAR_EXPSTK:
4819 set_rad_from_setting(settings, QSL("studio/bc/dbar_expstk/colsrows"),
4820 QStringList() << QSL("radDBESCols") << QSL("radDBESRows"));
4821 set_cmb_from_setting(settings, QSL("studio/bc/dbar_expstk/cols"), QSL("cmbDBESCols"));
4822 set_cmb_from_setting(settings, QSL("studio/bc/dbar_expstk/rows"), QSL("cmbDBESRows"));
4823 set_dspn_from_setting(settings, QSL("studio/bc/dbar_expstk/height_per_row"), QSL("spnDBESHeightPerRow"),
4824 0.0f);
4825 break;
4826
4827 case BARCODE_ULTRA:
4828 set_rad_from_setting(settings, QSL("studio/bc/ultra/autoresizing"),
4829 QStringList() << QSL("radUltraAuto") << QSL("radUltraEcc"));
4830 set_cmb_from_setting(settings, QSL("studio/bc/ultra/ecc"), QSL("cmbUltraEcc"));
4831 set_cmb_from_setting(settings, QSL("studio/bc/ultra/revision"), QSL("cmbUltraRevision"));
4832 set_rad_from_setting(settings, QSL("studio/bc/ultra/encoding_mode"),
4833 QStringList() << QSL("radUltraStand") << QSL("radUltraGS1"));
4834 set_cmb_from_setting(settings, QSL("studio/bc/ultra/structapp_count"), QSL("cmbUltraStructAppCount"));
4835 set_cmb_from_setting(settings, QSL("studio/bc/ultra/structapp_index"), QSL("cmbUltraStructAppIndex"));
4836 set_spn_from_setting(settings, QSL("studio/bc/ultra/structapp_id"), QSL("spnUltraStructAppID"), 0);
4837 break;
4838
4839 case BARCODE_UPCA:
4840 case BARCODE_UPCA_CHK:
4841 case BARCODE_UPCA_CC:
4842 set_cmb_from_setting(settings, QSL("studio/bc/upca/addongap"), QSL("cmbUPCAAddonGap"));
4843 set_dspn_from_setting(settings, QSL("studio/bc/upca/guard_descent"), QSL("spnUPCAGuardDescent"), 5.0f);
4844 set_chk_from_setting(settings, QSL("studio/bc/upca/chk_no_quiet_zones"), QSL("chkUPCANoQuietZones"));
4845 set_chk_from_setting(settings, QSL("studio/bc/upca/chk_guard_whitespace"), QSL("chkUPCAGuardWhitespace"));
4846 break;
4847
4848 case BARCODE_EANX:
4849 case BARCODE_EANX_CHK:
4850 case BARCODE_EANX_CC:
4851 set_cmb_from_setting(settings, QSL("studio/bc/eanx/addongap"), QSL("cmbUPCEANAddonGap"));
4852 set_dspn_from_setting(settings, QSL("studio/bc/eanx/guard_descent"), QSL("spnUPCEANGuardDescent"), 5.0f);
4853 set_chk_from_setting(settings, QSL("studio/bc/eanx/chk_no_quiet_zones"), QSL("chkUPCEANNoQuietZones"));
4854 set_chk_from_setting(settings, QSL("studio/bc/eanx/chk_guard_whitespace"),
4855 QSL("chkUPCEANGuardWhitespace"));
4856 break;
4857
4858 case BARCODE_UPCE:
4859 case BARCODE_UPCE_CHK:
4860 case BARCODE_UPCE_CC:
4861 set_cmb_from_setting(settings, QSL("studio/bc/upce/addongap"), QSL("cmbUPCEANAddonGap"));
4862 set_dspn_from_setting(settings, QSL("studio/bc/upce/guard_descent"), QSL("spnUPCEANGuardDescent"), 5.0f);
4863 set_chk_from_setting(settings, QSL("studio/bc/upce/chk_no_quiet_zones"), QSL("chkUPCEANNoQuietZones"));
4864 set_chk_from_setting(settings, QSL("studio/bc/upce/chk_guard_whitespace"),
4865 QSL("chkUPCEANGuardWhitespace"));
4866 break;
4867
4868 case BARCODE_ISBNX:
4869 set_cmb_from_setting(settings, QSL("studio/bc/isbnx/addongap"), QSL("cmbUPCEANAddonGap"));
4870 set_dspn_from_setting(settings, QSL("studio/bc/isbnx/guard_descent"), QSL("spnUPCEANGuardDescent"), 5.0f);
4871 set_chk_from_setting(settings, QSL("studio/bc/isbnx/chk_no_quiet_zones"), QSL("chkUPCEANNoQuietZones"));
4872 set_chk_from_setting(settings, QSL("studio/bc/isbnx/chk_guard_whitespace"),
4873 QSL("chkUPCEANGuardWhitespace"));
4874 break;
4875
4876 case BARCODE_VIN:
4877 set_chk_from_setting(settings, QSL("studio/bc/vin/chk_import_char_prefix"), QSL("chkVINImportChar"));
4878 break;
4879 }
4880 }
4881
4882 float MainWindow::get_dpmm(const struct Zint::QZintXdimDpVars* vars) const
4883 {
4884 return (float) (vars->resolution_units == 1 ? vars->resolution / 25.4 : vars->resolution);
4885 }
4886
4887 const char *MainWindow::getFileType(const struct Zint::QZintXdimDpVars* vars, bool msg) const
4888 {
4889 return Zint::QZintXdimDpVars::getFileType(m_bc.bc.symbol(), vars, msg);
4890 }
4891
4892 /* vim: set ts=4 sw=4 et : */