Load video widgets for the video annotations of the document in the main page view.

Add them as part of the page items, so they can be resized, moved and shown/hidden automatically according to the related pages.

svn path=/trunk/KDE/kdegraphics/okular/; revision=851960
This commit is contained in:
Pino Toscano 2008-08-25 01:59:23 +00:00
parent da420dbcd3
commit 6993fda364
3 changed files with 45 additions and 0 deletions

View file

@ -59,12 +59,14 @@
#include "pageviewannotator.h"
#include "toolaction.h"
#include "tts.h"
#include "videowidget.h"
#include "core/action.h"
#include "core/document.h"
#include "core/form.h"
#include "core/page.h"
#include "core/misc.h"
#include "core/generator.h"
#include "core/movie.h"
#include "settings.h"
static int pageflags = PagePainter::Accessibility | PagePainter::EnhanceLinks |
@ -771,6 +773,19 @@ void PageView::notifySetup( const QVector< Okular::Page * > & pageSet, int setup
hasformwidgets = true;
}
}
const QLinkedList< Okular::Annotation * > annotations = (*setIt)->annotations();
QLinkedList< Okular::Annotation * >::const_iterator aIt = annotations.begin(), aEnd = annotations.end();
for ( ; aIt != aEnd; ++aIt )
{
Okular::Annotation * a = *aIt;
if ( a->subType() == Okular::Annotation::AMovie )
{
Okular::MovieAnnotation * movieAnn = static_cast< Okular::MovieAnnotation * >( a );
VideoWidget * vw = new VideoWidget( movieAnn, d->document, widget() );
item->videoWidgets().insert( movieAnn->movie(), vw );
vw->show();
}
}
}
// invalidate layout so relayout/repaint will happen on next viewport change

View file

@ -32,6 +32,8 @@
// local includes
#include "formwidgets.h"
#include "guiutils.h"
#include "videowidget.h"
#include "core/movie.h"
#include "core/page.h"
#include "settings.h"
@ -50,6 +52,7 @@ PageViewItem::~PageViewItem()
QHash<int, FormWidgetIface*>::iterator it = m_formWidgets.begin(), itEnd = m_formWidgets.end();
for ( ; it != itEnd; ++it )
delete *it;
qDeleteAll( m_videoWidgets );
}
const Okular::Page * PageViewItem::page() const
@ -122,6 +125,11 @@ QHash<int, FormWidgetIface*>& PageViewItem::formWidgets()
return m_formWidgets;
}
QHash< Okular::Movie *, VideoWidget* >& PageViewItem::videoWidgets()
{
return m_videoWidgets;
}
void PageViewItem::setWHZC( int w, int h, double z, const Okular:: NormalizedRect & c )
{
m_croppedGeometry.setWidth( w );
@ -138,6 +146,13 @@ void PageViewItem::setWHZC( int w, int h, double z, const Okular:: NormalizedRec
qRound( fabs( r.right - r.left ) * m_uncroppedGeometry.width() ),
qRound( fabs( r.bottom - r.top ) * m_uncroppedGeometry.height() ) );
}
Q_FOREACH ( VideoWidget *vw, m_videoWidgets )
{
const Okular::NormalizedRect r = vw->normGeometry();
vw->resize(
qRound( fabs( r.right - r.left ) * m_uncroppedGeometry.width() ),
qRound( fabs( r.bottom - r.top ) * m_uncroppedGeometry.height() ) );
}
}
void PageViewItem::moveTo( int x, int y )
@ -155,12 +170,23 @@ void PageViewItem::moveTo( int x, int y )
qRound( x + m_uncroppedGeometry.width() * r.left ) + 1,
qRound( y + m_uncroppedGeometry.height() * r.top ) + 1 );
}
Q_FOREACH ( VideoWidget *vw, m_videoWidgets )
{
const Okular::NormalizedRect r = vw->normGeometry();
vw->move(
qRound( x + m_uncroppedGeometry.width() * r.left ) + 1,
qRound( y + m_uncroppedGeometry.height() * r.top ) + 1 );
}
}
void PageViewItem::setVisible( bool visible )
{
setFormWidgetsVisible( visible && m_formsVisible );
m_visible = visible;
Q_FOREACH ( VideoWidget *vw, m_videoWidgets )
{
vw->setVisible( m_visible );
}
}
void PageViewItem::invalidate()

View file

@ -24,8 +24,10 @@ class QAction;
class QLabel;
class QTimer;
class FormWidgetIface;
class VideoWidget;
namespace Okular {
class Movie;
class Page;
}
@ -46,6 +48,7 @@ class PageViewItem
double zoomFactor() const;
bool isVisible() const;
QHash<int, FormWidgetIface*>& formWidgets();
QHash< Okular::Movie *, VideoWidget * >& videoWidgets();
/* The page is cropped as follows: */
const Okular::NormalizedRect & crop() const;
@ -84,6 +87,7 @@ class PageViewItem
QRect m_uncroppedGeometry;
Okular::NormalizedRect m_crop;
QHash<int, FormWidgetIface*> m_formWidgets;
QHash< Okular::Movie *, VideoWidget * > m_videoWidgets;
};