Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

properly detect and enable Qt6 WebEngine integration #7030

Merged
merged 1 commit into from
Aug 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 35 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
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)
Expand Down
2 changes: 2 additions & 0 deletions config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,6 @@

#cmakedefine01 NEXTCLOUD_DEV

#cmakedefine WITH_WEBENGINE

#endif
32 changes: 1 addition & 31 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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})")

Expand Down
6 changes: 3 additions & 3 deletions src/gui/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
8 changes: 6 additions & 2 deletions src/gui/creds/webflowcredentialsdialog.cpp
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
#include "webflowcredentialsdialog.h"

Check notice on line 1 in src/gui/creds/webflowcredentialsdialog.cpp

View workflow job for this annotation

GitHub Actions / build

Run clang-format on src/gui/creds/webflowcredentialsdialog.cpp

File src/gui/creds/webflowcredentialsdialog.cpp does not conform to Custom style guidelines. (lines 16)

#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)
Expand Down
6 changes: 4 additions & 2 deletions src/gui/creds/webflowcredentialsdialog.h
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
#ifndef WEBFLOWCREDENTIALSDIALOG_H
#define WEBFLOWCREDENTIALSDIALOG_H

#include <QDialog>
#include <QUrl>
#include "config.h"

Check failure on line 4 in src/gui/creds/webflowcredentialsdialog.h

View workflow job for this annotation

GitHub Actions / build

src/gui/creds/webflowcredentialsdialog.h:4:10 [clang-diagnostic-error]

'config.h' file not found

#include "accountfwd.h"
#include "creds/flow2auth.h"

#include <QDialog>
#include <QUrl>

class QLabel;

Check warning on line 12 in src/gui/creds/webflowcredentialsdialog.h

View workflow job for this annotation

GitHub Actions / build

src/gui/creds/webflowcredentialsdialog.h:12:7 [cppcoreguidelines-avoid-non-const-global-variables]

variable 'QLabel' is non-const and globally accessible, consider making it const
class QVBoxLayout;

namespace OCC {
Expand Down
2 changes: 2 additions & 0 deletions src/gui/wizard/owncloudwizardcommon.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
#ifndef MIRALL_OWNCLOUD_WIZARD_COMMON_H
#define MIRALL_OWNCLOUD_WIZARD_COMMON_H

#include "config.h"

Check failure on line 19 in src/gui/wizard/owncloudwizardcommon.h

View workflow job for this annotation

GitHub Actions / build

src/gui/wizard/owncloudwizardcommon.h:19:10 [clang-diagnostic-error]

'config.h' file not found

#include <QString>

class QVariant;
Expand Down
11 changes: 7 additions & 4 deletions src/gui/wizard/webview.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "webview.h"

Check notice on line 1 in src/gui/wizard/webview.cpp

View workflow job for this annotation

GitHub Actions / build

Run clang-format on src/gui/wizard/webview.cpp

File src/gui/wizard/webview.cpp does not conform to Custom style guidelines. (lines 205, 208)

#include <QWebEnginePage>
#include <QWebEngineProfile>
Expand Down Expand Up @@ -51,7 +51,7 @@
void setUrl(const QUrl &url);

protected:
bool certificateError(const QWebEngineCertificateError &certificateError) override;
bool slotCertificateError(const QWebEngineCertificateError &certificateError);

Check warning on line 54 in src/gui/wizard/webview.cpp

View workflow job for this annotation

GitHub Actions / build

src/gui/wizard/webview.cpp:54:10 [modernize-use-trailing-return-type]

use a trailing return type for this function

bool acceptNavigationRequest(const QUrl &url, QWebEnginePage::NavigationType type, bool isMainFrame) override;

Expand Down Expand Up @@ -202,8 +202,11 @@
}


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) {
Expand All @@ -218,7 +221,7 @@
_enforceHttps = url.scheme() == QStringLiteral("https");
}

bool WebEnginePage::certificateError(const QWebEngineCertificateError &certificateError)
bool WebEnginePage::slotCertificateError(const QWebEngineCertificateError &certificateError)

Check warning on line 224 in src/gui/wizard/webview.cpp

View workflow job for this annotation

GitHub Actions / build

src/gui/wizard/webview.cpp:224:21 [modernize-use-trailing-return-type]

use a trailing return type for this function

Check warning on line 224 in src/gui/wizard/webview.cpp

View workflow job for this annotation

GitHub Actions / build

src/gui/wizard/webview.cpp:224:21 [readability-convert-member-functions-to-static]

method 'slotCertificateError' can be made static
{
/**
* TODO properly improve this.
Expand Down
2 changes: 2 additions & 0 deletions src/libsync/networkjobs.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
#ifndef NETWORKJOBS_H
#define NETWORKJOBS_H

#include "config.h"

Check failure on line 19 in src/libsync/networkjobs.h

View workflow job for this annotation

GitHub Actions / build

src/libsync/networkjobs.h:19:10 [clang-diagnostic-error]

'config.h' file not found

#include "abstractnetworkjob.h"

#include "common/result.h"
Expand Down
Loading