From: Friedemann Kleint Date: Wed, 31 Jul 2013 09:15:25 +0000 (+0200) Subject: Fix file browser in qmlvideofx example. X-Git-Tag: upstream/5.2.95+rc1~52^2~5 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=c86d14a380118bc530547c69ba982d2c5e04a992;p=platform%2Fupstream%2Fqtmultimedia.git Fix file browser in qmlvideofx example. Similar to de9092389f2e43370c2cfcd6759d08cc11da9a68 for qmlvideo. 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: I36bafaa608ff054190dc76694f6254a74f3b513e Reviewed-by: Yoann Lopes --- diff --git a/examples/multimedia/video/qmlvideofx/main.cpp b/examples/multimedia/video/qmlvideofx/main.cpp index b0698e2..7465dea 100644 --- a/examples/multimedia/video/qmlvideofx/main.cpp +++ b/examples/multimedia/video/qmlvideofx/main.cpp @@ -116,21 +116,13 @@ int main(int argc, char *argv[]) FileReader fileReader; viewer.rootContext()->setContextProperty("fileReader", &fileReader); - QUrl appPath(QString("file://%1").arg(app.applicationDirPath())); - QUrl imagePath; + const QUrl appPath(QUrl::fromLocalFile(app.applicationDirPath())); const QStringList picturesLocation = QStandardPaths::standardLocations(QStandardPaths::PicturesLocation); - if (picturesLocation.isEmpty()) - imagePath = appPath.resolved(QUrl("images")); - else - imagePath = QString("file://%1").arg(picturesLocation.first()); + const QUrl imagePath = picturesLocation.isEmpty() ? appPath : QUrl::fromLocalFile(picturesLocation.first()); viewer.rootContext()->setContextProperty("imagePath", imagePath); - QUrl videoPath; const QStringList moviesLocation = QStandardPaths::standardLocations(QStandardPaths::MoviesLocation); - if (moviesLocation.isEmpty()) - videoPath = appPath.resolved(QUrl("./")); - else - videoPath = QString("file://%1").arg(moviesLocation.first()); + const QUrl videoPath = moviesLocation.isEmpty() ? appPath : QUrl::fromLocalFile(moviesLocation.first()); viewer.rootContext()->setContextProperty("videoPath", videoPath); viewer.setTitle("qmlvideofx"); diff --git a/examples/multimedia/video/qmlvideofx/qml/qmlvideofx/FileBrowser.qml b/examples/multimedia/video/qmlvideofx/qml/qmlvideofx/FileBrowser.qml index 3d4343c..7c86103 100644 --- a/examples/multimedia/video/qmlvideofx/qml/qmlvideofx/FileBrowser.qml +++ b/examples/multimedia/video/qmlvideofx/qml/qmlvideofx/FileBrowser.qml @@ -102,7 +102,10 @@ Rectangle { Rectangle { id: wrapper function launch() { - var path = "file://" + filePath + var path = "file://"; + if (filePath.length > 2 && filePath[1] === ':') // Windows drive logic, see QUrl::fromLocalFile() + path += '/'; + path += filePath; if (folders.isFolder(index)) down(path); else @@ -307,7 +310,7 @@ Rectangle { MouseArea { id: upRegion; anchors.centerIn: parent width: 56 height: 56 - onClicked: if (folders.parentFolder != "") up() + onClicked: up() } states: [ State { @@ -353,6 +356,8 @@ Rectangle { function up() { var path = folders.parentFolder; + if (path.toString().length === 0 || path.toString() === 'file:') + return; if (folders == folders1) { view = view2 folders = folders2;