Remove partial support for QWebEngine

Printing never worked, none of this was ever included in test builds. Also, now
that there are official releases of QtWebKit again, this just doesn't seem worth
carrying along anymore.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Dirk Hohndel 2019-03-19 12:40:33 -07:00
parent b6c7abc1a7
commit 643f4a5726
7 changed files with 2 additions and 132 deletions

View file

@ -7,13 +7,9 @@
#include <algorithm>
#include <QPainter>
#ifdef USE_WEBENGINE
#include <QtWebEngineWidgets>
#else
#include <QtWebKitWidgets>
#include <QWebElementCollection>
#include <QWebElement>
#endif
#include "profile-widget/profilewidget2.h"
Printer::Printer(QPaintDevice *paintDevice, print_options *printOptions, template_options *templateOptions, PrintMode printMode)
@ -24,11 +20,7 @@ Printer::Printer(QPaintDevice *paintDevice, print_options *printOptions, templat
this->printMode = printMode;
dpi = 0;
done = 0;
#ifdef USE_WEBENGINE
webView = new QWebEngineView();
#else
webView = new QWebView();
#endif
}
Printer::~Printer()
@ -71,7 +63,6 @@ void Printer::putProfileImage(QRect profilePlaceholder, QRect viewPort, QPainter
void Printer::flowRender()
{
// add extra padding at the bottom to pages with height not divisible by view port
#ifndef USE_WEBENGINE
int paddingBottom = pageSize.height() - (webView->page()->mainFrame()->contentsSize().height() % pageSize.height());
QString styleString = QString::fromUtf8("padding-bottom: ") + QString::number(paddingBottom) + "px;";
webView->page()->mainFrame()->findFirstElement("body").setAttribute("style", styleString);
@ -126,9 +117,6 @@ void Printer::flowRender()
webView->page()->mainFrame()->render(&painter, QWebFrame::ContentsLayer, reigon);
painter.end();
#else
// FIX ME
#endif
}
void Printer::render(int Pages = 0)
@ -154,9 +142,6 @@ void Printer::render(int Pages = 0)
painter.setRenderHint(QPainter::SmoothPixmapTransform);
// get all refereces to diveprofile class in the Html template
#ifdef USE_WEBENGINE
//FIX ME
#else
QWebElementCollection collection = webView->page()->mainFrame()->findAllElements(".diveprofile");
QSize originalSize = profile->size();
@ -190,18 +175,13 @@ void Printer::render(int Pages = 0)
static_cast<QPrinter*>(paintDevice)->newPage();
}
painter.end();
#endif
// return profle settings
profile->setFrameStyle(profileFrameStyle);
profile->setPrintMode(false);
profile->setFontPrintScale(fontScale);
profile->setToolTipVisibile(true);
#ifdef USE_WEBENGINE
//FIXME
#else
profile->resize(originalSize);
#endif
qPrefDisplay::set_animation_speed(animationOriginal);
//replot the dive after returning the settings
@ -232,12 +212,9 @@ void Printer::print()
//rendering resolution = selected paper size in inchs * printer dpi
pageSize.setHeight(qCeil(printerPtr->pageRect(QPrinter::Inch).height() * dpi));
pageSize.setWidth(qCeil(printerPtr->pageRect(QPrinter::Inch).width() * dpi));
#ifdef USE_WEBENGINE
//FIXME
#else
webView->page()->setViewportSize(pageSize);
webView->page()->mainFrame()->setScrollBarPolicy(Qt::Vertical, Qt::ScrollBarAlwaysOff);
#endif
// export border width with at least 1 pixel
// templateOptions->borderwidth = std::max(1, pageSize.width() / 1000);
if (printOptions->type == print_options::DIVELIST) {
@ -255,15 +232,11 @@ void Printer::print()
// get number of dives per page from data-numberofdives attribute in the body of the selected template
bool ok;
#ifdef USE_WEBENGINE
// FIX ME
#else
divesPerPage = webView->page()->mainFrame()->findFirstElement("body").attribute("data-numberofdives").toInt(&ok);
if (!ok) {
divesPerPage = 1; // print each dive in a single page if the attribute is missing or malformed
//TODO: show warning
}
#endif
int Pages;
if (divesPerPage == 0) {
flowRender();
@ -280,11 +253,7 @@ void Printer::previewOnePage()
pageSize.setHeight(paintDevice->height());
pageSize.setWidth(paintDevice->width());
#ifdef USE_WEBENGINE
//FIXME
#else
webView->page()->setViewportSize(pageSize);
#endif
// initialize the border settings
// templateOptions->border_width = std::max(1, pageSize.width() / 1000);
if (printOptions->type == print_options::DIVELIST) {
@ -292,10 +261,6 @@ void Printer::previewOnePage()
} else if (printOptions->type == print_options::STATISTICS ) {
webView->setHtml(t.generateStatistics());
}
#ifdef USE_WEBENGINE
// FIX ME
render(1);
#else
bool ok;
int divesPerPage = webView->page()->mainFrame()->findFirstElement("body").attribute("data-numberofdives").toInt(&ok);
if (!ok) {
@ -307,6 +272,5 @@ void Printer::previewOnePage()
} else {
render(1);
}
#endif
}
}