Fix positional arguments

This commit is contained in:
cutefishd 2021-03-31 12:54:58 +08:00
parent 140bbfd29c
commit 52ab6e64fa
2 changed files with 11 additions and 3 deletions

View file

@ -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);

View file

@ -72,6 +72,7 @@ Item {
isDesktopView: true
iconSize: globalSettings.desktopIconSize
focus: true
model: folderModel