mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
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:
parent
b6c7abc1a7
commit
643f4a5726
7 changed files with 2 additions and 132 deletions
|
@ -41,7 +41,6 @@ option(NO_USERMANUAL "don't include a viewer for the user manual" OFF)
|
|||
#Options regarding enabling parts of subsurface
|
||||
option(BTSUPPORT "enable support for QtBluetooth (requires Qt5.4 or newer)" ON)
|
||||
option(FTDISUPPORT "enable support for libftdi based serial" OFF)
|
||||
option(USE_WEBENGINE "Use QWebEngine instead of QWebKit" OFF)
|
||||
|
||||
# Options regarding What should we build on subsurface
|
||||
option(MAKE_TESTS "Make the tests" ON)
|
||||
|
|
|
@ -2,11 +2,5 @@ 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()
|
||||
list(APPEND QT_EXTRA_COMPONENTS WebKitWidgets)
|
||||
endif()
|
||||
|
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,11 +3,7 @@
|
|||
#define PRINTER_H
|
||||
|
||||
#include <QPrinter>
|
||||
#ifdef USE_WEBENGINE
|
||||
#include <QWebEngineView>
|
||||
#else
|
||||
#include <QWebView>
|
||||
#endif
|
||||
#include <QRect>
|
||||
#include <QPainter>
|
||||
|
||||
|
@ -25,11 +21,7 @@ public:
|
|||
|
||||
private:
|
||||
QPaintDevice *paintDevice;
|
||||
#ifdef USE_WEBENGINE
|
||||
QWebEngineView *webView;
|
||||
#else
|
||||
QWebView *webView;
|
||||
#endif
|
||||
print_options *printOptions;
|
||||
template_options *templateOptions;
|
||||
QSize pageSize;
|
||||
|
|
|
@ -35,27 +35,6 @@ void SearchBar::enableButtons(const QString &s)
|
|||
ui.findNext->setEnabled(s.length());
|
||||
}
|
||||
|
||||
#ifdef USE_WEBENGINE
|
||||
MyQWebEnginePage::MyQWebEnginePage(QObject* parent) : QWebEnginePage(parent)
|
||||
{
|
||||
}
|
||||
|
||||
bool MyQWebEnginePage::acceptNavigationRequest(const QUrl & url, QWebEnginePage::NavigationType type, bool)
|
||||
{
|
||||
if (type == QWebEnginePage::NavigationTypeLinkClicked)
|
||||
{
|
||||
QDesktopServices::openUrl(url);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
MyQWebEngineView::MyQWebEngineView(QWidget* parent)
|
||||
{
|
||||
}
|
||||
#endif
|
||||
|
||||
UserManual::UserManual(QWidget *parent) : QDialog(parent)
|
||||
{
|
||||
QShortcut *closeKey = new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_W), this);
|
||||
|
@ -76,20 +55,12 @@ UserManual::UserManual(QWidget *parent) : QDialog(parent)
|
|||
setWindowTitle(tr("User manual"));
|
||||
setWindowIcon(QIcon(":subsurface-icon"));
|
||||
|
||||
#ifdef USE_WEBENGINE
|
||||
userManual = new MyQWebEngineView(this);
|
||||
MyQWebEnginePage *page = new MyQWebEnginePage();
|
||||
userManual->setPage(page);
|
||||
#else
|
||||
userManual = new QWebView(this);
|
||||
#endif
|
||||
QString colorBack = palette().highlight().color().name(QColor::HexRgb);
|
||||
QString colorText = palette().highlightedText().color().name(QColor::HexRgb);
|
||||
userManual->setStyleSheet(QString("QWebView { selection-background-color: %1; selection-color: %2; }")
|
||||
.arg(colorBack).arg(colorText));
|
||||
#ifndef USE_WEBENGINE
|
||||
userManual->page()->setLinkDelegationPolicy(QWebPage::DelegateExternalLinks);
|
||||
#endif
|
||||
QString searchPath = getSubsurfaceDataPath("Documentation");
|
||||
if (searchPath.size()) {
|
||||
// look for localized versions of the manual first
|
||||
|
@ -114,9 +85,7 @@ UserManual::UserManual(QWidget *parent) : QDialog(parent)
|
|||
searchBar->hide();
|
||||
connect(actionShowSearch, SIGNAL(triggered(bool)), searchBar, SLOT(show()));
|
||||
connect(actionHideSearch, SIGNAL(triggered(bool)), searchBar, SLOT(hide()));
|
||||
#ifndef USE_WEBENGINE
|
||||
connect(userManual, SIGNAL(linkClicked(QUrl)), this, SLOT(linkClickedSlot(QUrl)));
|
||||
#endif
|
||||
connect(searchBar, SIGNAL(searchTextChanged(QString)), this, SLOT(searchTextChanged(QString)));
|
||||
connect(searchBar, SIGNAL(searchNext()), this, SLOT(searchNext()));
|
||||
connect(searchBar, SIGNAL(searchPrev()), this, SLOT(searchPrev()));
|
||||
|
@ -128,13 +97,6 @@ UserManual::UserManual(QWidget *parent) : QDialog(parent)
|
|||
setLayout(vboxLayout);
|
||||
}
|
||||
|
||||
#ifdef USE_WEBENGINE
|
||||
void UserManual::search(QString text, QWebEnginePage::FindFlags flags = 0)
|
||||
{
|
||||
userManual->findText(text, flags,
|
||||
[this, text](bool found) {searchBar->setStyleSheet(found || text.length() == 0 ? "" : "QLineEdit{background: red;}");});
|
||||
}
|
||||
#else
|
||||
void UserManual::search(QString text, QWebPage::FindFlags flags = 0)
|
||||
{
|
||||
if (userManual->findText(text, QWebPage::FindWrapsAroundDocument | flags) || text.length() == 0) {
|
||||
|
@ -143,7 +105,6 @@ void UserManual::search(QString text, QWebPage::FindFlags flags = 0)
|
|||
searchBar->setStyleSheet("QLineEdit{background: red;}");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
void UserManual::searchTextChanged(const QString& text)
|
||||
{
|
||||
|
@ -158,19 +119,13 @@ void UserManual::searchNext()
|
|||
|
||||
void UserManual::searchPrev()
|
||||
{
|
||||
#ifdef USE_WEBENGINE
|
||||
search(mLastText, QWebEnginePage::FindBackward);
|
||||
#else
|
||||
search(mLastText, QWebPage::FindBackward);
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifndef USE_WEBENGINE
|
||||
void UserManual::linkClickedSlot(const QUrl& url)
|
||||
{
|
||||
QDesktopServices::openUrl(url);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef Q_OS_MAC
|
||||
void UserManual::showEvent(QShowEvent *e) {
|
||||
|
|
|
@ -2,12 +2,7 @@
|
|||
#ifndef USERMANUAL_H
|
||||
#define USERMANUAL_H
|
||||
|
||||
#ifdef USE_WEBENGINE
|
||||
#include <QWebEngineView>
|
||||
#include <QWebEnginePage>
|
||||
#else
|
||||
#include <QWebView>
|
||||
#endif
|
||||
#include <QDialog>
|
||||
#include "ui_searchbar.h"
|
||||
|
||||
|
@ -27,27 +22,6 @@ private:
|
|||
Ui::SearchBar ui;
|
||||
};
|
||||
|
||||
#ifdef USE_WEBENGINE
|
||||
class MyQWebEnginePage : public QWebEnginePage
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
MyQWebEnginePage(QObject* parent = 0);
|
||||
bool acceptNavigationRequest(const QUrl & url, QWebEnginePage::NavigationType type, bool);
|
||||
};
|
||||
|
||||
class MyQWebEngineView : public QWebEngineView
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
MyQWebEngineView(QWidget* parent = 0);
|
||||
MyQWebEnginePage* page() const;
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
class UserManual : public QDialog {
|
||||
Q_OBJECT
|
||||
|
||||
|
@ -67,18 +41,11 @@ slots:
|
|||
void searchTextChanged(const QString& s);
|
||||
void searchNext();
|
||||
void searchPrev();
|
||||
#ifndef USE_WEBENGINE
|
||||
void linkClickedSlot(const QUrl& url);
|
||||
#endif
|
||||
private:
|
||||
SearchBar *searchBar;
|
||||
QString mLastText;
|
||||
#ifdef USE_WEBENGINE
|
||||
QWebEngineView *userManual;
|
||||
void search(QString, QWebEnginePage::FindFlags);
|
||||
#else
|
||||
QWebView *userManual;
|
||||
void search(QString, QWebPage::FindFlags);
|
||||
#endif
|
||||
};
|
||||
#endif // USERMANUAL_H
|
||||
|
|
|
@ -147,7 +147,6 @@ cmake -DBTSUPPORT=OFF \
|
|||
-DNO_DOCS=ON \
|
||||
-DNO_PRINTING=ON \
|
||||
-DNO_USERMANUAL=ON \
|
||||
-DUSE_WEBENGINE=OFF \
|
||||
-DSUBSURFACE_TARGET_EXECUTABLE=DesktopExecutable \
|
||||
build
|
||||
cd build || aborting "Couldn't cd into $SSRF_PATH/build directory"
|
||||
|
|
Loading…
Add table
Reference in a new issue