Mercurial > octave
changeset 29048:440ace36950e stable
avoid warnings about deprecated QWheelEvent::pos method
* TerminalView.cpp (TerminalView::wheelEvent):
Use QWheelEvent::position if available.
* Canvas.cc (Canvas::canvasWheelEvent): Likewise.
* acinclude.m4 (OCTAVE_CHECK_FUNC_QWHEELEVENT_POSITION): New macro.
(OCTAVE_CHECK_QT_VERSION): Use it.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Wed, 11 Nov 2020 23:18:47 -0500 |
parents | 94396ec1a89d |
children | 461bd8b9ce91 |
files | libgui/graphics/Canvas.cc libgui/qterminal/libqterminal/unix/TerminalView.cpp m4/acinclude.m4 |
diffstat | 3 files changed, 43 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/libgui/graphics/Canvas.cc Wed Nov 11 23:08:08 2020 -0500 +++ b/libgui/graphics/Canvas.cc Wed Nov 11 23:18:47 2020 -0500 @@ -928,7 +928,12 @@ if (childObj.isa ("axes")) { - graphics_object go = selectFromAxes (childObj, event->pos ()); +#if defined (HAVE_QWHEELEVENT_POSITION) + QPoint pos = event->position().toPoint (); +#else + QPoint pos = event->pos (); +#endif + graphics_object go = selectFromAxes (childObj, pos); if (go) {
--- a/libgui/qterminal/libqterminal/unix/TerminalView.cpp Wed Nov 11 23:08:08 2020 -0500 +++ b/libgui/qterminal/libqterminal/unix/TerminalView.cpp Wed Nov 11 23:18:47 2020 -0500 @@ -2065,7 +2065,12 @@ { int charLine; int charColumn; - getCharacterPosition( ev->pos() , charLine , charColumn ); +#if defined (HAVE_QWHEELEVENT_POSITION) + QPoint pos = ev->position().toPoint(); +#else + QPoint pos = ev->pos(); +#endif + getCharacterPosition( pos , charLine , charColumn ); #if defined (HAVE_QWHEELEVENT_ANGLEDELTA) int delta = ev->angleDelta().y();
--- a/m4/acinclude.m4 Wed Nov 11 23:08:08 2020 -0500 +++ b/m4/acinclude.m4 Wed Nov 11 23:18:47 2020 -0500 @@ -862,6 +862,36 @@ fi ]) dnl +dnl Check whether the Qt class QWheelEvent has the position member function. +dnl This member function was introduced in Qt 5.14. +dnl +AC_DEFUN([OCTAVE_CHECK_FUNC_QWHEELEVENT_POSITION], [ + AC_CACHE_CHECK([for QWheelEvent::position in <QWheelEvent>], + [octave_cv_func_qwheelevent_position], + [AC_LANG_PUSH(C++) + ac_octave_save_CPPFLAGS="$CPPFLAGS" + ac_octave_save_CXXFLAGS="$CXXFLAGS" + CPPFLAGS="$QT_CPPFLAGS $CXXPICFLAG $CPPFLAGS" + CXXFLAGS="$CXXPICFLAG $CXXFLAGS" + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ + #include <QWheelEvent> + void foo (const QWheelEvent& ev) + { + ev.position (); + }; + ]])], + octave_cv_func_qwheelevent_position=yes, + octave_cv_func_qwheelevent_position=no) + CPPFLAGS="$ac_octave_save_CPPFLAGS" + CXXFLAGS="$ac_octave_save_CXXFLAGS" + AC_LANG_POP(C++) + ]) + if test $octave_cv_func_qwheelevent_position = yes; then + AC_DEFINE(HAVE_QWHEELEVENT_POSITION, 1, + [Define to 1 if you have the `QWheelEvent::position' member function.]) + fi +]) +dnl dnl Check whether Qt message handler function accepts QMessageLogContext dnl argument. This change was introduced in Qt 5. dnl @@ -2405,6 +2435,7 @@ OCTAVE_CHECK_FUNC_QTABWIDGET_SETMOVABLE OCTAVE_CHECK_FUNC_QTMESSAGEHANDLER_ACCEPTS_QMESSAGELOGCONTEXT OCTAVE_CHECK_FUNC_QWHEELEVENT_ANGLEDELTA + OCTAVE_CHECK_FUNC_QWHEELEVENT_POSITION OCTAVE_CHECK_MEMBER_QFONT_FORCE_INTEGER_METRICS OCTAVE_CHECK_MEMBER_QFONT_MONOSPACE OCTAVE_HAVE_QGUIAPPLICATION