Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit 99667e4c authored by Albert Astals Cid's avatar Albert Astals Cid

Make leaving the presentation area finish the drawing

BUGS: 354016
parent 76c1e944
......@@ -655,22 +655,7 @@ void PresentationWidget::mouseReleaseEvent( QMouseEvent * e )
{
if ( m_drawingEngine )
{
QRect r = routeMouseDrawingEvent( e );
(void)r;
if ( m_drawingEngine->creationCompleted() )
{
// add drawing to current page
m_frames[ m_frameIndex ]->drawings << m_drawingEngine->endSmoothPath();
// 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
togglePencilMode( false );
togglePencilMode( true );
// schedule repaint
update();
}
routeMouseDrawingEvent( e );
return;
}
......@@ -1208,11 +1193,57 @@ QRect PresentationWidget::routeMouseDrawingEvent( QMouseEvent * e )
double nX = ( (double)e->x() - (double)geom.left() ) / (double)geom.width();
double nY = ( (double)e->y() - (double)geom.top() ) / (double)geom.height();
QRect ret;
if ( hasclicked && nX >= 0 && nX < 1 && nY >= 0 && nY < 1 )
bool isInside = nX >= 0 && nX < 1 && nY >= 0 && nY < 1;
if ( hasclicked && !isInside ) {
// Fake a move to the last border pos
nX = qBound(0., nX, 1.);
nY = qBound(0., nY, 1.);
m_drawingEngine->event( AnnotatorEngine::Move, button, nX, nY, geom.width(), geom.height(), page );
// Fake a release in the following lines
eventType = AnnotatorEngine::Release;
isInside = true;
} else if ( !hasclicked && isInside )
{
// we're coming from the outside, pretend we started clicking at the closest border
if ( nX < ( 1 - nX ) && nX < nY && nX < ( 1 - nY ) )
nX = 0;
else if ( nY < ( 1 - nY ) && nY < nX && nY < ( 1 - nX ) )
nY = 0;
else if ( ( 1 - nX ) < nX && ( 1 - nX ) < nY && ( 1 - nX ) < ( 1 - nY ) )
nX = 1;
else
nY = 1;
hasclicked = true;
eventType = AnnotatorEngine::Press;
}
if ( hasclicked && isInside )
{
ret = m_drawingEngine->event( eventType, button, nX, nY, geom.width(), geom.height(), page );
}
if ( eventType == AnnotatorEngine::Release )
{
hasclicked = false;
}
if ( m_drawingEngine->creationCompleted() )
{
// add drawing to current page
m_frames[ m_frameIndex ]->drawings << m_drawingEngine->endSmoothPath();
// 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
togglePencilMode( false );
togglePencilMode( true );
// schedule repaint
update();
}
return ret;
}
......
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