subsurface/cmake/Modules/HandleUserManual.cmake
Robert C. Helling e7977ee280 desktop: re-add WebEngine support
This reverts commit 643f4a5726 and finishes the task of adding WebEngine as an
alternate backend to be used in printing.

The ultimate goal is to be able to build without QtWebKit (as that is no longer
supported in Qt6). WebKit was used in two places: The user manual and printing.
This patch makes printing work with WebEngine.

The main obstacle is that WebEngine no longer allows accessing HTML elements
from C++ code and rendering the page to a QPainter.

The old version used this to figure out dimensions and page breaks for the
pages and then in the QPainter placed the profile images. With WebEninge, you
need to access the elements using JavaScript which is now used to place the
profile in the html proplerly as an <img> tag. To this end, both html and
profile images are written to a temporary directory on disk.

This image replacement by JavaScript is only necessary to make old templates
still work. It could be replaced by actually putting <img> tags in the
templates (but this would break user edited templates).

In my experiments, the page breaking was done great by html/css, so the
additional magic seems superflous.

What remains to be done:
* remove empty page at the end of printout
* make preview great again (in particlar needed for template editing)

Note: since QtWebEngine currently cannot be built with our toolchain on
Windows, this patch keeps QtWebKit support around by making the QtWebEngine
compile-time conditional via #ifdefs.

[Dirk Hohndel: merged a few commits to make this more logical - the resulting
commit is fairly big, but IMHO preferrable]

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2021-11-26 12:32:10 -08:00

13 lines
331 B
CMake

if(NO_USERMANUAL)
message(STATUS "building without usermanual")
add_definitions(-DNO_USERMANUAL)
else()
if(USE_WEBENGINE)
message(STATUS "building with QWebEngine")
list(APPEND QT_EXTRA_COMPONENTS WebEngineWidgets)
add_definitions(-DUSE_WEBENGINE)
else()
list(APPEND QT_EXTRA_COMPONENTS WebKitWidgets)
endif()
endif()