Skip to content

Commit

Permalink
Fix Qt 5.5 compat. as req. by MacOs distr
Browse files Browse the repository at this point in the history
  • Loading branch information
trufanov-nok committed Dec 24, 2019
1 parent 432705c commit 6abced6
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 10 deletions.
25 changes: 24 additions & 1 deletion ExportDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();


Expand Down Expand Up @@ -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);
}

Expand Down
7 changes: 5 additions & 2 deletions FileNameDisambiguator.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,11 @@ class FileNameDisambiguator : public RefCountable
void performRelinking(AbstractRelinker const& relinker);
private:
class Impl;

std::unique_ptr<Impl> m_ptrImpl;
#ifdef TARGET_OS_MAC
std::auto_ptr<Impl> m_ptrImpl;
#else
std::unique_ptr<Impl> m_ptrImpl;
#endif
};

#endif
5 changes: 5 additions & 0 deletions MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
14 changes: 8 additions & 6 deletions OutputFileNameGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down
2 changes: 1 addition & 1 deletion packaging/osx/buildscantailor.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 <boost/test/auto_unit_test\.hpp>%#include <boost/test/included/unit_test.hpp>%g' $STSRC/imageproc/tests/main.cpp # hardcoded in cpp now [truf]
#[ ! -f $STSRC/tests/main.cpp.old ] && sed -i '.old' -e '1,$ s%^#include <boost/test/auto_unit_test\.hpp>%#include <boost/test/included/unit_test.hpp>%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
Expand Down

0 comments on commit 6abced6

Please sign in to comment.