[education/rkward] /: Allow to configure HTML engine to use

Thomas Friedrichsmeier null at kde.org
Thu Apr 9 20:44:24 BST 2026


Git commit f989f196d2c2d78482fd35109d8354b3aa4e9470 by Thomas Friedrichsmeier.
Committed on 09/04/2026 at 19:44.
Pushed by tfry into branch 'master'.

Allow to configure HTML engine to use

(at compiletime and at runtime)

M  +1    -1    .gitlab-ci.yml
M  +45   -2    CMakeLists.txt
M  +1    -0    ChangeLog
M  +8    -1    INSTALL
M  +2    -3    rkward/CMakeLists.txt
M  +23   -8    rkward/main.cpp
M  +1    -1    rkward/rkward.cpp
M  +1    -0    rkward/settings/CMakeLists.txt
M  +22   -3    rkward/settings/rksettingsmodulegeneral.cpp
M  +8    -0    rkward/settings/rksettingsmodulegeneral.h
M  +8    -1    rkward/windows/CMakeLists.txt
M  +21   -3    rkward/windows/rkhtmlviewer.cpp
M  +36   -34   rkward/windows/rkqwebenginewidget.cpp
M  +4    -2    rkward/windows/rkqwebenginewidget.h
M  +16   -14   rkward/windows/rkqwebview.cpp
M  +6    -4    rkward/windows/rkqwebview.h
M  +8    -6    rkward/windows/rkqwebview.js

https://invent.kde.org/education/rkward/-/commit/f989f196d2c2d78482fd35109d8354b3aa4e9470

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 1cf92fcc9..e994d096e 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -16,7 +16,7 @@ include:
 #      - /gitlab-templates/flatpak.yml // just a waste of CPU power in the current state
 
 # NOTE: This is meant to modify the default linux-qt6.yml-job, and currently it does. It will need to be updated once the underlying name changes, though
-suse_tumbleweed_qt610:
+suse_tumbleweed_qt611:
   script:
     - git config --global --add safe.directory $CI_PROJECT_DIR
     # no dlopen() loading, to get at better symbol information for the backend process from ASAN
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 9e4c80a63..96d0472c0 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -27,10 +27,47 @@ INCLUDE(ECMAddAppIcon)
 INCLUDE(ECMMarkNonGuiExecutable)
 INCLUDE(FeatureSummary)
 
-FIND_PACKAGE(Qt6 6.6 CONFIG REQUIRED COMPONENTS Widgets Core Xml Network Qml PrintSupport WebEngineWidgets WebView WebSockets)
+OPTION(FORCE_WITH_QWEBENGINE "Build QWebEngine based HTML renderer (overrides automatic selection)" OFF)
+ADD_FEATURE_INFO("FORCE_WITH_QWEBENGINE: Build QWebEngine based HTML renderer" FORCE_WITH_QWEBENGINE "Override automatic detection of with HTML render to build for. Setting this option to ON implies that no other HTML renderer support is compiled, unless it is also specified with the corresponding option (see FORCE_WITH_QWEBVIEW).")
+
+OPTION(FORCE_WITH_QWEBVIEW "Build QWebView based HTML renderer (overrides automatic selection)" OFF)
+ADD_FEATURE_INFO("FORCE_WITH_QWEBVIEW: Build QWebView based HTML renderer" FORCE_WITH_QWEBVIEW "Override automatic detection of with HTML render to build for. Setting this option to ON implies that no other HTML renderer support is compiled, unless it is also specified with the corresponding option (see FORCE_WITH_QWEBENGINE).")
+
+OPTION(DLOPEN_RLIB "dlopen the R library at runtime rather than linking it" ON)
+ADD_FEATURE_INFO("DLOPEN_RLIB: dlopen() R library" DLOPEN_RLIB "This feature allows more flexibility in using a different R installation at runtime than at compile time.")
+
+SET(REQUIRED_QT6_LIBS Widgets Core Xml Network Qml PrintSupport)
+SET(OPTIONAL_QT6_LIBS)
+IF(FORCE_WITH_QWEBENGINE)
+  LIST(APPEND REQUIRED_QT6_LIBS WebEngineWidgets)
+ELSE()
+  LIST(APPEND OPTIONAL_QT6_LIBS WebEngineWidgets)
+ENDIF()
+IF(FORCE_WITH_QWEBVIEW)
+  LIST(APPEND REQUIRED_QT6_LIBS WebView WebSockets)
+ELSE()
+  LIST(APPEND OPTIONAL_QT6_LIBS WebView WebSockets)
+ENDIF()
+
+FIND_PACKAGE(Qt6 6.6 CONFIG REQUIRED COMPONENTS ${REQUIRED_QT6_LIBS} OPTIONAL_COMPONENTS ${OPTIONAL_QT6_LIBS})
 FIND_PACKAGE(KF6 6.0.0 REQUIRED COMPONENTS CoreAddons DocTools I18n XmlGui TextEditor WidgetsAddons Parts Config Notifications WindowSystem Archive BreezeIcons OPTIONAL_COMPONENTS Crash)
 FIND_PACKAGE(Gettext REQUIRED)
 
