Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Qt6 port, warning suppression #188

Open
wants to merge 29 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
df1f8e2
Add Korean Translate
mirusu400 Oct 9, 2019
61e423c
Add French translation
maltaisn Oct 5, 2020
2de32ff
Add Polish translation
fyrtax Sep 25, 2021
e03960a
Ignore build folder
Feb 5, 2022
595a1ee
German translation added
Feb 5, 2022
592300b
Merge remote-tracking branch 'polish/master'
Feb 5, 2022
d3a03bc
Merge remote-tracking branch 'french/master'
Feb 5, 2022
87af484
Add option to use black as filling background color
Feb 5, 2022
b83d557
Better translation
Feb 5, 2022
7d4c4f3
Add 1200 DPI as option
Feb 5, 2022
692ffd8
Fix for #87af484 which broke the build
Feb 5, 2022
d16344c
Merge remote-tracking branch 'korean/master'
Feb 5, 2022
ca7d423
Update readme
Feb 5, 2022
b472a7a
German translation synced with project and translated missing phrases
Feb 6, 2022
a07c618
Translations synced with project
Feb 6, 2022
f3fe586
Bump version
Feb 6, 2022
a2ad776
Qt6 port, warning suppression
kunzjacq Feb 15, 2022
f8be714
Enable compilation with both Qt5 and Qt6
kunzjacq Feb 16, 2022
06238ee
Require at least Qt 5.15
kunzjacq Feb 16, 2022
1359b27
Enable compilation with Qt5 starting from version 5.9
kunzjacq Feb 17, 2022
8ad0ec2
misc fix regarding the use of a deprecated function
kunzjacq Feb 18, 2022
a4c655f
misc fix regarding the use of a deprecated function (take two)
kunzjacq Feb 18, 2022
e1218c5
Update README.md
vigri Feb 24, 2022
4df65ca
Enable compilation with Qt6 and MSVC
kunzjacq Feb 25, 2022
a0112f9
fix install with MinGW GCC from command-line
kunzjacq Mar 5, 2022
5442e12
ignore CMake user settings
kunzjacq Mar 5, 2022
4e3d89b
Enable the installation of scantailor-advanced with libjpeg-turbo under
kunzjacq Mar 6, 2022
bd35d95
Merge branch 'master' into Qt6
kunzjacq Mar 9, 2022
6bc208f
Add missing include for Qt 6.3.0 compatibility
kunzjacq Apr 17, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
CMakeLists.txt.user
build/

119 changes: 83 additions & 36 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ if (NOT DEFAULT_COMPILER_FLAGS_IS_SET)
if (CMAKE_COMPILER_IS_GNUCC AND CMAKE_COMPILER_IS_GNUCXX)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wpedantic -Werror=return-type -Wno-unused")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wpedantic -Werror=return-type -Wno-unused")
add_compile_options("$<$<CONFIG:RELEASE>:-march=native;-mtune=native>")
endif()

set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS}"
Expand Down Expand Up @@ -106,7 +107,7 @@ if (WIN32)
set(ZLIB_INSTALL_PREFIX "${zlib_dir_assumed}" CACHE PATH "Prefix where zlib is installed")
set(PNG_INSTALL_PREFIX "${png_dir_assumed}" CACHE PATH "Prefix where png is installed")
set(TIFF_INSTALL_PREFIX "${tiff_dir_assumed}" CACHE PATH "Prefix where tiff is installed")
set(QT_INSTALL_PREFIX "${qt_dir_assumed}" CACHE PATH "Prefix where Qt5 is installed")
set(QT_INSTALL_PREFIX "${qt_dir_assumed}" CACHE PATH "Prefix where Qt is installed")
set(BOOST_ROOT "${boost_dir_assumed}" CACHE PATH "Prefix where Boost is installed")

macro(list_append_existing_path Var Path)
Expand All @@ -131,7 +132,7 @@ endif()
find_package(JPEG REQUIRED)

if (WIN32)
add_dynamic_library_locations(JPEG::JPEG)
add_dynamic_library_locations(JPEG::JPEG "libjpeg-62.dll")
endif()

#=================================== ZLIB ===================================#
Expand All @@ -147,7 +148,7 @@ endif()
find_package(PNG REQUIRED)

