1
mirror of https://invent.kde.org/network/falkon.git synced 2024-09-21 09:42:10 +02:00

Use QTWEBENGINE_VERSION instead of QT_VERSION

Allows to build against separate QtWebEngine releases.
This commit is contained in:
David Rosca 2018-05-14 13:53:05 +02:00
parent e01024942f
commit 148d2d94c1
No known key found for this signature in database
GPG Key ID: EBC3FC294452C6D8
12 changed files with 19 additions and 20 deletions

View File

@ -45,7 +45,7 @@ add_definitions(-DQT_NO_URL_CAST_FROM_STRING -DQT_USE_QSTRINGBUILDER -DQT_NO_CAS
# Mandatory: Qt5 # Mandatory: Qt5
set(QT_MIN_VERSION "5.9.0") set(QT_MIN_VERSION "5.9.0")
find_package(Qt5 ${QT_MIN_VERSION} REQUIRED COMPONENTS Core Widgets Network Sql QuickWidgets PrintSupport WebEngineWidgets WebChannel) find_package(Qt5 ${QT_MIN_VERSION} REQUIRED COMPONENTS Core Widgets Network Sql QuickWidgets PrintSupport WebEngine WebEngineWidgets WebChannel)
if (BUILD_TESTING) if (BUILD_TESTING)
find_package(Qt5 ${QT_MIN_VERSION} REQUIRED COMPONENTS Test) find_package(Qt5 ${QT_MIN_VERSION} REQUIRED COMPONENTS Test)
endif() endif()
@ -85,8 +85,6 @@ if (WIN32)
add_definitions(-D_WIN32_WINNT=${ver}) add_definitions(-D_WIN32_WINNT=${ver})
endif() endif()
set(HAVE_QTWEBENGINE_5_10 NOT Qt5WebEngineWidgets_VERSION VERSION_LESS 5.10.0)
# Mandatory: OpenSSL # Mandatory: OpenSSL
find_package(OpenSSL REQUIRED) find_package(OpenSSL REQUIRED)

View File

@ -9,6 +9,3 @@
/* Disable DBus support */ /* Disable DBus support */
#cmakedefine DISABLE_DBUS #cmakedefine DISABLE_DBUS
/* QtWebEngine is at least version 5.10 */
#cmakedefine01 HAVE_QTWEBENGINE_5_10

View File

@ -293,6 +293,9 @@ qt5_add_resources(SRCS
add_library(FalkonPrivate SHARED ${SRCS}) add_library(FalkonPrivate SHARED ${SRCS})
get_property(QT_WEBENGINE_INCLUDE_DIRS TARGET Qt5::WebEngine PROPERTY INTERFACE_INCLUDE_DIRECTORIES)
target_include_directories(FalkonPrivate SYSTEM PUBLIC ${QT_WEBENGINE_INCLUDE_DIRS})
target_link_libraries(FalkonPrivate target_link_libraries(FalkonPrivate
Qt5::Widgets Qt5::Widgets
Qt5::WebEngineWidgets Qt5::WebEngineWidgets

View File

@ -921,11 +921,11 @@ void MainApplication::loadSettings()
webSettings->setAttribute(QWebEngineSettings::LocalContentCanAccessRemoteUrls, true); webSettings->setAttribute(QWebEngineSettings::LocalContentCanAccessRemoteUrls, true);
webSettings->setAttribute(QWebEngineSettings::FocusOnNavigationEnabled, false); webSettings->setAttribute(QWebEngineSettings::FocusOnNavigationEnabled, false);
#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0) #if QTWEBENGINE_VERSION >= QT_VERSION_CHECK(5, 10, 0)
webSettings->setAttribute(QWebEngineSettings::AllowWindowActivationFromJavaScript, settings.value("allowJavaScriptActivateWindow", false).toBool()); webSettings->setAttribute(QWebEngineSettings::AllowWindowActivationFromJavaScript, settings.value("allowJavaScriptActivateWindow", false).toBool());
#endif #endif
#if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0) #if QTWEBENGINE_VERSION >= QT_VERSION_CHECK(5, 11, 0)
webSettings->setAttribute(QWebEngineSettings::JavascriptCanPaste, settings.value("allowJavaScriptPaste", true).toBool()); webSettings->setAttribute(QWebEngineSettings::JavascriptCanPaste, settings.value("allowJavaScriptPaste", true).toBool());
webSettings->setAttribute(QWebEngineSettings::PlaybackRequiresUserGesture, settings.value("DisableVideoAutoPlay", false).toBool()); webSettings->setAttribute(QWebEngineSettings::PlaybackRequiresUserGesture, settings.value("DisableVideoAutoPlay", false).toBool());
webSettings->setAttribute(QWebEngineSettings::WebRTCPublicInterfacesOnly, settings.value("WebRTCPublicIpOnly", true).toBool()); webSettings->setAttribute(QWebEngineSettings::WebRTCPublicInterfacesOnly, settings.value("WebRTCPublicIpOnly", true).toBool());

View File

@ -20,6 +20,7 @@
#include <QDebug> #include <QDebug>
#include <QFlags> #include <QFlags>
#include <QtWebEngineVersion>
#ifdef FALKON_SHAREDLIBRARY #ifdef FALKON_SHAREDLIBRARY
#define FALKON_EXPORT Q_DECL_EXPORT #define FALKON_EXPORT Q_DECL_EXPORT

View File

@ -36,7 +36,7 @@ CookieJar::CookieJar(QObject* parent)
loadSettings(); loadSettings();
m_client->loadAllCookies(); m_client->loadAllCookies();
#if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0) #if QTWEBENGINE_VERSION >= QT_VERSION_CHECK(5, 11, 0)
m_client->setCookieFilter(std::bind(&CookieJar::cookieFilter, this, std::placeholders::_1)); m_client->setCookieFilter(std::bind(&CookieJar::cookieFilter, this, std::placeholders::_1));
#endif #endif
@ -46,7 +46,7 @@ CookieJar::CookieJar(QObject* parent)
CookieJar::~CookieJar() CookieJar::~CookieJar()
{ {
#if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0) #if QTWEBENGINE_VERSION >= QT_VERSION_CHECK(5, 11, 0)
m_client->setCookieFilter(nullptr); m_client->setCookieFilter(nullptr);
#endif #endif
} }
@ -127,7 +127,7 @@ void CookieJar::slotCookieRemoved(const QNetworkCookie &cookie)
emit cookieRemoved(cookie); emit cookieRemoved(cookie);
} }
#if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0) #if QTWEBENGINE_VERSION >= QT_VERSION_CHECK(5, 11, 0)
bool CookieJar::cookieFilter(const QWebEngineCookieStore::FilterRequest &request) const bool CookieJar::cookieFilter(const QWebEngineCookieStore::FilterRequest &request) const
{ {
if (!m_allowCookies) { if (!m_allowCookies) {

View File

@ -55,7 +55,7 @@ private:
void slotCookieAdded(const QNetworkCookie &cookie); void slotCookieAdded(const QNetworkCookie &cookie);
void slotCookieRemoved(const QNetworkCookie &cookie); void slotCookieRemoved(const QNetworkCookie &cookie);
#if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0) #if QTWEBENGINE_VERSION >= QT_VERSION_CHECK(5, 11, 0)
bool cookieFilter(const QWebEngineCookieStore::FilterRequest &request) const; bool cookieFilter(const QWebEngineCookieStore::FilterRequest &request) const;
#endif #endif

View File

@ -75,7 +75,7 @@ CookieManager::CookieManager(QWidget *parent)
ui->blackList->addItems(settings.value("blacklist", QStringList()).toStringList()); ui->blackList->addItems(settings.value("blacklist", QStringList()).toStringList());
settings.endGroup(); settings.endGroup();
#if QT_VERSION < QT_VERSION_CHECK(5, 11, 0) #if QTWEBENGINE_VERSION < QT_VERSION_CHECK(5, 11, 0)
ui->filter3rdParty->hide(); ui->filter3rdParty->hide();
#endif #endif

View File

@ -29,11 +29,11 @@ JsOptions::JsOptions(QWidget* parent)
ui->setupUi(this); ui->setupUi(this);
#if QT_VERSION < QT_VERSION_CHECK(5, 10, 0) #if QTWEBENGINE_VERSION < QT_VERSION_CHECK(5, 10, 0)
ui->jscanActivateWindow->setVisible(false); ui->jscanActivateWindow->setVisible(false);
#endif #endif
#if QT_VERSION < QT_VERSION_CHECK(5, 11, 0) #if QTWEBENGINE_VERSION < QT_VERSION_CHECK(5, 11, 0)
ui->jscanPaste->setVisible(false); ui->jscanPaste->setVisible(false);
#endif #endif

View File

@ -110,7 +110,7 @@ Preferences::Preferences(BrowserWindow* window)
ui->checkUpdates->setVisible(false); ui->checkUpdates->setVisible(false);
#endif #endif
#if QT_VERSION < QT_VERSION_CHECK(5, 11, 0) #if QTWEBENGINE_VERSION < QT_VERSION_CHECK(5, 11, 0)
ui->disableVideoAutoPlay->setVisible(false); ui->disableVideoAutoPlay->setVisible(false);
ui->webRTCPublicIpOnly->setVisible(false); ui->webRTCPublicIpOnly->setVisible(false);
#endif #endif

View File

@ -67,7 +67,7 @@ void WebInspector::setView(WebView *view)
m_view = view; m_view = view;
Q_ASSERT(isEnabled()); Q_ASSERT(isEnabled());
#if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0) #if QTWEBENGINE_VERSION >= QT_VERSION_CHECK(5, 11, 0)
page()->setInspectedPage(m_view->page()); page()->setInspectedPage(m_view->page());
connect(m_view, &WebView::pageChanged, this, &WebInspector::deleteLater); connect(m_view, &WebView::pageChanged, this, &WebInspector::deleteLater);
#else #else
@ -97,7 +97,7 @@ void WebInspector::inspectElement()
bool WebInspector::isEnabled() bool WebInspector::isEnabled()
{ {
#if QT_VERSION < QT_VERSION_CHECK(5, 11, 0) #if QTWEBENGINE_VERSION < QT_VERSION_CHECK(5, 11, 0)
if (!qEnvironmentVariableIsSet("QTWEBENGINE_REMOTE_DEBUGGING")) { if (!qEnvironmentVariableIsSet("QTWEBENGINE_REMOTE_DEBUGGING")) {
return false; return false;
} }

View File

@ -495,7 +495,7 @@ void WebView::copyLinkToClipboard()
void WebView::savePageAs() void WebView::savePageAs()
{ {
#if HAVE_QTWEBENGINE_5_10 #if QTWEBENGINE_VERSION >= QT_VERSION_CHECK(5, 10, 0)
page()->runJavaScript(QSL("document.contentType"), WebPage::SafeJsWorld, [this](const QVariant &res) { page()->runJavaScript(QSL("document.contentType"), WebPage::SafeJsWorld, [this](const QVariant &res) {
const QSet<QString> webPageTypes = { const QSet<QString> webPageTypes = {
QSL("text/html"), QSL("text/html"),
@ -1250,7 +1250,7 @@ void WebView::contextMenuEvent(QContextMenuEvent *event)
bool WebView::focusNextPrevChild(bool next) bool WebView::focusNextPrevChild(bool next)
{ {
#if QT_VERSION < QT_VERSION_CHECK(5, 11, 0) #if QTWEBENGINE_VERSION < QT_VERSION_CHECK(5, 11, 0)
// QTBUG-67043 // QTBUG-67043
// Workaround QtWebEngine issue where QWebEngineView loses focus on second load() call. // Workaround QtWebEngine issue where QWebEngineView loses focus on second load() call.
if (next) { if (next) {