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

List:       kde-commits
Subject:    [okular] ui: Fix visibility of VideoWidget on page change events
From:       Tobias Koenig <tokoe () kde ! org>
Date:       2012-09-21 9:33:10
Message-ID: 20120921093310.C01C0A6094 () git ! kde ! org
[Download RAW message or body]

Git commit f70dc3c1e111d9a8cd1b8bcbc595765776d3f7eb by Tobias Koenig.
Committed on 21/09/2012 at 11:20.
Pushed by tokoe into branch 'master'.

Fix visibility of VideoWidget on page change events

We have to differ between the initialization and the
'page entered' and 'page left' event.
This avoids that all VideoWidgets with poster image show up
on first slide or do no disappear when changing slide.

M  +25   -1    ui/pageview.cpp
M  +1    -0    ui/pageview.h
M  +1    -1    ui/presentationwidget.cpp
M  +5    -1    ui/videowidget.cpp
M  +5    -0    ui/videowidget.h

http://commits.kde.org/okular/f70dc3c1e111d9a8cd1b8bcbc595765776d3f7eb

diff --git a/ui/pageview.cpp b/ui/pageview.cpp
index d3e1888..205a9fa 100644
--- a/ui/pageview.cpp
+++ b/ui/pageview.cpp
@@ -863,7 +863,7 @@ void PageView::notifySetup( const QVector< Okular::Page * > & pageSet, int setup
                 Okular::MovieAnnotation * movieAnn = static_cast< Okular::MovieAnnotation * >( a );
                 VideoWidget * vw = new VideoWidget( movieAnn, d->document, viewport() );
                 item->videoWidgets().insert( movieAnn->movie(), vw );
-                vw->pageEntered();
+                vw->pageInitialized();
             }
         }
     }
@@ -1232,6 +1232,30 @@ bool PageView::canUnloadPixmap( int pageNumber ) const
     // if hidden premit unloading
     return true;
 }
+
+void PageView::notifyCurrentPageChanged( int previous, int current )
+{
+    if ( previous != -1 )
+    {
+        PageViewItem * item = d->items.at( previous );
+        if ( item )
+        {
+            Q_FOREACH ( VideoWidget *videoWidget, item->videoWidgets() )
+                videoWidget->pageLeft();
+        }
+    }
+
+    if ( current != -1 )
+    {
+        PageViewItem * item = d->items.at( current );
+        if ( item )
+        {
+            Q_FOREACH ( VideoWidget *videoWidget, item->videoWidgets() )
+                videoWidget->pageEntered();
+        }
+    }
+}
+
 //END DocumentObserver inherited methods
 
 //BEGIN View inherited methods
diff --git a/ui/pageview.h b/ui/pageview.h
index 8cf8844..9f56620 100644
--- a/ui/pageview.h
+++ b/ui/pageview.h
@@ -82,6 +82,7 @@ Q_OBJECT
         void notifyContentsCleared( int changedFlags );
         void notifyZoom(int factor);
         bool canUnloadPixmap( int pageNum ) const;
+        void notifyCurrentPageChanged( int previous, int current );
 
         // inherited from View
         uint viewId() const { return observerId(); }
diff --git a/ui/presentationwidget.cpp b/ui/presentationwidget.cpp
index 95e78d4..b15ad71 100644
--- a/ui/presentationwidget.cpp
+++ b/ui/presentationwidget.cpp
@@ -318,7 +318,7 @@ void PresentationWidget::notifySetup( const QVector< Okular::Page * > & pageSet,
                 Okular::MovieAnnotation * movieAnn = static_cast< Okular::MovieAnnotation * >( a );
                 VideoWidget * vw = new VideoWidget( movieAnn, m_document, this );
                 frame->videoWidgets.insert( movieAnn->movie(), vw );
-                vw->pageEntered();
+                vw->pageInitialized();
             }
         }
         frame->recalcGeometry( m_width, m_height, screenRatio );
diff --git a/ui/videowidget.cpp b/ui/videowidget.cpp
index ea0e5b8..3d7ebab 100644
--- a/ui/videowidget.cpp
+++ b/ui/videowidget.cpp
@@ -212,7 +212,6 @@ void VideoWidget::Private::setPosterImage( const QImage &image )
     }
 
     posterImagePage->setPixmap( QPixmap::fromImage( image ) );
-    q->show();
 }
 
 void VideoWidget::Private::stateChanged( Phonon::State newState, Phonon::State )
@@ -323,6 +322,11 @@ bool VideoWidget::isPlaying() const
     return d->player->isPlaying();
 }
 
+void VideoWidget::pageInitialized()
+{
+    hide();
+}
+
 void VideoWidget::pageEntered()
 {
     if ( d->anno->movie()->showPosterImage() )
diff --git a/ui/videowidget.h b/ui/videowidget.h
index 384e2ff..f5d22b9 100644
--- a/ui/videowidget.h
+++ b/ui/videowidget.h
@@ -31,6 +31,11 @@ class VideoWidget : public QWidget
         bool isPlaying() const;
 
         /**
+         * This method is called when the page the video widget is located on has been initialized.
+         */
+        void pageInitialized();
+
+        /**
          * This method is called when the page the video widget is located on has been entered.
          */
         void pageEntered();
[prev in list] [next in list] [prev in thread] [next in thread] 

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