summaryrefslogtreecommitdiffstats
path: root/examples/multimedia
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@digia.com>2013-07-26 14:18:16 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-07-30 16:38:48 +0200
commitde9092389f2e43370c2cfcd6759d08cc11da9a68 (patch)
treea632ed80e7c5f5b33598915bd8e190ad7afc40ac /examples/multimedia
parent9f26d9e24230d73f6525723cb972ca880fdcb07a (diff)
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>
Diffstat (limited to 'examples/multimedia')
-rw-r--r--examples/multimedia/video/qmlvideo/main.cpp10
-rw-r--r--examples/multimedia/video/qmlvideo/qml/qmlvideo/FileBrowser.qml10
2 files changed, 12 insertions, 8 deletions
diff --git a/examples/multimedia/video/qmlvideo/main.cpp b/examples/multimedia/video/qmlvideo/main.cpp
index 81c38d240..a14684ff7 100644
--- a/examples/multimedia/video/qmlvideo/main.cpp
+++ b/examples/multimedia/video/qmlvideo/main.cpp
@@ -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");
diff --git a/examples/multimedia/video/qmlvideo/qml/qmlvideo/FileBrowser.qml b/examples/multimedia/video/qmlvideo/qml/qmlvideo/FileBrowser.qml
index 18b7b0e09..cb668b8e9 100644
--- a/examples/multimedia/video/qmlvideo/qml/qmlvideo/FileBrowser.qml
+++ b/examples/multimedia/video/qmlvideo/qml/qmlvideo/FileBrowser.qml
@@ -101,7 +101,11 @@ Rectangle {
Rectangle {
id: wrapper
function launch() {
- var path = "file://" + filePath;
+ console.debug("launch " + 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
@@ -306,7 +310,7 @@ Rectangle {
MouseArea { id: upRegion; anchors.centerIn: parent
width: 56
height: 56
- onClicked: if (folders.parentFolder != "") up()
+ onClicked: up()
}
states: [
State {
@@ -352,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;