From f7db4dc3404456604c961cc20381bd418eb50933 Mon Sep 17 00:00:00 2001 From: Abs62 Date: Thu, 26 Sep 2013 18:57:59 +0400 Subject: [PATCH] Win-specific: Avoid wrong mouse wheel handling in QWebView if system preferences is set to "scroll by page" (issue #385) --- articlewebview.cc | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/articlewebview.cc b/articlewebview.cc index b2b081dc..8b8cf149 100644 --- a/articlewebview.cc +++ b/articlewebview.cc @@ -7,6 +7,10 @@ #include #include "articleinspector.hh" +#ifdef Q_OS_WIN32 +#include +#endif + ArticleWebView::ArticleWebView( QWidget *parent ): QWebView( parent ), #if QT_VERSION >= 0x040600 @@ -143,6 +147,27 @@ void ArticleWebView::focusInEvent( QFocusEvent * event ) void ArticleWebView::wheelEvent( QWheelEvent *ev ) { +#ifdef Q_OS_WIN32 + + // Avoid wrong mouse wheel handling in QWebView + // if system preferences is set to "scroll by page" + + if( ev->modifiers() == Qt::NoModifier ) + { + unsigned nLines; + SystemParametersInfo( SPI_GETWHEELSCROLLLINES, 0, &nLines, 0 ); + if( nLines == WHEEL_PAGESCROLL ) + { + QKeyEvent kev( QEvent::KeyPress, ev->delta() > 0 ? Qt::Key_PageUp : Qt::Key_PageDown, + Qt::NoModifier ); + QApplication::sendEvent( this, &kev ); + + ev->accept(); + return; + } + } +#endif + if ( ev->modifiers().testFlag( Qt::ControlModifier ) ) { ev->ignore();