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:
committed by
The Qt Project
parent
9f26d9e242
commit
de9092389f
@@ -129,13 +129,11 @@ int main(int argc, char *argv[])
|
|||||||
rootObject, SLOT(qmlFramePainted()));
|
rootObject, SLOT(qmlFramePainted()));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
QUrl videoPath;
|
|
||||||
const QStringList moviesLocation = QStandardPaths::standardLocations(QStandardPaths::MoviesLocation);
|
const QStringList moviesLocation = QStandardPaths::standardLocations(QStandardPaths::MoviesLocation);
|
||||||
if (moviesLocation.isEmpty()) {
|
const QUrl videoPath =
|
||||||
QUrl appPath(QString("file://%1").arg(app.applicationDirPath()));
|
QUrl::fromLocalFile(moviesLocation.isEmpty() ?
|
||||||
videoPath = appPath.resolved(QUrl("./"));
|
app.applicationDirPath() :
|
||||||
} else
|
moviesLocation.front());
|
||||||
videoPath = QString("file://%1").arg(moviesLocation.first());
|
|
||||||
viewer.rootContext()->setContextProperty("videoPath", videoPath);
|
viewer.rootContext()->setContextProperty("videoPath", videoPath);
|
||||||
|
|
||||||
QMetaObject::invokeMethod(rootObject, "init");
|
QMetaObject::invokeMethod(rootObject, "init");
|
||||||
|
|||||||
@@ -101,7 +101,11 @@ Rectangle {
|
|||||||
Rectangle {
|
Rectangle {
|
||||||
id: wrapper
|
id: wrapper
|
||||||
function launch() {
|
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))
|
if (folders.isFolder(index))
|
||||||
down(path);
|
down(path);
|
||||||
else
|
else
|
||||||
@@ -306,7 +310,7 @@ Rectangle {
|
|||||||
MouseArea { id: upRegion; anchors.centerIn: parent
|
MouseArea { id: upRegion; anchors.centerIn: parent
|
||||||
width: 56
|
width: 56
|
||||||
height: 56
|
height: 56
|
||||||
onClicked: if (folders.parentFolder != "") up()
|
onClicked: up()
|
||||||
}
|
}
|
||||||
states: [
|
states: [
|
||||||
State {
|
State {
|
||||||
@@ -352,6 +356,8 @@ Rectangle {
|
|||||||
|
|
||||||
function up() {
|
function up() {
|
||||||
var path = folders.parentFolder;
|
var path = folders.parentFolder;
|
||||||
|
if (path.toString().length === 0 || path.toString() === 'file:')
|
||||||
|
return;
|
||||||
if (folders == folders1) {
|
if (folders == folders1) {
|
||||||
view = view2
|
view = view2
|
||||||
folders = folders2;
|
folders = folders2;
|
||||||
|
|||||||
Reference in New Issue
Block a user