[rkward/work/qtwebengine] /: Make Ctrl+Scroll wheel work with QWebEngine

Thomas Friedrichsmeier null at kde.org
Mon Mar 30 20:42:56 BST 2020


Git commit 9beda6f8c033105104b241066cbd649ee903e5cd by Thomas Friedrichsmeier.
Committed on 30/03/2020 at 19:42.
Pushed by tfry into branch 'work/qtwebengine'.

Make Ctrl+Scroll wheel work with QWebEngine

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

https://commits.kde.org/rkward/9beda6f8c033105104b241066cbd649ee903e5cd

diff --git a/ChangeLog b/ChangeLog
index e3601679..420480cb 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -4,7 +4,6 @@
     - Restore scroll position (needs to happen *after* page load)
     - Support help:// protocol
     - Support pdf
-    - Support Ctrl+scrollwheel
 - <text> elements in plugins may now also contain clickable links, including rkward://-scheme links
 * TODO: Bring new code hinting features to the console window!
 - On unix-systems, RKWard can now be run without installation
diff --git a/rkward/windows/rkhtmlwindow.cpp b/rkward/windows/rkhtmlwindow.cpp
index 44e90e0a..d3ea32ff 100644
--- a/rkward/windows/rkhtmlwindow.cpp
+++ b/rkward/windows/rkhtmlwindow.cpp
@@ -202,6 +202,7 @@ class RKWebView : public KWebView {
 public:
 	RKWebView (QWidget *parent) : KWebView (parent, false) {};
 #else
+#include <QWheelEvent>
 class RKWebView : public QWebEngineView {
 public:
 	RKWebView (QWidget *parent) : QWebEngineView (parent) {};
@@ -209,6 +210,14 @@ public:
 		if (!page ()) return;
 		page ()->print (printer, [](bool){});
 	};
+protected:
+	void wheelEvent (QWheelEvent *event) override {
+		if (event->modifiers () & Qt::ControlModifier) {
+			setZoomFactor (zoomFactor () + event->angleDelta ().y () / 1200.0);
+			event->accept ();
+		}
+		else QWebEngineView::wheelEvent (event);
+	}
 #endif
 };
 



More information about the rkward-tracker mailing list