The double connect to onLoadFinished clearly was incorrect, but even with
that removed we still seemed to call the printer before the modified page
finished loading.
Moving the profilesMissing = false setting into the callback also seems
obviously correct, but also wasn't enough to make this work.
So in the end I went the brute force route.
We run the Javascript code to insert the profile images (which is done
in JS to stay compatible with existing templates - yes, this could be
reimplemented differently using Qt primitives - but that would result in
parsing HTML code and that really is what WebEngine is for and the JS
code is known to work...).
And then we write the new HTML out to a file and load that file.
And once THAT file finishes loading (now with all the profiles - if
there were any in the template in the first place), send that to be
printed.
This seems convoluted and silly - but I simply couldn't get a single
step flow to work on openSUSE (which is where this was tested and
implemented).
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This allows the template editor to preview in a QWebEngineView. It also
improves the logic of the buttons (Apply updates the preview but does not force
a save first).
Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
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>