mirror of
https://github.com/zealdocs/zeal.git
synced 2024-11-23 14:26:12 +03:00
core,ui: Remove support for Qt WebEngine
This commit is contained in:
parent
d11913c49c
commit
a5ef8e88c5
@ -33,26 +33,6 @@ UI_DIR = $$BUILD_ROOT/.ui
|
||||
VERSION = 0.3.1
|
||||
DEFINES += ZEAL_VERSION=\\\"$${VERSION}\\\"
|
||||
|
||||
# Browser engine
|
||||
CONFIG(zeal_qtwebengine) {
|
||||
qtHaveModule(webenginewidgets): BROWSER_ENGINE = qtwebengine
|
||||
else: error("Qt WebEngine is not available.")
|
||||
} else {
|
||||
qtHaveModule(webkitwidgets): BROWSER_ENGINE = qtwebkit
|
||||
else: qtHaveModule(webenginewidgets): BROWSER_ENGINE = qtwebengine
|
||||
else: error("Zeal requires Qt WebEngine or Qt WebKit.")
|
||||
}
|
||||
|
||||
equals(BROWSER_ENGINE, qtwebengine) {
|
||||
message("Browser engine: Qt WebEngine.")
|
||||
QT += webenginewidgets
|
||||
DEFINES += USE_WEBENGINE
|
||||
} else {
|
||||
message("Browser engine: Qt WebKit.")
|
||||
QT += webkitwidgets
|
||||
DEFINES += USE_WEBKIT
|
||||
}
|
||||
|
||||
# Portable build
|
||||
CONFIG(zeal_portable) {
|
||||
message("Portable build: Yes.")
|
||||
|
@ -1,6 +1,6 @@
|
||||
ZEAL_LIB_NAME = Core
|
||||
|
||||
QT += network
|
||||
QT += network webkit widgets
|
||||
|
||||
unix:!macx {
|
||||
CONFIG += link_pkgconfig
|
||||
|
@ -28,13 +28,7 @@
|
||||
#include <QStandardPaths>
|
||||
#include <QUrl>
|
||||
#include <QUuid>
|
||||
|
||||
#ifdef USE_WEBENGINE
|
||||
#include <QWebEngineSettings>
|
||||
typedef QWebEngineSettings QWebSettings;
|
||||
#else
|
||||
#include <QWebSettings>
|
||||
#endif
|
||||
|
||||
namespace {
|
||||
// Configuration file groups
|
||||
@ -53,10 +47,8 @@ Settings::Settings(QObject *parent) :
|
||||
QObject(parent)
|
||||
{
|
||||
// TODO: Move to user style sheet (related to #268)
|
||||
#ifndef USE_WEBENGINE
|
||||
QWebSettings::globalSettings()
|
||||
->setUserStyleSheetUrl(QUrl(QStringLiteral("qrc:///browser/highlight.css")));
|
||||
#endif
|
||||
|
||||
load();
|
||||
}
|
||||
|
@ -47,20 +47,9 @@
|
||||
#include <QSystemTrayIcon>
|
||||
#include <QTabBar>
|
||||
#include <QTimer>
|
||||
|
||||
#ifdef USE_WEBENGINE
|
||||
#include <QWebEngineHistory>
|
||||
#include <QWebEngineHistoryItem>
|
||||
#include <QWebEnginePage>
|
||||
|
||||
typedef QWebEngineHistory QWebHistory;
|
||||
typedef QWebEngineHistoryItem QWebHistoryItem;
|
||||
typedef QWebEnginePage QWebPage;
|
||||
#else
|
||||
#include <QWebFrame>
|
||||
#include <QWebHistory>
|
||||
#include <QWebPage>
|
||||
#endif
|
||||
|
||||
using namespace Zeal;
|
||||
|
||||
@ -76,10 +65,8 @@ struct TabState
|
||||
tocModel = new Registry::SearchModel();
|
||||
|
||||
webPage = new QWebPage();
|
||||
#ifndef USE_WEBENGINE
|
||||
webPage->setLinkDelegationPolicy(QWebPage::DelegateExternalLinks);
|
||||
webPage->setNetworkAccessManager(Core::Application::instance()->networkManager());
|
||||
#endif
|
||||
}
|
||||
|
||||
TabState(const TabState &other)
|
||||
@ -94,10 +81,8 @@ struct TabState
|
||||
tocModel = new Registry::SearchModel(*other.tocModel);
|
||||
|
||||
webPage = new QWebPage();
|
||||
#ifndef USE_WEBENGINE
|
||||
webPage->setLinkDelegationPolicy(QWebPage::DelegateExternalLinks);
|
||||
webPage->setNetworkAccessManager(Core::Application::instance()->networkManager());
|
||||
#endif
|
||||
|
||||
restoreHistory(other.saveHistory());
|
||||
}
|
||||
@ -125,29 +110,17 @@ struct TabState
|
||||
}
|
||||
|
||||
QUrl url() const {
|
||||
#ifdef USE_WEBENGINE
|
||||
return webPage->url();
|
||||
#else
|
||||
return webPage->mainFrame()->url();
|
||||
#endif
|
||||
}
|
||||
|
||||
void loadUrl(const QUrl &url)
|
||||
{
|
||||
#ifdef USE_WEBENGINE
|
||||
webPage->load(url);
|
||||
#else
|
||||
webPage->mainFrame()->load(url);
|
||||
#endif
|
||||
}
|
||||
|
||||
QString title() const
|
||||
{
|
||||
#ifdef USE_WEBENGINE
|
||||
return webPage->title();
|
||||
#else
|
||||
return webPage->mainFrame()->title();
|
||||
#endif
|
||||
}
|
||||
|
||||
QString searchQuery;
|
||||
@ -409,7 +382,7 @@ MainWindow::MainWindow(Core::Application *app, QWidget *parent) :
|
||||
|
||||
openDocset(index);
|
||||
|
||||
// Get focus back. QWebPageEngine::load() always steals focus.
|
||||
// Get focus back.
|
||||
ui->lineEdit->setFocus(Qt::MouseFocusReason);
|
||||
});
|
||||
|
||||
@ -489,11 +462,7 @@ void MainWindow::openDocset(const QModelIndex &index)
|
||||
return;
|
||||
|
||||
ui->webView->load(url.toUrl());
|
||||
|
||||
// QWebEnginePage::load() always steals focus, so no need to do it twice.
|
||||
#ifndef USE_WEBENGINE
|
||||
ui->webView->focus();
|
||||
#endif
|
||||
}
|
||||
|
||||
QString MainWindow::docsetName(const QUrl &url) const
|
||||
|
@ -30,14 +30,7 @@
|
||||
|
||||
#include <QDir>
|
||||
#include <QFileDialog>
|
||||
|
||||
#ifdef USE_WEBENGINE
|
||||
#include <QWebEngineSettings>
|
||||
|
||||
typedef QWebEngineSettings QWebSettings;
|
||||
#else
|
||||
#include <QWebSettings>
|
||||
#endif
|
||||
|
||||
using namespace Zeal;
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
ZEAL_LIB_NAME = Ui
|
||||
|
||||
QT += widgets
|
||||
QT += webkitwidgets
|
||||
|
||||
# QxtGlobalShortcut dependencies
|
||||
unix:!macx {
|
||||
|
@ -28,15 +28,9 @@
|
||||
#include <QLineEdit>
|
||||
#include <QStyle>
|
||||
#include <QResizeEvent>
|
||||
|
||||
#ifdef USE_WEBENGINE
|
||||
#include <QWebEngineHistory>
|
||||
#include <QWebEnginePage>
|
||||
#else
|
||||
#include <QWebFrame>
|
||||
#include <QWebHistory>
|
||||
#include <QWebPage>
|
||||
#endif
|
||||
|
||||
SearchableWebView::SearchableWebView(QWidget *parent) :
|
||||
QWidget(parent),
|
||||
@ -56,12 +50,7 @@ SearchableWebView::SearchableWebView(QWidget *parent) :
|
||||
|
||||
connect(m_webView, &QWebView::urlChanged, this, &SearchableWebView::urlChanged);
|
||||
connect(m_webView, &QWebView::titleChanged, this, &SearchableWebView::titleChanged);
|
||||
#ifdef USE_WEBENGINE
|
||||
// not implemented?
|
||||
// connect(m_webView->page(), &QWebPage::linkClicked, this, &SearchableWebView::linkClicked);
|
||||
#else
|
||||
connect(m_webView, &QWebView::linkClicked, this, &SearchableWebView::linkClicked);
|
||||
#endif
|
||||
}
|
||||
|
||||
void SearchableWebView::setPage(QWebPage *page)
|
||||
@ -147,11 +136,7 @@ void SearchableWebView::showSearchBar()
|
||||
void SearchableWebView::hideSearchBar()
|
||||
{
|
||||
m_searchLineEdit->hide();
|
||||
#ifdef USE_WEBENGINE
|
||||
m_webView->findText(QString());
|
||||
#else
|
||||
m_webView->findText(QString(), QWebPage::HighlightAllOccurrences);
|
||||
#endif
|
||||
}
|
||||
|
||||
bool SearchableWebView::canGoBack() const
|
||||
@ -186,11 +171,6 @@ void SearchableWebView::resizeEvent(QResizeEvent *event)
|
||||
|
||||
void SearchableWebView::find(const QString &text)
|
||||
{
|
||||
#ifdef USE_WEBENGINE
|
||||
// FIXME: There's no way to just show highlight when search term is already selected.
|
||||
// So we need a workaround before switching to Qt WebEngine.
|
||||
m_webView->findText(text);
|
||||
#else
|
||||
if (m_webView->selectedText() != text) {
|
||||
m_webView->findText(QString(), QWebPage::HighlightAllOccurrences);
|
||||
m_webView->findText(QString());
|
||||
@ -201,29 +181,22 @@ void SearchableWebView::find(const QString &text)
|
||||
}
|
||||
|
||||
m_webView->findText(text, QWebPage::HighlightAllOccurrences);
|
||||
#endif
|
||||
}
|
||||
|
||||
void SearchableWebView::findNext(const QString &text, bool backward)
|
||||
{
|
||||
#ifdef USE_WEBENGINE
|
||||
QWebPage::FindFlags flags = 0;
|
||||
#else
|
||||
QWebPage::FindFlags flags = QWebPage::FindWrapsAroundDocument;
|
||||
#endif
|
||||
if (backward)
|
||||
flags |= QWebPage::FindBackward;
|
||||
|
||||
m_webView->findText(text, flags);
|
||||
}
|
||||
|
||||
void SearchableWebView::moveLineEdit()
|
||||
{
|
||||
int frameWidth = style()->pixelMetric(QStyle::PM_DefaultFrameWidth);
|
||||
#ifdef USE_WEBENGINE
|
||||
// FIXME: scrollbar width
|
||||
#else
|
||||
frameWidth += m_webView->page()->currentFrame()->scrollBarGeometry(Qt::Vertical).width();
|
||||
#endif
|
||||
|
||||
m_searchLineEdit->move(rect().right() - frameWidth - m_searchLineEdit->sizeHint().width(), rect().top());
|
||||
m_searchLineEdit->raise();
|
||||
}
|
||||
|
@ -28,13 +28,7 @@
|
||||
|
||||
|
||||
class QLineEdit;
|
||||
|
||||
#ifdef USE_WEBENGINE
|
||||
class QWebEnginePage;
|
||||
typedef QWebEnginePage QWebPage;
|
||||
#else
|
||||
class QWebPage;
|
||||
#endif
|
||||
|
||||
class WebView;
|
||||
|
||||
|
@ -26,11 +26,8 @@
|
||||
#include "../mainwindow.h"
|
||||
|
||||
#include <QApplication>
|
||||
#include <QWheelEvent>
|
||||
|
||||
#ifndef USE_WEBENGINE
|
||||
#include <QWebFrame>
|
||||
#endif
|
||||
#include <QWheelEvent>
|
||||
|
||||
WebView::WebView(QWidget *parent) :
|
||||
QWebView(parent)
|
||||
@ -68,7 +65,6 @@ void WebView::mousePressEvent(QMouseEvent *event)
|
||||
forward();
|
||||
event->accept();
|
||||
break;
|
||||
#ifndef USE_WEBENGINE
|
||||
case Qt::LeftButton:
|
||||
if (!(event->modifiers() & Qt::ControlModifier || event->modifiers() & Qt::ShiftModifier))
|
||||
break;
|
||||
@ -77,7 +73,6 @@ void WebView::mousePressEvent(QMouseEvent *event)
|
||||
if (m_clickedLink.isValid())
|
||||
event->accept();
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@ -85,7 +80,6 @@ void WebView::mousePressEvent(QMouseEvent *event)
|
||||
QWebView::mousePressEvent(event);
|
||||
}
|
||||
|
||||
#ifndef USE_WEBENGINE
|
||||
void WebView::mouseReleaseEvent(QMouseEvent *event)
|
||||
{
|
||||
switch (event->button()) {
|
||||
@ -104,7 +98,6 @@ void WebView::mouseReleaseEvent(QMouseEvent *event)
|
||||
}
|
||||
QWebView::mouseReleaseEvent(event);
|
||||
}
|
||||
#endif
|
||||
|
||||
void WebView::wheelEvent(QWheelEvent *event)
|
||||
{
|
||||
@ -116,7 +109,6 @@ void WebView::wheelEvent(QWheelEvent *event)
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef USE_WEBENGINE
|
||||
QUrl WebView::clickedLink(const QPoint &pos) const
|
||||
{
|
||||
QWebFrame *frame = page()->frameAt(pos);
|
||||
@ -125,7 +117,6 @@ QUrl WebView::clickedLink(const QPoint &pos) const
|
||||
|
||||
return frame->hitTestContent(pos).linkUrl();
|
||||
}
|
||||
#endif
|
||||
|
||||
void WebView::updateZoomFactor()
|
||||
{
|
||||
|
@ -24,15 +24,7 @@
|
||||
#ifndef WEBVIEW_H
|
||||
#define WEBVIEW_H
|
||||
|
||||
#ifdef USE_WEBENGINE
|
||||
#include <QWebEnginePage>
|
||||
#include <QWebEngineView>
|
||||
|
||||
typedef QWebEnginePage QWebPage;
|
||||
typedef QWebEngineView QWebView;
|
||||
#else
|
||||
#include <QWebView>
|
||||
#endif
|
||||
|
||||
class WebView : public QWebView
|
||||
{
|
||||
@ -46,18 +38,14 @@ public:
|
||||
protected:
|
||||
QWebView *createWindow(QWebPage::WebWindowType type) override;
|
||||
void mousePressEvent(QMouseEvent *event) override;
|
||||
#ifndef USE_WEBENGINE
|
||||
void mouseReleaseEvent(QMouseEvent *event) override;
|
||||
#endif
|
||||
void wheelEvent(QWheelEvent *event) override;
|
||||
|
||||
private:
|
||||
#ifndef USE_WEBENGINE
|
||||
QUrl clickedLink(const QPoint &pos) const;
|
||||
QUrl m_clickedLink;
|
||||
#endif
|
||||
void updateZoomFactor();
|
||||
|
||||
QUrl m_clickedLink;
|
||||
int m_zoomFactor = 0;
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user