diff options
-rw-r--r-- | CMakeLists.txt | 44 | ||||
-rw-r--r-- | cmake/Functions.cmake | 71 | ||||
-rw-r--r-- | configure.cmake | 96 | ||||
-rw-r--r-- | examples/CMakeLists.txt | 8 | ||||
-rw-r--r-- | examples/pdf/CMakeLists.txt | 5 | ||||
-rw-r--r-- | examples/pdf/multipage/CMakeLists.txt | 62 | ||||
-rw-r--r-- | examples/pdf/multipage/viewer.qml | 46 | ||||
-rw-r--r-- | examples/pdf/pdfviewer/CMakeLists.txt | 62 | ||||
-rw-r--r-- | examples/pdf/pdfviewer/viewer.qml | 48 | ||||
-rw-r--r-- | examples/pdfwidgets/CMakeLists.txt | 1 | ||||
-rw-r--r-- | examples/pdfwidgets/pdfviewer/CMakeLists.txt | 63 | ||||
-rw-r--r-- | src/CMakeLists.txt | 23 | ||||
-rw-r--r-- | src/host/CMakeLists.txt | 9 | ||||
-rw-r--r-- | src/pdf/CMakeLists.txt | 161 | ||||
-rw-r--r-- | src/pdf/configure.cmake | 39 | ||||
-rw-r--r-- | src/pdf/configure/BUILD.root.gn.in | 36 | ||||
-rw-r--r-- | src/pdf/jsbridge.cpp | 38 | ||||
-rw-r--r-- | src/pdf/plugins/imageformats/pdf/CMakeLists.txt | 11 | ||||
-rw-r--r-- | src/pdf/plugins/imageformats/pdf/main.cpp (renamed from src/plugins/imageformats/pdf/main.cpp) | 0 | ||||
-rw-r--r-- | src/pdf/plugins/imageformats/pdf/pdf.json (renamed from src/plugins/imageformats/pdf/pdf.json) | 0 | ||||
-rw-r--r-- | src/pdf/plugins/imageformats/pdf/qpdfiohandler.cpp (renamed from src/plugins/imageformats/pdf/qpdfiohandler.cpp) | 0 | ||||
-rw-r--r-- | src/pdf/plugins/imageformats/pdf/qpdfiohandler_p.h (renamed from src/plugins/imageformats/pdf/qpdfiohandler_p.h) | 0 | ||||
-rw-r--r-- | src/pdf/qpdfbookmarkmodel.cpp | 1 | ||||
-rw-r--r-- | src/pdf/qpdfbookmarkmodel.h (renamed from src/pdf/api/qpdfbookmarkmodel.h) | 0 | ||||
-rw-r--r-- | src/pdf/qpdfdestination.h (renamed from src/pdf/api/qpdfdestination.h) | 0 | ||||
-rw-r--r-- | src/pdf/qpdfdestination_p.h (renamed from src/pdf/api/qpdfdestination_p.h) | 0 | ||||
-rw-r--r-- | src/pdf/qpdfdocument.h (renamed from src/pdf/api/qpdfdocument.h) | 0 | ||||
-rw-r--r-- | src/pdf/qpdfdocument_p.h (renamed from src/pdf/api/qpdfdocument_p.h) | 0 | ||||
-rw-r--r-- | src/pdf/qpdfdocumentrenderoptions.h (renamed from src/pdf/api/qpdfdocumentrenderoptions.h) | 0 | ||||
-rw-r--r-- | src/pdf/qpdflinkmodel_p.h (renamed from src/pdf/api/qpdflinkmodel_p.h) | 0 | ||||
-rw-r--r-- | src/pdf/qpdflinkmodel_p_p.h (renamed from src/pdf/api/qpdflinkmodel_p_p.h) | 0 | ||||
-rw-r--r-- | src/pdf/qpdfnamespace.h (renamed from src/pdf/api/qpdfnamespace.h) | 0 | ||||
-rw-r--r-- | src/pdf/qpdfpagenavigation.h (renamed from src/pdf/api/qpdfpagenavigation.h) | 0 | ||||
-rw-r--r-- | src/pdf/qpdfpagerenderer.h (renamed from src/pdf/api/qpdfpagerenderer.h) | 0 | ||||
-rw-r--r-- | src/pdf/qpdfsearchmodel.h (renamed from src/pdf/api/qpdfsearchmodel.h) | 0 | ||||
-rw-r--r-- | src/pdf/qpdfsearchmodel_p.h (renamed from src/pdf/api/qpdfsearchmodel_p.h) | 0 | ||||
-rw-r--r-- | src/pdf/qpdfsearchresult.h (renamed from src/pdf/api/qpdfsearchresult.h) | 0 | ||||
-rw-r--r-- | src/pdf/qpdfsearchresult_p.h (renamed from src/pdf/api/qpdfsearchresult_p.h) | 0 | ||||
-rw-r--r-- | src/pdf/qpdfselection.h (renamed from src/pdf/api/qpdfselection.h) | 0 | ||||
-rw-r--r-- | src/pdf/qpdfselection_p.h (renamed from src/pdf/api/qpdfselection_p.h) | 0 | ||||
-rw-r--r-- | src/pdf/qtpdf.gni | 7 | ||||
-rw-r--r-- | src/pdf/qtpdfglobal.h (renamed from src/pdf/api/qtpdfglobal.h) | 0 | ||||
-rw-r--r-- | src/pdf/quick/qmldir | 4 | ||||
-rw-r--r-- | src/pdfquick/CMakeLists.txt | 55 | ||||
-rw-r--r-- | src/pdfquick/plugin.cpp (renamed from src/pdf/quick/plugin.cpp) | 8 | ||||
-rw-r--r-- | src/pdfquick/plugins.qmltypes (renamed from src/pdf/quick/plugins.qmltypes) | 0 | ||||
-rw-r--r-- | src/pdfquick/qml/+material/PdfStyle.qml (renamed from src/pdf/quick/qml/+material/PdfStyle.qml) | 0 | ||||
-rw-r--r-- | src/pdfquick/qml/+universal/PdfStyle.qml (renamed from src/pdf/quick/qml/+universal/PdfStyle.qml) | 0 | ||||
-rw-r--r-- | src/pdfquick/qml/PdfMultiPageView.qml (renamed from src/pdf/quick/qml/PdfMultiPageView.qml) | 0 | ||||
-rw-r--r-- | src/pdfquick/qml/PdfPageView.qml (renamed from src/pdf/quick/qml/PdfPageView.qml) | 0 | ||||
-rw-r--r-- | src/pdfquick/qml/PdfScrollablePageView.qml (renamed from src/pdf/quick/qml/PdfScrollablePageView.qml) | 0 | ||||
-rw-r--r-- | src/pdfquick/qml/PdfStyle.qml (renamed from src/pdf/quick/qml/PdfStyle.qml) | 0 | ||||
-rw-r--r-- | src/pdfquick/qquickpdfdocument.cpp (renamed from src/pdf/quick/qquickpdfdocument.cpp) | 0 | ||||
-rw-r--r-- | src/pdfquick/qquickpdfdocument_p.h (renamed from src/pdf/quick/qquickpdfdocument_p.h) | 3 | ||||
-rw-r--r-- | src/pdfquick/qquickpdflinkmodel.cpp (renamed from src/pdf/quick/qquickpdflinkmodel.cpp) | 0 | ||||
-rw-r--r-- | src/pdfquick/qquickpdflinkmodel_p.h (renamed from src/pdf/quick/qquickpdflinkmodel_p.h) | 7 | ||||
-rw-r--r-- | src/pdfquick/qquickpdfnavigationstack.cpp (renamed from src/pdf/quick/qquickpdfnavigationstack.cpp) | 4 | ||||
-rw-r--r-- | src/pdfquick/qquickpdfnavigationstack_p.h (renamed from src/pdf/quick/qquickpdfnavigationstack_p.h) | 7 | ||||
-rw-r--r-- | src/pdfquick/qquickpdfsearchmodel.cpp (renamed from src/pdf/quick/qquickpdfsearchmodel.cpp) | 0 | ||||
-rw-r--r-- | src/pdfquick/qquickpdfsearchmodel_p.h (renamed from src/pdf/quick/qquickpdfsearchmodel_p.h) | 7 | ||||
-rw-r--r-- | src/pdfquick/qquickpdfselection.cpp (renamed from src/pdf/quick/qquickpdfselection.cpp) | 4 | ||||
-rw-r--r-- | src/pdfquick/qquickpdfselection_p.h (renamed from src/pdf/quick/qquickpdfselection_p.h) | 6 | ||||
-rw-r--r-- | src/pdfquick/qquicktableviewextra.cpp (renamed from src/pdf/quick/qquicktableviewextra.cpp) | 0 | ||||
-rw-r--r-- | src/pdfquick/qquicktableviewextra_p.h (renamed from src/pdf/quick/qquicktableviewextra_p.h) | 5 | ||||
-rw-r--r-- | src/pdfquick/qtpdfquickglobal_p.h | 59 | ||||
-rw-r--r-- | src/pdfwidgets/CMakeLists.txt | 15 | ||||
-rw-r--r-- | sync.profile | 4 | ||||
-rw-r--r-- | tests/CMakeLists.txt | 3 | ||||
-rw-r--r-- | tests/auto/CMakeLists.txt | 7 | ||||
-rw-r--r-- | tests/auto/pdf/CMakeLists.txt | 6 | ||||
-rw-r--r-- | tests/auto/pdf/qpdfbookmarkmodel/CMakeLists.txt | 9 | ||||
-rw-r--r-- | tests/auto/pdf/qpdfdocument/CMakeLists.txt | 9 | ||||
-rw-r--r-- | tests/auto/pdf/qpdfpagenavigation/CMakeLists.txt | 8 | ||||
-rw-r--r-- | tests/auto/pdf/qpdfpagerenderer/CMakeLists.txt | 9 | ||||
-rw-r--r-- | tests/auto/pdf/qpdfsearchmodel/CMakeLists.txt | 8 |
75 files changed, 853 insertions, 225 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 9939167a0..823945088 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -39,21 +39,25 @@ set(__QtFeature_only_evaluate_features OFF) include(configure.cmake) include(src/core/api/configure.cmake) include(src/webenginequick/configure.cmake) +include(src/pdf/configure.cmake) qt_feature_module_end(ONLY_EVALUATE_FEATURES) - -if(NOT ${webEngineSupport}) +if(NOT ${QtWebEngine_SUPPORT}) add_custom_target(WebEngineErrorMessage ALL - ${CMAKE_COMMAND} -E cmake_echo_color --red "QtWebEngine will not be built: ${webEngineError}" - COMMENT "Check QtWebEngine support") - message("-- Support check for QtWebEngine failed: ${webEngineError}") + ${CMAKE_COMMAND} -E cmake_echo_color --red "QtWebEngine will not be built: ${QtWebEngine_ERROR}" + COMMENT "Check QtWebEngine support" + VERBATIM + ) + message("-- Support check for QtWebEngine failed: ${QtWebEngine_ERROR}") set(QT_FEATURE_qtwebengine_build OFF CACHE BOOL "Build QtWebEngine" FORCE) endif() -if(NOT ${pdfSupport}) +if(NOT ${QtPdf_SUPPORT}) add_custom_target(PdfErrorMessage ALL - ${CMAKE_COMMAND} -E cmake_echo_color --red "QtPdf will not be built: ${pdfError}" - COMMENT "Check QtPdf support") - message("-- Support check for QtPdf failed: ${pdfError}") + ${CMAKE_COMMAND} -E cmake_echo_color --red "QtPdf will not be built: ${QtPdf_ERROR}" + COMMENT "Check QtPdf support" + VERBATIM + ) + message("-- Support check for QtPdf failed: ${QtPdf_ERROR}") set(QT_FEATURE_qtpdf_build OFF CACHE BOOL "Build QtPdf" FORCE) endif() @@ -63,11 +67,19 @@ if(NOT QT_FEATURE_qtwebengine_build AND NOT QT_FEATURE_qtpdf_build) return() endif() -add_subdirectory(src/core/api) -add_subdirectory(src/core/tools) -add_subdirectory(src/process) -add_subdirectory(src/webenginewidgets) -add_subdirectory(src/webenginequick) +if(QT_FEATURE_qtwebengine_build) + add_subdirectory(src/core/api) + add_subdirectory(src/core/tools) + add_subdirectory(src/process) + add_subdirectory(src/webenginewidgets) + add_subdirectory(src/webenginequick) +endif() + +if(QT_FEATURE_qtpdf_build) + add_subdirectory(src/pdf) + add_subdirectory(src/pdfwidgets) + add_subdirectory(src/pdfquick) +endif() qt_build_repo_end() get_install_config(installConfig) @@ -112,6 +124,7 @@ endif() get_filename_component(WEBENGINE_ROOT_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}" REALPATH) get_qt_features(featureList webengine) get_qt_features(featureList qtwebengine) +get_qt_features(featureList qtpdf) if(NOT DEFINED CMAKE_TOOLCHAIN_FILE AND QT_SUPERBUILD) set(CMAKE_TOOLCHAIN_FILE "${CMAKE_BINARY_DIR}/qtbase/lib/cmake/Qt6/qt.toolchain.cmake") @@ -233,7 +246,7 @@ if(NOT Ninja_FOUND) externalproject_add_stepdependencies(gn install ninja) endif() -if(NOT QT_FEATURE_framework) +if(QT_FEATURE_qtwebengine_build AND NOT QT_FEATURE_framework) # install resources (again), coin calls install with DESTDIR install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/translations/qtwebengine_locales DESTINATION ${CMAKE_INSTALL_PREFIX}/translations @@ -269,6 +282,7 @@ if(CMAKE_CROSSCOMPILING) -DCMAKE_C_FLAGS= -DCMAKE_CXX_FLAGS= -DQT_FEATURE_qtwebengine_build=${QT_FEATURE_qtwebengine_build} + -DQT_FEATURE_qtpdf_build=${QT_FEATURE_qtpdf_build} ) externalproject_add_stepdependencies(qtwebengine install hostBuild) endif() diff --git a/cmake/Functions.cmake b/cmake/Functions.cmake index 4f342eb2d..516ae79fc 100644 --- a/cmake/Functions.cmake +++ b/cmake/Functions.cmake @@ -1,19 +1,22 @@ -function(assertTargets errorResult supportResult) - if(NOT DEFINED ${supportResult}) - set(${supportResult} ON PARENT_SCOPE) - set(${supportResult} ON) - endif() - if(${${supportResult}}) - list(REMOVE_ITEM ARGN ${errorResult}) - list(REMOVE_ITEM ARGN ${supportResult}) - foreach(qtTarget IN ITEMS ${ARGN}) - if(NOT TARGET Qt::${qtTarget}) - set(${errorResult} "Missing required Qt::${qtTarget}." PARENT_SCOPE) - set(${supportResult} OFF PARENT_SCOPE) - return() - endif() - endforeach() - endif() +function(assertTargets) + qt_parse_all_arguments(arg "add_check_for_support" + "" "" "MODULES;TARGETS" "${ARGN}" + ) + foreach(module ${arg_MODULES}) + if(NOT DEFINED ${module}_SUPPORT) + set(${module}_SUPPORT ON PARENT_SCOPE) + set(${module}_SUPPORT ON) + endif() + if(${module}_SUPPORT) + foreach(qtTarget ${arg_TARGETS}) + if(NOT TARGET Qt::${qtTarget}) + set(${module}_ERROR "Missing required Qt::${qtTarget}." PARENT_SCOPE) + set(${module}_SUPPORT OFF PARENT_SCOPE) + break() + endif() + endforeach() + endif() + endforeach() endfunction() function(add_implicit_dependencies target) @@ -27,29 +30,31 @@ function(add_implicit_dependencies target) endif() endfunction() - # TODO: this should be idealy in qtbase -function(add_check_for_support errorResult supportResult) - if(NOT DEFINED ${supportResult}) - set(${supportResult} ON PARENT_SCOPE) - set(${supportResult} ON) - endif() - if(${${supportResult}}) - qt_parse_all_arguments(arg "add_check_for_support" - "" "MODULE" "MESSAGE;CONDITION" "${ARGN}") - if("x${arg_CONDITION}" STREQUAL x) - set(arg_CONDITION ON) +function(add_check_for_support) + qt_parse_all_arguments(arg "add_check_for_support" + "" "" "MODULES;MESSAGE;CONDITION" "${ARGN}" + ) + foreach(module ${arg_MODULES}) + if(NOT DEFINED ${module}_SUPPORT) + set(${module}_SUPPORT ON PARENT_SCOPE) + set(${module}_SUPPORT ON) endif() - qt_evaluate_config_expression(result ${arg_CONDITION}) - if(NOT ${result}) - set(${supportResult} OFF PARENT_SCOPE) - set(${errorResult} ${arg_MESSAGE} PARENT_SCOPE) + if(${module}_SUPPORT) + if("x${arg_CONDITION}" STREQUAL x) + set(arg_CONDITION ON) + endif() + qt_evaluate_config_expression(result ${arg_CONDITION}) + if(NOT ${result}) + set(${module}_SUPPORT OFF PARENT_SCOPE) + set(${module}_ERROR ${arg_MESSAGE} PARENT_SCOPE) qt_configure_add_report_entry(TYPE WARNING - MESSAGE "${arg_MODULE} won't be built. ${arg_MESSAGE}" + MESSAGE "${module} won't be built. ${arg_MESSAGE}" CONDITION ON ) + endif() endif() - endif() + endforeach() endfunction() function(get_qt_features outList module) diff --git a/configure.cmake b/configure.cmake index 418d90fbe..995f4c342 100644 --- a/configure.cmake +++ b/configure.cmake @@ -9,7 +9,7 @@ if(QT_CONFIGURE_RUNNING) endfunction() else() find_package(Ninja 1.7.2) - find_package(Gn ${QT_REPO_MODULE_VERSION} EXACT) + find_package(Gn ${QT_REPO_MODULES_VERSION} EXACT) find_package(Python2 2.7.5) find_package(GPerf) find_package(BISON) @@ -207,7 +207,17 @@ qt_feature("qtwebengine-quick-build" PRIVATE ) qt_feature("qtpdf-build" PRIVATE LABEL "Build Qt PDF" - PURPOSE "Enables building the Qt PDF rendering module." + PURPOSE "Enables building the Qt Pdf modules." +) +qt_feature("qtpdf-widgets-build" PRIVATE + LABEL "Build Qt PdfWidgets" + PURPOSE "Enables building the Qt Pdf module." + CONDITION TARGET Qt::Widgets +) +qt_feature("qtpdf-quick-build" PRIVATE + LABEL "Build Qt PdfQuick" + PURPOSE "Enables building the Qt Pdf module." + CONDITION TARGET Qt::Quick AND TARGET Qt::Qml ) qt_feature("webengine-system-ninja" PRIVATE LABEL "Use system ninja" @@ -326,77 +336,80 @@ else() set(WIN_ARM_64 OFF) endif() -assertTargets(webEngineError webEngineSupport Gui Widgets OpenGL OpenGLWidgets Quick Qml) -add_check_for_support(webEngineError webEngineSupport - MODULE QtWebEngine +assertTargets( + MODULES QtWebEngine QtPdf + TARGETS Gui Widgets OpenGL OpenGLWidgets Quick Qml +) +add_check_for_support( + MODULES QtWebEngine QtPdf CONDITION LINUX OR (WIN32 AND NOT WIN_ARM_64) OR (MACOS AND NOT CMAKE_CROSSCOMPILING) MESSAGE "Build can be done only on Linux, Windows or macOS." ) if(LINUX AND CMAKE_CROSSCOMPILING) get_gn_arch(testArch ${TEST_architecture_arch}) - add_check_for_support(webEngineError webEngineSupport - MODULE QtWebEngine + add_check_for_support( + MODULES QtWebEngine QtPdf CONDITION testArch MESSAGE "Cross compiling is not supported for ${TEST_architecture_arch}." ) endif() -add_check_for_support(webEngineError webEngineSupport - MODULE QtWebEngine +add_check_for_support( + MODULES QtWebEngine QtPdf CONDITION NOT QT_FEATURE_static MESSAGE "Static build is not supported." ) -add_check_for_support(webEngineError webEngineSupport - MODULE QtWebEngine +add_check_for_support( + MODULES QtWebEngine QtPdf CONDITION TARGET Nodejs::Nodejs MESSAGE "Nodejs is required." ) -add_check_for_support(webEngineError webEngineSupport - MODULE QtWebEngine +add_check_for_support( + MODULES QtWebEngine QtPdf CONDITION Python2_FOUND MESSAGE "Python2 version 2.7.5 or later is required." ) -add_check_for_support(webEngineError webEngineSupport - MODULE QtWebEngine +add_check_for_support( + MODULES QtWebEngine QtPdf CONDITION GPerf_FOUND MESSAGE "Tool gperf is required." ) -add_check_for_support(webEngineError webEngineSupport - MODULE QtWebEngine +add_check_for_support( + MODULES QtWebEngine QtPdf CONDITION BISON_FOUND MESSAGE "Tool bison is required." ) -add_check_for_support(webEngineError webEngineSupport - MODULE QtWebEngine +add_check_for_support( + MODULES QtWebEngine QtPdf CONDITION FLEX_FOUND MESSAGE "Tool flex is required." ) -add_check_for_support(webEngineError webEngineSupport - MODULE QtWebEngine +add_check_for_support( + MODULES QtWebEngine QtPdf CONDITION NOT LINUX OR PkgConfig_FOUND MESSAGE "A pkg-config support is required." ) -add_check_for_support(webEngineError webEngineSupport - MODULE QtWebEngine +add_check_for_support( + MODULES QtWebEngine QtPdf CONDITION NOT LINUX OR TEST_glibc MESSAGE "A suitable version >= 2.17 of glibc is required." ) -add_check_for_support(webEngineError webEngineSupport - MODULE QtWebEngine +add_check_for_support( + MODULES QtWebEngine QtPdf CONDITION NOT LINUX OR TEST_khr MESSAGE "Build requires Khronos development headers for build - see mesa/libegl1-mesa-dev" ) -add_check_for_support(webEngineError webEngineSupport - MODULE QtWebEngine +add_check_for_support( + MODULES QtWebEngine CONDITION NOT LINUX OR FONTCONFIG_FOUND MESSAGE "Build requires fontconfig." ) -add_check_for_support(webEngineError webEngineSupport - MODULE QtWebEngine +add_check_for_support( + MODULES QtWebEngine CONDITION NOT LINUX OR NSS_FOUND MESSAGE "Build requires nss >= 3.26." ) -add_check_for_support(webEngineError webEngineSupport - MODULE QtWebEngine +add_check_for_support( + MODULES QtWebEngine CONDITION NOT LINUX OR DBUS_FOUND MESSAGE "Build requires dbus." ) @@ -409,19 +422,19 @@ foreach(xs ${xcbSupport}) set(xcbErrorMessage "${xcbErrorMessage} ${xs}:NO") endif() endforeach() -add_check_for_support(webEngineError webEngineSupport - MODULE QtWebEngine +add_check_for_support( + MODULES QtWebEngine CONDITION NOT LINUX OR NOT QT_FEATURE_xcb OR QT_FEATURE_webengine_ozone_x11 MESSAGE "Could not find all necessary libraries for qpa-xcb support.\ ${xcbErrorMessage}" ) -add_check_for_support(webEngineError webEngineSupport - MODULE QtWebEngine +add_check_for_support( + MODULES QtWebEngine QtPdf CONDITION NOT WIN32 OR TEST_winversion MESSAGE "Build requires Visual Studio 2019 or higher." ) -add_check_for_support(webEngineError webEngineSupport - MODULE QtWebEngine +add_check_for_support( + MODULES QtWebEngine QtPdf CONDITION (LINUX AND CMAKE_CXX_COMPILER_ID STREQUAL GNU) OR (LINUX AND CMAKE_CXX_COMPILER_ID STREQUAL Clang) OR @@ -431,11 +444,6 @@ add_check_for_support(webEngineError webEngineSupport (MACOS AND CMAKE_CXX_COMPILER_ID STREQUAL AppleClang) MESSAGE "${CMAKE_CXX_COMPILER_ID} compiler is not supported." ) -add_check_for_support(pdfError pdfSupport - MODULE QtPdf - CONDITION OFF - MESSAGE "QtPdf is missing cmake port." -) #### Summary @@ -475,13 +483,13 @@ qt_configure_end_summary_section() qt_configure_add_report_entry( TYPE NOTE MESSAGE "QtWebEngine build is disabled by user." - CONDITION ${webEngineSupport} AND NOT QT_FEATURE_qtwebengine_build + CONDITION QtWebEngine_SUPPORT AND NOT QT_FEATURE_qtwebengine_build ) qt_configure_add_report_entry( TYPE NOTE MESSAGE "QtPdf build is disabled by user." - CONDITION ${pdfSupport} AND NOT QT_FEATURE_qtpdf_build + CONDITION QtPdf_SUPPORT AND NOT QT_FEATURE_qtpdf_build ) qt_configure_add_report_entry( diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 5c6e1592d..2bd079b43 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -13,7 +13,9 @@ project(QtWebEngineExamples set(QT_USE_FIXED_QT_ADD_RESOURCE_BASE TRUE) find_package(Qt6 ${PROJECT_VERSION} CONFIG REQUIRED COMPONENTS BuildInternals Core) -find_package(Qt6 ${PROJECT_VERSION} CONFIG OPTIONAL_COMPONENTS WebEngineCore WebEngineWidgets WebEngineQuick QuickControls2) +find_package(Qt6 ${PROJECT_VERSION} CONFIG OPTIONAL_COMPONENTS + WebEngineCore WebEngineWidgets WebEngineQuick PdfWidgets QuickControls2 Svg +) qt_build_repo_begin() qt_examples_build_begin() @@ -23,10 +25,10 @@ endif() if(QT_FEATURE_qtwebengine_build AND QT_FEATURE_qtwebengine_widgets_build) add_subdirectory(webenginewidgets) endif() -if(QT_FEATURE_qtpdf_build ) +if(QT_FEATURE_qtpdf_build AND QT_FEATURE_qtpdf_quick_build) add_subdirectory(pdf) endif() -if(QT_FEATURE_qtpdf_build AND QT_FEATURE_pdf_widgets) +if(QT_FEATURE_qtpdf_build AND QT_FEATURE_qtpdf_widgets_build) add_subdirectory(pdfwidgets) endif() diff --git a/examples/pdf/CMakeLists.txt b/examples/pdf/CMakeLists.txt new file mode 100644 index 000000000..cca6c03db --- /dev/null +++ b/examples/pdf/CMakeLists.txt @@ -0,0 +1,5 @@ +add_subdirectory(pdfviewer) +add_subdirectory(multipage) +if(NOT TARGET Qt::Svg) + message(WARNING "QtSvg is required as runtime dependency for qtpdfquick examples.") +endif() diff --git a/examples/pdf/multipage/CMakeLists.txt b/examples/pdf/multipage/CMakeLists.txt new file mode 100644 index 000000000..141da88b6 --- /dev/null +++ b/examples/pdf/multipage/CMakeLists.txt @@ -0,0 +1,62 @@ +cmake_minimum_required(VERSION 3.16) +project(multipage LANGUAGES CXX) + +set(CMAKE_INCLUDE_CURRENT_DIR ON) + +set(CMAKE_AUTOMOC ON) +set(CMAKE_AUTORCC ON) +set(CMAKE_AUTOUIC ON) + +if(NOT DEFINED INSTALL_EXAMPLESDIR) + set(INSTALL_EXAMPLESDIR "examples") +endif() + +set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/pdf/multipage") + +find_package(Qt6 COMPONENTS Gui) +find_package(Qt6 COMPONENTS Qml) + +qt_add_executable(multipage + main.cpp +) +set_target_properties(multipage PROPERTIES + WIN32_EXECUTABLE TRUE + MACOSX_BUNDLE TRUE +) +target_link_libraries(multipage PUBLIC + Qt::Gui + Qt::Qml +) + +set(viewer_resource_files + "resources/document-open.svg" + "resources/edit-clear.svg" + "resources/edit-copy.svg" + "resources/edit-select-all.svg" + "resources/go-down-search.svg" + "resources/go-next-view-page.svg" + "resources/go-previous-view-page.svg" + "resources/go-up-search.svg" + "resources/rotate-left.svg" + "resources/rotate-right.svg" + "resources/test.pdf" + "resources/zoom-fit-best.svg" + "resources/zoom-fit-width.svg" + "resources/zoom-in.svg" + "resources/zoom-original.svg" + "resources/zoom-out.svg" + "viewer.qml" +) + +qt6_add_resources(multipage "viewer" + PREFIX + "/pdfviewer" + FILES + ${viewer_resource_files} +) + +install(TARGETS multipage + RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}" + BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}" + LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}" +) diff --git a/examples/pdf/multipage/viewer.qml b/examples/pdf/multipage/viewer.qml index f66c8d381..ed84d5547 100644 --- a/examples/pdf/multipage/viewer.qml +++ b/examples/pdf/multipage/viewer.qml @@ -47,14 +47,14 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ -import QtQml 2.14 // workaround for QTBUG-82873 -import QtQuick 2.14 -import QtQuick.Controls 2.14 -import QtQuick.Layouts 1.14 -import QtQuick.Pdf 5.15 -import QtQuick.Shapes 1.14 -import QtQuick.Window 2.14 -import Qt.labs.platform 1.1 as Platform +import QtQml // workaround for QTBUG-82873 +import QtQuick +import QtQuick.Controls +import QtQuick.Layouts +import QtQuick.Pdf +import QtQuick.Shapes +import QtQuick.Window +import Qt.labs.platform as Platform ApplicationWindow { id: root @@ -72,7 +72,7 @@ ApplicationWindow { ToolButton { action: Action { shortcut: StandardKey.Open - icon.source: "resources/document-open.svg" + icon.source: "qrc:/pdfviewer/resources/document-open.svg" onTriggered: fileDialog.open() } } @@ -80,7 +80,7 @@ ApplicationWindow { action: Action { shortcut: StandardKey.ZoomIn enabled: view.renderScale < 10 - icon.source: "resources/zoom-in.svg" + icon.source: "qrc:/pdfviewer/resources/zoom-in.svg" onTriggered: view.renderScale *= Math.sqrt(2) } } @@ -88,46 +88,46 @@ ApplicationWindow { action: Action { shortcut: StandardKey.ZoomOut enabled: view.renderScale > 0.1 - icon.source: "resources/zoom-out.svg" + icon.source: "qrc:/pdfviewer/resources/zoom-out.svg" onTriggered: view.renderScale /= Math.sqrt(2) } } ToolButton { action: Action { - icon.source: "resources/zoom-fit-width.svg" + icon.source: "qrc:/pdfviewer/resources/zoom-fit-width.svg" onTriggered: view.scaleToWidth(root.contentItem.width, root.contentItem.height) } } ToolButton { action: Action { - icon.source: "resources/zoom-fit-best.svg" + icon.source: "qrc:/pdfviewer/resources/zoom-fit-best.svg" onTriggered: view.scaleToPage(root.contentItem.width, root.contentItem.height) } } ToolButton { action: Action { shortcut: "Ctrl+0" - icon.source: "resources/zoom-original.svg" + icon.source: "qrc:/pdfviewer/resources/zoom-original.svg" onTriggered: view.resetScale() } } ToolButton { action: Action { shortcut: "Ctrl+L" - icon.source: "resources/rotate-left.svg" + icon.source: "qrc:/pdfviewer/resources/rotate-left.svg" onTriggered: view.pageRotation -= 90 } } ToolButton { action: Action { shortcut: "Ctrl+R" - icon.source: "resources/rotate-right.svg" + icon.source: "qrc:/pdfviewer/resources/rotate-right.svg" onTriggered: view.pageRotation += 90 } } ToolButton { action: Action { - icon.source: "resources/go-previous-view-page.svg" + icon.source: "qrc:/pdfviewer/resources/go-previous-view-page.svg" enabled: view.backEnbled onTriggered: view.back() } @@ -152,7 +152,7 @@ ApplicationWindow { } ToolButton { action: Action { - icon.source: "resources/go-next-view-page.svg" + icon.source: "qrc:/pdfviewer/resources/go-next-view-page.svg" enabled: view.forwardEnabled onTriggered: view.forward() } @@ -163,14 +163,14 @@ ApplicationWindow { ToolButton { action: Action { shortcut: StandardKey.SelectAll - icon.source: "resources/edit-select-all.svg" + icon.source: "qrc:/pdfviewer/resources/edit-select-all.svg" onTriggered: view.selectAll() } } ToolButton { action: Action { shortcut: StandardKey.Copy - icon.source: "resources/edit-copy.svg" + icon.source: "qrc:/pdfviewer/resources/edit-copy.svg" enabled: view.selectedText !== "" onTriggered: view.copySelectionToClipboard() } @@ -308,7 +308,7 @@ ApplicationWindow { anchors.fill: parent ToolButton { action: Action { - icon.source: "resources/go-up-search.svg" + icon.source: "qrc:/pdfviewer/resources/go-up-search.svg" shortcut: StandardKey.FindPrevious onTriggered: view.searchBack() } @@ -324,7 +324,7 @@ ApplicationWindow { onAccepted: searchDrawer.open() Image { visible: searchField.text !== "" - source: "resources/edit-clear.svg" + source: "qrc:/pdfviewer/resources/edit-clear.svg" anchors { right: parent.right top: parent.top @@ -339,7 +339,7 @@ ApplicationWindow { } ToolButton { action: Action { - icon.source: "resources/go-down-search.svg" + icon.source: "qrc:/pdfviewer/resources/go-down-search.svg" shortcut: StandardKey.FindNext onTriggered: view.searchForward() } diff --git a/examples/pdf/pdfviewer/CMakeLists.txt b/examples/pdf/pdfviewer/CMakeLists.txt new file mode 100644 index 000000000..8265861d0 --- /dev/null +++ b/examples/pdf/pdfviewer/CMakeLists.txt @@ -0,0 +1,62 @@ +cmake_minimum_required(VERSION 3.16) +project(pdfviewer LANGUAGES CXX) + +set(CMAKE_INCLUDE_CURRENT_DIR ON) + +set(CMAKE_AUTOMOC ON) +set(CMAKE_AUTORCC ON) +set(CMAKE_AUTOUIC ON) + +if(NOT DEFINED INSTALL_EXAMPLESDIR) + set(INSTALL_EXAMPLESDIR "examples") +endif() + +set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/pdf/pdfviewer") + +find_package(Qt6 COMPONENTS Gui) +find_package(Qt6 COMPONENTS Qml) + +qt_add_executable(pdfviewerquick + main.cpp +) +set_target_properties(pdfviewerquick PROPERTIES + WIN32_EXECUTABLE TRUE + MACOSX_BUNDLE TRUE +) +target_link_libraries(pdfviewerquick PUBLIC + Qt::Gui + Qt::Qml +) + +set(viewer_resource_files + "resources/document-open.svg" + "resources/edit-clear.svg" + "resources/edit-copy.svg" + "resources/edit-select-all.svg" + "resources/go-down-search.svg" + "resources/go-next-view-page.svg" + "resources/go-previous-view-page.svg" + "resources/go-up-search.svg" + "resources/rotate-left.svg" + "resources/rotate-right.svg" + "resources/test.pdf" + "resources/zoom-fit-best.svg" + "resources/zoom-fit-width.svg" + "resources/zoom-in.svg" + "resources/zoom-original.svg" + "resources/zoom-out.svg" + "viewer.qml" +) + +qt6_add_resources(pdfviewerquick "viewer" + PREFIX + "/pdfviewer" + FILES + ${viewer_resource_files} +) + +install(TARGETS pdfviewerquick + RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}" + BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}" + LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}" +) diff --git a/examples/pdf/pdfviewer/viewer.qml b/examples/pdf/pdfviewer/viewer.qml index 38d62740a..8c85a09da 100644 --- a/examples/pdf/pdfviewer/viewer.qml +++ b/examples/pdf/pdfviewer/viewer.qml @@ -47,15 +47,15 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ -import QtQml 2.14 // workaround for QTBUG-82873 -import QtQuick 2.14 -import QtQuick.Controls 2.14 -import QtQuick.Layouts 1.14 -import QtQuick.Pdf 5.15 -import QtQuick.Shapes 1.14 -import QtQuick.Window 2.14 -import Qt.labs.animation 1.0 -import Qt.labs.platform 1.1 as Platform +import QtQml // workaround for QTBUG-82873 +import QtQuick +import QtQuick.Controls +import QtQuick.Layouts +import QtQuick.Pdf +import QtQuick.Shapes +import QtQuick.Window +import Qt.labs.animation +import Qt.labs.platform as Platform ApplicationWindow { id: root @@ -74,7 +74,7 @@ ApplicationWindow { ToolButton { action: Action { shortcut: StandardKey.Open - icon.source: "resources/document-open.svg" + icon.source: "qrc:/pdfviewer/resources/document-open.svg" onTriggered: fileDialog.open() } } @@ -82,7 +82,7 @@ ApplicationWindow { action: Action { shortcut: StandardKey.ZoomIn enabled: view.sourceSize.width < 10000 - icon.source: "resources/zoom-in.svg" + icon.source: "qrc:/pdfviewer/resources/zoom-in.svg" onTriggered: view.renderScale *= root.scaleStep } } @@ -90,46 +90,46 @@ ApplicationWindow { action: Action { shortcut: StandardKey.ZoomOut enabled: view.sourceSize.width > 50 - icon.source: "resources/zoom-out.svg" + icon.source: "qrc:/pdfviewer/resources/zoom-out.svg" onTriggered: view.renderScale /= root.scaleStep } } ToolButton { action: Action { - icon.source: "resources/zoom-fit-width.svg" + icon.source: "qrc:/pdfviewer/resources/zoom-fit-width.svg" onTriggered: view.scaleToWidth(root.contentItem.width, root.contentItem.height) } } ToolButton { action: Action { - icon.source: "resources/zoom-fit-best.svg" + icon.source: "qrc:/pdfviewer/resources/zoom-fit-best.svg" onTriggered: view.scaleToPage(root.contentItem.width, root.contentItem.height) } } ToolButton { action: Action { shortcut: "Ctrl+0" - icon.source: "resources/zoom-original.svg" + icon.source: "qrc:/pdfviewer/resources/zoom-original.svg" onTriggered: view.resetScale() } } ToolButton { action: Action { shortcut: "Ctrl+L" - icon.source: "resources/rotate-left.svg" + icon.source: "qrc:/pdfviewer/resources/rotate-left.svg" onTriggered: view.pageRotation -= 90 } } ToolButton { action: Action { shortcut: "Ctrl+R" - icon.source: "resources/rotate-right.svg" + icon.source: "qrc:/pdfviewer/resources/rotate-right.svg" onTriggered: view.pageRotation += 90 } } ToolButton { action: Action { - icon.source: "resources/go-previous-view-page.svg" + icon.source: "qrc:/pdfviewer/resources/go-previous-view-page.svg" enabled: view.backEnabled onTriggered: view.back() } @@ -155,7 +155,7 @@ ApplicationWindow { } ToolButton { action: Action { - icon.source: "resources/go-next-view-page.svg" + icon.source: "qrc:/pdfviewer/resources/go-next-view-page.svg" enabled: view.forwardEnabled onTriggered: view.forward() } @@ -166,14 +166,14 @@ ApplicationWindow { ToolButton { action: Action { shortcut: StandardKey.SelectAll - icon.source: "resources/edit-select-all.svg" + icon.source: "qrc:/pdfviewer/resources/edit-select-all.svg" onTriggered: view.selectAll() } } ToolButton { action: Action { shortcut: StandardKey.Copy - icon.source: "resources/edit-copy.svg" + icon.source: "qrc:/pdfviewer/resources/edit-copy.svg" enabled: view.selectedText !== "" onTriggered: view.copySelectionToClipboard() } @@ -282,7 +282,7 @@ ApplicationWindow { anchors.fill: parent ToolButton { action: Action { - icon.source: "resources/go-up-search.svg" + icon.source: "qrc:/pdfviewer/resources/go-up-search.svg" shortcut: StandardKey.FindPrevious onTriggered: view.searchBack() } @@ -299,7 +299,7 @@ ApplicationWindow { onAccepted: searchDrawer.open() Image { visible: searchField.text !== "" - source: "resources/edit-clear.svg" + source: "qrc:/pdfviewer/resources/edit-clear.svg" anchors { right: parent.right top: parent.top @@ -314,7 +314,7 @@ ApplicationWindow { } ToolButton { action: Action { - icon.source: "resources/go-down-search.svg" + icon.source: "qrc:/pdfviewer/resources/go-down-search.svg" shortcut: StandardKey.FindNext onTriggered: view.searchForward() } diff --git a/examples/pdfwidgets/CMakeLists.txt b/examples/pdfwidgets/CMakeLists.txt new file mode 100644 index 000000000..37496ebe3 --- /dev/null +++ b/examples/pdfwidgets/CMakeLists.txt @@ -0,0 +1 @@ +add_subdirectory(pdfviewer) diff --git a/examples/pdfwidgets/pdfviewer/CMakeLists.txt b/examples/pdfwidgets/pdfviewer/CMakeLists.txt new file mode 100644 index 000000000..afcbf035a --- /dev/null +++ b/examples/pdfwidgets/pdfviewer/CMakeLists.txt @@ -0,0 +1,63 @@ +# Generated from pdfviewer.pro. + +cmake_minimum_required(VERSION 3.14) +project(pdfviewer LANGUAGES CXX) + +set(CMAKE_INCLUDE_CURRENT_DIR ON) + +set(CMAKE_AUTOMOC ON) +set(CMAKE_AUTORCC ON) +set(CMAKE_AUTOUIC ON) + +if(NOT DEFINED INSTALL_EXAMPLESDIR) + set(INSTALL_EXAMPLESDIR "examples") +endif() + +set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/pdfwidgets/pdfviewer") + +find_package(Qt6 COMPONENTS Core) +find_package(Qt6 COMPONENTS Gui) +find_package(Qt6 COMPONENTS Widgets) + +qt_add_executable(pdfviewerwidgets + main.cpp + mainwindow.cpp mainwindow.h mainwindow.ui + pageselector.cpp pageselector.h + zoomselector.cpp zoomselector.h +) +set_target_properties(pdfviewerwidgets PROPERTIES + WIN32_EXECUTABLE TRUE + MACOSX_BUNDLE TRUE +) +target_link_libraries(pdfviewerwidgets PUBLIC + Qt::Core + Qt::Gui + Qt::Widgets + Qt::PdfWidgets +) + + +# Resources: +set(resources_resource_files + "images/busy.png" + "images/fileopen.png" + "images/go-next-24.png" + "images/go-previous-24.png" + "images/zoom-in-24.png" + "images/zoom-in-32.png" + "images/zoom-out-24.png" + "images/zoom-out-32.png" +) + +qt6_add_resources(pdfviewerwidgets "resources" + PREFIX + "/icons" + FILES + ${resources_resource_files} +) + +install(TARGETS pdfviewerwidgets + RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}" + BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}" + LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}" +) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index f46b55f82..2db5f81e7 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -23,9 +23,24 @@ set(QT_USE_FIXED_QT_ADD_RESOURCE_BASE TRUE) find_package(Qt6 ${PROJECT_VERSION} CONFIG REQUIRED COMPONENTS BuildInternals Core) qt_build_repo_begin() -add_subdirectory(core) -add_subdirectory(process) -add_subdirectory(webenginewidgets) -add_subdirectory(webenginequick) +if(QT_FEATURE_qtwebengine_build) + add_subdirectory(core) + add_subdirectory(process) + if(QT_FEATURE_qtwebengine_widgets_build) + add_subdirectory(webenginewidgets) + endif() + if(QT_FEATURE_qtwebengine_quick_build) + add_subdirectory(webenginequick) + endif() +endif() +if(QT_FEATURE_qtpdf_build) + add_subdirectory(pdf) + if(QT_FEATURE_qtpdf_widgets_build) + add_subdirectory(pdfwidgets) + endif() + if(QT_FEATURE_qtpdf_quick_build) + add_subdirectory(pdfquick) + endif() +endif() qt_build_repo_end() diff --git a/src/host/CMakeLists.txt b/src/host/CMakeLists.txt index 9053d1e59..822fa8a27 100644 --- a/src/host/CMakeLists.txt +++ b/src/host/CMakeLists.txt @@ -36,3 +36,12 @@ if(QT_FEATURE_qtwebengine_build) DESTINATION ${WEBENGINE_ROOT_BUILD_DIR}/src/core/v8_toolchain ) endif() +if(QT_FEATURE_qtpdf_build) + install(FILES ${buildDir}/host_toolchain/BUILD.gn + DESTINATION ${WEBENGINE_ROOT_BUILD_DIR}/src/pdf/host_toolchain + ) + install(FILES ${buildDir}/v8_toolchain/BUILD.gn + DESTINATION ${WEBENGINE_ROOT_BUILD_DIR}/src/pdf/v8_toolchain + ) +endif() + diff --git a/src/pdf/CMakeLists.txt b/src/pdf/CMakeLists.txt new file mode 100644 index 000000000..b639b1243 --- /dev/null +++ b/src/pdf/CMakeLists.txt @@ -0,0 +1,161 @@ +if(NOT DEFINED WEBENGINE_ROOT_SOURCE_DIR) + get_filename_component(WEBENGINE_ROOT_SOURCE_DIR + "${CMAKE_CURRENT_LIST_DIR}/../.." REALPATH + ) +endif() +find_package(Qt6 ${PROJECT_VERSION} REQUIRED COMPONENTS Gui Network OpenGL Quick) +include(${WEBENGINE_ROOT_SOURCE_DIR}/cmake/Functions.cmake) +set(buildDir "${CMAKE_CURRENT_BINARY_DIR}") + +add_subdirectory(plugins/imageformats/pdf) + +qt_internal_add_module(Pdf + SOURCES + qpdfbookmarkmodel.cpp qpdfbookmarkmodel.h + qpdfdestination.cpp qpdfdestination.h qpdfdestination_p.h + qpdfdocument.cpp qpdfdocument.h qpdfdocument_p.h + qpdfdocumentrenderoptions.h + qpdflinkmodel.cpp qpdflinkmodel_p.h qpdflinkmodel_p_p.h + qpdfpagenavigation.cpp qpdfpagenavigation.h + qpdfpagerenderer.cpp qpdfpagerenderer.h + qpdfsearchmodel.cpp qpdfsearchmodel.h qpdfsearchmodel_p.h + qpdfsearchresult.cpp qpdfsearchresult.h qpdfsearchresult_p.h + qpdfselection.cpp qpdfselection.h qpdfselection_p.h + qtpdfglobal.h + qpdfnamespace.h + INCLUDE_DIRECTORIES + ../3rdparty/chromium + DEFINES + QT_BUILD_PDF_LIB + NOMINMAX + LIBRARIES + Qt::CorePrivate + Qt::Network + PUBLIC_LIBRARIES + Qt::Core + Qt::Gui +) + +make_config_for_gn(Pdf gn_config) +make_install_only(Pdf) +qt_internal_add_docs(Pdf + doc/qtpdf.qdocconf +) + +## +# REPO BUILD +## + +if(WEBENGINE_REPO_BUILD) + find_package(Qt6 ${PROJECT_VERSION} CONFIG REQUIRED COMPONENTS BuildInternals Core) + find_package(Gn ${QT_REPO_MODULE_VERSION} EXACT REQUIRED) + find_package(Ninja 1.7.2 REQUIRED) + find_package(Python2 2.7.5 REQUIRED) + find_package(Nodejs 10.19 REQUIRED) + find_package(PkgConfig) + if(PkgConfig_FOUND) + create_pkg_config_host_wrapper() + endif() + + ## + # TOOLCHAIN SETUP + ## + + if(LINUX) + setup_toolchains() + endif() + + ## + # MULTICONFIG SETUP + ## + + get_configs(configs) + get_architectures(archs) + + foreach(arch ${archs}) + foreach(config ${configs}) + + ## + # BULID.gn SETUP + ## + + set(buildGn pdf_${config}_${arch}) + add_gn_target(${buildGn} ${config} ${arch} SOURCES DEFINES CXX_COMPILE_OPTIONS C_COMPILE_OPTIONS INCLUDES) + resolve_target_includes(gnIncludes Pdf) + get_forward_declaration_macro(forwardDeclarationMacro) + read_gn_target(${buildGn} ${WEBENGINE_ROOT_BUILD_DIR}/src/pdf/${config}/gn_config.cxx.cmake) + read_gn_target(${buildGn} ${WEBENGINE_ROOT_BUILD_DIR}/src/pdf/${config}/gn_config.c.cmake) + configure_gn_target(${buildGn} ${config} + ${WEBENGINE_ROOT_SOURCE_DIR}/src/pdf/configure/BUILD.root.gn.in ${buildDir}/${config}/${arch}/BUILD.gn) + + ## + # GN PARAMETERS + ## + + unset(gnArgArg) + append_build_type_setup(gnArgArg) + append_compiler_linker_sdk_setup(gnArgArg) + append_sanitizer_setup(gnArgArg) + append_toolchain_setup(gnArgArg) + append_pkg_config_setup(gnArgArg) + + list(APPEND gnArgArg + qtwebengine_target="${buildDir}/${config}/${arch}:QtPdf" + enable_remoting=false + enable_web_speech=false + chrome_pgo_phase=0 + ) + + if(LINUX) + list(APPEND gnArgArg + use_x11=false + is_cfi=false + ozone_auto_platforms=false + use_gnome_keyring=false) + endif() + if(MACOS) + list(APPEND gnArgArg angle_enable_vulkan=false) + endif() + if(WIN32) + list(APPEND gnArgArg + ninja_use_custom_environment_files=false + safe_browsing_mode=0 + ) + endif() + + extend_gn_list(gnArgArg + ARGS pdf_enable_v8 + CONDITION QT_FEATURE_pdf_v8 + ) + extend_gn_list(gnArgArg + ARGS pdf_enable_xfa + CONDITION QT_FEATURE_pdf_xfa + ) + extend_gn_list(gnArgArg + ARGS pdf_enable_xfa_bmp + CONDITION QT_FEATURE_pdf_xfa_bmp + ) + extend_gn_list(gnArgArg + ARGS pdf_enable_xfa_gif + CONDITION QT_FEATURE_pdf_xfa_gif + ) + extend_gn_list(gnArgArg + ARGS pdf_enable_xfa_png + CONDITION QT_FEATURE_pdf_xfa_png + ) + extend_gn_list(gnArgArg + ARGS pdf_enable_xfa_tiff + CONDITION QT_FEATURE_pdf_xfa_tiff + ) + + ## + # GN CALL + ## + + execute_gn(gnArgArg) + endforeach() + endforeach() + set(arch ${CMAKE_SYSTEM_PROCESSOR}) + target_include_directories(Pdf PRIVATE ${buildDir}/$<CONFIG>/${arch}/gen) + add_gn_build_aritfacts_to_target(Pdf QtPdf ON ${buildDir}) +endif() diff --git a/src/pdf/configure.cmake b/src/pdf/configure.cmake new file mode 100644 index 000000000..ce1203205 --- /dev/null +++ b/src/pdf/configure.cmake @@ -0,0 +1,39 @@ +qt_feature("pdf-v8" PRIVATE + LABEL "Support V8" + PURPOSE "Enables javascript support." + AUTODETECT false + CONDITION NOT IOS +) +qt_feature("pdf-xfa" PRIVATE + LABEL "Support XFA" + PURPOSE "Enables XFA support." + CONDITION QT_FEATURE_pdf_v8 +) +qt_feature("pdf-xfa-bmp" PRIVATE + LABEL "Support XFA-BMP" + PURPOSE "Enables XFA-BMP support." + CONDITION QT_FEATURE_pdf_xfa +) +qt_feature("pdf-xfa-gif" PRIVATE + LABEL "Support XFA-GIF" + PURPOSE "Enables XFA-GIF support." + CONDITION QT_FEATURE_pdf_xfa +) +qt_feature("pdf-xfa-png" PRIVATE + LABEL "Support XFA-PNG" + PURPOSE "Enables XFA-PNG support." + CONDITION QT_FEATURE_pdf_xfa +) +qt_feature("pdf-xfa-tiff" PRIVATE + LABEL "Support XFA-TIFF" + PURPOSE "Enables XFA-TIFF support." + CONDITION QT_FEATURE_pdf_xfa +) +qt_configure_add_summary_section(NAME "Qt PDF") +qt_configure_add_summary_entry(ARGS "pdf-v8") +qt_configure_add_summary_entry(ARGS "pdf-xfa") +qt_configure_add_summary_entry(ARGS "pdf-xfa-bmp") +qt_configure_add_summary_entry(ARGS "pdf-xfa-gif") +qt_configure_add_summary_entry(ARGS "pdf-xfa-png") +qt_configure_add_summary_entry(ARGS "pdf-xfa-tiff") +qt_configure_end_summary_section() diff --git a/src/pdf/configure/BUILD.root.gn.in b/src/pdf/configure/BUILD.root.gn.in new file mode 100644 index 000000000..a0cd41747 --- /dev/null +++ b/src/pdf/configure/BUILD.root.gn.in @@ -0,0 +1,36 @@ +config("QtPdf_config") { + cflags = [ + @GN_CFLAGS_C@, + ] + cflags_cc = [ + @GN_CFLAGS_CC@, + ] + defines = [ + @GN_DEFINES@, + ] + include_dirs = [ + @GN_INCLUDE_DIRS@, + rebase_path("${target_gen_dir}/.moc/") + ] +} + +config("cpp17_config") { + # static initialized constexpr expressions must be compiled always as c++14 or always as c++17 + # and our qtwebengine core sources use them as c++17 + if (is_win) { + cflags_cc = [ "/std:c++17" ] + } else { + cflags_cc = [ "-std=c++17" ] + } +} + +shared_library("QtPdf") { + cmake_config = "@GN_CONFIG@" + configs += [ + ":cpp17_config", + ":QtPdf_config" + ] + deps = [ + "//third_party/pdfium" + ] +} diff --git a/src/pdf/jsbridge.cpp b/src/pdf/jsbridge.cpp deleted file mode 100644 index 33d3b2465..000000000 --- a/src/pdf/jsbridge.cpp +++ /dev/null @@ -1,38 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2020 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the QtPDF module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL3$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPLv3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or later as published by the Free -** Software Foundation and appearing in the file LICENSE.GPL included in -** the packaging of this file. Please review the following information to -** ensure the GNU General Public License version 2.0 requirements will be -** met: http://www.gnu.org/licenses/gpl-2.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "fpdfsdk/javascript/JS_Runtime_Stub.cpp" - diff --git a/src/pdf/plugins/imageformats/pdf/CMakeLists.txt b/src/pdf/plugins/imageformats/pdf/CMakeLists.txt new file mode 100644 index 000000000..8a33e590b --- /dev/null +++ b/src/pdf/plugins/imageformats/pdf/CMakeLists.txt @@ -0,0 +1,11 @@ +qt_internal_add_plugin(QPdfPlugin + OUTPUT_NAME qpdf + TYPE imageformats + SOURCES + main.cpp + qpdfiohandler.cpp qpdfiohandler_p.h + LIBRARIES + Qt::PdfPrivate +) + +make_install_only(QPdfPlugin) diff --git a/src/plugins/imageformats/pdf/main.cpp b/src/pdf/plugins/imageformats/pdf/main.cpp index b4d59353c..b4d59353c 100644 --- a/src/plugins/imageformats/pdf/main.cpp +++ b/src/pdf/plugins/imageformats/pdf/main.cpp diff --git a/src/plugins/imageformats/pdf/pdf.json b/src/pdf/plugins/imageformats/pdf/pdf.json index 1f5268ca1..1f5268ca1 100644 --- a/src/plugins/imageformats/pdf/pdf.json +++ b/src/pdf/plugins/imageformats/pdf/pdf.json diff --git a/src/plugins/imageformats/pdf/qpdfiohandler.cpp b/src/pdf/plugins/imageformats/pdf/qpdfiohandler.cpp index 4f610935c..4f610935c 100644 --- a/src/plugins/imageformats/pdf/qpdfiohandler.cpp +++ b/src/pdf/plugins/imageformats/pdf/qpdfiohandler.cpp diff --git a/src/plugins/imageformats/pdf/qpdfiohandler_p.h b/src/pdf/plugins/imageformats/pdf/qpdfiohandler_p.h index 99a91154c..99a91154c 100644 --- a/src/plugins/imageformats/pdf/qpdfiohandler_p.h +++ b/src/pdf/plugins/imageformats/pdf/qpdfiohandler_p.h diff --git a/src/pdf/qpdfbookmarkmodel.cpp b/src/pdf/qpdfbookmarkmodel.cpp index b0e8bbecd..0450870a1 100644 --- a/src/pdf/qpdfbookmarkmodel.cpp +++ b/src/pdf/qpdfbookmarkmodel.cpp @@ -272,6 +272,7 @@ void QPdfBookmarkModel::setStructureMode(StructureMode mode) int QPdfBookmarkModel::columnCount(const QModelIndex &parent) const { + Q_UNUSED(parent); return 1; } diff --git a/src/pdf/api/qpdfbookmarkmodel.h b/src/pdf/qpdfbookmarkmodel.h index 8e06a1547..8e06a1547 100644 --- a/src/pdf/api/qpdfbookmarkmodel.h +++ b/src/pdf/qpdfbookmarkmodel.h diff --git a/src/pdf/api/qpdfdestination.h b/src/pdf/qpdfdestination.h index f9c186ff6..f9c186ff6 100644 --- a/src/pdf/api/qpdfdestination.h +++ b/src/pdf/qpdfdestination.h diff --git a/src/pdf/api/qpdfdestination_p.h b/src/pdf/qpdfdestination_p.h index 3520fb795..3520fb795 100644 --- a/src/pdf/api/qpdfdestination_p.h +++ b/src/pdf/qpdfdestination_p.h diff --git a/src/pdf/api/qpdfdocument.h b/src/pdf/qpdfdocument.h index 54ca687fa..54ca687fa 100644 --- a/src/pdf/api/qpdfdocument.h +++ b/src/pdf/qpdfdocument.h diff --git a/src/pdf/api/qpdfdocument_p.h b/src/pdf/qpdfdocument_p.h index b6ee2dfd0..b6ee2dfd0 100644 --- a/src/pdf/api/qpdfdocument_p.h +++ b/src/pdf/qpdfdocument_p.h diff --git a/src/pdf/api/qpdfdocumentrenderoptions.h b/src/pdf/qpdfdocumentrenderoptions.h index cafb4716f..cafb4716f 100644 --- a/src/pdf/api/qpdfdocumentrenderoptions.h +++ b/src/pdf/qpdfdocumentrenderoptions.h diff --git a/src/pdf/api/qpdflinkmodel_p.h b/src/pdf/qpdflinkmodel_p.h index cf9c0aad4..cf9c0aad4 100644 --- a/src/pdf/api/qpdflinkmodel_p.h +++ b/src/pdf/qpdflinkmodel_p.h diff --git a/src/pdf/api/qpdflinkmodel_p_p.h b/src/pdf/qpdflinkmodel_p_p.h index 0606b4746..0606b4746 100644 --- a/src/pdf/api/qpdflinkmodel_p_p.h +++ b/src/pdf/qpdflinkmodel_p_p.h diff --git a/src/pdf/api/qpdfnamespace.h b/src/pdf/qpdfnamespace.h index e76d0abd9..e76d0abd9 100644 --- a/src/pdf/api/qpdfnamespace.h +++ b/src/pdf/qpdfnamespace.h diff --git a/src/pdf/api/qpdfpagenavigation.h b/src/pdf/qpdfpagenavigation.h index dc412c33b..dc412c33b 100644 --- a/src/pdf/api/qpdfpagenavigation.h +++ b/src/pdf/qpdfpagenavigation.h diff --git a/src/pdf/api/qpdfpagerenderer.h b/src/pdf/qpdfpagerenderer.h index faeaef8af..faeaef8af 100644 --- a/src/pdf/api/qpdfpagerenderer.h +++ b/src/pdf/qpdfpagerenderer.h diff --git a/src/pdf/api/qpdfsearchmodel.h b/src/pdf/qpdfsearchmodel.h index 1a413c763..1a413c763 100644 --- a/src/pdf/api/qpdfsearchmodel.h +++ b/src/pdf/qpdfsearchmodel.h diff --git a/src/pdf/api/qpdfsearchmodel_p.h b/src/pdf/qpdfsearchmodel_p.h index 551eff47c..551eff47c 100644 --- a/src/pdf/api/qpdfsearchmodel_p.h +++ b/src/pdf/qpdfsearchmodel_p.h diff --git a/src/pdf/api/qpdfsearchresult.h b/src/pdf/qpdfsearchresult.h index 0acf03d52..0acf03d52 100644 --- a/src/pdf/api/qpdfsearchresult.h +++ b/src/pdf/qpdfsearchresult.h diff --git a/src/pdf/api/qpdfsearchresult_p.h b/src/pdf/qpdfsearchresult_p.h index eca37890e..eca37890e 100644 --- a/src/pdf/api/qpdfsearchresult_p.h +++ b/src/pdf/qpdfsearchresult_p.h diff --git a/src/pdf/api/qpdfselection.h b/src/pdf/qpdfselection.h index 70077fdb0..70077fdb0 100644 --- a/src/pdf/api/qpdfselection.h +++ b/src/pdf/qpdfselection.h diff --git a/src/pdf/api/qpdfselection_p.h b/src/pdf/qpdfselection_p.h index 37ca3a3ce..37ca3a3ce 100644 --- a/src/pdf/api/qpdfselection_p.h +++ b/src/pdf/qpdfselection_p.h diff --git a/src/pdf/qtpdf.gni b/src/pdf/qtpdf.gni deleted file mode 100644 index c31f3e9a0..000000000 --- a/src/pdf/qtpdf.gni +++ /dev/null @@ -1,7 +0,0 @@ -include_dirs = [ -] - -deps = [ - "//third_party/pdfium" -] - diff --git a/src/pdf/api/qtpdfglobal.h b/src/pdf/qtpdfglobal.h index 8b4b0c206..8b4b0c206 100644 --- a/src/pdf/api/qtpdfglobal.h +++ b/src/pdf/qtpdfglobal.h diff --git a/src/pdf/quick/qmldir b/src/pdf/quick/qmldir deleted file mode 100644 index 65fa95cda..000000000 --- a/src/pdf/quick/qmldir +++ /dev/null @@ -1,4 +0,0 @@ -module QtQuick.Pdf -plugin pdfplugin -classname QtQuick2PdfPlugin -typeinfo plugins.qmltypes diff --git a/src/pdfquick/CMakeLists.txt b/src/pdfquick/CMakeLists.txt new file mode 100644 index 000000000..12cb393ff --- /dev/null +++ b/src/pdfquick/CMakeLists.txt @@ -0,0 +1,55 @@ +find_package(Qt6 ${PROJECT_VERSION} CONFIG REQUIRED COMPONENTS Core Gui Qml Quick) + +get_configure_mode(configureMode) + +set(qml_files +# TODO: +# "qml/+material/PdfStyle.qml" +# "qml/+universal/PdfStyle.qml" + "qml/PdfMultiPageView.qml" + "qml/PdfPageView.qml" + "qml/PdfScrollablePageView.qml" + "qml/PdfStyle.qml" +) + +qt_internal_add_qml_module(PdfQuick + URI "QtQuick.Pdf" + VERSION "${PROJECT_VERSION}" + CLASS_NAME QtQuick2PdfPlugin + NO_GENERATE_PLUGIN_SOURCE + NO_PLUGIN_OPTIONAL + NO_GENERATE_QMLTYPES + PLUGIN_TARGET qtpdfquickplugin + QML_FILES ${qml_files} + DEPENDENCIES QtQuickControls2 + SOURCES + qquickpdfdocument.cpp qquickpdfdocument_p.h + qquickpdflinkmodel.cpp qquickpdflinkmodel_p.h + qquickpdfnavigationstack.cpp qquickpdfnavigationstack_p.h + qquickpdfsearchmodel.cpp qquickpdfsearchmodel_p.h + qquickpdfselection.cpp qquickpdfselection_p.h + qquicktableviewextra.cpp qquicktableviewextra_p.h + qtpdfquickglobal_p.h + INCLUDE_DIRECTORIES + ../3rdparty/chromium + PUBLIC_LIBRARIES + Qt::QuickPrivate + Qt::PdfPrivate + Qt::Core + Qt::Gui + Qt::Qml +) + +qt_internal_extend_target(qtpdfquickplugin + SOURCES + plugin.cpp + LIBRARIES + Qt::CorePrivate + Qt::PdfQuickPrivate +) + +make_install_only(PdfQuick) +make_install_only(qtpdfquickplugin) + + + diff --git a/src/pdf/quick/plugin.cpp b/src/pdfquick/plugin.cpp index b082fcb4a..23f32bc39 100644 --- a/src/pdf/quick/plugin.cpp +++ b/src/pdfquick/plugin.cpp @@ -48,7 +48,7 @@ QT_BEGIN_NAMESPACE /*! - \qmlmodule QtQuick.Pdf 5.15 + \qmlmodule QtQuick.Pdf \title Qt Quick PDF QML Types \ingroup qmlmodules \brief Provides QML types for handling PDF documents. @@ -58,7 +58,7 @@ QT_BEGIN_NAMESPACE To use the types in this module, import the module with the following line: \code - import QtQuick.Pdf 5.15 + import QtQuick.Pdf \endcode */ @@ -91,10 +91,6 @@ public: qmlRegisterType<QQuickPdfSearchModel>(uri, 5, 15, "PdfSearchModel"); qmlRegisterType<QQuickPdfSelection>(uri, 5, 15, "PdfSelection"); qmlRegisterType<QQuickTableViewExtra>(uri, 5, 15, "TableViewExtra"); - - qmlRegisterType(QUrl("qrc:/qt-project.org/qtpdf/qml/PdfPageView.qml"), uri, 5, 15, "PdfPageView"); - qmlRegisterType(QUrl("qrc:/qt-project.org/qtpdf/qml/PdfMultiPageView.qml"), uri, 5, 15, "PdfMultiPageView"); - qmlRegisterType(QUrl("qrc:/qt-project.org/qtpdf/qml/PdfScrollablePageView.qml"), uri, 5, 15, "PdfScrollablePageView"); } }; diff --git a/src/pdf/quick/plugins.qmltypes b/src/pdfquick/plugins.qmltypes index a30361d33..a30361d33 100644 --- a/src/pdf/quick/plugins.qmltypes +++ b/src/pdfquick/plugins.qmltypes diff --git a/src/pdf/quick/qml/+material/PdfStyle.qml b/src/pdfquick/qml/+material/PdfStyle.qml index 12df30466..12df30466 100644 --- a/src/pdf/quick/qml/+material/PdfStyle.qml +++ b/src/pdfquick/qml/+material/PdfStyle.qml diff --git a/src/pdf/quick/qml/+universal/PdfStyle.qml b/src/pdfquick/qml/+universal/PdfStyle.qml index e92f2a080..e92f2a080 100644 --- a/src/pdf/quick/qml/+universal/PdfStyle.qml +++ b/src/pdfquick/qml/+universal/PdfStyle.qml diff --git a/src/pdf/quick/qml/PdfMultiPageView.qml b/src/pdfquick/qml/PdfMultiPageView.qml index 71485c214..71485c214 100644 --- a/src/pdf/quick/qml/PdfMultiPageView.qml +++ b/src/pdfquick/qml/PdfMultiPageView.qml diff --git a/src/pdf/quick/qml/PdfPageView.qml b/src/pdfquick/qml/PdfPageView.qml index b90ad2d7f..b90ad2d7f 100644 --- a/src/pdf/quick/qml/PdfPageView.qml +++ b/src/pdfquick/qml/PdfPageView.qml diff --git a/src/pdf/quick/qml/PdfScrollablePageView.qml b/src/pdfquick/qml/PdfScrollablePageView.qml index 51d9e530d..51d9e530d 100644 --- a/src/pdf/quick/qml/PdfScrollablePageView.qml +++ b/src/pdfquick/qml/PdfScrollablePageView.qml diff --git a/src/pdf/quick/qml/PdfStyle.qml b/src/pdfquick/qml/PdfStyle.qml index 090465ce6..090465ce6 100644 --- a/src/pdf/quick/qml/PdfStyle.qml +++ b/src/pdfquick/qml/PdfStyle.qml diff --git a/src/pdf/quick/qquickpdfdocument.cpp b/src/pdfquick/qquickpdfdocument.cpp index 79b23ca84..79b23ca84 100644 --- a/src/pdf/quick/qquickpdfdocument.cpp +++ b/src/pdfquick/qquickpdfdocument.cpp diff --git a/src/pdf/quick/qquickpdfdocument_p.h b/src/pdfquick/qquickpdfdocument_p.h index cefa4f756..cfeeb7b98 100644 --- a/src/pdf/quick/qquickpdfdocument_p.h +++ b/src/pdfquick/qquickpdfdocument_p.h @@ -48,6 +48,7 @@ // We mean it. // +#include <QtPdfQuick/private/qtpdfquickglobal_p.h> #include <QtPdf/QPdfDocument> #include <QDateTime> #include <QJSValue> @@ -57,7 +58,7 @@ QT_BEGIN_NAMESPACE -class QQuickPdfDocument : public QObject, public QQmlParserStatus +class Q_PDFQUICK_EXPORT QQuickPdfDocument : public QObject, public QQmlParserStatus { Q_OBJECT Q_PROPERTY(QUrl source READ source WRITE setSource NOTIFY sourceChanged) diff --git a/src/pdf/quick/qquickpdflinkmodel.cpp b/src/pdfquick/qquickpdflinkmodel.cpp index 4f3958337..4f3958337 100644 --- a/src/pdf/quick/qquickpdflinkmodel.cpp +++ b/src/pdfquick/qquickpdflinkmodel.cpp diff --git a/src/pdf/quick/qquickpdflinkmodel_p.h b/src/pdfquick/qquickpdflinkmodel_p.h index 6f19daa28..d777643ef 100644 --- a/src/pdf/quick/qquickpdflinkmodel_p.h +++ b/src/pdfquick/qquickpdflinkmodel_p.h @@ -48,15 +48,16 @@ // We mean it. // -#include "qquickpdfdocument_p.h" -#include "../api/qpdflinkmodel_p.h" +#include <QtPdfQuick/private/qtpdfquickglobal_p.h> +#include <QtPdfQuick/private/qquickpdfdocument_p.h> +#include <QtPdf/private/qpdflinkmodel_p.h> #include <QVariant> #include <QtQml/qqml.h> QT_BEGIN_NAMESPACE -class QQuickPdfLinkModel : public QPdfLinkModel +class Q_PDFQUICK_EXPORT QQuickPdfLinkModel : public QPdfLinkModel { Q_OBJECT Q_PROPERTY(QQuickPdfDocument *document READ document WRITE setDocument NOTIFY documentChanged) diff --git a/src/pdf/quick/qquickpdfnavigationstack.cpp b/src/pdfquick/qquickpdfnavigationstack.cpp index 044023ef6..e41e43ed5 100644 --- a/src/pdf/quick/qquickpdfnavigationstack.cpp +++ b/src/pdfquick/qquickpdfnavigationstack.cpp @@ -205,7 +205,7 @@ void QQuickPdfNavigationStack::push(int page, QPointF location, qreal zoom, bool QStringList ret; for (auto d : m_pageHistory) ret << QString::number(d->page); - return ret.join(','); + return ret.join(QLatin1Char(',')); }(); } @@ -248,7 +248,7 @@ void QQuickPdfNavigationStack::update(int page, QPointF location, qreal zoom) QStringList ret; for (auto d : m_pageHistory) ret << QString::number(d->page); - return ret.join(','); + return ret.join(QLatin1Char(',')); }(); } diff --git a/src/pdf/quick/qquickpdfnavigationstack_p.h b/src/pdfquick/qquickpdfnavigationstack_p.h index 5df00add5..1d37a4a85 100644 --- a/src/pdf/quick/qquickpdfnavigationstack_p.h +++ b/src/pdfquick/qquickpdfnavigationstack_p.h @@ -48,14 +48,15 @@ // We mean it. // -#include "qquickpdfdocument_p.h" -#include "../api/qpdfdestination_p.h" +#include <QtPdfQuick/private/qtpdfquickglobal_p.h> +#include <QtPdfQuick/private/qquickpdfdocument_p.h> +#include <QtPdf/private/qpdfdestination_p.h> #include <QtQml/qqml.h> QT_BEGIN_NAMESPACE -class QQuickPdfNavigationStack : public QObject +class Q_PDFQUICK_EXPORT QQuickPdfNavigationStack : public QObject { Q_OBJECT Q_PROPERTY(int currentPage READ currentPage NOTIFY currentPageChanged) diff --git a/src/pdf/quick/qquickpdfsearchmodel.cpp b/src/pdfquick/qquickpdfsearchmodel.cpp index d91ca69f8..d91ca69f8 100644 --- a/src/pdf/quick/qquickpdfsearchmodel.cpp +++ b/src/pdfquick/qquickpdfsearchmodel.cpp diff --git a/src/pdf/quick/qquickpdfsearchmodel_p.h b/src/pdfquick/qquickpdfsearchmodel_p.h index 3f0f6f4c1..ad92d4222 100644 --- a/src/pdf/quick/qquickpdfsearchmodel_p.h +++ b/src/pdfquick/qquickpdfsearchmodel_p.h @@ -48,15 +48,16 @@ // We mean it. // -#include "qquickpdfdocument_p.h" -#include "../api/qpdfsearchmodel.h" +#include <QtPdfQuick/private/qtpdfquickglobal_p.h> +#include <QtPdfQuick/private/qquickpdfdocument_p.h> +#include <QtPdf/qpdfsearchmodel.h> #include <QtCore/qvariant.h> #include <QtQml/qqml.h> QT_BEGIN_NAMESPACE -class QQuickPdfSearchModel : public QPdfSearchModel +class Q_PDFQUICK_EXPORT QQuickPdfSearchModel : public QPdfSearchModel { Q_OBJECT Q_PROPERTY(QQuickPdfDocument *document READ document WRITE setDocument NOTIFY documentChanged) diff --git a/src/pdf/quick/qquickpdfselection.cpp b/src/pdfquick/qquickpdfselection.cpp index bdedb4dfb..54a13828a 100644 --- a/src/pdf/quick/qquickpdfselection.cpp +++ b/src/pdfquick/qquickpdfselection.cpp @@ -49,7 +49,7 @@ Q_LOGGING_CATEGORY(qLcIm, "qt.pdf.im") QT_BEGIN_NAMESPACE -static const QRegularExpression WordDelimiter("\\s"); +static const QRegularExpression WordDelimiter(QStringLiteral("\\s")); /*! \qmltype PdfSelection @@ -323,6 +323,8 @@ QVariant QQuickPdfSelection::inputMethodQuery(Qt::InputMethodQuery query) const break; case Qt::ImPlatformData: break; + case Qt::ImReadOnly: + break; case Qt::ImQueryInput: case Qt::ImQueryAll: qWarning() << "unexpected composite query"; diff --git a/src/pdf/quick/qquickpdfselection_p.h b/src/pdfquick/qquickpdfselection_p.h index 75631a876..b364a6c03 100644 --- a/src/pdf/quick/qquickpdfselection_p.h +++ b/src/pdfquick/qquickpdfselection_p.h @@ -48,18 +48,18 @@ // We mean it. // +#include <QtPdfQuick/private/qtpdfquickglobal_p.h> +#include <QtPdfQuick/private/qquickpdfdocument_p.h> #include <QPointF> #include <QPolygonF> #include <QVariant> #include <QtQml/qqml.h> #include <QtQuick/qquickitem.h> -#include "qquickpdfdocument_p.h" - QT_BEGIN_NAMESPACE class QPdfSelection; -class QQuickPdfSelection : public QQuickItem +class Q_PDFQUICK_EXPORT QQuickPdfSelection : public QQuickItem { Q_OBJECT Q_PROPERTY(QQuickPdfDocument *document READ document WRITE setDocument NOTIFY documentChanged) diff --git a/src/pdf/quick/qquicktableviewextra.cpp b/src/pdfquick/qquicktableviewextra.cpp index 017764a95..017764a95 100644 --- a/src/pdf/quick/qquicktableviewextra.cpp +++ b/src/pdfquick/qquicktableviewextra.cpp diff --git a/src/pdf/quick/qquicktableviewextra_p.h b/src/pdfquick/qquicktableviewextra_p.h index 11b4955a1..30eed696d 100644 --- a/src/pdf/quick/qquicktableviewextra_p.h +++ b/src/pdfquick/qquicktableviewextra_p.h @@ -48,16 +48,17 @@ // We mean it. // +#include <QtPdfQuick/private/qtpdfquickglobal_p.h> +#include <QtQuick/private/qquicktableview_p.h> #include <QPointF> #include <QPolygonF> #include <QVariant> #include <QtQml/qqml.h> #include <QtQuick/qquickitem.h> -#include <QtQuick/private/qquicktableview_p.h> QT_BEGIN_NAMESPACE -class QQuickTableViewExtra : public QObject +class Q_PDFQUICK_EXPORT QQuickTableViewExtra : public QObject { Q_OBJECT Q_PROPERTY(QQuickTableView *tableView READ tableView WRITE setTableView) diff --git a/src/pdfquick/qtpdfquickglobal_p.h b/src/pdfquick/qtpdfquickglobal_p.h new file mode 100644 index 000000000..226a82c28 --- /dev/null +++ b/src/pdfquick/qtpdfquickglobal_p.h @@ -0,0 +1,59 @@ +/**************************************************************************** +** +** Copyright (C) 2021 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtWebEngine module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QTPDFQUICKGLOBAL_H +#define QTPDFQUICKGLOBAL_H + +#include <QtCore/qglobal.h> + +QT_BEGIN_NAMESPACE + +#ifndef QT_STATIC +# if defined(QT_BUILD_PDFQUICK_LIB) +# define Q_PDFQUICK_EXPORT Q_DECL_EXPORT +# else +# define Q_PDFQUICK_EXPORT Q_DECL_IMPORT +# endif +#else +# define Q_PDFQUICK_EXPORT +#endif + +QT_END_NAMESPACE + +#endif // QTPDFQUICKGLOBAL_H diff --git a/src/pdfwidgets/CMakeLists.txt b/src/pdfwidgets/CMakeLists.txt new file mode 100644 index 000000000..04ca1387e --- /dev/null +++ b/src/pdfwidgets/CMakeLists.txt @@ -0,0 +1,15 @@ +find_package(Qt6 ${PROJECT_VERSION} CONFIG REQUIRED COMPONENTS Core Gui Widgets) + +qt_internal_add_module(PdfWidgets + SOURCES + qpdfview.cpp qpdfview.h qpdfview_p.h + qtpdfwidgetsglobal.h + LIBRARIES + Qt::WidgetsPrivate + PUBLIC_LIBRARIES + Qt::Core + Qt::Gui + Qt::Widgets + Qt::Pdf +) +make_install_only(PdfWidgets) diff --git a/sync.profile b/sync.profile index 57ec30099..44a85e829 100644 --- a/sync.profile +++ b/sync.profile @@ -3,12 +3,12 @@ "QtWebEngineWidgets" => "$basedir/src/webenginewidgets", "QtWebEngineCore" => "$basedir/src/core/api", "QtPdf" => "$basedir/src/pdf", + "QtPdfQuick" => "$basedir/src/pdfquick", "QtPdfWidgets" => "$basedir/src/pdfwidgets", ); %moduleheaders = ( # restrict the module headers to those found in relative path "QtWebEngineQuick" => "api", - "QtWebEngineWidgets" => "api", - "QtPdf" => "api" + "QtWebEngineWidgets" => "api" ); %classnames = ( ); diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 8d1f1a002..ace11de4a 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -16,7 +16,8 @@ endif() find_package(Qt6 ${PROJECT_VERSION} CONFIG REQUIRED COMPONENTS BuildInternals Core) find_package(Qt6 ${PROJECT_VERSION} CONFIG OPTIONAL_COMPONENTS Gui Widgets - WebEngineCore WebEngineWidgets WebEngineQuick QuickWidgets Test QuickTest WebSockets) + WebEngineCore WebEngineWidgets WebEngineQuick Pdf QuickWidgets Test QuickTest WebSockets +) if(NOT QT_BUILD_STANDALONE_TESTS) qt_build_repo_begin() diff --git a/tests/auto/CMakeLists.txt b/tests/auto/CMakeLists.txt index 2227e6e46..1e5c1f6bd 100644 --- a/tests/auto/CMakeLists.txt +++ b/tests/auto/CMakeLists.txt @@ -12,6 +12,7 @@ if(QT_FEATURE_qtwebengine_widgets_build OR (QT_BUILD_STANDALONE_TESTS AND TARGET Qt::WebEngineWidgets)) add_subdirectory(widgets) endif() -#if(QT_FEATURE_build_qtpdf AND QT_FEATURE_webengine_qtpdf_support) -# add_subdirectory(pdf) -#endif() +if(QT_FEATURE_qtpdf_build + OR (QT_BUILD_STANDALONE_TESTS AND TARGET Qt::Pdf)) + add_subdirectory(pdf) +endif() diff --git a/tests/auto/pdf/CMakeLists.txt b/tests/auto/pdf/CMakeLists.txt new file mode 100644 index 000000000..1220581ca --- /dev/null +++ b/tests/auto/pdf/CMakeLists.txt @@ -0,0 +1,6 @@ +add_subdirectory(qpdfbookmarkmodel) +add_subdirectory(qpdfpagenavigation) +add_subdirectory(qpdfpagerenderer) +if(TARGET Qt::PrintSupport) + add_subdirectory(qpdfdocument) +endif() diff --git a/tests/auto/pdf/qpdfbookmarkmodel/CMakeLists.txt b/tests/auto/pdf/qpdfbookmarkmodel/CMakeLists.txt new file mode 100644 index 000000000..f0300ce7b --- /dev/null +++ b/tests/auto/pdf/qpdfbookmarkmodel/CMakeLists.txt @@ -0,0 +1,9 @@ +qt_internal_add_test(tst_qpdfbookmarkmodel + SOURCES + tst_qpdfbookmarkmodel.cpp + PUBLIC_LIBRARIES + Qt::Gui + Qt::Network + Qt::Pdf +) + diff --git a/tests/auto/pdf/qpdfdocument/CMakeLists.txt b/tests/auto/pdf/qpdfdocument/CMakeLists.txt new file mode 100644 index 000000000..4551fdb6c --- /dev/null +++ b/tests/auto/pdf/qpdfdocument/CMakeLists.txt @@ -0,0 +1,9 @@ +qt_internal_add_test(tst_qpdfdocument + SOURCES + tst_qpdfdocument.cpp + PUBLIC_LIBRARIES + Qt::Gui + Qt::Network + Qt::PrintSupport + Qt::Pdf +) diff --git a/tests/auto/pdf/qpdfpagenavigation/CMakeLists.txt b/tests/auto/pdf/qpdfpagenavigation/CMakeLists.txt new file mode 100644 index 000000000..12ece7507 --- /dev/null +++ b/tests/auto/pdf/qpdfpagenavigation/CMakeLists.txt @@ -0,0 +1,8 @@ +qt_internal_add_test(tst_qpdfpagenavigation + SOURCES + tst_qpdfpagenavigation.cpp + PUBLIC_LIBRARIES + Qt::Gui + Qt::Network + Qt::Pdf +) diff --git a/tests/auto/pdf/qpdfpagerenderer/CMakeLists.txt b/tests/auto/pdf/qpdfpagerenderer/CMakeLists.txt new file mode 100644 index 000000000..f4084cce1 --- /dev/null +++ b/tests/auto/pdf/qpdfpagerenderer/CMakeLists.txt @@ -0,0 +1,9 @@ +qt_internal_add_test(tst_qpdfpagerenderer + SOURCES + tst_qpdfpagerenderer.cpp + PUBLIC_LIBRARIES + Qt::Gui + Qt::Network + Qt::Pdf +) + diff --git a/tests/auto/pdf/qpdfsearchmodel/CMakeLists.txt b/tests/auto/pdf/qpdfsearchmodel/CMakeLists.txt new file mode 100644 index 000000000..2c3e744d0 --- /dev/null +++ b/tests/auto/pdf/qpdfsearchmodel/CMakeLists.txt @@ -0,0 +1,8 @@ +qt_internal_add_test(tst_qpdfsearchmodel + SOURCES + tst_qpdfsearchmodel.cpp + PUBLIC_LIBRARIES + Qt::Gui + Qt::Network + Qt::Pdf +) |