Skip to content

Commit

Permalink
correctly convert url to original string
Browse files Browse the repository at this point in the history
encode then decode.
TODO: use url in qml if possible (QuickSubtitle)
  • Loading branch information
wang-bin committed Nov 7, 2014
1 parent fd9027c commit 8e2cb09
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 17 deletions.
12 changes: 2 additions & 10 deletions qml/QmlAVPlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,7 @@ void QmlAVPlayer::componentComplete()
{
// TODO: set player parameters
if (mSource.isValid() && (mAutoLoad || mAutoPlay)) {
if (mSource.isLocalFile()) {
mpPlayer->setFile(mSource.toLocalFile());
} else {
mpPlayer->setFile(mSource.toString());
}
mpPlayer->setFile(QUrl::fromPercentEncoding(mSource.toEncoded()));
}

m_complete = true;
Expand Down Expand Up @@ -134,11 +130,7 @@ void QmlAVPlayer::setSource(const QUrl &url)
if (mSource == url)
return;
mSource = url;
if (mSource.isLocalFile()) {
mpPlayer->setFile(mSource.toLocalFile());
} else {
mpPlayer->setFile(mSource.toString());
}
mpPlayer->setFile(QUrl::fromPercentEncoding(mSource.toEncoded()));
emit sourceChanged(); //TODO: emit only when player loaded a new source

if (mHasAudio) {
Expand Down
5 changes: 1 addition & 4 deletions qml/QuickVideoPreview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,7 @@ void QuickVideoPreview::setFile(const QUrl &value)
qDebug() << value;
m_file = value;
emit fileChanged();
if (m_file.isLocalFile())
m_extractor.setSource(m_file.toLocalFile());
else
m_extractor.setSource(m_file.toString());
m_extractor.setSource(QUrl::fromPercentEncoding(m_file.toEncoded()));
}

QUrl QuickVideoPreview::file() const
Expand Down
6 changes: 3 additions & 3 deletions src/subtitle/Subtitle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -345,14 +345,14 @@ void Subtitle::load()
return;
}
// read from a url
QFile f(priv->url.toString());//QUrl::FullyDecoded));
QFile f(QUrl::fromPercentEncoding(priv->url.toEncoded()));
if (f.exists()) {
u8 = priv->readFromFile(f.fileName());
if (u8.isEmpty())
return;
priv->loaded = priv->processRawData(u8);
if (priv->loaded)
emit loaded(priv->url.toString());
emit loaded(QUrl::fromPercentEncoding(priv->url.toEncoded()));
checkCapability();
if (old_processor != priv->processor)
emit engineChanged();
Expand Down Expand Up @@ -699,7 +699,7 @@ bool Subtitle::Private::processRawData(SubtitleProcessor *sp, const QByteArray &
qWarning() << "open subtitle qbuffer error: " << buf.errorString();
}
qDebug("processing subtitle from a tmp utf8 file...");
QString name = url.toLocalFile().section('/', -1);
QString name = QUrl::fromPercentEncoding(url.toEncoded()).section('/', -1);
if (name.isEmpty())
name = QFileInfo(file_name).fileName(); //priv->name.section('/', -1); // if no seperator?
if (name.isEmpty())
Expand Down

0 comments on commit 8e2cb09

Please sign in to comment.