properly detect and enable Qt6 WebEngine integration

Signed-off-by: Matthieu Gallien <matthieu.gallien@nextcloud.com>
This commit is contained in:
Matthieu Gallien 2024-08-26 19:11:33 +02:00 committed by Matthieu Gallien
parent 7eecc034d1
commit 7a979c732a
9 changed files with 62 additions and 46 deletions

View file

@ -243,10 +243,41 @@ if(BUILD_CLIENT)
endif()
endif()
if (APPLE)
option(BUILD_WITH_WEBENGINE "BUILD_WITH_WEBENGINE" OFF)
else ()
option(BUILD_WITH_WEBENGINE "BUILD_WITH_WEBENGINE" ON)
if (BUILD_WITH_WEBENGINE)
find_package(Qt${QT_VERSION_MAJOR}WebEngineCore ${REQUIRED_QT_VERSION} CONFIG QUIET)
if(APPLE)
set_package_properties(Qt${QT_VERSION_MAJOR}WebEngineCore PROPERTIES
DESCRIPTION "Qt${QT_VERSION_MAJOR} WebEngineCore component."
TYPE RECOMMENDED
)
else()
set_package_properties(Qt${QT_VERSION_MAJOR}WebEngineCore PROPERTIES
DESCRIPTION "Qt${QT_VERSION_MAJOR} WebEngine component."
TYPE REQUIRED
)
endif()
find_package(Qt${QT_MAJOR_VERSION}WebEngineWidgets ${REQUIRED_QT_VERSION} CONFIG QUIET)
if(APPLE)
set_package_properties(Qt${QT_MAJOR_VERSION}WebEngineWidgets PROPERTIES
DESCRIPTION "Qt${QT_MAJOR_VERSION} WebEngineWidgets component."
TYPE RECOMMENDED
)
else()
set_package_properties(Qt${QT_MAJOR_VERSION}WebEngineWidgets PROPERTIES
DESCRIPTION "Qt${QT_MAJOR_VERSION} WebEngineWidgets component."
TYPE REQUIRED
)
endif()
if(Qt${QT_MAJOR_VERSION}WebEngineCore_FOUND AND Qt${QT_MAJOR_VERSION}WebEngineWidgets_FOUND)
message(STATUS "Enable use of Qt6 WebEngine module")
set(WITH_WEBENGINE 1)
else()
unset(WITH_WEBENGINE)
message(STATUS "Disable use of Qt6 WebEngine module")
endif()
endif()
if (NOT DEFINED APPLICATION_ICON_NAME)

View file

@ -63,4 +63,6 @@
#cmakedefine01 NEXTCLOUD_DEV
#cmakedefine WITH_WEBENGINE
#endif

View file

@ -1,6 +1,6 @@
include(ECMEnableSanitizers)
set(REQUIRED_QT_VERSION "5.15.0")
set(REQUIRED_QT_VERSION "6.5.0")
find_package(Qt${QT_MAJOR_VERSION}Core ${REQUIRED_QT_VERSION} CONFIG QUIET)
set_package_properties(Qt${QT_MAJOR_VERSION}Core PROPERTIES
@ -38,36 +38,6 @@ find_package(Qt${QT_VERSION_MAJOR}Core5Compat ${REQUIRED_QT_VERSION} CONFIG QUIE
TYPE REQUIRED
)
find_package(Qt${QT_MAJOR_VERSION}WebEngineWidgets ${REQUIRED_QT_VERSION} CONFIG QUIET)
if(NOT BUILD_WITH_WEBENGINE)
set_package_properties(Qt${QT_MAJOR_VERSION}WebEngineWidgets PROPERTIES
DESCRIPTION "Qt${QT_MAJOR_VERSION} WebEngineWidgets component."
TYPE RECOMMENDED
)
else()
set_package_properties(Qt${QT_MAJOR_VERSION}WebEngineWidgets PROPERTIES
DESCRIPTION "Qt${QT_MAJOR_VERSION} WebEngineWidgets component."
TYPE REQUIRED
)
endif()
find_package(Qt${QT_VERSION_MAJOR}WebEngineCore ${REQUIRED_QT_VERSION} CONFIG QUIET)
if(APPLE)
set_package_properties(Qt${QT_VERSION_MAJOR}WebEngineCore PROPERTIES
DESCRIPTION "Qt${QT_VERSION_MAJOR} WebEngineCore component."
TYPE RECOMMENDED
)
else()
set_package_properties(Qt${QT_VERSION_MAJOR}WebEngine PROPERTIES
DESCRIPTION "Qt${QT_VERSION_MAJOR} WebEngine component."
TYPE REQUIRED
)
endif()
if(Qt${QT_MAJOR_VERSION}WebEngine_FOUND AND Qt${QT_MAJOR_VERSION}WebEngineWidgets_FOUND)
add_compile_definitions(WITH_WEBENGINE=1)
endif()
get_target_property (QT_QMAKE_EXECUTABLE Qt::qmake IMPORTED_LOCATION)
message(STATUS "Using Qt ${Qt${QT_MAJOR_VERSION}Core_VERSION} (${QT_QMAKE_EXECUTABLE})")

View file

@ -251,7 +251,7 @@ set(client_SRCS
wizard/linklabel.cpp
)
if (Qt${QT_MAJOR_VERSION}WebEngine_FOUND AND Qt${QT_MAJOR_VERSION}WebEngineWidgets_FOUND)
if (WITH_WEBENGINE)
list(APPEND client_SRCS
wizard/webviewpage.h
wizard/webviewpage.cpp
@ -581,8 +581,8 @@ foreach(FILE IN LISTS client_UI_SRCS)
set_property(SOURCE ${FILE} PROPERTY SKIP_UNITY_BUILD_INCLUSION ON)
endforeach()
if(Qt6WebEngine_FOUND AND Qt6WebEngineWidgets_FOUND)
target_link_libraries(nextcloudCore PUBLIC Qt::WebEngineWidgets)
if(WITH_WEBENGINE)
target_link_libraries(nextcloudCore PUBLIC Qt::WebEngineWidgets Qt::WebEngineCore)
endif()
set_target_properties(nextcloudCore

View file

@ -1,17 +1,21 @@
#include "webflowcredentialsdialog.h"
#include <QVBoxLayout>
#include <QLabel>
#include "config.h"
#include "theme.h"
#include "application.h"
#include "owncloudgui.h"
#include "wizard/owncloudwizardcommon.h"
#ifdef WITH_WEBENGINE
#include "wizard/webview.h"
#endif // WITH_WEBENGINE
#include "wizard/flow2authwidget.h"
#include <QVBoxLayout>
#include <QLabel>
namespace OCC {
WebFlowCredentialsDialog::WebFlowCredentialsDialog(Account *account, bool useFlow2, QWidget *parent)

View file

@ -1,12 +1,14 @@
#ifndef WEBFLOWCREDENTIALSDIALOG_H
#define WEBFLOWCREDENTIALSDIALOG_H
#include <QDialog>
#include <QUrl>
#include "config.h"
#include "accountfwd.h"
#include "creds/flow2auth.h"
#include <QDialog>
#include <QUrl>
class QLabel;
class QVBoxLayout;

View file

@ -16,6 +16,8 @@
#ifndef MIRALL_OWNCLOUD_WIZARD_COMMON_H
#define MIRALL_OWNCLOUD_WIZARD_COMMON_H
#include "config.h"
#include <QString>
class QVariant;

View file

@ -51,7 +51,7 @@ public:
void setUrl(const QUrl &url);
protected:
bool certificateError(const QWebEngineCertificateError &certificateError) override;
bool slotCertificateError(const QWebEngineCertificateError &certificateError);
bool acceptNavigationRequest(const QUrl &url, QWebEnginePage::NavigationType type, bool isMainFrame) override;
@ -202,8 +202,11 @@ void WebViewPageUrlSchemeHandler::requestStarted(QWebEngineUrlRequestJob *reques
}
WebEnginePage::WebEnginePage(QWebEngineProfile *profile, QObject* parent) : QWebEnginePage(profile, parent) {
WebEnginePage::WebEnginePage(QWebEngineProfile *profile, QObject* parent)
: QWebEnginePage(profile, parent)
{
connect(this, &QWebEnginePage::certificateError,
this, &WebEnginePage::slotCertificateError);
}
QWebEnginePage * WebEnginePage::createWindow(QWebEnginePage::WebWindowType type) {
@ -218,7 +221,7 @@ void WebEnginePage::setUrl(const QUrl &url)
_enforceHttps = url.scheme() == QStringLiteral("https");
}
bool WebEnginePage::certificateError(const QWebEngineCertificateError &certificateError)
bool WebEnginePage::slotCertificateError(const QWebEngineCertificateError &certificateError)
{
/**
* TODO properly improve this.

View file

@ -16,6 +16,8 @@
#ifndef NETWORKJOBS_H
#define NETWORKJOBS_H
#include "config.h"
#include "abstractnetworkjob.h"
#include "common/result.h"