Commit 486df962 authored by Tobias Koenig's avatar Tobias Koenig
Browse files

Make video player behave similar to Adobe Acroread

Hide the video player initially until the user has clicked on
the annotation area. This ensures that an available 'first-frame' image
is always visible. Also change the appearance of the mouse cursor when
the annotation area is entered.

REVIEW:104159
parent 1a96a7c7
......@@ -859,7 +859,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->show();
vw->hide();
}
}
}
......@@ -2207,6 +2207,18 @@ void PageView::mouseReleaseEvent( QMouseEvent * e )
}
else
{
Okular::Annotation *ann = 0;
rect = pageItem->page()->objectRect( Okular::ObjectRect::OAnnotation, nX, nY, pageItem->uncroppedWidth(), pageItem->uncroppedHeight() );
if ( rect )
ann = ( (Okular::AnnotationObjectRect *)rect )->annotation();
if ( ann )
{
VideoWidget *vw = pageItem->videoWidgets().value( static_cast<Okular::MovieAnnotation*>( ann )->movie() );
vw->show();
vw->play();
}
#if 0
// a link can move us to another page or even to another document, there's no point in trying to
// process the click on the image once we have processes the click on the link
......@@ -3491,11 +3503,18 @@ void PageView::updateCursor( const QPoint &p )
else
{
d->mouseOnRect = false;
if ( annotobj
&& ( QApplication::keyboardModifiers() & Qt::ControlModifier )
&& static_cast< const Okular::AnnotationObjectRect * >( annotobj )->annotation()->canBeMoved() )
if ( annotobj )
{
setCursor( Qt::OpenHandCursor );
if ( ( QApplication::keyboardModifiers() & Qt::ControlModifier )
&& static_cast< const Okular::AnnotationObjectRect * >( annotobj )->annotation()->canBeMoved() )
{
setCursor( Qt::OpenHandCursor );
}
else if ( static_cast< const Okular::AnnotationObjectRect * >( annotobj )->annotation()->subType() == Okular::Annotation::AMovie )
{
d->mouseOnRect = true;
setCursor( Qt::PointingHandCursor );
}
}
else if ( Okular::Settings::mouseMode() == Okular::Settings::EnumMouseMode::Browse )
{
......@@ -3881,6 +3900,7 @@ void PageView::slotRequestVisiblePixmaps( int newValue )
if ( vw->isPlaying() && viewportRectAtZeroZero.intersect( vw->geometry() ).isEmpty() ) {
vw->stop();
vw->hide();
}
}
......
......@@ -182,10 +182,6 @@ 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()
......
......@@ -489,6 +489,17 @@ void PresentationWidget::mousePressEvent( QMouseEvent * e )
if ( ( m_pressedLink = getLink( e->x(), e->y() ) ) )
return;
const Okular::Annotation *annotation = getAnnotation( e->x(), e->y() );
if ( annotation && ( annotation->subType() == Okular::Annotation::AMovie ) )
{
const Okular::MovieAnnotation *movieAnnotation = static_cast<const Okular::MovieAnnotation*>( annotation );
VideoWidget *vw = m_frames[ m_frameIndex ]->videoWidgets.value( movieAnnotation->movie() );
vw->show();
vw->play();
return;
}
// handle clicking on top-right overlay
if ( !( Okular::Settings::slidesCursor() == Okular::Settings::EnumSlidesCursor::Hidden ) &&
m_overlayGeometry.contains( e->pos() ) )
......@@ -679,7 +690,7 @@ void PresentationWidget::leaveEvent( QEvent * e )
}
// </widget events>
const Okular::Action * PresentationWidget::getLink( int x, int y, QRect * geometry ) const
const void * PresentationWidget::getObjectRect( Okular::ObjectRect::ObjectType type, int x, int y, QRect * geometry ) const
{
// no links on invalid pages
if ( geometry && !geometry->isNull() )
......@@ -702,7 +713,7 @@ const Okular::Action * PresentationWidget::getLink( int x, int y, QRect * geomet
// check if 1) there is an object and 2) it's a link
const QRect d = QApplication::desktop()->screenGeometry( m_screen );
const Okular::ObjectRect * object = page->objectRect( Okular::ObjectRect::Action, nx, ny, d.width(), d.height() );
const Okular::ObjectRect * object = page->objectRect( type, nx, ny, d.width(), d.height() );
if ( !object )
return 0;
......@@ -714,18 +725,32 @@ const Okular::Action * PresentationWidget::getLink( int x, int y, QRect * geomet
}
// return the link pointer
return (Okular::Action *)object->object();
return object->object();
}
const Okular::Action * PresentationWidget::getLink( int x, int y, QRect * geometry ) const
{
return reinterpret_cast<const Okular::Action*>( getObjectRect( Okular::ObjectRect::Action, x, y, geometry ) );
}
const Okular::Annotation * PresentationWidget::getAnnotation( int x, int y, QRect * geometry ) const
{
return reinterpret_cast<const Okular::Annotation*>( getObjectRect( Okular::ObjectRect::OAnnotation, x, y, geometry ) );
}
void PresentationWidget::testCursorOnLink( int x, int y )
{
const Okular::Action * link = getLink( x, y, 0 );
const Okular::Annotation *annotation = getAnnotation( x, y, 0 );
const bool needsHandCursor = ( ( link != 0 ) ||
( ( annotation != 0 ) && ( annotation->subType() == Okular::Annotation::AMovie ) ) );
// only react on changes (in/out from a link)
if ( (link && !m_handCursor) || (!link && m_handCursor) )
if ( ( needsHandCursor && !m_handCursor ) || ( !needsHandCursor && m_handCursor ) )
{
// change cursor shape
m_handCursor = link != 0;
m_handCursor = needsHandCursor;
setCursor( QCursor( m_handCursor ? Qt::PointingHandCursor : Qt::ArrowCursor ) );
}
}
......@@ -804,13 +829,6 @@ void PresentationWidget::changePage( int newPage )
vw->hide();
}
}
Q_FOREACH ( VideoWidget *vw, m_frames[ m_frameIndex ]->videoWidgets )
{
vw->show();
vw->raise();
}
}
}
......
......@@ -14,6 +14,7 @@
#include <qpixmap.h>
#include <qstringlist.h>
#include <qwidget.h>
#include "core/area.h"
#include "core/observer.h"
#include "core/pagetransition.h"
......@@ -68,7 +69,9 @@ class PresentationWidget : public QWidget, public Okular::DocumentObserver
void leaveEvent( QEvent * e );
private:
const void * getObjectRect( Okular::ObjectRect::ObjectType type, int x, int y, QRect * geometry = 0 ) const;
const Okular::Action * getLink( int x, int y, QRect * geometry = 0 ) const;
const Okular::Annotation * getAnnotation( int x, int y, QRect * geometry = 0 ) const;
void testCursorOnLink( int x, int y );
void overlayClick( const QPoint & position );
void changePage( int newPage );
......
......@@ -27,7 +27,7 @@ class VideoWidget : public QWidget
void setNormGeometry( const Okular::NormalizedRect &rect );
Okular::NormalizedRect normGeometry() const;
bool isPlaying() const;
public slots:
......
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