diff --git a/qmake/common.pri b/qmake/common.pri index 7a19fa2..04d510e 100644 --- a/qmake/common.pri +++ b/qmake/common.pri @@ -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.") diff --git a/src/libs/core/core.pri b/src/libs/core/core.pri index 0f7c62e..41f944c 100644 --- a/src/libs/core/core.pri +++ b/src/libs/core/core.pri @@ -1,6 +1,6 @@ ZEAL_LIB_NAME = Core -QT += network +QT += network webkit widgets unix:!macx { CONFIG += link_pkgconfig diff --git a/src/libs/core/settings.cpp b/src/libs/core/settings.cpp index bf514e5..2f95776 100644 --- a/src/libs/core/settings.cpp +++ b/src/libs/core/settings.cpp @@ -28,13 +28,7 @@ #include #include #include - -#ifdef USE_WEBENGINE -#include -typedef QWebEngineSettings QWebSettings; -#else #include -#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(); } diff --git a/src/libs/ui/mainwindow.cpp b/src/libs/ui/mainwindow.cpp index 79ab0e2..a30d719 100644 --- a/src/libs/ui/mainwindow.cpp +++ b/src/libs/ui/mainwindow.cpp @@ -47,20 +47,9 @@ #include #include #include - -#ifdef USE_WEBENGINE -#include -#include -#include - -typedef QWebEngineHistory QWebHistory; -typedef QWebEngineHistoryItem QWebHistoryItem; -typedef QWebEnginePage QWebPage; -#else #include #include #include -#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 diff --git a/src/libs/ui/settingsdialog.cpp b/src/libs/ui/settingsdialog.cpp index 78ca60b..8b3f777 100644 --- a/src/libs/ui/settingsdialog.cpp +++ b/src/libs/ui/settingsdialog.cpp @@ -30,14 +30,7 @@ #include #include - -#ifdef USE_WEBENGINE -#include - -typedef QWebEngineSettings QWebSettings; -#else #include -#endif using namespace Zeal; diff --git a/src/libs/ui/ui.pri b/src/libs/ui/ui.pri index ca5169d..c38640d 100644 --- a/src/libs/ui/ui.pri +++ b/src/libs/ui/ui.pri @@ -1,6 +1,6 @@ ZEAL_LIB_NAME = Ui -QT += widgets +QT += webkitwidgets # QxtGlobalShortcut dependencies unix:!macx { diff --git a/src/libs/ui/widgets/searchablewebview.cpp b/src/libs/ui/widgets/searchablewebview.cpp index 93e919f..5ef0aba 100644 --- a/src/libs/ui/widgets/searchablewebview.cpp +++ b/src/libs/ui/widgets/searchablewebview.cpp @@ -28,15 +28,9 @@ #include #include #include - -#ifdef USE_WEBENGINE -#include -#include -#else #include #include #include -#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(); } diff --git a/src/libs/ui/widgets/searchablewebview.h b/src/libs/ui/widgets/searchablewebview.h index 1b1f5bb..bb35457 100644 --- a/src/libs/ui/widgets/searchablewebview.h +++ b/src/libs/ui/widgets/searchablewebview.h @@ -28,13 +28,7 @@ class QLineEdit; - -#ifdef USE_WEBENGINE -class QWebEnginePage; -typedef QWebEnginePage QWebPage; -#else class QWebPage; -#endif class WebView; diff --git a/src/libs/ui/widgets/webview.cpp b/src/libs/ui/widgets/webview.cpp index bcb132a..9b1f958 100644 --- a/src/libs/ui/widgets/webview.cpp +++ b/src/libs/ui/widgets/webview.cpp @@ -26,11 +26,8 @@ #include "../mainwindow.h" #include -#include - -#ifndef USE_WEBENGINE #include -#endif +#include 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() { diff --git a/src/libs/ui/widgets/webview.h b/src/libs/ui/widgets/webview.h index ae2d87f..1b592d5 100644 --- a/src/libs/ui/widgets/webview.h +++ b/src/libs/ui/widgets/webview.h @@ -24,15 +24,7 @@ #ifndef WEBVIEW_H #define WEBVIEW_H -#ifdef USE_WEBENGINE -#include -#include - -typedef QWebEnginePage QWebPage; -typedef QWebEngineView QWebView; -#else #include -#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; };