+if(Qt6WebEngineWidgets_FOUND AND (${FORCE_WITH_QWEBENGINE} OR NOT ${FORCE_WITH_QWEBVIEW}))
+  set(WITH_QWEBENGINE ON)
+  set(RK_QWEBENGINE_FLAGS -DRK_WITH_QWEBENGINE=1)
+else()
+  set(WITH_QWEBENGINE OFF)
+  set(RK_QWEBENGINE_FLAGS -DRK_WITH_QWEBENGINE=0)
+endif()
+if(Qt6WebView_FOUND AND Qt6WebSockets_FOUND AND (${FORCE_WITH_QWEBVIEW} OR NOT ${FORCE_WITH_QWEBENGINE}))
+  set(WITH_QWEBVIEW ON)
+  set(RK_QWEBVIEW_FLAGS -DRK_WITH_QWEBVIEW=1)
+else()
+  set(WITH_QWEBVIEW OFF)
+  set(RK_QWEBVIEW_FLAGS -DRK_WITH_QWEBVIEW=0)
+endif()
+
 if(NOT WIN32) # will apparently pick up trash, on Windows, sometimes
   FIND_PACKAGE(KDSingleApplication-qt6 1.1.0 QUIET)
 endif()
@@ -57,4 +94,10 @@ ADD_SUBDIRECTORY(tests)
 KI18N_INSTALL(po)
 KDOCTOOLS_INSTALL(po)
 
-FEATURE_SUMMARY(WHAT ALL FATAL_ON_MISSING_REQUIRED_PACKAGES)
+FEATURE_SUMMARY(WHAT ENABLED_FEATURES DISABLED_FEATURES)
+FEATURE_SUMMARY(WHAT PACKAGES_FOUND PACKAGES_NOT_FOUND FATAL_ON_MISSING_REQUIRED_PACKAGES)
+message(STATUS "QWebView support: ${WITH_QWEBVIEW}")
+message(STATUS "QWebEngine support: ${WITH_QWEBENGINE}")
+if(NOT (WITH_QWEBVIEW OR WITH_QWEBENGINE))
+  message(FATAL_ERROR "Found no suitable HTML renderer. Please install either the QWebEngineWidgets library or QWebView and QWebSockets.")
+endif()
diff --git a/ChangeLog b/ChangeLog
index ba5649f65..8e45e5b73 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,5 @@
 --- Version 0.8.3 - UNRELEASED
+- Added: Support HTML rendering with QWebView, which allows to use native renderers on some platforms
 - Fixed: Crash when splitting view on a data.frame editor window
 - Fixed: Allow compilation with the upcoming R 4.6
 - Fixed: Horizontal text alignment would be inaccurate for some symbols in RK() device
diff --git a/INSTALL b/INSTALL
index fa927ef4f..44c73378a 100644
--- a/INSTALL
+++ b/INSTALL
@@ -43,9 +43,16 @@ In some cases you may want to set the following options:
 -DUSE_BINARY_PACKAGES
 	Currently only interpreted on Mac OS: If RKWard should default to installing binary R packages (if available) use
 	-DUSE_BINARY_PACKAGE=1. Otherwise, RKWard will default to building R packages from source.
--DDLOPEN_RLIB
+-DDLOPEN_RLIB=OFF
 	By default, the backend code is loaded using dlopen() to avoid certain runtime conflicts, esp. in distributed AppImages. This, however, makes it hard to
 	get at proper debug symbol information. For debugging purposes it may thus be useful to set this to "0", explictly
