[education/rkward] /: Fix zooming help/output pages with Ctrl+scroll wheel, when compiled with QWebEngine

Thomas Friedrichsmeier null at kde.org
Sat Jun 4 21:52:45 BST 2022


Git commit 1892c0005749c6a1269e0b1a7fbb85ebda47f9c3 by Thomas Friedrichsmeier.
Committed on 04/06/2022 at 20:52.
Pushed by tfry into branch 'master'.

Fix zooming help/output pages with Ctrl+scroll wheel, when compiled with QWebEngine

M  +1    -0    ChangeLog
M  +17   -5    rkward/windows/rkhtmlwindow.cpp

https://invent.kde.org/education/rkward/commit/1892c0005749c6a1269e0b1a7fbb85ebda47f9c3

diff --git a/ChangeLog b/ChangeLog
index d7021378..64e6083c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,4 @@
+- Fix zooming help/output pages with Ctrl+scroll wheel, when compiled with QWebEngine
 - Fix problem handling rkward:// links from dialogs on some sytems
 - Allow to select search provider, when searching for a term online
 - Experimental feature targetted at package developers: Add option to restart R backend
diff --git a/rkward/windows/rkhtmlwindow.cpp b/rkward/windows/rkhtmlwindow.cpp
index 59a5a17b..3cafac45 100644
--- a/rkward/windows/rkhtmlwindow.cpp
+++ b/rkward/windows/rkhtmlwindow.cpp
@@ -247,13 +247,25 @@ public:
 		page ()->print (printer, [](bool){});
 	};
 protected:
-	void wheelEvent (QWheelEvent *event) override {
-		if (event->modifiers () & Qt::ControlModifier) {
-			setZoomFactor (zoomFactor () + event->angleDelta ().y () / 1200.0);
-			event->accept ();
+	bool eventFilter(QObject *, QEvent *event) override {
+		if (event->type() == QEvent::Wheel) {
+			QWheelEvent *we = static_cast<QWheelEvent*>(event);
+			if (we->modifiers()  & Qt::ControlModifier) {
+				setZoomFactor(zoomFactor() + we->angleDelta ().y() / 1200.0);
+				return true;
+			}
+		}
+		return false;
+	}
+	void childEvent(QChildEvent * event) override {
+		if (event->type() == QChildEvent::ChildAdded) {
+			event->child()->installEventFilter(this);
 		}
-		else QWebEngineView::wheelEvent (event);
 	}
+	// NOTE: Code below won't work, due to https://bugreports.qt.io/browse/QTBUG-43602
+/*	void wheelEvent (QWheelEvent *event) override {
+		[handle zooming]
+	} */
 #endif
 };
 


More information about the rkward-tracker mailing list