if (WIN32)
add_dynamic_library_locations(PNG::PNG)
add_dynamic_library_locations(PNG::PNG "libpng16.dll")
endif()

#=================================== TIFF ===================================#
Expand All @@ -163,6 +164,8 @@ endif()

#================================= Boost ================================#

#set(Boost_NO_WARN_NEW_VERSIONS ON)

if (WIN32)
if (MINGW)
if (CMAKE_SIZEOF_VOID_P EQUAL 8)
Expand All @@ -172,10 +175,11 @@ if (WIN32)
endif()
set(Boost_ARCHITECTURE ${_boost_architecture} CACHE STRING "")

#set(Boost_DEBUG ON)
string(REGEX MATCHALL "[0-9]+" _boost_compiler_version ${CMAKE_CXX_COMPILER_VERSION})
list(GET _boost_compiler_version 0 _boost_compiler_version_major)
list(GET _boost_compiler_version 1 _boost_compiler_version_minor)
set(Boost_COMPILER "mgw${_boost_compiler_version_major}${_boost_compiler_version_minor}" CACHE STRING "")
set(Boost_COMPILER "-mgw${_boost_compiler_version_major}" CACHE STRING "")
endif()

real_path_find_glob(boost_include_dir_hints "${BOOST_ROOT}/include/boost-[_0-9]*/boost")
Expand All @@ -202,11 +206,40 @@ endif()

#=================================== Qt ===================================#

set(qt_min_version 5.6)
set(qt_min_version 5.9)

find_package(
Qt5 ${qt_min_version}
Qt6
COMPONENTS Core Gui Widgets Xml Network LinguistTools OpenGL Svg OpenGLWidgets
CONFIG)
if (Qt6_FOUND)
set(QT_BINDIR "${QT6_INSTALL_PREFIX}/bin")
else()
find_package(Qt5 ${qt_min_version}
COMPONENTS Core Gui Widgets Xml Network LinguistTools OpenGL Svg
CONFIG REQUIRED)
set(QT_BINDIR "${QT5_INSTALL_PREFIX}/bin")
endif()

if(Qt6_FOUND)
set(Qt_Core_lib Qt::Core)
set(Qt_Gui_lib Qt::Gui)
set(Qt_Network_lib Qt::Network)
set(Qt_OpenGL_lib Qt::OpenGL)
set(Qt_Svg_lib Qt::Svg)
set(Qt_Widgets_lib Qt::Widgets)
set(Qt_Xml_lib Qt::Xml)
set(Qt_OpenGLWidgets_lib Qt::OpenGLWidgets)
else()
set(Qt_Core_lib Qt5::Core)
set(Qt_Gui_lib Qt5::Gui)
set(Qt_Network_lib Qt5::Network)
set(Qt_OpenGL_lib Qt5::OpenGL)
set(Qt_Svg_lib Qt5::Svg)
set(Qt_Widgets_lib Qt5::Widgets)
set(Qt_Xml_lib Qt5::Xml)
endif()


#=================================== Threads ===================================#

Expand Down Expand Up @@ -293,7 +326,11 @@ finalize_translations(scantailor ${translation_files})
update_translations_target(update_translations scantailor)

list(FILTER translation_files EXCLUDE REGEX ".*untranslated.ts")
qt5_add_translation(qm_files ${translation_files})
if(Qt6_FOUND)
Qt_add_translation(qm_files ${translation_files})
else()
Qt5_add_translation(qm_files ${translation_files})
endif()
add_custom_target(compile_translations ALL DEPENDS ${qm_files})
if (WIN32)
install(FILES ${qm_files} DESTINATION "${CMAKE_INSTALL_BINDIR}/translations")
Expand Down Expand Up @@ -324,10 +361,17 @@ if (WIN32)
endmacro()

