From 52ab6e64faa973f1c61cdc6ba793b244cd78aa57 Mon Sep 17 00:00:00 2001 From: cutefishd Date: Wed, 31 Mar 2021 12:54:58 +0800 Subject: [PATCH] Fix positional arguments --- main.cpp | 13 ++++++++++--- qml/Desktop/main.qml | 1 + 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/main.cpp b/main.cpp index 6ef8847..e5a1290 100644 --- a/main.cpp +++ b/main.cpp @@ -72,12 +72,10 @@ int main(int argc, char *argv[]) QCommandLineOption desktopOption(QStringList() << "d" << "desktop" << "Desktop Mode"); parser.addOption(desktopOption); parser.process(app); - parser.addHelpOption(); if (parser.isSet(desktopOption)) { DesktopView view; view.show(); - return app.exec(); } @@ -92,7 +90,16 @@ int main(int argc, char *argv[]) // Handle urls if (!parser.positionalArguments().isEmpty()) { QStringList arguments = parser.positionalArguments(); - engine.rootContext()->setContextProperty("arg", arguments.first()); + QUrl url(arguments.first()); + if (!url.isValid()) + url = QUrl::fromLocalFile(arguments.first()); + + if (url.isValid()) + engine.rootContext()->setContextProperty("arg", arguments.first()); + else + engine.rootContext()->setContextProperty("arg", ""); + } else { + engine.rootContext()->setContextProperty("arg", ""); } engine.load(url); diff --git a/qml/Desktop/main.qml b/qml/Desktop/main.qml index 783c5e1..de4daa7 100644 --- a/qml/Desktop/main.qml +++ b/qml/Desktop/main.qml @@ -72,6 +72,7 @@ Item { isDesktopView: true iconSize: globalSettings.desktopIconSize + focus: true model: folderModel