mirror of
https://git.code.sf.net/p/zint/code
synced 2025-05-14 07:04:34 -04:00
GUI: add CLI equivalent dialog (#163); use spinboxes in Sequence dialog
and restrict sequence to max 10,000, add button icons; make Export dialog sizable and show every 100 results, add button icon; fix saving CHANNEL option, fix Export painting main window (Windows), fix guard descent not-resetting qzint: add getAsCLI(), warnLevel(), extra isStackable()/isComposite() etc Add ZBarcode_BarcodeName() manual: doc above, some fixes, tweaks
This commit is contained in:
parent
9d85c425f4
commit
739a64a6ff
34 changed files with 2264 additions and 1199 deletions
|
@ -28,29 +28,36 @@
|
|||
#include "sequencewindow.h"
|
||||
#include "exportwindow.h"
|
||||
|
||||
SequenceWindow::SequenceWindow()
|
||||
// Shorthand
|
||||
#define QSL QStringLiteral
|
||||
|
||||
SequenceWindow::SequenceWindow(BarcodeItem *bc) : m_bc(bc)
|
||||
{
|
||||
setupUi(this);
|
||||
QSettings settings;
|
||||
#if QT_VERSION < 0x60000
|
||||
settings.setIniCodec("UTF-8");
|
||||
#endif
|
||||
QValidator *intvalid = new QIntValidator(this);
|
||||
|
||||
linStartVal->setText(settings.value("studio/sequence/start_value", "1").toString());
|
||||
linEndVal->setText(settings.value("studio/sequence/end_value", "10").toString());
|
||||
linIncVal->setText(settings.value("studio/sequence/increment", "1").toString());
|
||||
linFormat->setText(settings.value("studio/sequence/format", "$$$$$$").toString());
|
||||
QByteArray geometry = settings.value(QSL("studio/sequence/window_geometry")).toByteArray();
|
||||
restoreGeometry(geometry);
|
||||
|
||||
linStartVal->setValidator(intvalid);
|
||||
linEndVal->setValidator(intvalid);
|
||||
linIncVal->setValidator(intvalid);
|
||||
connect(btnClose, SIGNAL( clicked( bool )), SLOT(quit_now()));
|
||||
connect(btnReset, SIGNAL( clicked( bool )), SLOT(reset_preview()));
|
||||
connect(btnCreate, SIGNAL( clicked( bool )), SLOT(create_sequence()));
|
||||
connect(txtPreview, SIGNAL( textChanged()), SLOT(check_generate()));
|
||||
connect(btnImport, SIGNAL( clicked( bool )), SLOT(import()));
|
||||
connect(btnExport, SIGNAL( clicked( bool )), SLOT(generate_sequence()));
|
||||
spnSeqStartVal->setValue(settings.value(QSL("studio/sequence/start_value"), 1).toInt());
|
||||
spnSeqEndVal->setValue(settings.value(QSL("studio/sequence/end_value"), 10).toInt());
|
||||
spnSeqIncVal->setValue(settings.value(QSL("studio/sequence/increment"), 1).toInt());
|
||||
linSeqFormat->setText(settings.value(QSL("studio/sequence/format"), QSL("$$$$$$")).toString());
|
||||
|
||||
QIcon closeIcon(QIcon::fromTheme(QSL("window-close"), QIcon(QSL(":res/x.svg"))));
|
||||
QIcon clearIcon(QIcon::fromTheme(QSL("edit-clear"), QIcon(QSL(":res/delete.svg"))));
|
||||
btnSeqClose->setIcon(closeIcon);
|
||||
btnSeqClear->setIcon(clearIcon);
|
||||
|
||||
connect(btnSeqClose, SIGNAL( clicked( bool )), SLOT(close()));
|
||||
connect(btnSeqClear, SIGNAL( clicked( bool )), SLOT(clear_preview()));
|
||||
connect(btnSeqCreate, SIGNAL( clicked( bool )), SLOT(create_sequence()));
|
||||
connect(txtSeqPreview, SIGNAL( textChanged()), SLOT(check_generate()));
|
||||
connect(btnSeqImport, SIGNAL( clicked( bool )), SLOT(import()));
|
||||
connect(btnSeqExport, SIGNAL( clicked( bool )), SLOT(generate_sequence()));
|
||||
}
|
||||
|
||||
SequenceWindow::~SequenceWindow()
|
||||
|
@ -59,40 +66,36 @@ SequenceWindow::~SequenceWindow()
|
|||
#if QT_VERSION < 0x60000
|
||||
settings.setIniCodec("UTF-8");
|
||||
#endif
|
||||
settings.setValue(QSL("studio/sequence/window_geometry"), saveGeometry());
|
||||
|
||||
settings.setValue("studio/sequence/start_value", linStartVal->text());
|
||||
settings.setValue("studio/sequence/end_value", linEndVal->text());
|
||||
settings.setValue("studio/sequence/increment", linIncVal->text());
|
||||
settings.setValue("studio/sequence/format", linFormat->text());
|
||||
settings.setValue(QSL("studio/sequence/start_value"), spnSeqStartVal->value());
|
||||
settings.setValue(QSL("studio/sequence/end_value"), spnSeqEndVal->value());
|
||||
settings.setValue(QSL("studio/sequence/increment"), spnSeqIncVal->value());
|
||||
settings.setValue(QSL("studio/sequence/format"), linSeqFormat->text());
|
||||
}
|
||||
|
||||
void SequenceWindow::quit_now()
|
||||
void SequenceWindow::clear_preview()
|
||||
{
|
||||
close();
|
||||
txtSeqPreview->clear();
|
||||
}
|
||||
|
||||
void SequenceWindow::reset_preview()
|
||||
{
|
||||
txtPreview->clear();
|
||||
}
|
||||
|
||||
QString SequenceWindow::apply_format(QString raw_number)
|
||||
QString SequenceWindow::apply_format(const QString& raw_number)
|
||||
{
|
||||
QString adjusted, reversed;
|
||||
QString format;
|
||||
int format_len, input_len, i, inpos;
|
||||
QChar format_qchar;
|
||||
|
||||
format = linFormat->text();
|
||||
format = linSeqFormat->text();
|
||||
input_len = raw_number.length();
|
||||
format_len = format.length();
|
||||
|
||||
inpos = input_len;
|
||||
|
||||
for(i = format_len; i > 0; i--) {
|
||||
for (i = format_len; i > 0; i--) {
|
||||
format_qchar = format[i - 1];
|
||||
char format_char = format_qchar.toLatin1();
|
||||
switch(format_char) {
|
||||
switch (format_char) {
|
||||
case '#':
|
||||
if (inpos > 0) {
|
||||
adjusted += raw_number[inpos - 1];
|
||||
|
@ -132,42 +135,41 @@ QString SequenceWindow::apply_format(QString raw_number)
|
|||
|
||||
void SequenceWindow::create_sequence()
|
||||
{
|
||||
QString startval, endval, incval, part, outputtext;
|
||||
QStringList outputtext;
|
||||
int start, stop, step, i;
|
||||
bool ok;
|
||||
|
||||
startval = linStartVal->text();
|
||||
endval = linEndVal->text();
|
||||
incval = linIncVal->text();
|
||||
start = startval.toInt(&ok, 10);
|
||||
stop = endval.toInt(&ok, 10);
|
||||
step = incval.toInt(&ok, 10);
|
||||
start = spnSeqStartVal->value();
|
||||
stop = spnSeqEndVal->value();
|
||||
step = spnSeqIncVal->value();
|
||||
|
||||
if((stop <= start) || (step <= 0)) {
|
||||
QMessageBox::critical(this, tr("Sequence Error"), tr("One or more of the input values is incorrect."));
|
||||
if (stop < start) {
|
||||
QMessageBox::critical(this, tr("Sequence Error"),
|
||||
tr("End Value must be greater than or equal to Start Value."));
|
||||
return;
|
||||
}
|
||||
if ((stop - start) / step > 10000) {
|
||||
QMessageBox::critical(this, tr("Sequence Error"), tr("The maximum sequence allowed is 10,000 items."));
|
||||
return;
|
||||
}
|
||||
|
||||
for(i = start; i <= stop; i += step) {
|
||||
part = apply_format(QString::number(i, 10));
|
||||
part += '\n';
|
||||
outputtext += part;
|
||||
for (i = start; i <= stop; i += step) {
|
||||
outputtext << apply_format(QString::number(i, 10));
|
||||
}
|
||||
|
||||
txtPreview->setPlainText(outputtext);
|
||||
txtSeqPreview->setPlainText(outputtext.join('\n'));
|
||||
}
|
||||
|
||||
void SequenceWindow::check_generate()
|
||||
{
|
||||
QString preview_copy;
|
||||
|
||||
preview_copy = txtPreview->toPlainText();
|
||||
if(preview_copy.isEmpty()) {
|
||||
btnExport->setEnabled(false);
|
||||
lblExport->setEnabled(false);
|
||||
preview_copy = txtSeqPreview->toPlainText();
|
||||
if (preview_copy.isEmpty()) {
|
||||
btnSeqExport->setEnabled(false);
|
||||
lblSeqExport->setEnabled(false);
|
||||
} else {
|
||||
btnExport->setEnabled(true);
|
||||
lblExport->setEnabled(true);
|
||||
btnSeqExport->setEnabled(true);
|
||||
lblSeqExport->setEnabled(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -182,8 +184,8 @@ void SequenceWindow::import()
|
|||
QFile file;
|
||||
QByteArray outstream;
|
||||
|
||||
import_dialog.setWindowTitle("Import File");
|
||||
import_dialog.setDirectory(settings.value("studio/default_dir",
|
||||
import_dialog.setWindowTitle(tr("Import File"));
|
||||
import_dialog.setDirectory(settings.value(QSL("studio/default_dir"),
|
||||
QDir::toNativeSeparators(QDir::homePath())).toString());
|
||||
|
||||
if (import_dialog.exec()) {
|
||||
|
@ -193,23 +195,21 @@ void SequenceWindow::import()
|
|||
}
|
||||
|
||||
file.setFileName(filename);
|
||||
if(!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
||||
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
||||
QMessageBox::critical(this, tr("Open Error"), tr("Could not open selected file."));
|
||||
return;
|
||||
}
|
||||
|
||||
outstream = file.readAll();
|
||||
|
||||
txtPreview->setPlainText(QString(outstream));
|
||||
txtSeqPreview->setPlainText(QString(outstream));
|
||||
file.close();
|
||||
|
||||
settings.setValue("studio/default_dir", filename.mid(0, filename.lastIndexOf(QDir::separator())));
|
||||
settings.setValue(QSL("studio/default_dir"), filename.mid(0, filename.lastIndexOf(QDir::separator())));
|
||||
}
|
||||
|
||||
void SequenceWindow::generate_sequence()
|
||||
{
|
||||
ExportWindow dlg;
|
||||
dlg.barcode = barcode;
|
||||
dlg.output_data = txtPreview->toPlainText();
|
||||
ExportWindow dlg(m_bc, txtSeqPreview->toPlainText());
|
||||
dlg.exec();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue