Commit f4d70641 authored by Oliver Sander's avatar Oliver Sander Committed by Albert Astals Cid

Turn cursor to cross-hair when stylus is near the screen

parent 4f297e34
......@@ -283,6 +283,9 @@ PresentationWidget::PresentationWidget( QWidget * parent, Okular::Document * doc
// 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()
......@@ -312,6 +315,8 @@ PresentationWidget::~PresentationWidget()
// delete frames
qDeleteAll( m_frames );
qApp->removeEventFilter( this );
}
......@@ -531,6 +536,29 @@ void PresentationWidget::setPlayPauseIcon()
}
}
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;
}
// <widget events>
bool PresentationWidget::event( QEvent * e )
{
......
......@@ -74,6 +74,9 @@ class PresentationWidget : public QWidget, public Okular::DocumentObserver
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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment