From kde-commits Thu Oct 25 06:31:39 2012 From: Tobias Koenig Date: Thu, 25 Oct 2012 06:31:39 +0000 To: kde-commits Subject: [okular] ui: Adapt PageView and PresentationWidget to handle ScreenAnnotations correctly Message-Id: <20121025063139.0CF9AA6078 () git ! kde ! org> X-MARC-Message: https://marc.info/?l=kde-commits&m=135114671505015 Git commit 6dddb7eff892702080ab61bdb414896e14dd4585 by Tobias Koenig. Committed on 27/09/2012 at 14:15. Pushed by tokoe into branch 'master'. Adapt PageView and PresentationWidget to handle ScreenAnnotations correctly REVIEW: 106986 M +75 -6 ui/pageview.cpp M +2 -0 ui/pageview.h M +62 -7 ui/presentationwidget.cpp M +2 -0 ui/presentationwidget.h http://commits.kde.org/okular/6dddb7eff892702080ab61bdb414896e14dd4585 diff --git a/ui/pageview.cpp b/ui/pageview.cpp index 7380a7a..804b521 100644 --- a/ui/pageview.cpp +++ b/ui/pageview.cpp @@ -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::Renditio= nAction*)), this, SLOT(slotProcessRenditionAction(const Okular::RenditionAc= tion*))); + // schedule the welcome message QMetaObject::invokeMethod(this, "slotShowWelcome", Qt::QueuedConnectio= n); } @@ -875,6 +878,17 @@ void PageView::notifySetup( const QVector< Okular::Pag= e * > & pageSet, int setup item->videoWidgets().insert( movieAnn->movie(), vw ); vw->pageInitialized(); } + else if ( a->subType() =3D=3D Okular::Annotation::AScreen ) + { + const Okular::ScreenAnnotation * screenAnn =3D static_cast= < Okular::ScreenAnnotation * >( a ); + Okular::Movie *movie =3D GuiUtils::renditionMovieFromScree= nAnnotation( screenAnn ); + if ( movie ) + { + VideoWidget * vw =3D 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 =3D ( (Okular::AnnotationObjectRect *)rect )->= annotation(); = - if ( ann && ann->subType() =3D=3D Okular::Annotation::= AMovie ) + if ( ann ) { - VideoWidget *vw =3D pageItem->videoWidgets().value= ( static_cast( ann )->movie() ); - vw->show(); - vw->play(); + if ( ann->subType() =3D=3D Okular::Annotation::AMo= vie ) + { + VideoWidget *vw =3D pageItem->videoWidgets().v= alue( static_cast( ann )->movie() ); + vw->show(); + vw->play(); + } + else if ( ann->subType() =3D=3D Okular::Annotation= ::AScreen ) + { + d->document->processAction( static_cast( ann )->action() ); + } } #if 0 // a link can move us to another page or even to anoth= er document, there's no point in trying to @@ -3612,16 +3633,25 @@ void PageView::updateCursor( const QPoint &p ) d->mouseOnRect =3D false; if ( annotobj ) { + const Okular::Annotation *annotation =3D static_cast< = const Okular::AnnotationObjectRect * >( annotobj )->annotation(); if ( ( QApplication::keyboardModifiers() & Qt::Control= Modifier ) - && static_cast< const Okular::AnnotationObjectRec= t * >( annotobj )->annotation()->canBeMoved() ) + && annotation->canBeMoved() ) { setCursor( Qt::OpenHandCursor ); } - else if ( static_cast< const Okular::AnnotationObjectR= ect * >( annotobj )->annotation()->subType() =3D=3D Okular::Annotation::AMo= vie ) + else if ( annotation->subType() =3D=3D Okular::Annotat= ion::AMovie ) { d->mouseOnRect =3D true; setCursor( Qt::PointingHandCursor ); } + else if ( annotation->subType() =3D=3D Okular::Annotat= ion::AScreen ) + { + if ( GuiUtils::renditionMovieFromScreenAnnotation(= static_cast< const Okular::ScreenAnnotation * >( annotation ) ) !=3D 0 ) + { + d->mouseOnRect =3D true; + setCursor( Qt::PointingHandCursor ); + } + } } else if ( Okular::Settings::mouseMode() =3D=3D Okular::Set= tings::EnumMouseMode::Browse ) { @@ -4621,6 +4651,45 @@ void PageView::slotProcessMovieAction( const Okular:= :MovieAction *action ) }; } = +void PageView::slotProcessRenditionAction( const Okular::RenditionAction *= action ) +{ + Okular::Movie *movie =3D action->movie(); + if ( !movie ) + return; + + const int currentPage =3D d->document->viewport().pageNumber; + + PageViewItem *item =3D d->items.at( currentPage ); + if ( !item ) + return; + + VideoWidget *vw =3D item->videoWidgets().value( movie ); + if ( !vw ) + return; + + if ( action->operation() =3D=3D 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" diff --git a/ui/pageview.h b/ui/pageview.h index 17b3717..aa7584c 100644 --- a/ui/pageview.h +++ b/ui/pageview.h @@ -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 *ac= tion ); }; = #endif diff --git a/ui/presentationwidget.cpp b/ui/presentationwidget.cpp index f160a31..35b9d34 100644 --- a/ui/presentationwidget.cpp +++ b/ui/presentationwidget.cpp @@ -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 * paren= t, Okular::Document * doc connect( m_nextPageTimer, SIGNAL(timeout()), this, SLOT(slotNextPage()= ) ); = = connect( m_document, SIGNAL(processMovieAction(const Okular::MovieActi= on*)), this, SLOT(slotProcessMovieAction(const Okular::MovieAction*)) ); + connect( m_document, SIGNAL(processRenditionAction(const Okular::Rendi= tionAction*)), this, SLOT(slotProcessRenditionAction(const Okular::Renditio= nAction*)) ); = // handle cursor appearance as specified in configuration if ( Okular::Settings::slidesCursor() =3D=3D Okular::Settings::EnumSli= desCursor::HiddenDelay ) @@ -320,6 +322,17 @@ void PresentationWidget::notifySetup( const QVector< O= kular::Page * > & pageSet, frame->videoWidgets.insert( movieAnn->movie(), vw ); vw->pageInitialized(); } + else if ( a->subType() =3D=3D Okular::Annotation::AScreen ) + { + const Okular::ScreenAnnotation * screenAnn =3D static_cast= < Okular::ScreenAnnotation * >( a ); + Okular::Movie *movie =3D GuiUtils::renditionMovieFromScree= nAnnotation( screenAnn ); + if ( movie ) + { + VideoWidget * vw =3D 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 =3D getAnnotation( e->x(), e-= >y() ); - if ( annotation && ( annotation->subType() =3D=3D Okular::Annotati= on::AMovie ) ) + if ( annotation ) { - const Okular::MovieAnnotation *movieAnnotation =3D static_cast= ( annotation ); + if ( annotation->subType() =3D=3D Okular::Annotation::AMovie ) + { + const Okular::MovieAnnotation *movieAnnotation =3D static_= cast( annotation ); = - VideoWidget *vw =3D m_frames[ m_frameIndex ]->videoWidgets.val= ue( movieAnnotation->movie() ); - vw->show(); - vw->play(); - return; + VideoWidget *vw =3D m_frames[ m_frameIndex ]->videoWidgets= .value( movieAnnotation->movie() ); + vw->show(); + vw->play(); + return; + } + else if ( annotation->subType() =3D=3D Okular::Annotation::ASc= reen ) + { + m_document->processAction( static_cast( annotation )->action() ); + return; + } } = // handle clicking on top-right overlay @@ -848,7 +869,8 @@ void PresentationWidget::testCursorOnLink( int x, int y= ) const Okular::Annotation *annotation =3D getAnnotation( x, y, 0 ); = const bool needsHandCursor =3D ( ( link !=3D 0 ) || - ( ( annotation !=3D 0 ) && ( annotation->= subType() =3D=3D Okular::Annotation::AMovie ) ) ); + ( ( annotation !=3D 0 ) && ( annotation->= subType() =3D=3D Okular::Annotation::AMovie ) ) || + ( ( annotation !=3D 0 ) && ( annotation->= subType() =3D=3D Okular::Annotation::AScreen ) && ( GuiUtils::renditionMovi= eFromScreenAnnotation( static_cast< const Okular::ScreenAnnotation * >( ann= otation ) ) !=3D 0 ) ) ); = // only react on changes (in/out from a link) if ( ( needsHandCursor && !m_handCursor ) || ( !needsHandCursor && m_h= andCursor ) ) @@ -2103,4 +2125,37 @@ void PresentationWidget::slotProcessMovieAction( con= st Okular::MovieAction *acti }; } = +void PresentationWidget::slotProcessRenditionAction( const Okular::Renditi= onAction *action ) +{ + Okular::Movie *movie =3D action->movie(); + if ( !movie ) + return; + + VideoWidget *vw =3D m_frames[ m_frameIndex ]->videoWidgets.value( movi= e ); + if ( !vw ) + return; + + if ( action->operation() =3D=3D 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" diff --git a/ui/presentationwidget.h b/ui/presentationwidget.h index 4cb4b2b..1608ef8 100644 --- a/ui/presentationwidget.h +++ b/ui/presentationwidget.h @@ -33,6 +33,7 @@ class Annotation; class Document; class MovieAction; class Page; +class RenditionAction; } = /** @@ -150,6 +151,7 @@ class PresentationWidget : public QWidget, public Okula= r::DocumentObserver void chooseScreen( QAction * ); void toggleBlackScreenMode( bool ); void slotProcessMovieAction( const Okular::MovieAction *action ); + void slotProcessRenditionAction( const Okular::RenditionAction *ac= tion ); }; = #endif