Remove DMatrix option bug in UI

Do not change value of option3 if user has selected a Data Matrix symbol size.
If a warning is generated when saving, make this visible to user.
Fixes #85 reported by Harald Oehlmann
This commit is contained in:
Robin Stuart 2017-12-19 22:01:45 +00:00
parent 9f50714b44
commit c55340f4f3
3 changed files with 33 additions and 14 deletions

View File

@ -220,6 +220,10 @@ namespace Zint {
void QZint::setSecurityLevel(int securityLevel) { void QZint::setSecurityLevel(int securityLevel) {
m_securityLevel = securityLevel; m_securityLevel = securityLevel;
} }
int QZint::getError() {
return m_error;
}
QString QZint::error_message() const { QString QZint::error_message() const {
return m_lastError; return m_lastError;
@ -275,14 +279,12 @@ namespace Zint {
QByteArray bgcol = bg_colour_hash.right(6).toLatin1(); QByteArray bgcol = bg_colour_hash.right(6).toLatin1();
strcpy(m_zintSymbol->fgcolour, fgcol.data()); strcpy(m_zintSymbol->fgcolour, fgcol.data());
strcpy(m_zintSymbol->bgcolour, bgcol.data()); strcpy(m_zintSymbol->bgcolour, bgcol.data());
int error = ZBarcode_Encode_and_Print(m_zintSymbol, (unsigned char*) bstr.data(), bstr.length(), 0); m_error = ZBarcode_Encode_and_Print(m_zintSymbol, (unsigned char*) bstr.data(), bstr.length(), 0);
if (error > ZINT_WARN_INVALID_OPTION) { if (m_error != 0) {
m_lastError = m_zintSymbol->errtxt; m_lastError = m_zintSymbol->errtxt;
}
if (error == 0) {
return true;
} else {
return false; return false;
} else {
return true;
} }
} }

View File

@ -70,6 +70,8 @@ public:
int securityLevel() const; int securityLevel() const;
void setSecurityLevel(int securityLevel); void setSecurityLevel(int securityLevel);
int getError();
float scale() const; float scale() const;
void setScale(float scale); void setScale(float scale);

View File

@ -247,8 +247,13 @@ bool MainWindow::save()
} }
if(m_bc.bc.save_to_file(filename) == false) { if(m_bc.bc.save_to_file(filename) == false) {
if (m_bc.bc.getError() > 4) {
QMessageBox::critical(this,tr("Save Error"),m_bc.bc.error_message()); QMessageBox::critical(this,tr("Save Error"),m_bc.bc.error_message());
return false; return false;
} else {
QMessageBox::warning(this, tr("Save Warning"),m_bc.bc.error_message());
return true;
}
} }
settings.setValue("studio/default_dir", filename.mid(0, filename.lastIndexOf(QDir::separator()))); settings.setValue("studio/default_dir", filename.mid(0, filename.lastIndexOf(QDir::separator())));
@ -920,14 +925,24 @@ void MainWindow::update_preview()
m_bc.bc.setInputMode(GS1_MODE); m_bc.bc.setInputMode(GS1_MODE);
m_bc.bc.setWidth(m_optionWidget->findChild<QComboBox*>("cmbDM200Size")->currentIndex()); m_bc.bc.setWidth(m_optionWidget->findChild<QComboBox*>("cmbDM200Size")->currentIndex());
if(m_optionWidget->findChild<QCheckBox*>("chkDMRectangle")->isChecked())
m_bc.bc.setOption3(DM_SQUARE); if (m_optionWidget->findChild<QComboBox*>("cmbDM200Size")->currentIndex() == 0) {
else { // Supressing rectangles or allowing DMRE only makes sense if in automatic size mode
if(m_optionWidget->findChild<QCheckBox*>("chkDMRE")->isChecked()) findChild<QCheckBox*>("chkDMRectangle")->setEnabled(true);
m_bc.bc.setOption3(DM_DMRE); findChild<QCheckBox*>("chkDMRE")->setEnabled(true);
else if(m_optionWidget->findChild<QCheckBox*>("chkDMRectangle")->isChecked())
m_bc.bc.setOption3(0); m_bc.bc.setOption3(DM_SQUARE);
} else {
if(m_optionWidget->findChild<QCheckBox*>("chkDMRE")->isChecked())
m_bc.bc.setOption3(DM_DMRE);
else
m_bc.bc.setOption3(0);
}
} else {
findChild<QCheckBox*>("chkDMRectangle")->setEnabled(false);
findChild<QCheckBox*>("chkDMRE")->setEnabled(false);
m_bc.bc.setOption3(0);
}
break; break;
case BARCODE_QRCODE: case BARCODE_QRCODE: