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 коммит произвёл Matthieu Gallien
Родитель 7eecc034d1
Коммит 7a979c732a
9 изменённых файлов: 62 добавлений и 46 удалений

Просмотреть файл

@ -243,10 +243,41 @@ if(BUILD_CLIENT)
endif() endif()
endif() endif()
if (APPLE) option(BUILD_WITH_WEBENGINE "BUILD_WITH_WEBENGINE" ON)
option(BUILD_WITH_WEBENGINE "BUILD_WITH_WEBENGINE" OFF) if (BUILD_WITH_WEBENGINE)
else () find_package(Qt${QT_VERSION_MAJOR}WebEngineCore ${REQUIRED_QT_VERSION} CONFIG QUIET)
option(BUILD_WITH_WEBENGINE "BUILD_WITH_WEBENGINE" ON) 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() endif()
if (NOT DEFINED APPLICATION_ICON_NAME) if (NOT DEFINED APPLICATION_ICON_NAME)

Просмотреть файл

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

Просмотреть файл

@ -1,6 +1,6 @@
include(ECMEnableSanitizers) 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) find_package(Qt${QT_MAJOR_VERSION}Core ${REQUIRED_QT_VERSION} CONFIG QUIET)
set_package_properties(Qt${QT_MAJOR_VERSION}Core PROPERTIES 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 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) get_target_property (QT_QMAKE_EXECUTABLE Qt::qmake IMPORTED_LOCATION)
message(STATUS "Using Qt ${Qt${QT_MAJOR_VERSION}Core_VERSION} (${QT_QMAKE_EXECUTABLE})") message(STATUS "Using Qt ${Qt${QT_MAJOR_VERSION}Core_VERSION} (${QT_QMAKE_EXECUTABLE})")

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

@ -51,7 +51,7 @@ public:
void setUrl(const QUrl &url); void setUrl(const QUrl &url);
protected: protected:
bool certificateError(const QWebEngineCertificateError &certificateError) override; bool slotCertificateError(const QWebEngineCertificateError &certificateError);
bool acceptNavigationRequest(const QUrl &url, QWebEnginePage::NavigationType type, bool isMainFrame) override; 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) { QWebEnginePage * WebEnginePage::createWindow(QWebEnginePage::WebWindowType type) {
@ -218,7 +221,7 @@ void WebEnginePage::setUrl(const QUrl &url)
_enforceHttps = url.scheme() == QStringLiteral("https"); _enforceHttps = url.scheme() == QStringLiteral("https");
} }
bool WebEnginePage::certificateError(const QWebEngineCertificateError &certificateError) bool WebEnginePage::slotCertificateError(const QWebEngineCertificateError &certificateError)
{ {
/** /**
* TODO properly improve this. * TODO properly improve this.

Просмотреть файл

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