[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [okular] ui: Adapt PageView and PresentationWidget to handle ScreenAnnotations correctly
From:       Tobias Koenig <tokoe () kde ! org>
Date:       2012-10-25 6:31:39
Message-ID: 20121025063139.0CF9AA6078 () git ! kde ! org
[Download RAW message or body]

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::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"
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 *action );
 };
 
 #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 * 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"
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 \
Okular::DocumentObserver  void chooseScreen( QAction * );
         void toggleBlackScreenMode( bool );
         void slotProcessMovieAction( const Okular::MovieAction *action );
+        void slotProcessRenditionAction( const Okular::RenditionAction *action );
 };
 
 #endif


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic