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
remotes/origin/old/work/tiff-improvements
Pino Toscano 18 years ago
parent da420dbcd3
commit 6993fda364
  1. 15
      ui/pageview.cpp
  2. 26
      ui/pageviewutils.cpp
  3. 4
      ui/pageviewutils.h

@ -59,12 +59,14 @@
#include "pageviewannotator.h" #include "pageviewannotator.h"
#include "toolaction.h" #include "toolaction.h"
#include "tts.h" #include "tts.h"
#include "videowidget.h"
#include "core/action.h" #include "core/action.h"
#include "core/document.h" #include "core/document.h"
#include "core/form.h" #include "core/form.h"
#include "core/page.h" #include "core/page.h"
#include "core/misc.h" #include "core/misc.h"
#include "core/generator.h" #include "core/generator.h"
#include "core/movie.h"
#include "settings.h" #include "settings.h"
static int pageflags = PagePainter::Accessibility | PagePainter::EnhanceLinks | static int pageflags = PagePainter::Accessibility | PagePainter::EnhanceLinks |
@ -771,6 +773,19 @@ void PageView::notifySetup( const QVector< Okular::Page * > & pageSet, int setup
hasformwidgets = true; 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 // invalidate layout so relayout/repaint will happen on next viewport change

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

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

Loading…
Cancel
Save