Commit f70dc3c1 authored by Tobias Koenig's avatar Tobias Koenig
Browse files

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.
parent 770e2818
......@@ -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
......
......@@ -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(); }
......
......@@ -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 );
......
......@@ -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() )
......
......@@ -30,6 +30,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.
*/
......
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