# Install the DLLs of the dependencies.
set(dep_libs
JPEG::JPEG PNG::PNG ZLIB::ZLIB TIFF::TIFF
Qt5::Core Qt5::Gui Qt5::Widgets Qt5::Xml
Qt5::Network Qt5::OpenGL Qt5::Svg)
if(Qt6_FOUND)
set(dep_libs
JPEG::JPEG PNG::PNG ZLIB::ZLIB TIFF::TIFF
Qt::Core Qt::Gui Qt::Widgets Qt::Xml
Qt::Network Qt::OpenGL Qt::Svg Qt6::OpenGLWidgets)
else()
set(dep_libs
JPEG::JPEG PNG::PNG ZLIB::ZLIB TIFF::TIFF
Qt5::Core Qt5::Gui Qt5::Widgets Qt5::Xml
Qt5::Network Qt5::OpenGL Qt5::Svg)
endif()

foreach (_target ${dep_libs})
get_target_property(target_type ${_target} TYPE)
Expand All @@ -346,34 +390,37 @@ if (WIN32)
add_runtime_libs_to_install(DEBUG "${debug_loc}")
endforeach()

# Install Qt's plugins.
macro (install_qt_plugin SubDir Target)
if (TARGET ${Target})
get_target_property(target_type ${Target} TYPE)
if (target_type STREQUAL "MODULE_LIBRARY")
get_target_property(release_loc ${Target} LOCATION_RELEASE)
get_target_property(debug_loc ${Target} LOCATION_DEBUG)
set_if_undefined(debug_loc "${release_loc}")

