Make VideoWidget independet of associated annotation type

REVIEW: 106606
This commit is contained in:
Tobias Koenig 2012-09-27 13:02:14 +02:00
parent f713dd0fdf
commit d68bba55b4
4 changed files with 23 additions and 22 deletions

View file

@ -871,7 +871,7 @@ void PageView::notifySetup( const QVector< Okular::Page * > & pageSet, int setup
if ( a->subType() == Okular::Annotation::AMovie )
{
Okular::MovieAnnotation * movieAnn = static_cast< Okular::MovieAnnotation * >( a );
VideoWidget * vw = new VideoWidget( movieAnn, d->document, viewport() );
VideoWidget * vw = new VideoWidget( movieAnn, movieAnn->movie(), d->document, viewport() );
item->videoWidgets().insert( movieAnn->movie(), vw );
vw->pageInitialized();
}

View file

@ -316,7 +316,7 @@ void PresentationWidget::notifySetup( const QVector< Okular::Page * > & pageSet,
if ( a->subType() == Okular::Annotation::AMovie )
{
Okular::MovieAnnotation * movieAnn = static_cast< Okular::MovieAnnotation * >( a );
VideoWidget * vw = new VideoWidget( movieAnn, m_document, this );
VideoWidget * vw = new VideoWidget( movieAnn, movieAnn->movie(), m_document, this );
frame->videoWidgets.insert( movieAnn->movie(), vw );
vw->pageInitialized();
}

View file

@ -29,8 +29,8 @@
#include <phonon/seekslider.h>
#include <phonon/videoplayer.h>
#include "core/area.h"
#include "core/annotations.h"
#include "core/area.h"
#include "core/document.h"
#include "core/movie.h"
#include "snapshottaker.h"
@ -58,8 +58,8 @@ static QAction* createToolBarButtonWithWidgetPopup( QToolBar* toolBar, QWidget *
class VideoWidget::Private
{
public:
Private( Okular::MovieAnnotation *ma, Okular::Document *doc, VideoWidget *qq )
: q( qq ), anno( ma ), document( doc ), player( 0 ), loaded( false )
Private( Okular::Movie *m, Okular::Document *doc, VideoWidget *qq )
: q( qq ), movie( m ), document( doc ), player( 0 ), loaded( false )
{
}
@ -83,7 +83,7 @@ public:
void playOrPause();
VideoWidget *q;
Okular::MovieAnnotation *anno;
Okular::Movie *movie;
Okular::Document *document;
Okular::NormalizedRect geom;
Phonon::VideoPlayer *player;
@ -105,7 +105,7 @@ void VideoWidget::Private::load()
loaded = true;
QString url = anno->movie()->url();
QString url = movie->url();
KUrl newurl;
if ( QDir::isRelativePath( url ) )
{
@ -143,7 +143,7 @@ void VideoWidget::Private::setupPlayPauseAction( PlayPauseMode mode )
void VideoWidget::Private::takeSnapshot()
{
const QString url = anno->movie()->url();
const QString url = movie->url();
KUrl newurl;
if ( QDir::isRelativePath( url ) )
{
@ -166,7 +166,7 @@ void VideoWidget::Private::takeSnapshot()
void VideoWidget::Private::videoStopped()
{
if ( anno->movie()->showPosterImage() )
if ( movie->showPosterImage() )
pageLayout->setCurrentIndex( 1 );
else
q->hide();
@ -174,14 +174,14 @@ void VideoWidget::Private::videoStopped()
void VideoWidget::Private::finished()
{
switch ( anno->movie()->playMode() )
switch ( movie->playMode() )
{
case Okular::Movie::PlayOnce:
case Okular::Movie::PlayOpen:
// playback has ended, nothing to do
stopAction->setEnabled( false );
setupPlayPauseAction( PlayMode );
if ( anno->movie()->playMode() == Okular::Movie::PlayOnce )
if ( movie->playMode() == Okular::Movie::PlayOnce )
controlBar->setVisible( false );
videoStopped();
break;
@ -214,7 +214,7 @@ void VideoWidget::Private::setPosterImage( const QImage &image )
if ( !image.isNull() )
{
// cache the snapshot image
anno->movie()->setPosterImage( image );
movie->setPosterImage( image );
}
posterImagePage->setPixmap( QPixmap::fromImage( image ) );
@ -226,8 +226,8 @@ void VideoWidget::Private::stateChanged( Phonon::State newState, Phonon::State )
pageLayout->setCurrentIndex( 0 );
}
VideoWidget::VideoWidget( Okular::MovieAnnotation *movieann, Okular::Document *document, QWidget *parent )
: QWidget( parent ), d( new Private( movieann, document, this ) )
VideoWidget::VideoWidget( const Okular::Annotation *annotation, Okular::Movie *movie, Okular::Document *document, QWidget *parent )
: QWidget( parent ), d( new Private( movie, document, this ) )
{
// do not propagate the mouse events to the parent widget;
// they should be tied to this widget, not spread around...
@ -268,12 +268,12 @@ VideoWidget::VideoWidget( Okular::MovieAnnotation *movieann, Okular::Document *d
d->controlBar, verticalSeekSlider, KIcon( "player-time" ) );
d->seekSliderMenuAction->setVisible( false );
d->controlBar->setVisible( movieann->movie()->showControls() );
d->controlBar->setVisible( movie->showControls() );
connect( d->player, SIGNAL(finished()), this, SLOT(finished()) );
connect( d->playPauseAction, SIGNAL(triggered()), this, SLOT(playOrPause()) );
d->geom = movieann->transformedBoundingRectangle();
d->geom = annotation->transformedBoundingRectangle();
// Setup poster image page
d->posterImagePage = new QLabel;
@ -288,11 +288,11 @@ VideoWidget::VideoWidget( Okular::MovieAnnotation *movieann, Okular::Document *d
d->pageLayout->addWidget( d->posterImagePage );
if ( movieann->movie()->showPosterImage() )
if ( movie->showPosterImage() )
{
d->pageLayout->setCurrentIndex( 1 );
const QImage posterImage = movieann->movie()->posterImage();
const QImage posterImage = movie->posterImage();
if ( posterImage.isNull() )
{
d->takeSnapshot();
@ -335,13 +335,13 @@ void VideoWidget::pageInitialized()
void VideoWidget::pageEntered()
{
if ( d->anno->movie()->showPosterImage() )
if ( d->movie->showPosterImage() )
{
d->pageLayout->setCurrentIndex( 1 );
show();
}
if ( d->anno->movie()->autoPlay() )
if ( d->movie->autoPlay() )
{
show();
QMetaObject::invokeMethod(this, "play", Qt::QueuedConnection);

View file

@ -13,8 +13,9 @@
#include <qwidget.h>
namespace Okular {
class Annotation;
class Document;
class MovieAnnotation;
class Movie;
class NormalizedRect;
}
@ -22,7 +23,7 @@ class VideoWidget : public QWidget
{
Q_OBJECT
public:
VideoWidget( Okular::MovieAnnotation *movieann, Okular::Document *document, QWidget *parent = 0 );
VideoWidget( const Okular::Annotation *annot, Okular::Movie *movie, Okular::Document *document, QWidget *parent = 0 );
~VideoWidget();
void setNormGeometry( const Okular::NormalizedRect &rect );