Fix file browser in qmlvideo example.

Use QUrl::fromLocalFile() to get Windows drive handling
right. Emulate its behavior in QML code. Fix up() to terminate
correctly.

Task-number: QTBUG-32139

Change-Id: Iec6d9f96fbe2181c939e9dbbe6aa042eac630918
Reviewed-by: Shawn Rutledge <shawn.rutledge@digia.com>
This commit is contained in:
Friedemann Kleint
2013-07-26 14:18:16 +02:00
committed by The Qt Project
parent 9f26d9e242
commit de9092389f
2 changed files with 12 additions and 8 deletions

View File

@@ -129,13 +129,11 @@ int main(int argc, char *argv[])
rootObject, SLOT(qmlFramePainted()));
#endif
QUrl videoPath;
const QStringList moviesLocation = QStandardPaths::standardLocations(QStandardPaths::MoviesLocation);
if (moviesLocation.isEmpty()) {
QUrl appPath(QString("file://%1").arg(app.applicationDirPath()));
videoPath = appPath.resolved(QUrl("./"));
} else
videoPath = QString("file://%1").arg(moviesLocation.first());
const QUrl videoPath =
QUrl::fromLocalFile(moviesLocation.isEmpty() ?
app.applicationDirPath() :
moviesLocation.front());
viewer.rootContext()->setContextProperty("videoPath", videoPath);
QMetaObject::invokeMethod(rootObject, "init");