+-DFORCE_WITH_QWEBENGINE=ON
+	RKWard supports two HTML rendering libraries, QWebEngine or QWebView. By default, either - or both - will be selected automatically, based on the
+	presence of the required libaries. Use this (and/or -DFORCE_WOTH_QWEBVIEW) to override the automatic selction. Setting either öf these options to ON
+	will disable building against the other library *unless* that is also specified with FORCE_WITH_XYZ.
+	Packagers please note that, on Linux, using QWebView currently still requires a runtime dependency on QWebEngine, as no native rendering plugin is
+	available in Qt at the time of this writing.
+-DFORCE_WITH_QWEBVIEW=ON
 
 Further generic options are listed on http://www.cmake.org/Wiki/CMake_Useful_Variables .
 
diff --git a/rkward/CMakeLists.txt b/rkward/CMakeLists.txt
index 4908273b1..f841df621 100644
--- a/rkward/CMakeLists.txt
+++ b/rkward/CMakeLists.txt
@@ -8,9 +8,6 @@ ENDIF(NOT ${PROJECT_NAME} STREQUAL "rkward")
 
 INCLUDE(SetVersionNumber.cmake)
 
-OPTION(DLOPEN_RLIB "dlopen the R library at runtime rather than linking it" ON)
-ADD_FEATURE_INFO("DLOPEN_RLIB: dlopen() R library" DLOPEN_RLIB "This feature allows more flexibility in using a different R installation at runtime than at compile time.")
-
 ADD_SUBDIRECTORY( dataeditor )
 ADD_SUBDIRECTORY( settings )
 ADD_SUBDIRECTORY( plugin )
@@ -55,6 +52,8 @@ ADD_EXECUTABLE(rkward ${RKWard_App_Sources})
 TARGET_COMPILE_DEFINITIONS(rkward PUBLIC -DINSTALL_PATH="${CMAKE_INSTALL_PREFIX}")
 FILE(RELATIVE_PATH RelPathToData /${KDE_INSTALL_BINDIR} /${KDE_INSTALL_DATADIR})
 TARGET_COMPILE_DEFINITIONS(rkward PUBLIC -DREL_PATH_TO_DATA="${RelPathToData}")
+TARGET_COMPILE_DEFINITIONS(rkward PUBLIC ${RK_QWEBENGINE_FLAGS} ${RK_QWEBVIEW_FLAGS})
+TARGET_COMPILE_DEFINITIONS(rkward_lib PUBLIC ${RK_QWEBENGINE_FLAGS} ${RK_QWEBVIEW_FLAGS})
 TARGET_LINK_LIBRARIES(rkward rkward_lib)
 IF(KF6Crash_FOUND)
 	TARGET_LINK_LIBRARIES(rkward KF6::Crash)
diff --git a/rkward/main.cpp b/rkward/main.cpp
index 61b494637..ada3a2d31 100644
--- a/rkward/main.cpp
+++ b/rkward/main.cpp
@@ -59,7 +59,6 @@ SPDX-License-Identifier: GPL-2.0-or-later
 #include <QThread>
 #include <QTime>
 #include <QUrl>
-#include <QtWebView>
 
 #include <stdio.h>
 #include <stdlib.h>
@@ -136,26 +135,42 @@ void RKDebug(int flags, int level, const char *fmt, ...) {
 	}
 }
 
