diff --git a/ui/presentationwidget.h b/ui/presentationwidget.h --- a/ui/presentationwidget.h +++ b/ui/presentationwidget.h @@ -74,6 +74,9 @@ void leaveEvent( QEvent * e ) override; bool gestureEvent (QGestureEvent * e ); + // Catch TabletEnterProximity and TabletLeaveProximity events from the QApplication + bool eventFilter (QObject * o, QEvent *ev ) override; + private: const void * getObjectRect( Okular::ObjectRect::ObjectType type, int x, int y, QRect * geometry = nullptr ) const; const Okular::Action * getLink( int x, int y, QRect * geometry = nullptr ) const; diff --git a/ui/presentationwidget.cpp b/ui/presentationwidget.cpp --- a/ui/presentationwidget.cpp +++ b/ui/presentationwidget.cpp @@ -277,6 +277,9 @@ // setFocus() so KCursor::setAutoHideCursor() goes into effect if it's enabled setFocus( Qt::OtherFocusReason ); + + // Catch TabletEnterProximity and TabletLeaveProximity events from the QApplication + qApp->installEventFilter( this ); } PresentationWidget::~PresentationWidget() @@ -308,6 +311,8 @@ QVector< PresentationFrame * >::iterator fIt = m_frames.begin(), fEnd = m_frames.end(); for ( ; fIt != fEnd; ++fIt ) delete *fIt; + + qApp->removeEventFilter( this ); } @@ -532,6 +537,29 @@ } } +bool PresentationWidget::eventFilter (QObject * o, QEvent *e ) +{ + if ( o == qApp ) + { + if ( e->type() == QTabletEvent::TabletEnterProximity ) + { + setCursor( QCursor( Qt::CrossCursor ) ); + } + if ( e->type() == QTabletEvent::TabletLeaveProximity ) + { + if ( Okular::Settings::slidesCursor() == Okular::Settings::EnumSlidesCursor::Visible ) + { + setCursor( QCursor( Qt::ArrowCursor ) ); + } + else + { + setCursor( QCursor( Qt::BlankCursor ) ); + } + } + } + return false; +} + // bool PresentationWidget::event( QEvent * e ) { @@ -748,6 +776,12 @@ if ( !m_drawingEngine && Okular::Settings::slidesCursor() != Okular::Settings::EnumSlidesCursor::Hidden ) testCursorOnLink( e->x(), e->y() ); + // Explicitly show the cursor, it may have been hidden by a recent TabletLeaveProximity event + if ( e->source() == Qt::MouseEventNotSynthesized && Okular::Settings::slidesCursor() != Okular::Settings::EnumSlidesCursor::Hidden ) + { + setCursor( QCursor( Qt::ArrowCursor ) ); + } + if ( !m_topBar->isHidden() ) { // hide a shown bar when exiting the area @@ -1336,8 +1370,9 @@ // manually disable and re-enable the pencil mode, so we can do // cleaning of the actual drawer and create a new one just after // that - that gives continuous drawing - slotChangeDrawingToolEngine( QDomElement() ); - slotChangeDrawingToolEngine( m_currentDrawingToolElement ); + delete m_drawingEngine; + m_drawingRect = QRect(); + m_drawingEngine = new SmoothPathEngine( m_currentDrawingToolElement ); // schedule repaint update();