From 6393813cff1631b37718fce2ca3d0a1b7d016f7c Mon Sep 17 00:00:00 2001 From: gitlost Date: Thu, 24 Nov 2022 14:18:31 +0000 Subject: [PATCH] - cmake: remove zintconfig.h.in for now as incompatible with MSVC project builds (will add back in future if go fully CMake) - NO_PNG -> ZINT_NO_PNG and new API function `Zint_NoPng()` to determine if no PNG support in libzint; replace use in GUI with backend_qt method `noPng()` --- ChangeLog | 5 ++ backend/CMakeLists.txt | 4 +- backend/Makefile.mingw | 4 +- backend/library.c | 11 ++- backend/png.c | 4 +- backend/raster.c | 10 +-- backend/tests/CMakeLists.txt | 6 ++ backend/tests/test_print.c | 6 +- backend/tests/testcommon.c | 4 +- backend/zint.h | 6 +- backend/zintconfig.h | 3 +- backend/zintconfig.h.in | 42 ----------- backend_qt/backend_qt.pro | 2 +- backend_qt/backend_vc8.pro | 2 +- backend_qt/qzint.cpp | 4 + backend_qt/qzint.h | 3 + backend_tcl/configure | 2 +- backend_tcl/configure.in | 2 +- backend_tcl/zint_tcl.dsp | 4 +- docs/manual.pmd | 9 +++ docs/manual.txt | 7 ++ frontend/main.c | 2 +- frontend/tests/test_args.c | 12 +-- frontend_qt/exportwindow.cpp | 34 ++++----- frontend_qt/extExport.ui | 4 +- frontend_qt/frontend_qt.pro | 4 +- frontend_qt/mainwindow.cpp | 82 ++++++++++----------- frontend_qt/mainwindow.h | 4 +- win32/vs2015/libzint.vcxproj | 8 +- win32/vs2015/vsx/libzintMD.vcxproj | 2 +- win32/zint_cmdline_vc6/zint_cmdline_vc6.dsp | 2 +- 31 files changed, 138 insertions(+), 156 deletions(-) delete mode 100644 backend/zintconfig.h.in diff --git a/ChangeLog b/ChangeLog index 84263ac5..6883f6e6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -31,6 +31,11 @@ Changes - DPD: add top boundary (width 3X) by default, using new BARCODE_BIND_TOP; "relabel" option; some compliance checks - manual: fuller DPD doc; some spelling typos, formatting +- cmake: fixes for static build and install directories, props koprok +- cmake: remove zintconfig.h.in for now as incompatible with MSVC project builds + (will add back in future if go fully CMake) +- NO_PNG -> ZINT_NO_PNG and new API function `Zint_NoPng()` to determine if no + PNG support in libzint; replace use in GUI with backend_qt method `noPng()` Bugs ---- diff --git a/backend/CMakeLists.txt b/backend/CMakeLists.txt index 7a365f69..d779033f 100644 --- a/backend/CMakeLists.txt +++ b/backend/CMakeLists.txt @@ -4,8 +4,6 @@ project(zint) -configure_file(zintconfig.h.in ${CMAKE_CURRENT_SOURCE_DIR}/zintconfig.h) - set(zint_COMMON_SRCS common.c library.c large.c reedsol.c gs1.c eci.c general_field.c) set(zint_ONEDIM_SRCS bc412.c code.c code128.c 2of5.c upcean.c telepen.c medical.c plessey.c rss.c) set(zint_POSTAL_SRCS postal.c auspost.c imail.c mailmark.c) @@ -69,7 +67,7 @@ endif() if(ZINT_USE_PNG AND PNG_FOUND) zint_target_link_libraries(PNG::PNG) else() - zint_target_compile_definitions(PUBLIC NO_PNG) + zint_target_compile_definitions(PRIVATE ZINT_NO_PNG) endif() if(ZINT_TEST) diff --git a/backend/Makefile.mingw b/backend/Makefile.mingw index 246717de..a7b1c421 100644 --- a/backend/Makefile.mingw +++ b/backend/Makefile.mingw @@ -34,8 +34,8 @@ LIB_OBJ:= $(COMMON_OBJ) $(ONEDIM_OBJ) $(TWODIM_OBJ) $(POSTAL_OBJ) $(OUTPUT_OBJ) DLL_OBJ:= $(LIB_OBJ:.o=.lo) dllversion.lo -ifeq ($(NO_PNG),true) -DEFINES+= -DNO_PNG +ifeq ($(ZINT_NO_PNG),true) +DEFINES+= -DZINT_NO_PNG else DEFINES_DLL+= -DPNG_DLL -DZLIB_DLL LIBS+= -lpng -lz diff --git a/backend/library.c b/backend/library.c index 2ac74156..06e56bf2 100644 --- a/backend/library.c +++ b/backend/library.c @@ -61,7 +61,7 @@ struct zint_symbol *ZBarcode_Create(void) { symbol->fgcolor = &symbol->fgcolour[0]; strcpy(symbol->bgcolour, "ffffff"); symbol->bgcolor = &symbol->bgcolour[0]; -#ifdef NO_PNG +#ifdef ZINT_NO_PNG strcpy(symbol->outfile, "out.gif"); #else strcpy(symbol->outfile, "out.png"); @@ -1856,6 +1856,15 @@ unsigned int ZBarcode_Cap(int symbol_id, unsigned int cap_flag) { return result; } +/* Whether Zint built without PNG support */ +int ZBarcode_NoPng(void) { +#ifdef ZINT_NO_PNG + return 1; +#else + return 0; +#endif +} + /* Return the version of Zint linked to */ int ZBarcode_Version(void) { if (ZINT_VERSION_BUILD) { diff --git a/backend/png.c b/backend/png.c index 1334ec08..799bb967 100644 --- a/backend/png.c +++ b/backend/png.c @@ -30,7 +30,7 @@ */ /* SPDX-License-Identifier: BSD-3-Clause */ -#ifndef NO_PNG +#ifndef ZINT_NO_PNG #include #include @@ -348,4 +348,4 @@ INTERNAL int png_pixel_plot(struct zint_symbol *symbol, unsigned char *pixelbuf) /* https://stackoverflow.com/a/26541331 Suppresses gcc warning ISO C forbids an empty translation unit */ typedef int make_iso_compilers_happy; /* vim: set ts=4 sw=4 et : */ -#endif /* NO_PNG */ +#endif /* ZINT_NO_PNG */ diff --git a/backend/raster.c b/backend/raster.c index 17d902fc..ac893a21 100644 --- a/backend/raster.c +++ b/backend/raster.c @@ -49,9 +49,9 @@ #define UPCEAN_TEXT 1 -#ifndef NO_PNG +#ifndef ZINT_NO_PNG INTERNAL int png_pixel_plot(struct zint_symbol *symbol, unsigned char *pixelbuf); -#endif /* NO_PNG */ +#endif /* ZINT_NO_PNG */ INTERNAL int bmp_pixel_plot(struct zint_symbol *symbol, unsigned char *pixelbuf); INTERNAL int pcx_pixel_plot(struct zint_symbol *symbol, unsigned char *pixelbuf); INTERNAL int gif_pixel_plot(struct zint_symbol *symbol, unsigned char *pixelbuf); @@ -233,7 +233,7 @@ static int save_raster_image_to_file(struct zint_symbol *symbol, const int image } break; case OUT_PNG_FILE: -#ifndef NO_PNG +#ifndef ZINT_NO_PNG error_number = png_pixel_plot(symbol, rotated_pixbuf); #else if (rotate_angle) { @@ -1335,12 +1335,12 @@ static int plot_raster_default(struct zint_symbol *symbol, const int rotate_angl INTERNAL int plot_raster(struct zint_symbol *symbol, int rotate_angle, int file_type) { int error; -#ifdef NO_PNG +#ifdef ZINT_NO_PNG if (file_type == OUT_PNG_FILE) { strcpy(symbol->errtxt, "660: PNG format disabled at compile time"); return ZINT_ERROR_INVALID_OPTION; } -#endif /* NO_PNG */ +#endif /* ZINT_NO_PNG */ error = out_check_colour_options(symbol); if (error != 0) { diff --git a/backend/tests/CMakeLists.txt b/backend/tests/CMakeLists.txt index a1819c32..1ab1b02a 100644 --- a/backend/tests/CMakeLists.txt +++ b/backend/tests/CMakeLists.txt @@ -25,12 +25,18 @@ if(ZINT_SHARED) add_library(testcommon ${testcommon_SRCS}) target_link_libraries(testcommon zint) target_include_directories(testcommon PUBLIC ${zint_backend_tests_SOURCE_DIR}) + if(NOT (ZINT_USE_PNG AND PNG_FOUND)) + target_compile_definitions(testcommon PRIVATE ZINT_NO_PNG) + endif() endif() if(ZINT_STATIC) add_library(testcommon-static ${testcommon_SRCS}) target_link_libraries(testcommon-static zint-static) target_include_directories(testcommon-static PUBLIC ${zint_backend_tests_SOURCE_DIR}) + if(NOT (ZINT_USE_PNG AND PNG_FOUND)) + target_compile_definitions(testcommon-static PRIVATE ZINT_NO_PNG) + endif() endif() zint_add_test(2of5 test_2of5) diff --git a/backend/tests/test_print.c b/backend/tests/test_print.c index 980680e3..4a4cb839 100644 --- a/backend/tests/test_print.c +++ b/backend/tests/test_print.c @@ -102,9 +102,9 @@ static void test_print(const testCtx *const p_ctx) { } for (j = 0; j < exts_size; j++) { -#ifdef NO_PNG - if (strcmp(exts[j], "png") == 0) continue; -#endif + + if (ZBarcode_NoPng() && strcmp(exts[j], "png") == 0) continue; + assert_nonzero(sizeof(data_subdir) > strlen(data_dir) + 1 + strlen(exts[j]), "sizeof(data_subdir) (%d) <= strlen(data_dir) (%d) + 1 + strlen(%s) (%d)\n", (int) sizeof(data_subdir), (int) strlen(data_dir), exts[j], (int) strlen(exts[j])); diff --git a/backend/tests/testcommon.c b/backend/tests/testcommon.c index 9516bc3d..cc8cb7a1 100644 --- a/backend/tests/testcommon.c +++ b/backend/tests/testcommon.c @@ -38,7 +38,7 @@ #include #include #endif -#ifndef NO_PNG +#ifndef ZINT_NO_PNG #include #include #include @@ -1363,7 +1363,7 @@ int testUtilRename(const char *oldpath, const char *newpath) { /* Compare 2 PNG files */ int testUtilCmpPngs(const char *png1, const char *png2) { int ret = -1; -#ifdef NO_PNG +#ifdef ZINT_NO_PNG (void)png1; (void)png2; #else FILE *fp1; diff --git a/backend/zint.h b/backend/zint.h index 28ba5311..9818d4bb 100644 --- a/backend/zint.h +++ b/backend/zint.h @@ -102,7 +102,7 @@ extern "C" { char bgcolour[10]; /* Background as RGB/RGBA hexadecimal string, 6 or 8 characters, NUL-terminated */ char *fgcolor; /* Pointer to fgcolour (alternate spelling) */ char *bgcolor; /* Pointer to bgcolour (alternate spelling) */ - char outfile[256]; /* Name of file to output to, NUL-terminated. Default "out.png" ("out.gif" if NO_PNG) */ + char outfile[256]; /* Name of file to output to, NUL-terminated. Default "out.png" ("out.gif" if no PNG) */ char primary[128]; /* Primary message data (MaxiCode, Composite), NUL-terminated */ int option_1; /* Symbol-specific options (see "../docs/manual.txt") */ int option_2; /* Symbol-specific options */ @@ -442,6 +442,10 @@ extern "C" { /* Return the capability flags for symbology `symbol_id` that match `cap_flag` */ ZINT_EXTERN unsigned int ZBarcode_Cap(int symbol_id, unsigned int cap_flag); + + /* Whether Zint built without PNG support */ + ZINT_EXTERN int ZBarcode_NoPng(void); + /* Return the version of Zint linked to */ ZINT_EXTERN int ZBarcode_Version(void); diff --git a/backend/zintconfig.h b/backend/zintconfig.h index 493fcf49..b39a5177 100644 --- a/backend/zintconfig.h +++ b/backend/zintconfig.h @@ -1,4 +1,5 @@ -/* zintconfig.h - the configured options and settings for libzint, generated from "zintconfig.h.in" by CMake */ +/* zintconfig.h - the configured options and settings for libzint + NOTE: previously generated by CMake from "zintconfig.h.in", disabled for now */ /* libzint - the open source barcode library Copyright (C) 2021-2022 Robin Stuart diff --git a/backend/zintconfig.h.in b/backend/zintconfig.h.in deleted file mode 100644 index 3fd78c32..00000000 --- a/backend/zintconfig.h.in +++ /dev/null @@ -1,42 +0,0 @@ -/* zintconfig.h - the configured options and settings for libzint, generated from "zintconfig.h.in" by CMake */ -/* - libzint - the open source barcode library - Copyright (C) 2021-2022 Robin Stuart - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - 1. Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - 2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - 3. Neither the name of the project nor the names of its contributors - may be used to endorse or promote products derived from this software - without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE - FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - SUCH DAMAGE. - */ -/* SPDX-License-Identifier: BSD-3-Clause */ - -#ifndef ZINTCONFIG_H -#define ZINTCONFIG_H - -#define ZINT_VERSION_MAJOR @ZINT_VERSION_MAJOR@ -#define ZINT_VERSION_MINOR @ZINT_VERSION_MINOR@ -#define ZINT_VERSION_RELEASE @ZINT_VERSION_RELEASE@ -#define ZINT_VERSION_BUILD @ZINT_VERSION_BUILD@ - -/* vim: set ts=4 sw=4 et : */ -#endif /* ZINTCONFIG_H */ diff --git a/backend_qt/backend_qt.pro b/backend_qt/backend_qt.pro index 047f6214..e27c2e61 100644 --- a/backend_qt/backend_qt.pro +++ b/backend_qt/backend_qt.pro @@ -19,7 +19,7 @@ INCLUDEPATH += ../backend #EDIT THIS !!!! DEFINES += ZINT_VERSION="\\\"2.11.1.9\\\"" -!contains(DEFINES, NO_PNG) { +!contains(DEFINES, ZINT_NO_PNG) { INCLUDEPATH += ../../lpng INCLUDEPATH += ../../zlib } diff --git a/backend_qt/backend_vc8.pro b/backend_qt/backend_vc8.pro index 8950f12b..82514bdf 100644 --- a/backend_qt/backend_vc8.pro +++ b/backend_qt/backend_vc8.pro @@ -13,7 +13,7 @@ INCLUDEPATH += ../backend d:\\opt\\include DEFINES += _CRT_SECURE_NO_WARNINGS _CRT_NONSTDC_NO_WARNINGS ZINT_VERSION=\\\"$$VERSION\\\" include="" -!contains(DEFINES, NO_PNG) { +!contains(DEFINES, ZINT_NO_PNG) { SOURCES += ../backend/png.c } diff --git a/backend_qt/qzint.cpp b/backend_qt/qzint.cpp index 2eebc9b5..a870c09b 100644 --- a/backend_qt/qzint.cpp +++ b/backend_qt/qzint.cpp @@ -682,6 +682,10 @@ namespace Zint { return m_lastError.length(); } + bool QZint::noPng() const { + return ZBarcode_NoPng() == 1; + } + int QZint::getVersion() const { return ZBarcode_Version(); } diff --git a/backend_qt/qzint.h b/backend_qt/qzint.h index d57ab6a7..efe1fc78 100644 --- a/backend_qt/qzint.h +++ b/backend_qt/qzint.h @@ -196,6 +196,9 @@ public: /* Note: legacy argument `mode` is not used */ void render(QPainter& painter, const QRectF& paintRect, AspectRatioMode mode = IgnoreAspectRatio); + /* Whether Zint library "libzint" built with PNG support or not (`ZBarcode_NoPng()`) */ + bool noPng() const; + int getVersion() const; /* Translate settings into Command Line equivalent. Set `win` to use Windows escaping of data. diff --git a/backend_tcl/configure b/backend_tcl/configure index d16c862c..85deb0ae 100755 --- a/backend_tcl/configure +++ b/backend_tcl/configure @@ -6235,7 +6235,7 @@ fi - PKG_CFLAGS="$PKG_CFLAGS -I../backend -DNO_PNG=1 -DZINT_VERSION=PACKAGE_VERSION" + PKG_CFLAGS="$PKG_CFLAGS -I../backend -DZINT_NO_PNG=1 -DZINT_VERSION=PACKAGE_VERSION" diff --git a/backend_tcl/configure.in b/backend_tcl/configure.in index dc7ca4d7..89df5653 100644 --- a/backend_tcl/configure.in +++ b/backend_tcl/configure.in @@ -115,7 +115,7 @@ TEA_ADD_SOURCES([ ../backend/vector.c zint.c ]) -TEA_ADD_CFLAGS([-I../backend -DNO_PNG=1 -DZINT_VERSION=PACKAGE_VERSION]) +TEA_ADD_CFLAGS([-I../backend -DZINT_NO_PNG=1 -DZINT_VERSION=PACKAGE_VERSION]) TEA_ADD_STUB_SOURCES([]) TEA_ADD_TCL_SOURCES([demo/demo.tcl]) diff --git a/backend_tcl/zint_tcl.dsp b/backend_tcl/zint_tcl.dsp index 8faef640..4b946364 100644 --- a/backend_tcl/zint_tcl.dsp +++ b/backend_tcl/zint_tcl.dsp @@ -43,7 +43,7 @@ RSC=rc.exe # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "ZINT_TCL_EXPORTS" /YX /FD /c -# ADD CPP /nologo /MD /W3 /GX /O2 /I "..\backend" /I "C:\Tcl\include" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "ZINT_TCL_EXPORTS" /D "NO_PNG" /FR /YX /FD /D ZINT_VERSION="\"2.11.1.9\"" /c +# ADD CPP /nologo /MD /W3 /GX /O2 /I "..\backend" /I "C:\Tcl\include" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "ZINT_TCL_EXPORTS" /D "ZINT_NO_PNG" /FR /YX /FD /D ZINT_VERSION="\"2.11.1.9\"" /c # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD BASE RSC /l 0x407 /d "NDEBUG" @@ -70,7 +70,7 @@ LINK32=link.exe # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "ZINT_TCL_EXPORTS" /YX /FD /GZ /c -# ADD CPP /nologo /MD /W3 /Gm /GX /ZI /Od /I "..\backend" /I "C:\Tcl\include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "ZINT_TCL_EXPORTS" /D "NO_PNG" /FR /YX /FD /GZ /D ZINT_VERSION="\"2.11.1.9\"" /c +# ADD CPP /nologo /MD /W3 /Gm /GX /ZI /Od /I "..\backend" /I "C:\Tcl\include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "ZINT_TCL_EXPORTS" /D "ZINT_NO_PNG" /FR /YX /FD /GZ /D ZINT_VERSION="\"2.11.1.9\"" /c # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD BASE RSC /l 0x407 /d "_DEBUG" diff --git a/docs/manual.pmd b/docs/manual.pmd index 2113c68e..940fedd8 100644 --- a/docs/manual.pmd +++ b/docs/manual.pmd @@ -2248,6 +2248,15 @@ if (cap & ZINT_CAP_ECI) { ## 5.14 Zint Version +Whether the Zint library linked to was built with PNG support may be determined +with: + +```c +int ZBarcode_NoPng(); +``` + +which returns 1 if no PNG support is available, else zero. + Lastly, the version of the Zint library linked to is returned by: ```c diff --git a/docs/manual.txt b/docs/manual.txt index d45ef1e0..7cdcae7a 100644 --- a/docs/manual.txt +++ b/docs/manual.txt @@ -2241,6 +2241,13 @@ For example: 5.14 Zint Version +Whether the Zint library linked to was built with PNG support may be determined +with: + + int ZBarcode_NoPng(); + +which returns 1 if no PNG support is available, else zero. + Lastly, the version of the Zint library linked to is returned by: int ZBarcode_Version(); diff --git a/frontend/main.c b/frontend/main.c index 7592af23..3e86f7e8 100644 --- a/frontend/main.c +++ b/frontend/main.c @@ -1000,7 +1000,7 @@ int main(int argc, char **argv) { fprintf(stderr, "Error 151: Memory failure\n"); exit(ZINT_ERROR_MEMORY); } - no_png = strcmp(my_symbol->outfile, "out.gif") == 0; + no_png = ZBarcode_NoPng(); if (argc == 1) { ZBarcode_Delete(my_symbol); diff --git a/frontend/tests/test_args.c b/frontend/tests/test_args.c index fac56152..684a609e 100644 --- a/frontend/tests/test_args.c +++ b/frontend/tests/test_args.c @@ -1176,11 +1176,7 @@ static void test_other_opts(const testCtx *const p_ctx) { char cmd[4096]; char buf[8192]; -#ifdef NO_PNG - const char *outfilename = "out.gif"; -#else - const char *outfilename = "out.png"; -#endif + const char *outfilename = ZBarcode_NoPng() ? "out.gif" : "out.png"; testStart("test_other_opts"); @@ -1244,11 +1240,7 @@ static void test_exit_status(const testCtx *const p_ctx) { char cmd[4096]; char buf[8192]; -#ifdef NO_PNG - const char *outfilename = "out.gif"; -#else - const char *outfilename = "out.png"; -#endif + const char *outfilename = ZBarcode_NoPng() ? "out.gif" : "out.png"; testStart("test_exit_status"); diff --git a/frontend_qt/exportwindow.cpp b/frontend_qt/exportwindow.cpp index 8d145389..68760a3e 100644 --- a/frontend_qt/exportwindow.cpp +++ b/frontend_qt/exportwindow.cpp @@ -34,6 +34,11 @@ ExportWindow::ExportWindow(BarcodeItem *bc, const QString& output_data) : m_bc(bc), m_output_data(output_data), m_lines(0) { setupUi(this); + + if (m_bc->bc.noPng()) { + cmbFileType->removeItem(0); // PNG + } + QSettings settings; #if QT_VERSION < 0x60000 settings.setIniCodec("UTF-8"); @@ -47,7 +52,8 @@ ExportWindow::ExportWindow(BarcodeItem *bc, const QString& output_data) linPrefix->setText(settings.value(QSL("studio/export/file_prefix"), QSL("bcs_")).toString()); linPostfix->setText(settings.value(QSL("studio/export/file_postfix"), QSL("")).toString()); cmbFileName->setCurrentIndex(settings.value(QSL("studio/export/name_format"), 0).toInt()); - cmbFileFormat->setCurrentIndex(settings.value(QSL("studio/export/filetype"), 0).toInt()); + cmbFileType->setCurrentIndex(std::min(settings.value(QSL("studio/export/filetype"), 0).toInt(), + cmbFileType->count() - 1)); QIcon closeIcon(QIcon::fromTheme(QSL("window-close"), QIcon(QSL(":res/x.svg")))); btnCancel->setIcon(closeIcon); @@ -77,7 +83,7 @@ ExportWindow::~ExportWindow() settings.setValue(QSL("studio/export/file_prefix"), linPrefix->text()); settings.setValue(QSL("studio/export/file_postfix"), linPostfix->text()); settings.setValue(QSL("studio/export/name_format"), cmbFileName->currentIndex()); - settings.setValue(QSL("studio/export/filetype"), cmbFileFormat->currentIndex()); + settings.setValue(QSL("studio/export/filetype"), cmbFileType->currentIndex()); } void ExportWindow::get_directory() @@ -122,25 +128,11 @@ void ExportWindow::process() } QString suffix; - switch (cmbFileFormat->currentIndex()) { -#ifdef NO_PNG - case 0: suffix = QSL(".eps"); break; - case 1: suffix = QSL(".gif"); break; - case 2: suffix = QSL(".svg"); break; - case 3: suffix = QSL(".bmp"); break; - case 4: suffix = QSL(".pcx"); break; - case 5: suffix = QSL(".emf"); break; - case 6: suffix = QSL(".tif"); break; -#else - case 0: suffix = QSL(".png"); break; - case 1: suffix = QSL(".eps"); break; - case 2: suffix = QSL(".gif"); break; - case 3: suffix = QSL(".svg"); break; - case 4: suffix = QSL(".bmp"); break; - case 5: suffix = QSL(".pcx"); break; - case 6: suffix = QSL(".emf"); break; - case 7: suffix = QSL(".tif"); break; -#endif + int suffixIdx = cmbFileType->currentText().lastIndexOf(QSL("(*.")); + if (suffixIdx == -1) { + suffix = m_bc->bc.noPng() ? QSL(".gif") : QSL(".png"); + } else { + suffix = cmbFileType->currentText().mid(suffixIdx + 2, 4); } QString filePathPrefix = linDestPath->text() % QDir::separator() % linPrefix->text(); diff --git a/frontend_qt/extExport.ui b/frontend_qt/extExport.ui index 430270dc..31b2bbf9 100644 --- a/frontend_qt/extExport.ui +++ b/frontend_qt/extExport.ui @@ -143,12 +143,12 @@ The type of file which you want to create - cmbFileFormat + cmbFileType - + The type of file which you want to create diff --git a/frontend_qt/frontend_qt.pro b/frontend_qt/frontend_qt.pro index aae1a84a..94c583bd 100644 --- a/frontend_qt/frontend_qt.pro +++ b/frontend_qt/frontend_qt.pro @@ -4,7 +4,7 @@ DEPENDPATH += . debug release INCLUDEPATH += . INCLUDEPATH += ../backend INCLUDEPATH += ../backend_qt -!contains(DEFINES, NO_PNG) { +!contains(DEFINES, ZINT_NO_PNG) { INCLUDEPATH += ../../lpng INCLUDEPATH += ../../zlib } @@ -82,7 +82,7 @@ QMAKE_LIBDIR += ../backend_qt/release LIBS += -lQt5Core QMAKE_LIBDIR += C:/qt/5.15.2static/lib -!contains(DEFINES, NO_PNG) { +!contains(DEFINES, ZINT_NO_PNG) { # Win win32:LIBS += -llibpng16 -lzlib win32:QMAKE_LIBDIR+="../../lpng/projects/vstudio/Release Library" diff --git a/frontend_qt/mainwindow.cpp b/frontend_qt/mainwindow.cpp index 36a6b03b..b5ab1750 100644 --- a/frontend_qt/mainwindow.cpp +++ b/frontend_qt/mainwindow.cpp @@ -50,9 +50,7 @@ static const QKeySequence openCLISeq(Qt::SHIFT | Qt::CTRL | Qt::Key_C); static const QKeySequence copyBMPSeq(Qt::SHIFT | Qt::CTRL | Qt::Key_B); static const QKeySequence copyEMFSeq(Qt::SHIFT | Qt::CTRL | Qt::Key_E); static const QKeySequence copyGIFSeq(Qt::SHIFT | Qt::CTRL | Qt::Key_G); -#ifndef NO_PNG static const QKeySequence copyPNGSeq(Qt::SHIFT | Qt::CTRL | Qt::Key_P); -#endif static const QKeySequence copySVGSeq(Qt::SHIFT | Qt::CTRL | Qt::Key_S); static const QKeySequence copyTIFSeq(Qt::SHIFT | Qt::CTRL | Qt::Key_T); @@ -355,10 +353,10 @@ MainWindow::MainWindow(QWidget *parent, Qt::WindowFlags fl) connect(m_copyEMFShortcut, SIGNAL(activated()), SLOT(copy_to_clipboard_emf())); m_copyGIFShortcut = new QShortcut(copyGIFSeq, this); connect(m_copyGIFShortcut, SIGNAL(activated()), SLOT(copy_to_clipboard_gif())); -#ifndef NO_PNG - m_copyPNGShortcut = new QShortcut(copyPNGSeq, this); - connect(m_copyPNGShortcut, SIGNAL(activated()), SLOT(copy_to_clipboard_png())); -#endif + if (!m_bc.bc.noPng()) { + m_copyPNGShortcut = new QShortcut(copyPNGSeq, this); + connect(m_copyPNGShortcut, SIGNAL(activated()), SLOT(copy_to_clipboard_png())); + } m_copySVGShortcut = new QShortcut(copySVGSeq, this); connect(m_copySVGShortcut, SIGNAL(activated()), SLOT(copy_to_clipboard_svg())); m_copyTIFShortcut = new QShortcut(copyTIFSeq, this); @@ -594,20 +592,20 @@ bool MainWindow::save() QDir::toNativeSeparators(QDir::homePath())).toString()); suffixes << QSL("eps") << QSL("gif") << QSL("svg") << QSL("bmp") << QSL("pcx") << QSL("emf") << QSL("tif"); -#ifdef NO_PNG - suffix = settings.value(QSL("studio/default_suffix"), QSL("gif")).toString(); - save_dialog.setNameFilter(tr( - "Encapsulated PostScript (*.eps);;Graphics Interchange Format (*.gif)" - ";;Scalable Vector Graphic (*.svg);;Windows Bitmap (*.bmp);;ZSoft PC Painter Image (*.pcx)" - ";;Enhanced Metafile (*.emf);;Tagged Image File Format (*.tif)")); -#else - suffix = settings.value(QSL("studio/default_suffix"), QSL("png")).toString(); - save_dialog.setNameFilter(tr( - "Portable Network Graphic (*.png);;Encapsulated PostScript (*.eps);;Graphics Interchange Format (*.gif)" - ";;Scalable Vector Graphic (*.svg);;Windows Bitmap (*.bmp);;ZSoft PC Painter Image (*.pcx)" - ";;Enhanced Metafile (*.emf);;Tagged Image File Format (*.tif)")); - suffixes << QSL("png"); -#endif + if (m_bc.bc.noPng()) { + suffix = settings.value(QSL("studio/default_suffix"), QSL("gif")).toString(); + save_dialog.setNameFilter(tr( + "Encapsulated PostScript (*.eps);;Graphics Interchange Format (*.gif)" + ";;Scalable Vector Graphic (*.svg);;Windows Bitmap (*.bmp);;ZSoft PC Painter Image (*.pcx)" + ";;Enhanced Metafile (*.emf);;Tagged Image File Format (*.tif)")); + } else { + suffix = settings.value(QSL("studio/default_suffix"), QSL("png")).toString(); + save_dialog.setNameFilter(tr( + "Portable Network Graphic (*.png);;Encapsulated PostScript (*.eps);;Graphics Interchange Format (*.gif)" + ";;Scalable Vector Graphic (*.svg);;Windows Bitmap (*.bmp);;ZSoft PC Painter Image (*.pcx)" + ";;Enhanced Metafile (*.emf);;Tagged Image File Format (*.tif)")); + suffixes << QSL("png"); + } if (QString::compare(suffix, QSL("png"), Qt::CaseInsensitive) == 0) save_dialog.selectNameFilter(tr("Portable Network Graphic (*.png)")); @@ -1290,14 +1288,12 @@ void MainWindow::copy_to_clipboard_pcx() copy_to_clipboard(QSL(".zint.pcx"), QSL("PCX"), "image/x-pcx"); } -#ifndef NO_PNG void MainWindow::copy_to_clipboard_png() { - copy_to_clipboard(QSL(".zint.png"), QSL("PNG")); + if (!m_bc.bc.noPng()) { + copy_to_clipboard(QSL(".zint.png"), QSL("PNG")); + } } -#else -void MainWindow::copy_to_clipboard_png() {} // Workaround Qt not parsing #ifndef NO_PNG in slots -#endif void MainWindow::copy_to_clipboard_svg() { @@ -1394,9 +1390,9 @@ void MainWindow::view_context_menu(const QPoint &pos) #ifdef MAINWINDOW_COPY_PCX menu.addAction(m_copyPCXAct); #endif -#ifndef NO_PNG - menu.addAction(m_copyPNGAct); -#endif + if (!m_bc.bc.noPng()) { + menu.addAction(m_copyPNGAct); + } menu.addAction(m_copySVGAct); menu.addAction(m_copyTIFAct); menu.addSeparator(); @@ -2984,12 +2980,12 @@ void MainWindow::createActions() connect(m_copyPCXAct, SIGNAL(triggered()), this, SLOT(copy_to_clipboard_pcx())); #endif -#ifndef NO_PNG - m_copyPNGAct = new QAction(copyIcon, tr("Copy as &PNG"), this); - m_copyPNGAct->setStatusTip(tr("Copy to clipboard as PNG")); - m_copyPNGAct->setShortcut(copyPNGSeq); - connect(m_copyPNGAct, SIGNAL(triggered()), this, SLOT(copy_to_clipboard_png())); -#endif + if (!m_bc.bc.noPng()) { + m_copyPNGAct = new QAction(copyIcon, tr("Copy as &PNG"), this); + m_copyPNGAct->setStatusTip(tr("Copy to clipboard as PNG")); + m_copyPNGAct->setShortcut(copyPNGSeq); + connect(m_copyPNGAct, SIGNAL(triggered()), this, SLOT(copy_to_clipboard_png())); + } m_copySVGAct = new QAction(copyIcon, tr("Copy as S&VG"), this); m_copySVGAct->setStatusTip(tr("Copy to clipboard as SVG")); @@ -3048,9 +3044,9 @@ void MainWindow::createMenu() #ifdef MAINWINDOW_COPY_PCX m_menu->addAction(m_copyPCXAct); #endif -#ifndef NO_PNG - m_menu->addAction(m_copyPNGAct); -#endif + if (!m_bc.bc.noPng()) { + m_menu->addAction(m_copyPNGAct); + } m_menu->addAction(m_copySVGAct); m_menu->addAction(m_copyTIFAct); m_menu->addSeparator(); @@ -3083,9 +3079,9 @@ void MainWindow::enableActions() #ifdef MAINWINDOW_COPY_PCX m_copyPCXAct->setEnabled(enabled); #endif -#ifndef NO_PNG - m_copyPNGAct->setEnabled(enabled); -#endif + if (!m_bc.bc.noPng()) { + m_copyPNGAct->setEnabled(enabled); + } m_copySVGAct->setEnabled(enabled); m_copyTIFAct->setEnabled(enabled); m_openCLIAct->setEnabled(enabled); @@ -3096,9 +3092,9 @@ void MainWindow::enableActions() m_copyBMPShortcut->setEnabled(enabled); m_copyEMFShortcut->setEnabled(enabled); m_copyGIFShortcut->setEnabled(enabled); -#ifndef NO_PNG - m_copyPNGShortcut->setEnabled(enabled); -#endif + if (!m_bc.bc.noPng()) { + m_copyPNGShortcut->setEnabled(enabled); + } m_copySVGShortcut->setEnabled(enabled); m_copyTIFShortcut->setEnabled(enabled); } diff --git a/frontend_qt/mainwindow.h b/frontend_qt/mainwindow.h index 1f2e48ca..84b99ad9 100644 --- a/frontend_qt/mainwindow.h +++ b/frontend_qt/mainwindow.h @@ -102,7 +102,7 @@ public slots: void copy_to_clipboard_emf(); void copy_to_clipboard_eps(); void copy_to_clipboard_gif(); - void copy_to_clipboard_png(); // Note Qt can't handle #ifndef NO_PNG in slots + void copy_to_clipboard_png(); void copy_to_clipboard_pcx(); void copy_to_clipboard_svg(); void copy_to_clipboard_tif(); @@ -201,9 +201,7 @@ private: QShortcut *m_copyBMPShortcut; QShortcut *m_copyEMFShortcut; QShortcut *m_copyGIFShortcut; -#ifndef NO_PNG QShortcut *m_copyPNGShortcut; -#endif QShortcut *m_copySVGShortcut; QShortcut *m_copyTIFShortcut; QAction *m_copyBMPAct; diff --git a/win32/vs2015/libzint.vcxproj b/win32/vs2015/libzint.vcxproj index 1caf9aa1..354bbd4d 100644 --- a/win32/vs2015/libzint.vcxproj +++ b/win32/vs2015/libzint.vcxproj @@ -117,7 +117,7 @@ Disabled ..\..\..\zlib\;..\..\..\lpng\;..\..\..\lpng\build;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_WINDOWS;_USRDLL;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_WARNINGS;ZINT_VERSION="2.11.1.9";NO_PNG;BUILD_ZINT_DLL;ZLIB_DLL;PNG_DLL;DEBUG;%(PreprocessorDefinitions) + WIN32;_DEBUG;_WINDOWS;_USRDLL;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_WARNINGS;ZINT_VERSION="2.11.1.9";ZINT_NO_PNG;BUILD_ZINT_DLL;ZLIB_DLL;PNG_DLL;DEBUG;%(PreprocessorDefinitions) true EnableFastChecks @@ -149,7 +149,7 @@ Disabled ..\..\..\zlib\;..\..\..\lpng\;..\..\..\lpng\build;%(AdditionalIncludeDirectories) - NO_PNG;WIN32;_DEBUG;_WINDOWS;_USRDLL;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_WARNINGS;ZINT_VERSION="2.11.1.9";BUILD_ZINT_DLL;ZLIB_DLL;PNG_DLL;DEBUG;%(PreprocessorDefinitions) + ZINT_NO_PNG;WIN32;_DEBUG;_WINDOWS;_USRDLL;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_WARNINGS;ZINT_VERSION="2.11.1.9";BUILD_ZINT_DLL;ZLIB_DLL;PNG_DLL;DEBUG;%(PreprocessorDefinitions) EnableFastChecks @@ -182,7 +182,7 @@ MaxSpeed false ..\..\..\zlib\;..\..\..\lpng\;..\..\..\lpng\build;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_WINDOWS;_USRDLL;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_WARNINGS;ZINT_VERSION="2.11.1.9";BUILD_ZINT_DLL;ZLIB_DLL;PNG_DLL;NO_PNG;%(PreprocessorDefinitions) + WIN32;NDEBUG;_WINDOWS;_USRDLL;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_WARNINGS;ZINT_VERSION="2.11.1.9";BUILD_ZINT_DLL;ZLIB_DLL;PNG_DLL;ZINT_NO_PNG;%(PreprocessorDefinitions) true MultiThreadedDLL @@ -215,7 +215,7 @@ MaxSpeed false ..\..\..\zlib\;..\..\..\lpng\;..\..\..\lpng\build;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_WINDOWS;_USRDLL;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_WARNINGS;ZINT_VERSION="2.11.1.9";BUILD_ZINT_DLL;NO_PNG;ZLIB_DLL;PNG_DLL;%(PreprocessorDefinitions) + WIN32;NDEBUG;_WINDOWS;_USRDLL;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_WARNINGS;ZINT_VERSION="2.11.1.9";BUILD_ZINT_DLL;ZINT_NO_PNG;ZLIB_DLL;PNG_DLL;%(PreprocessorDefinitions) true diff --git a/win32/vs2015/vsx/libzintMD.vcxproj b/win32/vs2015/vsx/libzintMD.vcxproj index ad4692d1..383c4885 100644 --- a/win32/vs2015/vsx/libzintMD.vcxproj +++ b/win32/vs2015/vsx/libzintMD.vcxproj @@ -39,7 +39,7 @@ MaxSpeed true d:\opt1\include;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_LIB;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_WARNINGS;ZINT_VERSION="2.11.1.9";NO_PNG;%(PreprocessorDefinitions) + WIN32;NDEBUG;_LIB;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_WARNINGS;ZINT_VERSION="2.11.1.9";ZINT_NO_PNG;%(PreprocessorDefinitions) true diff --git a/win32/zint_cmdline_vc6/zint_cmdline_vc6.dsp b/win32/zint_cmdline_vc6/zint_cmdline_vc6.dsp index 3dc7b830..52261345 100644 --- a/win32/zint_cmdline_vc6/zint_cmdline_vc6.dsp +++ b/win32/zint_cmdline_vc6/zint_cmdline_vc6.dsp @@ -66,7 +66,7 @@ LINK32=link.exe # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c -# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "..\..\backend" /I "..\..\..\lpng" /I "..\..\..\zlib" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D "NO_PNG" /D "DEBUG" /YX /FD /GZ /D ZINT_VERSION="\"2.11.1.9\"" /c +# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "..\..\backend" /I "..\..\..\lpng" /I "..\..\..\zlib" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D "ZINT_NO_PNG" /D "DEBUG" /YX /FD /GZ /D ZINT_VERSION="\"2.11.1.9\"" /c # ADD BASE RSC /l 0x407 /d "_DEBUG" # ADD RSC /l 0x407 /d "_DEBUG" BSC32=bscmake.exe