Account for non local non relative video file urls

BUGS: 376574
This commit is contained in:
Albert Astals Cid 2017-02-20 01:06:30 +01:00
parent 6f3970dbe4
commit ee7e3737f4

View file

@ -99,6 +99,25 @@ public:
double repetitionsLeft;
};
static QUrl urlFromUrlString(const QString &url, Okular::Document *document)
{
QUrl newurl;
if ( url.startsWith( QLatin1Char( '/' ) ) )
{
newurl = QUrl::fromLocalFile( url );
}
else
{
newurl = QUrl( url );
if ( newurl.isRelative() )
{
newurl = document->currentDocument().adjusted(QUrl::RemoveFilename);
newurl.setPath( newurl.path() + url );
}
}
return newurl;
}
void VideoWidget::Private::load()
{
repetitionsLeft = movie->playRepetitions();
@ -107,21 +126,7 @@ void VideoWidget::Private::load()
loaded = true;
QString url = movie->url();
QUrl newurl;
if ( QDir::isRelativePath( url ) )
{
newurl = document->currentDocument().adjusted(QUrl::RemoveFilename);
newurl.setPath( newurl.path() + url );
}
else
{
newurl = QUrl::fromLocalFile(url);
}
if ( newurl.isLocalFile() )
player->load( newurl );
else
player->load( newurl );
player->load( urlFromUrlString( movie->url(), document ) );
connect( player->mediaObject(), SIGNAL( stateChanged( Phonon::State, Phonon::State ) ),
q, SLOT( stateChanged( Phonon::State, Phonon::State ) ) );
@ -145,23 +150,8 @@ void VideoWidget::Private::setupPlayPauseAction( PlayPauseMode mode )
void VideoWidget::Private::takeSnapshot()
{
const QString url = movie->url();
QUrl newurl;
if ( QDir::isRelativePath( url ) )
{
newurl = document->currentDocument().adjusted(QUrl::RemoveFilename);
newurl.setPath( newurl.path() + url );
}
else
{
newurl = QUrl::fromLocalFile(url);
}
SnapshotTaker *taker = 0;
if ( newurl.isLocalFile() )
taker = new SnapshotTaker( newurl, q );
else
taker = new SnapshotTaker( newurl, q );
const QUrl url = urlFromUrlString( movie->url(), document );
SnapshotTaker *taker = new SnapshotTaker( url, q );
q->connect( taker, SIGNAL( finished( const QImage& ) ), q, SLOT( setPosterImage( const QImage& ) ) );
}