From 6abced6ab7ef308a8eb446508d7cd1db6c58011c Mon Sep 17 00:00:00 2001 From: Alexander Trufanov Date: Tue, 24 Dec 2019 18:20:52 +0300 Subject: [PATCH] Fix Qt 5.5 compat. as req. by MacOs distr --- ExportDialog.cpp | 25 ++++++++++++++++++++++++- FileNameDisambiguator.h | 7 +++++-- MainWindow.cpp | 5 +++++ OutputFileNameGenerator.cpp | 14 ++++++++------ packaging/osx/buildscantailor.sh | 2 +- 5 files changed, 43 insertions(+), 10 deletions(-) diff --git a/ExportDialog.cpp b/ExportDialog.cpp index 1ead83dc6..af7c1fcc0 100755 --- a/ExportDialog.cpp +++ b/ExportDialog.cpp @@ -241,9 +241,23 @@ ExportDialog::startExport(void) settings.generate_blank_back_subscans = ui.GenerateBlankBackSubscans->isChecked(); settings.use_sep_suffix_for_pics = ui.UseSepSuffixForPics->isChecked(); settings.page_gen_tweaks = PageGenTweak::NoTweaks; +#ifdef TARGET_OS_MAC + // for compatibility with Qt 5.5 + if (ui.KeepOriginalColorIllumForeSubscans->isChecked()) { + settings.page_gen_tweaks |= PageGenTweak::KeepOriginalColorIllumForeSubscans; + } else { + settings.page_gen_tweaks &= !PageGenTweak::KeepOriginalColorIllumForeSubscans; + } + + if (mode.testFlag(ExportMode::ImageWithoutOutputStage)) { + settings.page_gen_tweaks |= PageGenTweak::IgnoreOutputProcessingStage; + } else { + settings.page_gen_tweaks &= !PageGenTweak::IgnoreOutputProcessingStage; + } +#else settings.page_gen_tweaks.setFlag(PageGenTweak::KeepOriginalColorIllumForeSubscans, ui.KeepOriginalColorIllumForeSubscans->isChecked()); settings.page_gen_tweaks.setFlag(PageGenTweak::IgnoreOutputProcessingStage, mode.testFlag(ExportMode::ImageWithoutOutputStage)); - +#endif settings.export_selected_pages_only = ui.cbExportSelected->isChecked(); @@ -301,7 +315,16 @@ void ExportDialog::saveExportMode(ExportMode val, bool on) { ExportModes mode = (ExportModes) m_settings.value(_key_export_split_mixed_settings, ExportMode::Foreground | ExportMode::Background).toInt(); +#ifdef TARGET_OS_MAC + // for compatibility with Qt 5.5 + if (on) { + mode |= val; + } else { + mode &= !val; + } +#else mode.setFlag(val, on); +#endif m_settings.setValue(_key_export_split_mixed_settings, (int) mode); } diff --git a/FileNameDisambiguator.h b/FileNameDisambiguator.h index 8b3356493..7dd1350c7 100644 --- a/FileNameDisambiguator.h +++ b/FileNameDisambiguator.h @@ -85,8 +85,11 @@ class FileNameDisambiguator : public RefCountable void performRelinking(AbstractRelinker const& relinker); private: class Impl; - - std::unique_ptr m_ptrImpl; +#ifdef TARGET_OS_MAC + std::auto_ptr m_ptrImpl; +#else + std::unique_ptr m_ptrImpl; +#endif }; #endif diff --git a/MainWindow.cpp b/MainWindow.cpp index cc1599469..0d04c806c 100644 --- a/MainWindow.cpp +++ b/MainWindow.cpp @@ -2053,8 +2053,13 @@ void MainWindow::exportDialogClosed(QObject*) { // switching off export mode +#ifdef TARGET_OS_MAC + // for compatibility with Qt 5.5 + m_export_settings.page_gen_tweaks &= !(ExportDialog::PageGenTweak::KeepOriginalColorIllumForeSubscans | ExportDialog::PageGenTweak::IgnoreOutputProcessingStage); +#else m_export_settings.page_gen_tweaks.setFlag(ExportDialog::PageGenTweak::KeepOriginalColorIllumForeSubscans, false); m_export_settings.page_gen_tweaks.setFlag(ExportDialog::PageGenTweak::IgnoreOutputProcessingStage, false); +#endif } void initSplitImage(const QImage& source_img, QImage& target_img, QImage::Format format, bool grayscale_allowed) diff --git a/OutputFileNameGenerator.cpp b/OutputFileNameGenerator.cpp index 412e351fe..579f616c2 100644 --- a/OutputFileNameGenerator.cpp +++ b/OutputFileNameGenerator.cpp @@ -137,17 +137,19 @@ OutputFileNameGenerator::suggestOverridenFileName(QStringList const& insert_to_f } else { // empty page filename should be the first one in alphabetical order among all output filenames // we shall find a new filename for it - const QString old_name = insert_to_filenames.first(); + const QString& old_name = insert_to_filenames.first(); + const QString alph_start = alph[0]; + const QChar& alph_end = alph[alph.size()-1]; QString new_name = old_name; - while (new_name != QStringLiteral("&")) { - QChar char_to_test = *new_name.rbegin(); - if (char_to_test > *alph.rbegin()) { - char_to_test = *alph.rbegin(); + while (!new_name.isEmpty() && new_name != alph_start) { + QChar char_to_test = new_name[new_name.size()-1]; + if (char_to_test > alph_end) { + char_to_test = alph_end; } int i = alph.indexOf(char_to_test); if (i <= 0) { - new_name = new_name.right(new_name.size()-1); + new_name.chop(1); continue; } char_to_test = alph[i-1]; diff --git a/packaging/osx/buildscantailor.sh b/packaging/osx/buildscantailor.sh index d5f1e8dc3..f9c405c84 100755 --- a/packaging/osx/buildscantailor.sh +++ b/packaging/osx/buildscantailor.sh @@ -95,7 +95,7 @@ cd $STSRC # needed in case scantailor source is not updated to compile with new boost (>=1_34) test infrastructure #[ ! -f $STSRC/imageproc/tests/main.cpp.old ] && sed -i '.old' -e '1,$ s%^#include %#include %g' $STSRC/imageproc/tests/main.cpp # hardcoded in cpp now [truf] #[ ! -f $STSRC/tests/main.cpp.old ] && sed -i '.old' -e '1,$ s%^#include %#include %g' $STSRC/tests/main.cpp #hardcoded in cpp now [truf] -[ ! -f CMakeCache.txt ] && cmake -DCMAKE_FIND_FRAMEWORK=LAST -DCMAKE_OSX_ARCHITECTURES=x86_64 -DCMAKE_OSX_DEPLOYMENT_TARGET=$MACOSX_DEPLOYMENT_TARGET -DCMAKE_OSX_SYSROOT="$PATH_TO_SDK" -DPNG_INCLUDE_DIR=$BUILDDIR -DCMAKE_PREFIX_PATH=$HOME/Qt/5.5/clang_64/ . +[ ! -f CMakeCache.txt ] && cmake -DCMAKE_FIND_FRAMEWORK=LAST -DCMAKE_OSX_ARCHITECTURES=x86_64 -DCMAKE_OSX_DEPLOYMENT_TARGET=$MACOSX_DEPLOYMENT_TARGET -DCMAKE_OSX_SYSROOT="$PATH_TO_SDK" -DPNG_INCLUDE_DIR=$BUILDDIR -DCMAKE_PREFIX_PATH=$HOME/build/Qt/5.5/clang_64 . # I’ve hardcoded path to Qt above [Truf] make $OURDIR/makeapp.sh $STBUILDDIR $STSRC $BUILDDIR