diff --git a/backend_qt/qzint.cpp b/backend_qt/qzint.cpp index cd2b8637..ee12d6b3 100644 --- a/backend_qt/qzint.cpp +++ b/backend_qt/qzint.cpp @@ -220,6 +220,10 @@ namespace Zint { void QZint::setSecurityLevel(int securityLevel) { m_securityLevel = securityLevel; } + + int QZint::getError() { + return m_error; + } QString QZint::error_message() const { return m_lastError; @@ -275,14 +279,12 @@ namespace Zint { QByteArray bgcol = bg_colour_hash.right(6).toLatin1(); strcpy(m_zintSymbol->fgcolour, fgcol.data()); strcpy(m_zintSymbol->bgcolour, bgcol.data()); - int error = ZBarcode_Encode_and_Print(m_zintSymbol, (unsigned char*) bstr.data(), bstr.length(), 0); - if (error > ZINT_WARN_INVALID_OPTION) { + m_error = ZBarcode_Encode_and_Print(m_zintSymbol, (unsigned char*) bstr.data(), bstr.length(), 0); + if (m_error != 0) { m_lastError = m_zintSymbol->errtxt; - } - if (error == 0) { - return true; - } else { return false; + } else { + return true; } } diff --git a/backend_qt/qzint.h b/backend_qt/qzint.h index 48331a8d..ec154f35 100644 --- a/backend_qt/qzint.h +++ b/backend_qt/qzint.h @@ -70,6 +70,8 @@ public: int securityLevel() const; void setSecurityLevel(int securityLevel); + + int getError(); float scale() const; void setScale(float scale); diff --git a/frontend_qt/mainwindow.cpp b/frontend_qt/mainwindow.cpp index ace69705..60c34beb 100644 --- a/frontend_qt/mainwindow.cpp +++ b/frontend_qt/mainwindow.cpp @@ -247,8 +247,13 @@ bool MainWindow::save() } 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()); 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()))); @@ -920,14 +925,24 @@ void MainWindow::update_preview() m_bc.bc.setInputMode(GS1_MODE); m_bc.bc.setWidth(m_optionWidget->findChild("cmbDM200Size")->currentIndex()); - if(m_optionWidget->findChild("chkDMRectangle")->isChecked()) - m_bc.bc.setOption3(DM_SQUARE); - else { - if(m_optionWidget->findChild("chkDMRE")->isChecked()) - m_bc.bc.setOption3(DM_DMRE); - else - m_bc.bc.setOption3(0); - } + + if (m_optionWidget->findChild("cmbDM200Size")->currentIndex() == 0) { + // Supressing rectangles or allowing DMRE only makes sense if in automatic size mode + findChild("chkDMRectangle")->setEnabled(true); + findChild("chkDMRE")->setEnabled(true); + if(m_optionWidget->findChild("chkDMRectangle")->isChecked()) + m_bc.bc.setOption3(DM_SQUARE); + else { + if(m_optionWidget->findChild("chkDMRE")->isChecked()) + m_bc.bc.setOption3(DM_DMRE); + else + m_bc.bc.setOption3(0); + } + } else { + findChild("chkDMRectangle")->setEnabled(false); + findChild("chkDMRE")->setEnabled(false); + m_bc.bc.setOption3(0); + } break; case BARCODE_QRCODE: