mirror of
https://invent.kde.org/graphics/okular
synced 2024-08-27 03:30:20 +00:00
Adapt PageView and PresentationWidget to handle ScreenAnnotations correctly
REVIEW: 106986
This commit is contained in:
parent
77ccbbcbaa
commit
6dddb7eff8
|
@ -375,6 +375,9 @@ PageView::PageView( QWidget *parent, Okular::Document *document )
|
|||
// connect(...);
|
||||
setAttribute( Qt::WA_InputMethodEnabled, true );
|
||||
|
||||
connect(document, SIGNAL(processMovieAction(const Okular::MovieAction*)), this, SLOT(slotProcessMovieAction(const Okular::MovieAction*)));
|
||||
connect(document, SIGNAL(processRenditionAction(const Okular::RenditionAction*)), this, SLOT(slotProcessRenditionAction(const Okular::RenditionAction*)));
|
||||
|
||||
// schedule the welcome message
|
||||
QMetaObject::invokeMethod(this, "slotShowWelcome", Qt::QueuedConnection);
|
||||
}
|
||||
|
@ -875,6 +878,17 @@ void PageView::notifySetup( const QVector< Okular::Page * > & pageSet, int setup
|
|||
item->videoWidgets().insert( movieAnn->movie(), vw );
|
||||
vw->pageInitialized();
|
||||
}
|
||||
else if ( a->subType() == Okular::Annotation::AScreen )
|
||||
{
|
||||
const Okular::ScreenAnnotation * screenAnn = static_cast< Okular::ScreenAnnotation * >( a );
|
||||
Okular::Movie *movie = GuiUtils::renditionMovieFromScreenAnnotation( screenAnn );
|
||||
if ( movie )
|
||||
{
|
||||
VideoWidget * vw = new VideoWidget( screenAnn, movie, d->document, viewport() );
|
||||
item->videoWidgets().insert( movie, vw );
|
||||
vw->pageInitialized();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2273,11 +2287,18 @@ void PageView::mouseReleaseEvent( QMouseEvent * e )
|
|||
if ( rect )
|
||||
ann = ( (Okular::AnnotationObjectRect *)rect )->annotation();
|
||||
|
||||
if ( ann && ann->subType() == Okular::Annotation::AMovie )
|
||||
if ( ann )
|
||||
{
|
||||
VideoWidget *vw = pageItem->videoWidgets().value( static_cast<Okular::MovieAnnotation*>( ann )->movie() );
|
||||
vw->show();
|
||||
vw->play();
|
||||
if ( ann->subType() == Okular::Annotation::AMovie )
|
||||
{
|
||||
VideoWidget *vw = pageItem->videoWidgets().value( static_cast<Okular::MovieAnnotation*>( ann )->movie() );
|
||||
vw->show();
|
||||
vw->play();
|
||||
}
|
||||
else if ( ann->subType() == Okular::Annotation::AScreen )
|
||||
{
|
||||
d->document->processAction( static_cast<Okular::ScreenAnnotation*>( ann )->action() );
|
||||
}
|
||||
}
|
||||
#if 0
|
||||
// a link can move us to another page or even to another document, there's no point in trying to
|
||||
|
@ -3612,16 +3633,25 @@ void PageView::updateCursor( const QPoint &p )
|
|||
d->mouseOnRect = false;
|
||||
if ( annotobj )
|
||||
{
|
||||
const Okular::Annotation *annotation = static_cast< const Okular::AnnotationObjectRect * >( annotobj )->annotation();
|
||||
if ( ( QApplication::keyboardModifiers() & Qt::ControlModifier )
|
||||
&& static_cast< const Okular::AnnotationObjectRect * >( annotobj )->annotation()->canBeMoved() )
|
||||
&& annotation->canBeMoved() )
|
||||
{
|
||||
setCursor( Qt::OpenHandCursor );
|
||||
}
|
||||
else if ( static_cast< const Okular::AnnotationObjectRect * >( annotobj )->annotation()->subType() == Okular::Annotation::AMovie )
|
||||
else if ( annotation->subType() == Okular::Annotation::AMovie )
|
||||
{
|
||||
d->mouseOnRect = true;
|
||||
setCursor( Qt::PointingHandCursor );
|
||||
}
|
||||
else if ( annotation->subType() == Okular::Annotation::AScreen )
|
||||
{
|
||||
if ( GuiUtils::renditionMovieFromScreenAnnotation( static_cast< const Okular::ScreenAnnotation * >( annotation ) ) != 0 )
|
||||
{
|
||||
d->mouseOnRect = true;
|
||||
setCursor( Qt::PointingHandCursor );
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ( Okular::Settings::mouseMode() == Okular::Settings::EnumMouseMode::Browse )
|
||||
{
|
||||
|
@ -4621,6 +4651,45 @@ void PageView::slotProcessMovieAction( const Okular::MovieAction *action )
|
|||
};
|
||||
}
|
||||
|
||||
void PageView::slotProcessRenditionAction( const Okular::RenditionAction *action )
|
||||
{
|
||||
Okular::Movie *movie = action->movie();
|
||||
if ( !movie )
|
||||
return;
|
||||
|
||||
const int currentPage = d->document->viewport().pageNumber;
|
||||
|
||||
PageViewItem *item = d->items.at( currentPage );
|
||||
if ( !item )
|
||||
return;
|
||||
|
||||
VideoWidget *vw = item->videoWidgets().value( movie );
|
||||
if ( !vw )
|
||||
return;
|
||||
|
||||
if ( action->operation() == Okular::RenditionAction::None )
|
||||
return;
|
||||
|
||||
vw->show();
|
||||
|
||||
switch ( action->operation() )
|
||||
{
|
||||
case Okular::RenditionAction::Play:
|
||||
vw->stop();
|
||||
vw->play();
|
||||
break;
|
||||
case Okular::RenditionAction::Stop:
|
||||
vw->stop();
|
||||
break;
|
||||
case Okular::RenditionAction::Pause:
|
||||
vw->pause();
|
||||
break;
|
||||
case Okular::RenditionAction::Resume:
|
||||
vw->play();
|
||||
break;
|
||||
};
|
||||
}
|
||||
|
||||
//END private SLOTS
|
||||
|
||||
#include "pageview.moc"
|
||||
|
|
|
@ -38,6 +38,7 @@ class Document;
|
|||
class DocumentViewport;
|
||||
class Annotation;
|
||||
class MovieAction;
|
||||
class RenditionAction;
|
||||
}
|
||||
|
||||
class FormWidgetIface;
|
||||
|
@ -256,6 +257,7 @@ Q_OBJECT
|
|||
void externalKeyPressEvent( QKeyEvent *e );
|
||||
void slotAnnotationWindowDestroyed( QObject *window );
|
||||
void slotProcessMovieAction( const Okular::MovieAction *action );
|
||||
void slotProcessRenditionAction( const Okular::RenditionAction *action );
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -49,6 +49,7 @@
|
|||
|
||||
// local includes
|
||||
#include "annotationtools.h"
|
||||
#include "guiutils.h"
|
||||
#include "pagepainter.h"
|
||||
#include "presentationsearchbar.h"
|
||||
#include "videowidget.h"
|
||||
|
@ -224,6 +225,7 @@ PresentationWidget::PresentationWidget( QWidget * parent, Okular::Document * doc
|
|||
connect( m_nextPageTimer, SIGNAL(timeout()), this, SLOT(slotNextPage()) );
|
||||
|
||||
connect( m_document, SIGNAL(processMovieAction(const Okular::MovieAction*)), this, SLOT(slotProcessMovieAction(const Okular::MovieAction*)) );
|
||||
connect( m_document, SIGNAL(processRenditionAction(const Okular::RenditionAction*)), this, SLOT(slotProcessRenditionAction(const Okular::RenditionAction*)) );
|
||||
|
||||
// handle cursor appearance as specified in configuration
|
||||
if ( Okular::Settings::slidesCursor() == Okular::Settings::EnumSlidesCursor::HiddenDelay )
|
||||
|
@ -320,6 +322,17 @@ void PresentationWidget::notifySetup( const QVector< Okular::Page * > & pageSet,
|
|||
frame->videoWidgets.insert( movieAnn->movie(), vw );
|
||||
vw->pageInitialized();
|
||||
}
|
||||
else if ( a->subType() == Okular::Annotation::AScreen )
|
||||
{
|
||||
const Okular::ScreenAnnotation * screenAnn = static_cast< Okular::ScreenAnnotation * >( a );
|
||||
Okular::Movie *movie = GuiUtils::renditionMovieFromScreenAnnotation( screenAnn );
|
||||
if ( movie )
|
||||
{
|
||||
VideoWidget * vw = new VideoWidget( screenAnn, movie, m_document, this );
|
||||
frame->videoWidgets.insert( movie, vw );
|
||||
vw->pageInitialized();
|
||||
}
|
||||
}
|
||||
}
|
||||
frame->recalcGeometry( m_width, m_height, screenRatio );
|
||||
// add the frame to the vector
|
||||
|
@ -582,14 +595,22 @@ void PresentationWidget::mousePressEvent( QMouseEvent * e )
|
|||
return;
|
||||
|
||||
const Okular::Annotation *annotation = getAnnotation( e->x(), e->y() );
|
||||
if ( annotation && ( annotation->subType() == Okular::Annotation::AMovie ) )
|
||||
if ( annotation )
|
||||
{
|
||||
const Okular::MovieAnnotation *movieAnnotation = static_cast<const Okular::MovieAnnotation*>( annotation );
|
||||
if ( annotation->subType() == Okular::Annotation::AMovie )
|
||||
{
|
||||
const Okular::MovieAnnotation *movieAnnotation = static_cast<const Okular::MovieAnnotation*>( annotation );
|
||||
|
||||
VideoWidget *vw = m_frames[ m_frameIndex ]->videoWidgets.value( movieAnnotation->movie() );
|
||||
vw->show();
|
||||
vw->play();
|
||||
return;
|
||||
VideoWidget *vw = m_frames[ m_frameIndex ]->videoWidgets.value( movieAnnotation->movie() );
|
||||
vw->show();
|
||||
vw->play();
|
||||
return;
|
||||
}
|
||||
else if ( annotation->subType() == Okular::Annotation::AScreen )
|
||||
{
|
||||
m_document->processAction( static_cast<const Okular::ScreenAnnotation*>( annotation )->action() );
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// handle clicking on top-right overlay
|
||||
|
@ -848,7 +869,8 @@ void PresentationWidget::testCursorOnLink( int x, int y )
|
|||
const Okular::Annotation *annotation = getAnnotation( x, y, 0 );
|
||||
|
||||
const bool needsHandCursor = ( ( link != 0 ) ||
|
||||
( ( annotation != 0 ) && ( annotation->subType() == Okular::Annotation::AMovie ) ) );
|
||||
( ( annotation != 0 ) && ( annotation->subType() == Okular::Annotation::AMovie ) ) ||
|
||||
( ( annotation != 0 ) && ( annotation->subType() == Okular::Annotation::AScreen ) && ( GuiUtils::renditionMovieFromScreenAnnotation( static_cast< const Okular::ScreenAnnotation * >( annotation ) ) != 0 ) ) );
|
||||
|
||||
// only react on changes (in/out from a link)
|
||||
if ( ( needsHandCursor && !m_handCursor ) || ( !needsHandCursor && m_handCursor ) )
|
||||
|
@ -2103,4 +2125,37 @@ void PresentationWidget::slotProcessMovieAction( const Okular::MovieAction *acti
|
|||
};
|
||||
}
|
||||
|
||||
void PresentationWidget::slotProcessRenditionAction( const Okular::RenditionAction *action )
|
||||
{
|
||||
Okular::Movie *movie = action->movie();
|
||||
if ( !movie )
|
||||
return;
|
||||
|
||||
VideoWidget *vw = m_frames[ m_frameIndex ]->videoWidgets.value( movie );
|
||||
if ( !vw )
|
||||
return;
|
||||
|
||||
if ( action->operation() == Okular::RenditionAction::None )
|
||||
return;
|
||||
|
||||
vw->show();
|
||||
|
||||
switch ( action->operation() )
|
||||
{
|
||||
case Okular::RenditionAction::Play:
|
||||
vw->stop();
|
||||
vw->play();
|
||||
break;
|
||||
case Okular::RenditionAction::Stop:
|
||||
vw->stop();
|
||||
break;
|
||||
case Okular::RenditionAction::Pause:
|
||||
vw->pause();
|
||||
break;
|
||||
case Okular::RenditionAction::Resume:
|
||||
vw->play();
|
||||
break;
|
||||
};
|
||||
}
|
||||
|
||||
#include "presentationwidget.moc"
|
||||
|
|
|
@ -33,6 +33,7 @@ class Annotation;
|
|||
class Document;
|
||||
class MovieAction;
|
||||
class Page;
|
||||
class RenditionAction;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -150,6 +151,7 @@ class PresentationWidget : public QWidget, public Okular::DocumentObserver
|
|||
void chooseScreen( QAction * );
|
||||
void toggleBlackScreenMode( bool );
|
||||
void slotProcessMovieAction( const Okular::MovieAction *action );
|
||||
void slotProcessRenditionAction( const Okular::RenditionAction *action );
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue