Commit 89e2611f authored by Albert Astals Cid's avatar Albert Astals Cid
Browse files

Stop playing videos when they are no longer visible

This mimics Adobe Reader behaviour
BUGS: 286932
FIXED-IN: 4.8.0
parent e56df195
...@@ -3832,6 +3832,7 @@ void PageView::slotRequestVisiblePixmaps( int newValue ) ...@@ -3832,6 +3832,7 @@ void PageView::slotRequestVisiblePixmaps( int newValue )
QRect viewportRect( horizontalScrollBar()->value(), QRect viewportRect( horizontalScrollBar()->value(),
verticalScrollBar()->value(), verticalScrollBar()->value(),
viewport()->width(), viewport()->height() ); viewport()->width(), viewport()->height() );
const QRect viewportRectAtZeroZero( 0, 0, viewport()->width(), viewport()->height() );
// some variables used to determine the viewport // some variables used to determine the viewport
int nearPageNumber = -1; int nearPageNumber = -1;
...@@ -3862,6 +3863,10 @@ void PageView::slotRequestVisiblePixmaps( int newValue ) ...@@ -3862,6 +3863,10 @@ void PageView::slotRequestVisiblePixmaps( int newValue )
vw->move( vw->move(
qRound( i->uncroppedGeometry().left() + i->uncroppedWidth() * r.left ) + 1 - viewportRect.left(), qRound( i->uncroppedGeometry().left() + i->uncroppedWidth() * r.left ) + 1 - viewportRect.left(),
qRound( i->uncroppedGeometry().top() + i->uncroppedHeight() * r.top ) + 1 - viewportRect.top() ); qRound( i->uncroppedGeometry().top() + i->uncroppedHeight() * r.top ) + 1 - viewportRect.top() );
if ( vw->isPlaying() && viewportRectAtZeroZero.intersect( vw->geometry() ).isEmpty() ) {
vw->stop();
}
} }
if ( !i->isVisible() ) if ( !i->isVisible() )
......
...@@ -219,6 +219,11 @@ Okular::NormalizedRect VideoWidget::normGeometry() const ...@@ -219,6 +219,11 @@ Okular::NormalizedRect VideoWidget::normGeometry() const
return d->geom; return d->geom;
} }
bool VideoWidget::isPlaying() const
{
return d->player->isPlaying();
}
void VideoWidget::play() void VideoWidget::play()
{ {
d->load(); d->load();
......
...@@ -28,6 +28,8 @@ class VideoWidget : public QWidget ...@@ -28,6 +28,8 @@ class VideoWidget : public QWidget
void setNormGeometry( const Okular::NormalizedRect &rect ); void setNormGeometry( const Okular::NormalizedRect &rect );
Okular::NormalizedRect normGeometry() const; Okular::NormalizedRect normGeometry() const;
bool isPlaying() const;
public slots: public slots:
void play(); void play();
void pause(); void pause();
......
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