]> Some of my projects - aniplayer.git/commitdiff
Assume positional arguments are local files
authorAPTX <marek321@gmail.com>
Mon, 27 Feb 2017 00:36:33 +0000 (01:36 +0100)
committerAPTX <marek321@gmail.com>
Mon, 27 Feb 2017 00:36:33 +0000 (01:36 +0100)
This should make it possible to use relative file paths
as arguments.

core/instancemanager.cpp

index 1cb2df3b6b36956081a96eaaa0691d19e626decf..38d556d404f728335440eb65eb800b145659aafb 100644 (file)
@@ -25,6 +25,7 @@ void InstanceManager::startFirstInstance() {
   m_parser.process(*qApp);
 
   const auto positionalArgs = m_parser.positionalArguments();
+  qDebug() << "ARGS" << positionalArgs;
 
   QQmlApplicationEngine *engine = new QQmlApplicationEngine{this};
   Q_CHECK_PTR(engine);
@@ -34,8 +35,12 @@ void InstanceManager::startFirstInstance() {
 
   m_instances.insert(player);
 
-  if (!positionalArgs.empty())
-    player->setNextSource(QUrl::fromUserInput(positionalArgs[0]));
+  if (!positionalArgs.empty()) {
+    auto url =
+        QUrl::fromUserInput(positionalArgs[0], ".", QUrl::AssumeLocalFile);
+    qCDebug(imCategory) << "Parsed positional argument as" << url;
+    player->setNextSource(url);
+  }
   TimeFormatter timeFormatter;
   engine->rootContext()->setContextProperty("player", player);
   engine->rootContext()->setContextProperty("timeFormatter", &timeFormatter);