From 6993fda3645caeb851793a786a54ca9b7ebd58dc Mon Sep 17 00:00:00 2001 From: Pino Toscano Date: Mon, 25 Aug 2008 01:59:23 +0000 Subject: [PATCH] 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 --- ui/pageview.cpp | 15 +++++++++++++++ ui/pageviewutils.cpp | 26 ++++++++++++++++++++++++++ ui/pageviewutils.h | 4 ++++ 3 files changed, 45 insertions(+) diff --git a/ui/pageview.cpp b/ui/pageview.cpp index 90857636f..453c0fce1 100644 --- a/ui/pageview.cpp +++ b/ui/pageview.cpp @@ -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 diff --git a/ui/pageviewutils.cpp b/ui/pageviewutils.cpp index 987ab28b1..98b03bb01 100644 --- a/ui/pageviewutils.cpp +++ b/ui/pageviewutils.cpp @@ -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::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& 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() diff --git a/ui/pageviewutils.h b/ui/pageviewutils.h index 7f562eb97..d252562c4 100644 --- a/ui/pageviewutils.h +++ b/ui/pageviewutils.h @@ -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& 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 m_formWidgets; + QHash< Okular::Movie *, VideoWidget * > m_videoWidgets; };