1
0
forked from pool/libksysguard5
libksysguard5/0001-Only-link-to-Qt5WebChannel-if-Qt5WebEngineWidgets-av.patch
Luca Beltrame 77e38c34fc Accepting request 780869 from home:Vogtinator:plasma5.18
- Add patch to fix build on archs where WebEngine is not available:
  * 0001-Only-link-to-Qt5WebChannel-if-Qt5WebEngineWidgets-av.patch

OBS-URL: https://build.opensuse.org/request/show/780869
OBS-URL: https://build.opensuse.org/package/show/KDE:Frameworks5/libksysguard5?expand=0&rev=248
2020-03-02 09:31:20 +00:00

185 lines
6.6 KiB
Diff

From ba7f78716af618db5556fc17e421397fe67e96af Mon Sep 17 00:00:00 2001
From: Fabian Vogt <fabian@ritter-vogt.de>
Date: Wed, 12 Feb 2020 15:17:43 +0100
Subject: [PATCH] Only link to Qt5WebChannel if Qt5WebEngineWidgets available
Summary:
QWebChannel is only used if WebEngine is also available.
This converts scripting support into an optional feature which is only enabled if both dependencies are available.
Test Plan: Still builds.
Reviewers: #plasma, davidedmundson
Reviewed By: #plasma, davidedmundson
Subscribers: lbeltrame, plasma-devel
Tags: #plasma
Differential Revision: https://phabricator.kde.org/D27347
---
CMakeLists.txt | 16 ++++++++++++++--
config-ksysguard.h.cmake | 4 ++--
processui/CMakeLists.txt | 5 ++---
processui/scripting.cpp | 12 ++++++------
processui/scripting.h | 2 +-
5 files changed, 25 insertions(+), 14 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 075d706..d5df87c 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -26,7 +26,7 @@ include(CheckIncludeFiles)
include(CheckLibraryExists)
include(FeatureSummary)
-find_package(Qt5 ${QT_MIN_VERSION} REQUIRED CONFIG COMPONENTS DBus Network Widgets WebChannel)
+find_package(Qt5 ${QT_MIN_VERSION} REQUIRED CONFIG COMPONENTS DBus Network Widgets)
find_package(Qt5WebEngineWidgets ${QT_MIN_VERSION} CONFIG)
set_package_properties(Qt5WebEngineWidgets PROPERTIES
URL "git://code.qt.org/qt/qtwebenginewidgets.git"
@@ -34,6 +34,13 @@ set_package_properties(Qt5WebEngineWidgets PROPERTIES
TYPE OPTIONAL
PURPOSE "Used by the HTML-based GUI ksysguard library"
)
+find_package(Qt5WebChannel ${QT_MIN_VERSION} CONFIG)
+set_package_properties(Qt5WebChannel PROPERTIES
+ URL "git://code.qt.org/qt/qtwebchannel.git"
+ DESCRIPTION "Qt WebChannel module"
+ TYPE OPTIONAL
+ PURPOSE "Used by the HTML-based GUI ksysguard library"
+ )
find_package(KF5 REQUIRED COMPONENTS CoreAddons Config I18n WindowSystem Completion Auth WidgetsAddons IconThemes ConfigWidgets Service GlobalAccel KIO)
find_package(KF5 OPTIONAL_COMPONENTS Plasma)
@@ -75,9 +82,14 @@ if(X11_FOUND)
endif()
endif()
+set(WEBENGINE_SCRIPTING_ENABLED FALSE)
+if(Qt5WebEngineWidgets_FOUND AND Qt5WebChannel_FOUND)
+ set(WEBENGINE_SCRIPTING_ENABLED TRUE)
+endif()
+add_feature_info("Scripting plugin support" WEBENGINE_SCRIPTING_ENABLED "Support scripting plugins using WebEngine and WebChannel")
+
set(HAVE_X11 ${X11_FOUND})
set(HAVE_XRES ${X11_XRes_FOUND})
-set(HAVE_QTWEBENGINEWIDGETS ${Qt5WebEngineWidgets_FOUND})
configure_file(config-ksysguard.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-ksysguard.h )
add_definitions(-DQT_NO_URL_CAST_FROM_STRING)
diff --git a/config-ksysguard.h.cmake b/config-ksysguard.h.cmake
index ad648f1..e040efc 100644
--- a/config-ksysguard.h.cmake
+++ b/config-ksysguard.h.cmake
@@ -10,8 +10,8 @@
/* Define to 1 if you have the X11 xres file */
#cmakedefine HAVE_XRES 1
-/* Define if you have QtWebEngineWidgets */
-#cmakedefine01 HAVE_QTWEBENGINEWIDGETS
+/* Define if you have QtWebEngineWidgets and QtWebChannel */
+#cmakedefine01 WEBENGINE_SCRIPTING_ENABLED
/* Define if you have X11 at all */
#cmakedefine01 HAVE_X11
diff --git a/processui/CMakeLists.txt b/processui/CMakeLists.txt
index 868ad1a..32c1591 100644
--- a/processui/CMakeLists.txt
+++ b/processui/CMakeLists.txt
@@ -37,7 +37,6 @@ target_link_libraries(processui
KF5::ConfigCore
PRIVATE
Qt5::DBus
- Qt5::WebChannel
KF5::I18n
KF5::WindowSystem
KF5::AuthCore
@@ -59,8 +58,8 @@ if(X11_FOUND)
target_link_libraries(processui PRIVATE Qt5::X11Extras KF5::WindowSystem)
endif()
-if(Qt5WebEngineWidgets_FOUND)
- target_link_libraries(processui PRIVATE Qt5::WebEngineWidgets)
+if(WEBENGINE_SCRIPTING_ENABLED)
+ target_link_libraries(processui PRIVATE Qt5::WebEngineWidgets Qt5::WebChannel)
endif()
if(NOT HAVE_CLOCK_GETTIME_C)
diff --git a/processui/scripting.cpp b/processui/scripting.cpp
index feda425..c481a18 100644
--- a/processui/scripting.cpp
+++ b/processui/scripting.cpp
@@ -43,7 +43,7 @@
#include <QMessageBox>
#include <QDialogButtonBox>
-#if HAVE_QTWEBENGINEWIDGETS
+#if WEBENGINE_SCRIPTING_ENABLED
#include <QWebChannel>
#include <QWebEngineSettings>
#include <QWebEngineView>
@@ -53,7 +53,7 @@
#include <qtwebenginewidgetsversion.h>
#endif
-#if HAVE_QTWEBENGINEWIDGETS
+#if WEBENGINE_SCRIPTING_ENABLED
class RemoteUrlInterceptor : public QWebEngineUrlRequestInterceptor {
public:
RemoteUrlInterceptor(QObject *parent) : QWebEngineUrlRequestInterceptor(parent) {}
@@ -81,7 +81,7 @@ class ScriptingHtmlDialog : public QDialog {
connect(buttonBox, &QDialogButtonBox::accepted, this, &QDialog::accept);
connect(buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject);
-#if HAVE_QTWEBENGINEWIDGETS
+#if WEBENGINE_SCRIPTING_ENABLED
QVBoxLayout *layout = new QVBoxLayout;
layout->addWidget(&m_webView);
layout->addWidget(buttonBox);
@@ -95,7 +95,7 @@ class ScriptingHtmlDialog : public QDialog {
#endif
#endif
}
-#if HAVE_QTWEBENGINEWIDGETS
+#if WEBENGINE_SCRIPTING_ENABLED
QWebEngineView *webView() {
return &m_webView;
}
@@ -134,7 +134,7 @@ void Scripting::runScript(const QString &path, const QString &name) {
mScriptPath = path;
mScriptName = name;
-#if HAVE_QTWEBENGINEWIDGETS
+#if WEBENGINE_SCRIPTING_ENABLED
QUrl fileName = QUrl::fromLocalFile(path + QStringLiteral("index.html"));
if(!mScriptingHtmlDialog) {
mScriptingHtmlDialog = new ScriptingHtmlDialog(this);
@@ -250,7 +250,7 @@ new QWebChannel(window.qt.webChannelTransport, function(channel) {
i18n("KSysGuard library was compiled without QtWebEngineWidgets, please contact your distribution."));
#endif
}
-#if HAVE_QTWEBENGINEWIDGETS
+#if WEBENGINE_SCRIPTING_ENABLED
void Scripting::zoomIn() {
QWebEngineView *webView = mScriptingHtmlDialog->webView();
webView->setZoomFactor( webView->zoomFactor() * 1.1 );
diff --git a/processui/scripting.h b/processui/scripting.h
index e9794da..b6ca5e3 100644
--- a/processui/scripting.h
+++ b/processui/scripting.h
@@ -56,7 +56,7 @@ class Scripting : public QWidget {
private Q_SLOTS:
/** Run the script associated with the QAction that called this slot */
void runScriptSlot();
-#if HAVE_QTWEBENGINEWIDGETS
+#if WEBENGINE_SCRIPTING_ENABLED
void setupJavascriptObjects();
void refreshScript();
void zoomIn();
--
2.25.1