copy_to_build_dir("${release_loc}" SUBDIR ${SubDir} CONFIGURATIONS Release MinSizeRel RelWithDebInfo)
install(PROGRAMS "${release_loc}"
CONFIGURATIONS Release MinSizeRel RelWithDebInfo
#with Qt6, winqtdeploy is used to deploy plugins; the method below does not work anymore.
if (NOT Qt6_FOUND)
# Install Qt plugins.
macro (install_qt_plugin SubDir Target)
if (TARGET ${Target})
get_target_property(target_type ${Target} TYPE)
if (target_type STREQUAL "MODULE_LIBRARY")
get_target_property(release_loc ${Target} LOCATION_RELEASE)
get_target_property(debug_loc ${Target} LOCATION_DEBUG)
set_if_undefined(debug_loc "${release_loc}")

copy_to_build_dir("${release_loc}" SUBDIR ${SubDir} CONFIGURATIONS Release MinSizeRel RelWithDebInfo)
install(PROGRAMS "${release_loc}"
CONFIGURATIONS Release MinSizeRel RelWithDebInfo
DESTINATION "${CMAKE_INSTALL_BINDIR}/${SubDir}")
copy_to_build_dir("${debug_loc}" SUBDIR ${SubDir} CONFIGURATIONS Debug)
install(PROGRAMS "${debug_loc}"
CONFIGURATIONS Debug
copy_to_build_dir("${debug_loc}" SUBDIR ${SubDir} CONFIGURATIONS Debug)
install(PROGRAMS "${debug_loc}"
CONFIGURATIONS Debug
DESTINATION "${CMAKE_INSTALL_BINDIR}/${SubDir}")
endif()
endif()
endif()
endmacro()
endmacro()

install_qt_plugin("platforms" Qt::QWindowsIntegrationPlugin)
install_qt_plugin("styles" Qt::QWindowsVistaStylePlugin)
install_qt_plugin("imageformats" Qt::QJpegPlugin)
install_qt_plugin("accessible" Qt::QAccessiblePlugin)
install_qt_plugin("iconengines" Qt::QSvgIconPlugin)
install_qt_plugin("imageformats" Qt::QSvgPlugin)
endif()

install_qt_plugin("platforms" Qt5::QWindowsIntegrationPlugin)
install_qt_plugin("styles" Qt5::QWindowsVistaStylePlugin)
install_qt_plugin("imageformats" Qt5::QJpegPlugin)
install_qt_plugin("accessible" Qt5::QAccessiblePlugin)
install_qt_plugin("iconengines" Qt5::QSvgIconPlugin)
install_qt_plugin("imageformats" Qt5::QSvgPlugin)

# Install MinGW runtime components.
if (MINGW)
get_filename_component(_mingw_path ${CMAKE_CXX_COMPILER} PATH)
Expand Down Expand Up @@ -453,4 +500,4 @@ if (NOT TARGET uninstall)
add_custom_target(
uninstall
COMMAND "${CMAKE_COMMAND}" -P "${CMAKE_BINARY_DIR}/cmake_uninstall.cmake")
endif()
endif()
18 changes: 17 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ brings new ones and fixes.


#### <u>Contents</u>:
* [About this fork](#about-this-fork)
* [Description](#description)
* [Features](#features)
* [**ScanTailor Enhanced**](#scantailor-enhanced)
Expand Down Expand Up @@ -46,6 +47,21 @@ brings new ones and fixes.
* [Guides](#guides)
* [Building](#building)

About this fork
------------

Unfortunately, the [repository](https://github.com/4lex4/scantailor-advanced/releases) of @4lex4 seems to be no longer active.

For this reason I have created this fork. It contains:
- German translation
- Polish translation (PR in the original repository, credit goes to @ukolaj-s)
- French translation (PR in the original repository, credit goes to @maltaisn)
- Korean translation (PR in the original repository, credit goes to @brendan-t)
- Beside 'background' and white you can now choose black as filling color
- 1200 DPI output option

PRs are highly welcome ;-)

Description
------------

Expand Down Expand Up @@ -397,4 +413,4 @@ has't been moved due to dirty realization. Their functionality is fully covered
Building
----------

Go to [this repository](https://github.com/4lex4/scantailor-libs-build) and follow the instructions given there.
Go to [this repository](https://github.com/vigri/scantailor-libs-build) and follow the instructions given there.
13 changes: 10 additions & 3 deletions cmake/AddDynamicLibraryLocations.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
# appropriate <prefix name>_DYNAMIC_LIBRARY_<Config> cache variables should be set
# or the locations should be added to CMAKE_PROGRAM_PATH or CMAKE_PREFIX_PATH variables.
#
# An optional argument can be used to specify a non-standard name for the dynamic library.

function(add_dynamic_library_locations Targets)
foreach(_target ${Targets})
Expand All @@ -38,10 +39,16 @@ function(add_dynamic_library_locations Targets)
get_filename_component(imp_loc_ext ${imp_loc} EXT)
if (imp_loc_ext STREQUAL CMAKE_IMPORT_LIBRARY_SUFFIX)
get_filename_component(lib_name_we ${imp_loc} NAME_WE)
set(candidate_names
"${lib_name_we}${CMAKE_SHARED_LIBRARY_SUFFIX}")
if(DEFINED ARGV1)
list(APPEND candidate_names ${ARGV1})
endif()
find_program(
${_target}_${dynamic_lib}
NAMES ${lib_name_we}${CMAKE_SHARED_LIBRARY_SUFFIX}
DOC Path to the dynamic library of the shared target \(skip it if the target is not shared\).)
NAMES ${candidate_names}
DOC Path to the dynamic library of the shared target \(skip it if the target is not shared\).
NO_CACHE)
if (${_target}_${dynamic_lib})
set_target_properties(
${_target} PROPERTIES
Expand All @@ -50,4 +57,4 @@ function(add_dynamic_library_locations Targets)
endif()
endforeach()
endforeach()
endfunction()
endfunction()
2 changes: 1 addition & 1 deletion cmake/UpdateTranslations.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ macro (update_translations_target _update_target) #, _targets
set(_commands "")
foreach (_target ${ARGN})
list(
APPEND _commands COMMAND Qt5::lupdate -locations absolute -no-obsolete
APPEND _commands COMMAND Qt6::lupdate -locations absolute -no-obsolete
-pro "${CMAKE_BINARY_DIR}/update_translations_${_target}.pro")
endforeach()

Expand Down
13 changes: 12 additions & 1 deletion src/app/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,15 @@ target_include_directories(
"$<TARGET_PROPERTY:TIFF::TIFF,INTERFACE_INCLUDE_DIRECTORIES>")
install(TARGETS scantailor RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}")

translation_sources(scantailor ${gui_only_sources} ${gui_only_ui_files})
if (Qt6_FOUND AND WIN32)
#manage plugins with windeployqt.
add_custom_command(
TARGET scantailor
POST_BUILD
COMMAND ${QT_BINDIR}/windeployqt $<TARGET_FILE:scantailor>
COMMENT "deploy qt files alongside binary (e.g. plugins)"
)
install(CODE "execute_process(COMMAND \"${QT_BINDIR}/windeployqt\" \"\$\{CMAKE_INSTALL_PREFIX\}\")")
endif()

translation_sources(scantailor ${gui_only_sources} ${gui_only_ui_files})
2 changes: 2 additions & 0 deletions src/app/DefaultParamsDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ DefaultParamsDialog::DefaultParamsDialog(QWidget* parent)

fillingColorBox->addItem(tr("Background"), FILL_BACKGROUND);
fillingColorBox->addItem(tr("White"), FILL_WHITE);
fillingColorBox->addItem(tr("Black"), FILL_BLACK);

thresholdMethodBox->addItem(tr("Otsu"), OTSU);
thresholdMethodBox->addItem(tr("Sauvola"), SAUVOLA);
Expand All @@ -55,6 +56,7 @@ DefaultParamsDialog::DefaultParamsDialog(QWidget* parent)
dpiSelector->addItem("300", "300");
dpiSelector->addItem("400", "400");
dpiSelector->addItem("600", "600");
dpiSelector->addItem("1200", "1200");
m_customDpiItemIdx = dpiSelector->count();
m_customDpiValue = "200";
dpiSelector->addItem(tr("Custom"), m_customDpiValue);
Expand Down
1 change: 1 addition & 0 deletions src/app/FixDpiDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ FixDpiDialog::FixDpiDialog(const std::vector<ImageFileInfo>& files, QWidget* par
dpiCombo->addItem("300 x 300", QSize(300, 300));
dpiCombo->addItem("400 x 400", QSize(400, 400));
dpiCombo->addItem("600 x 600", QSize(600, 600));
dpiCombo->addItem("1200 x 1200", QSize(1200, 1200));

tabWidget->setTabText(NEED_FIXING_TAB, tr("Need Fixing"));
tabWidget->setTabText(ALL_PAGES_TAB, tr("All Pages"));
Expand Down
1 change: 1 addition & 0 deletions src/app/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include <QSortFilterProxyModel>
#include <QStackedLayout>
#include <QtWidgets/QInputDialog>
#include <QActionGroup>
#include <boost/lambda/lambda.hpp>
#include <memory>

Expand Down
1 change: 1 addition & 0 deletions src/app/ProjectFilesDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <QMessageBox>
#include <QSettings>
#include <QSortFilterProxyModel>
#include <QVector>
#include <deque>

#include "ImageMetadataLoader.h"
Expand Down
12 changes: 8 additions & 4 deletions src/app/RelinkablePathVisualization.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@
#include <QPaintEvent>
#include <QPushButton>
#include <QStyle>
#include <QFile>
#include <QStyleOption>
#include <QStylePainter>
#include <boost/bind.hpp>
#include <boost/bind/bind.hpp>

#include "ColorSchemeManager.h"
#include "RelinkablePath.h"
Expand Down Expand Up @@ -38,7 +39,6 @@ class RelinkablePathVisualization::ComponentButton : public QPushButton {
RelinkablePathVisualization::RelinkablePathVisualization(QWidget* parent)
: QWidget(parent), m_layout(new QHBoxLayout(this)) {
m_layout->setSpacing(0);
m_layout->setMargin(0);
}

void RelinkablePathVisualization::clear() {
Expand All @@ -53,8 +53,12 @@ void RelinkablePathVisualization::clear() {

void RelinkablePathVisualization::setPath(const RelinkablePath& path, bool clickable) {
clear();

QStringList components(path.normalizedPath().split(QChar('/'), QString::SkipEmptyParts));
#if QT_VERSION_MAJOR == 5 and QT_VERSION_MINOR < 14
auto opt = QString::SkipEmptyParts;
#else
auto opt = Qt::SkipEmptyParts;
#endif
QStringList components(path.normalizedPath().split(QChar('/'), opt));
if (components.empty()) {
return;
}
Expand Down
3 changes: 2 additions & 1 deletion src/app/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@
#include "MainWindow.h"

int main(int argc, char* argv[]) {
#if QT_VERSION_MAJOR == 5
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
QApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);

#endif
Application app(argc, argv);

#ifdef _WIN32
Expand Down
Loading