-#include <QWebEngineUrlScheme>
-
-int main(int argc, char *argv[]) {
-	RK_Debug::RK_Debug_Level = DL_WARNING;
-#if defined(Q_OS_MACOS)
+#if RK_WITH_QWEBENGINE
+#	include <QWebEngineUrlScheme>
+static void setupWebEngine() {
+#	if defined(Q_OS_MACOS)
 	// TODO: This is just a hackish workaround. See https://invent.kde.org/education/rkward/-/issues/28
 	const char *chromiumflags = "QTWEBENGINE_CHROMIUM_FLAGS";
 	if (!qEnvironmentVariableIsSet(chromiumflags)) {
 		qputenv(chromiumflags, "--no-sandbox --single-process --enable-features=NetworkServiceInProcess");
 	}
-#endif
+#	endif
 
 	// annoyingly, QWebEngineUrlSchemes have to be registered before creating the app.
 	QWebEngineUrlScheme scheme("help");
 	scheme.setSyntax(QWebEngineUrlScheme::Syntax::Path);
 	scheme.setFlags(QWebEngineUrlScheme::LocalAccessAllowed);
 	QWebEngineUrlScheme::registerScheme(scheme);
+}
+#else
+static void setupWebEngine() {}
+#endif
+
+#if RK_WITH_QWEBVIEW
+#	include <QtWebView>
+static void setupWebView() {
+	QtWebView::initialize();
+}
+#else
+static void setupWebView() {}
+#endif
+
+int main(int argc, char *argv[]) {
+	RK_Debug::RK_Debug_Level = DL_WARNING;
+	setupWebEngine();
+	setupWebView();
 	BreezeIcons::initIcons(); // install as fallback theme. Too many issues with missing icons, otherwise
 	QApplication app(argc, argv);
-	QtWebView::initialize();
 	KDSingleApplication app_singleton;
 #if defined(Q_OS_MACOS) || defined(Q_OS_WIN)
 	// Follow the example of kate, and use breeze theme on Windows and Mac, which appears to work best
diff --git a/rkward/rkward.cpp b/rkward/rkward.cpp
index f9cdcdb18..b23300e17 100644
--- a/rkward/rkward.cpp
+++ b/rkward/rkward.cpp
@@ -185,7 +185,7 @@ RKWardMainWindow::RKWardMainWindow() : KParts::MainWindow() {
 	RKComponentMap::initialize();
 
 	// stuff which should wait until the event loop is running
-#if defined(Q_OS_WIN)
+#if RK_WITH_QWEBENGINE && defined(Q_OS_WIN)
 	// HACK FIXME
 	// This is a very bad workaround around a very hideous QtWebEngine bug on Windows. Surfaced for us with the switch to Qt 6.9:
 	// crash in the QWebEnginePage c'tor, if that is invoked too soon after start *and* application was not started from the
diff --git a/rkward/settings/CMakeLists.txt b/rkward/settings/CMakeLists.txt
index 6ab40365a..516ebbad3 100644
--- a/rkward/settings/CMakeLists.txt
+++ b/rkward/settings/CMakeLists.txt
@@ -34,4 +34,5 @@ IF (WIN32 OR USE_BINARY_PACKAGES)
 ENDIF (WIN32 OR USE_BINARY_PACKAGES)
 
 ADD_LIBRARY(settings STATIC ${settings_STAT_SRCS})
+TARGET_COMPILE_DEFINITIONS(settings PUBLIC ${RK_QWEBENGINE_FLAGS} ${RK_QWEBVIEW_FLAGS})
 TARGET_LINK_LIBRARIES(settings Qt6::Widgets KF6::WidgetsAddons Qt6::Xml KF6::ConfigCore KF6::Parts KF6::TextEditor KF6::I18n KF6::KIOWidgets)
diff --git a/rkward/settings/rksettingsmodulegeneral.cpp b/rkward/settings/rksettingsmodulegeneral.cpp
index ab9b46555..fdac86167 100644
--- a/rkward/settings/rksettingsmodulegeneral.cpp
+++ b/rkward/settings/rksettingsmodulegeneral.cpp
@@ -50,6 +50,7 @@ bool RKSettingsModuleGeneral::rkward_version_changed;
 bool RKSettingsModuleGeneral::installation_moved = false;
 QString RKSettingsModuleGeneral::previous_rkward_data_dir;
 RKConfigValue<int> RKSettingsModuleGeneral::num_recent_files{"Max number of recent files", 8};
+RKConfigValue<RKSettingsModuleGeneral::HTMLEngine, int> RKSettingsModuleGeneral::html_engine("HTML rendering engine", DefaultRenderingEngine);
 RKConfigValue<bool> RKSettingsModuleGeneral::disable_hardware_rendering{"disable_hardware_rendering", true};
 
 class RKSettingsPageGeneral : public RKSettingsModuleWidget {
@@ -71,9 +72,6 @@ class RKSettingsPageGeneral : public RKSettingsModuleWidget {
 		auto vbox = new QVBoxLayout(group);
 		vbox->addWidget(RKSettingsModuleGeneral::autorestore_from_wd.makeCheckbox(i18n("Load .RData-file from startup directory, if available (R option '--restore')"), this));
 		vbox->addWidget(RKSettingsModuleGeneral::show_help_on_startup.makeCheckbox(i18n("Show RKWard Help on Startup"), this));
-		auto cb = RKSettingsModuleGeneral::disable_hardware_rendering.makeCheckbox(i18n("Disable HTML hardware rendering (setting takes effect after restarting RKWard)"), this);
-		RKCommonFunctions::setTips(i18n("The use of hardware acceleration for HTML rendering (e.g. help pages and plugin output) is known to cause instability in some installations, and is not generally needed for the - usually simple - content shown in RKWard. It is recommended to leave hardware acceleration disabled, unless you experience performance problems while viewing HTML content inside RKWard."), cb);
-		vbox->addWidget(cb);
 
 		QGroupBox *group_box = new QGroupBox(i18n("Initial working directory"), this);
 		QHBoxLayout *hlayout = new QHBoxLayout(group_box);
@@ -93,6 +91,26 @@ class RKSettingsPageGeneral : public RKSettingsModuleWidget {
 		vbox->addWidget(group_box);
 		main_vbox->addWidget(group);
 
+		group = new QGroupBox(i18n("HTML rendering (setings take effect after restarting RKWard)"));
+		hlayout = new QHBoxLayout(group);
+		hlayout->addWidget(new QLabel(i18n("Engine:")));
+		auto dd = RKSettingsModuleGeneral::html_engine.makeDropDown(RKConfigBase::LabelList({{RKSettingsModuleGeneral::DefaultRenderingEngine, i18n("Platform default")},
+#if RK_WITH_QWEBENGINE
+		                                                                                     {RKSettingsModuleGeneral::QWebEngineRenderingEngine, i18n("QWebEngine")},
+#endif
+#if RK_WITH_QWEBVIEW
+		                                                                                     { RKSettingsModuleGeneral::QWebViewRenderingEngine,
+			                                                                                   i18n("QWebView") }
+#endif
+		                                                            }),
+		                                                            this);
+		hlayout->addWidget(dd);
+		hlayout->addStretch();
+		auto cb = RKSettingsModuleGeneral::disable_hardware_rendering.makeCheckbox(i18n("Disable hardware acceleration"), this);
+		RKCommonFunctions::setTips(i18n("The use of hardware acceleration for HTML rendering (e.g. help pages and plugin output) is known to cause instability in some installations, and is not generally needed for the - usually simple - content shown in RKWard. It is recommended to leave hardware acceleration disabled, unless you experience performance problems while viewing HTML content inside RKWard."), cb);
+		hlayout->addWidget(cb);
+		main_vbox->addWidget(group);
+
 		main_vbox->addSpacing(2 * RKStyle::spacingHint());
 
 		auto num_recent_files_box = RKSettingsModuleGeneral::num_recent_files.makeSpinBox(1, INT_MAX, this);
@@ -208,6 +226,7 @@ void RKSettingsModuleGeneral::syncConfig(KConfig *config, RKConfigBase::ConfigSy
 	num_recent_files.syncConfig(cg, a);
 	initial_dir.syncConfig(cg, a);
 	disable_hardware_rendering.syncConfig(cg, a);
+	html_engine.syncConfig(cg, a);
 	if ((a == RKConfigBase::SaveConfig) && (initial_dir == LastUsedDirectory)) {
 		cg.writeEntry(initial_dir_specification.key(), QDir::currentPath());
 	} else {
diff --git a/rkward/settings/rksettingsmodulegeneral.h b/rkward/settings/rksettingsmodulegeneral.h
index d82ba54c6..683d55d06 100644
--- a/rkward/settings/rksettingsmodulegeneral.h
+++ b/rkward/settings/rksettingsmodulegeneral.h
@@ -42,6 +42,12 @@ class RKSettingsModuleGeneral : public RKSettingsModule {
 		RKMDIFocusFollowsMouse = 1
 	};
 
+	enum HTMLEngine {
+		DefaultRenderingEngine,
+		QWebEngineRenderingEngine,
+		QWebViewRenderingEngine
+	};
+
 	void syncConfig(KConfig *config, RKConfigBase::ConfigSyncAction) override;
 	void createPages(RKSettings *parent) override;
 	static constexpr PageId page_id = QLatin1String("general");
@@ -50,6 +56,7 @@ class RKSettingsModuleGeneral : public RKSettingsModule {
 	static QString &filesPath() { return files_path; };
 	static bool showHelpOnStartup() { return show_help_on_startup; };
 	static bool disableHardwareRendering() { return disable_hardware_rendering; };
+	static HTMLEngine htmlEngine() { return html_engine; };
 	static bool openRestoreFileOnLoad() { return autorestore_from_wd; };
 	static WorkplaceSaveMode workplaceSaveMode() { return workplace_save_mode; };
 	/** retrieve the saved workplace description. Meaningful only is workplaceSaveMode () == SaveWorkplaceWithSession */
@@ -109,6 +116,7 @@ class RKSettingsModuleGeneral : public RKSettingsModule {
 	static bool installation_moved;
 	static RKConfigValue<int> num_recent_files;
 	static RKConfigValue<bool> disable_hardware_rendering;
+	static RKConfigValue<HTMLEngine, int> html_engine;
 };
 
 #endif
diff --git a/rkward/windows/CMakeLists.txt b/rkward/windows/CMakeLists.txt
index fb1f2a169..708514e20 100644
--- a/rkward/windows/CMakeLists.txt
+++ b/rkward/windows/CMakeLists.txt
@@ -36,4 +36,11 @@ SET(windows_STAT_SRCS
 )
 
 ADD_LIBRARY(windows STATIC ${windows_STAT_SRCS})
-TARGET_LINK_LIBRARIES(windows Qt6::Widgets Qt6::PrintSupport Qt6::WebEngineWidgets Qt6::WebView Qt6::WebSockets Qt6::Qml Qt6::Quick Qt6::QuickWidgets KF6::TextEditor KF6::Notifications KF6::WindowSystem KF6::KIOFileWidgets KF6::I18n)
+TARGET_COMPILE_DEFINITIONS(windows PUBLIC ${RK_QWEBENGINE_FLAGS} ${RK_QWEBVIEW_FLAGS})
+TARGET_LINK_LIBRARIES(windows Qt6::Widgets Qt6::PrintSupport KF6::TextEditor KF6::Notifications KF6::WindowSystem KF6::KIOFileWidgets KF6::I18n)
+if(WITH_QWEBENGINE)
+	TARGET_LINK_LIBRARIES(windows Qt6::WebEngineWidgets)
+endif()
+if(WITH_QWEBVIEW)
+	TARGET_LINK_LIBRARIES(windows Qt6::WebView Qt6::WebSockets Qt6::Qml Qt6::Quick Qt6::QuickWidgets)
+endif()
diff --git a/rkward/windows/rkhtmlviewer.cpp b/rkward/windows/rkhtmlviewer.cpp
index 0176a625e..766e9e071 100644
--- a/rkward/windows/rkhtmlviewer.cpp
+++ b/rkward/windows/rkhtmlviewer.cpp
@@ -7,6 +7,7 @@ SPDX-License-Identifier: GPL-2.0-or-later
 
 #include "rkhtmlviewer.h"
 
+#include "../settings/rksettingsmodulegeneral.h"
 #include "rkhtmlwindow.h"
 #include "rkqwebenginewidget.h"
 #include "rkqwebview.h"
@@ -19,8 +20,25 @@ RKHTMLViewer::RKHTMLViewer(RKHTMLWindow *parent) : QObject(parent), window(paren
 
 RKHTMLViewer *RKHTMLViewer::getNew(RKHTMLWindow *parent) {
 	RK_TRACE(APP);
-	//return new RKQWebEngineWidget(parent);
+	const auto engine = RKSettingsModuleGeneral::htmlEngine();
+#if RK_WITH_QWEBENGINE
+	if (engine == RKSettingsModuleGeneral::QWebEngineRenderingEngine) {
+		return new RKQWebEngineWidget(parent);
+	}
+#endif
+#if RK_WITH_QWEBVIEW
+	if (engine == RKSettingsModuleGeneral::QWebViewRenderingEngine) {
+		return new RKQWebView(parent);
+	}
+#endif
+	// default to QWebEngine on Linux (where it mostly works), but to QWebView
+	// everywhere else (if possible)
+#if defined(Q_OS_LINUX) && RK_WITH_QWEBENGINE
+	return new RKQWebEngineWidget(parent);
+#endif
+#if RK_WITH_QWEBVIEW
 	return new RKQWebView(parent);
+#else
+	return new RKQWebEngineWidget(parent);
+#endif
 }
-
-#include "rkhtmlviewer.moc"
diff --git a/rkward/windows/rkqwebenginewidget.cpp b/rkward/windows/rkqwebenginewidget.cpp
index d975129fc..6f71813f2 100644
--- a/rkward/windows/rkqwebenginewidget.cpp
+++ b/rkward/windows/rkqwebenginewidget.cpp
@@ -5,36 +5,37 @@ SPDX-FileContributor: The RKWard Team <rkward at kde.org>
 SPDX-License-Identifier: GPL-2.0-or-later
 */
 
-#include "rkqwebenginewidget.h"
-
-#include <QBuffer>
-#include <QDir>
-#include <QFileDialog>
-#include <QFontDatabase>
-#include <QMenu>
-#include <QMimeDatabase>
-#include <QPrintDialog>
-#include <QWebEngineFindTextResult>
-#include <QWebEnginePage>
-#include <QWebEngineProfile>
-#include <QWebEngineScript>
-#include <QWebEngineScriptCollection>
-#include <QWebEngineSettings>
-#include <QWebEngineUrlRequestJob>
-#include <QWebEngineUrlSchemeHandler>
-#include <QWebEngineView>
-#include <QWheelEvent>
-
-#include <KIO/StoredTransferJob>
-#include <KLocalizedString>
-
-#include "../misc/rkfindbar.h"
-#include "../rkward.h"
-#include "../settings/rksettingsmoduler.h"
-#include "rkhtmlwindow.h"
-#include "rkworkplace.h"
-
-#include "../debug.h"
+#if RK_WITH_QWEBENGINE
+#	include "rkqwebenginewidget.h"
+
+#	include <QBuffer>
+#	include <QDir>
+#	include <QFileDialog>
+#	include <QFontDatabase>
+#	include <QMenu>
+#	include <QMimeDatabase>
+#	include <QPrintDialog>
+#	include <QWebEngineFindTextResult>
+#	include <QWebEnginePage>
+#	include <QWebEngineProfile>
+#	include <QWebEngineScript>
+#	include <QWebEngineScriptCollection>
+#	include <QWebEngineSettings>
+#	include <QWebEngineUrlRequestJob>
+#	include <QWebEngineUrlSchemeHandler>
+#	include <QWebEngineView>
+#	include <QWheelEvent>
+
+#	include <KIO/StoredTransferJob>
+#	include <KLocalizedString>
+
+#	include "../misc/rkfindbar.h"
+#	include "../rkward.h"
+#	include "../settings/rksettingsmoduler.h"
+#	include "rkhtmlwindow.h"
+#	include "rkworkplace.h"
+
+#	include "../debug.h"
 
 // TODO: remove dupe
 static QUrl restorableUrl(const QUrl &url) {
@@ -128,10 +129,10 @@ class RKWebPage : public QWebEnginePage {
 		// sigh: acceptNavigationRequest() does  not get called on the new page...
 		QMetaObject::Connection *const connection = new QMetaObject::Connection;
 		*connection = connect(ret, &RKWebPage::loadStarted, [ret, connection
-#ifdef _MSC_VER
+#	ifdef _MSC_VER
 		                                                     ,
 		                                                     this // capturing "this" makes MSVC happy
-#endif
+#	endif
 		]() {
 			QObject::disconnect(*connection);
 			delete connection;
@@ -209,8 +210,8 @@ RKQWebEngineWidget::RKQWebEngineWidget(RKHTMLWindow *parent) : RKHTMLViewer(pare
 
 	if (RKWebPage::opened_as_new) {
 		page = RKWebPage::opened_as_new;
-		RKWebPage::opened_as_new = nullptr;
 		RKWebPage::opened_as_new->window = parent;
+		RKWebPage::opened_as_new = nullptr;
 	} else {
 		page = new RKWebPage(parent);
 	}
@@ -381,4 +382,5 @@ void RKQWebEngineWidget::findRequest(const QString &text, bool backwards, RKFind
 	});
 }
 
-#include "rkqwebenginewidget.moc"
+#	include "rkqwebenginewidget.moc"
+#endif
diff --git a/rkward/windows/rkqwebenginewidget.h b/rkward/windows/rkqwebenginewidget.h
index 998384bfe..77eb2ea51 100644
--- a/rkward/windows/rkqwebenginewidget.h
+++ b/rkward/windows/rkqwebenginewidget.h
@@ -7,10 +7,11 @@ SPDX-License-Identifier: GPL-2.0-or-later
 
 #ifndef RKQWEBENGINEWIDGET_H
 #define RKQWEBENGINEWIDGET_H
+#if RK_WITH_QWEBENGINE
 
-#include <QPointer>
+#	include <QPointer>
 
-#include "rkhtmlviewer.h"
+#	include "rkhtmlviewer.h"
 
 class RKWebPage;
 class QWebEngineView;
@@ -43,3 +44,4 @@ class RKQWebEngineWidget : public RKHTMLViewer {
 };
 
 #endif
+#endif
diff --git a/rkward/windows/rkqwebview.cpp b/rkward/windows/rkqwebview.cpp
index 78f0a67fa..72804fa64 100644
--- a/rkward/windows/rkqwebview.cpp
+++ b/rkward/windows/rkqwebview.cpp
@@ -5,24 +5,25 @@ SPDX-FileContributor: The RKWard Team <rkward at kde.org>
 SPDX-License-Identifier: GPL-2.0-or-later
 */
 
-#include "rkqwebview.h"
+#if RK_WITH_QWEBVIEW
+#	include "rkqwebview.h"
 
-#include <KLocalizedString>
-#include <KStandardActions>
+#	include <KLocalizedString>
+#	include <KStandardActions>
 
-#include <QClipboard>
-#include <QFile>
-#include <QMenu>
-#include <QQuickItem>
-#include <QQuickWidget>
-#include <QWebSocket>
-#include <QWebSocketServer>
+#	include <QClipboard>
+#	include <QFile>
+#	include <QMenu>
+#	include <QQuickItem>
+#	include <QQuickWidget>
+#	include <QWebSocket>
+#	include <QWebSocketServer>
 
-#include "../misc/rkfindbar.h"
-#include "rkhtmlwindow.h"
-#include "rkworkplace.h"
+#	include "../misc/rkfindbar.h"
+#	include "rkhtmlwindow.h"
+#	include "rkworkplace.h"
 
-#include "../debug.h"
+#	include "../debug.h"
 
 class RKQWebViewCallbackServer {
   public:
@@ -316,3 +317,4 @@ void RKQWebView::zoomOut() {
 	RK_TRACE(APP);
 	QMetaObject::invokeMethod(webView(), "doZoom", Q_ARG(int, -1));
 }
+#endif
diff --git a/rkward/windows/rkqwebview.h b/rkward/windows/rkqwebview.h
index 069b0982f..8600c1bc5 100644
--- a/rkward/windows/rkqwebview.h
+++ b/rkward/windows/rkqwebview.h
@@ -7,12 +7,13 @@ SPDX-License-Identifier: GPL-2.0-or-later
 
 #ifndef RKQWEBVIEW_H
 #define RKQWEBVIEW_H
+#if RK_WITH_QWEBVIEW
 
-#include <QMap>
-#include <QPoint>
-#include <QPointer>
+#	include <QMap>
+#	include <QPoint>
+#	include <QPointer>
 
-#include "rkhtmlviewer.h"
+#	include "rkhtmlviewer.h"
 
 class QQuickWidget;
 class QQuickItem;
@@ -66,3 +67,4 @@ class RKQWebView : public RKHTMLViewer {
 };
 
 #endif
+#endif
diff --git a/rkward/windows/rkqwebview.js b/rkward/windows/rkqwebview.js
index 99cf45a95..a18a8b8ac 100644
--- a/rkward/windows/rkqwebview.js
+++ b/rkward/windows/rkqwebview.js
@@ -12,11 +12,11 @@ function __rkward_debounce(fun) {
 }
 
 document.onselectionchange = __rkward_debounce(function() {
-	__rkward_sendMessage("selChanged", { sel: document.getSelection().toString() });
+	__rkward_sendMessage("selChanged", {sel : document.getSelection().toString()});
 });
 
 document.onscroll = __rkward_debounce(function() {
-	__rkward_sendMessage("scroll", { x: window.scrollX, y: window.scrollY });
+	__rkward_sendMessage("scroll", {x : window.scrollX, y : window.scrollY});
 });
 
 function __rkward_sendMessage(msg, args) {
@@ -30,19 +30,21 @@ function __rkward_sendMessage(msg, args) {
 document.addEventListener('click', e => {
 	const origin = e.target.closest('a');
 	if (origin && origin.href.startswith('#')) {
-		__rkward_sendMessage("pageInternalNav", { url: origin.href });
+		__rkward_sendMessage("pageInternalNav", {url : origin.href});
 		e.preventDefault();
 	}
 });
 
 document.addEventListener('contextmenu', e => {
-	let params = { x: e.screenX, y: e.screenY };
+	let params = {x : e.screenX, y : e.screenY};
 	try {
 		params.url = e.target.closest('a').href;
-	} catch {}
+	} catch {
+	}
 	try {
 		params.src = e.target.closest('img').src;
-	} catch {}
+	} catch {
+	}
 	__rkward_sendMessage("contextMenu", params);
 	e.preventDefault();
 });



More information about the rkward-tracker mailing list