changeset 29047:94396ec1a89d stable

avoid warnings about deprecated QWheelEvent methods delta and orientation * documentation.cc (documentation_browser::wheelEvent): Use QWheelEvent::angleDelta if available. * TerminalView.cpp (TerminalView::hweelEvent): Likewise. * Canvas.cc (Canvas::canvasWheelEvent): Likewise. * acinclude.m4 (OCTAVE_CHECK_FUNC_QWHEELEVENT_ANGLEDELTA): Update test.
author John W. Eaton <jwe@octave.org>
date Wed, 11 Nov 2020 23:08:08 -0500
parents 4ec8a36990e8
children 440ace36950e
files libgui/graphics/Canvas.cc libgui/qterminal/libqterminal/unix/TerminalView.cpp libgui/src/documentation.cc m4/acinclude.m4
diffstat 4 files changed, 26 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/libgui/graphics/Canvas.cc	Wed Nov 11 14:24:24 2020 -0500
+++ b/libgui/graphics/Canvas.cc	Wed Nov 11 23:08:08 2020 -0500
@@ -954,7 +954,11 @@
 
                 if (zoom_enabled (figObj))
                   {
+#if defined (HAVE_QWHEELEVENT_ANGLEDELTA)
+                    if (event->angleDelta().y () > 0)
+#else
                     if (event->delta () > 0)
+#endif
                       newMouseMode = ZoomInMode;
                     else
                       newMouseMode = ZoomOutMode;
@@ -996,7 +1000,11 @@
                 {
                   axes::properties& ap = Utils::properties<axes> (axesObj);
 
+#if defined (HAVE_QWHEELEVENT_ANGLEDELTA)
+                  double factor = (event->angleDelta().y () > 0 ? 0.1 : -0.1);
+#else
                   double factor = (event->delta () > 0 ? 0.1 : -0.1);
+#endif
 
                   if (event->modifiers () == Qt::NoModifier
                       && mode != "horizontal")
--- a/libgui/qterminal/libqterminal/unix/TerminalView.cpp	Wed Nov 11 14:24:24 2020 -0500
+++ b/libgui/qterminal/libqterminal/unix/TerminalView.cpp	Wed Nov 11 23:08:08 2020 -0500
@@ -2051,8 +2051,13 @@
 
 void TerminalView::wheelEvent( QWheelEvent* ev )
 {
+#if defined (HAVE_QWHEELEVENT_ANGLEDELTA)
+  if (ev->angleDelta().y() == 0)
+    return;
+#else
   if (ev->orientation() != Qt::Vertical)
     return;
+#endif
 
   if ( _mouseMarks )
     _scrollBar->event(ev);
@@ -2062,7 +2067,12 @@
       int charColumn;
       getCharacterPosition( ev->pos() , charLine , charColumn );
 
-      emit mouseSignal( ev->delta() > 0 ? 4 : 5,
+#if defined (HAVE_QWHEELEVENT_ANGLEDELTA)
+      int delta = ev->angleDelta().y();
+#else
+      int delta = ev->delta();
+#endif
+      emit mouseSignal( delta > 0 ? 4 : 5,
                         charColumn + 1,
                         charLine + 1 +_scrollBar->value() -_scrollBar->maximum() ,
                         0);
--- a/libgui/src/documentation.cc	Wed Nov 11 14:24:24 2020 -0500
+++ b/libgui/src/documentation.cc	Wed Nov 11 23:08:08 2020 -0500
@@ -969,7 +969,11 @@
   {
     if (we->modifiers () == Qt::ControlModifier)
       {
-        if (we->delta () > 0)
+#if defined (HAVE_QWHEELEVENT_ANGLEDELTA)
+        if (we->angleDelta().y () > 0)
+#else
+        if (we->delta() > 0)
+#endif
           zoom_in ();
         else
           zoom_out ();
--- a/m4/acinclude.m4	Wed Nov 11 14:24:24 2020 -0500
+++ b/m4/acinclude.m4	Wed Nov 11 23:08:08 2020 -0500
@@ -845,14 +845,10 @@
     CXXFLAGS="$CXXPICFLAG $CXXFLAGS"
     AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
         #include <QWheelEvent>
-        class wheel_event : public QWheelEvent
+        void foo (const QWheelEvent& ev)
         {
-        public:
-          wheel_event (QWidget *parent = 0) : QWheelEvent (parent) { this->angleDelta (); }
-          ~wheel_event () {}
+          ev.angleDelta ();
         };
-        ]], [[
-        wheel_event tw;
         ]])],
       octave_cv_func_qwheelevent_angledelta=yes,
       octave_cv_func_qwheelevent_angledelta=no)