diff --git a/CMakeLists.txt b/CMakeLists.txt --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -26,14 +26,21 @@ 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" DESCRIPTION "Qt WebEngine module (web browsing engine)" 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 @@ 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 --- 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 --- a/processui/CMakeLists.txt +++ b/processui/CMakeLists.txt @@ -37,7 +37,6 @@ KF5::ConfigCore PRIVATE Qt5::DBus - Qt5::WebChannel KF5::I18n KF5::WindowSystem KF5::AuthCore @@ -59,8 +58,8 @@ 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.h b/processui/scripting.h --- a/processui/scripting.h +++ b/processui/scripting.h @@ -56,7 +56,7 @@ 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(); diff --git a/processui/scripting.cpp b/processui/scripting.cpp --- a/processui/scripting.cpp +++ b/processui/scripting.cpp @@ -43,7 +43,7 @@ #include #include -#if HAVE_QTWEBENGINEWIDGETS +#if WEBENGINE_SCRIPTING_ENABLED #include #include #include @@ -53,7 +53,7 @@ #include #endif -#if HAVE_QTWEBENGINEWIDGETS +#if WEBENGINE_SCRIPTING_ENABLED class RemoteUrlInterceptor : public QWebEngineUrlRequestInterceptor { public: RemoteUrlInterceptor(QObject *parent) : QWebEngineUrlRequestInterceptor(parent) {} @@ -81,7 +81,7 @@ 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 @@ #endif #endif } -#if HAVE_QTWEBENGINEWIDGETS +#if WEBENGINE_SCRIPTING_ENABLED QWebEngineView *webView() { return &m_webView; } @@ -134,7 +134,7 @@ 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 @@ 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 );