[{"id":4688,"web_url":"https://patchwork.libcamera.org/comment/4688/","msgid":"<20200430192350.GU5856@pendragon.ideasonboard.com>","date":"2020-04-30T19:23:50","subject":"Re: [libcamera-devel] [RFC/PATCH 3/5] qcam: Add an option to allow\n\tspecifying output path","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Niklas,\n\nThank you for the patch.\n\nOn Thu, Apr 30, 2020 at 02:36:02AM +0200, Niklas Söderlund wrote:\n> Add a command line option to specify an output path for files captured.\n> This will become more useful when JPEG capture is turned into an quick\n> operation instead of using a QFileDialog and when RAW capture support is\n> added.\n\nI'll comment on that when reviewing the corresponding patch.\n\n> \n> Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n> ---\n>  src/qcam/main.cpp        | 3 +++\n>  src/qcam/main_window.cpp | 8 ++++++--\n>  src/qcam/main_window.h   | 2 ++\n>  3 files changed, 11 insertions(+), 2 deletions(-)\n> \n> diff --git a/src/qcam/main.cpp b/src/qcam/main.cpp\n> index cd73fa764614e7e7..2999e4959d8ecff8 100644\n> --- a/src/qcam/main.cpp\n> +++ b/src/qcam/main.cpp\n> @@ -34,6 +34,9 @@ OptionsParser::Options parseOptions(int argc, char *argv[])\n>  \t\t\t \"help\");\n>  \tparser.addOption(OptStream, &streamKeyValue,\n>  \t\t\t \"Set configuration of a camera stream\", \"stream\", true);\n> +\tparser.addOption(OptSavePath, OptionString,\n> +\t\t\t \"Path to qcam picture storage\",\n> +\t\t\t \"output-dir\", ArgumentRequired, \"path\");\n\nWould it make sense to mention the default here ? Maybe doing\n\n\tdefaultPath_ = QStandardPaths::writableLocation(QStandardPaths::PicturesLocation);\n\nbefore parsing options, and having\n\n\tparser.addOption(OptSavePath, OptionString,\n\t\t\t \"Path to qcam picture storage (default: \" + defaultPath_ + \")\",\n\t\t\t \"output-dir\", ArgumentRequired, \"path\");\n\n(likely with QString/std::string conversion I'm afraid :-S)\n\n>  \n>  \tOptionsParser::Options options = parser.parse(argc, argv);\n>  \tif (options.isSet(OptHelp))\n> diff --git a/src/qcam/main_window.cpp b/src/qcam/main_window.cpp\n> index e77bc01df8f3edfe..470f78162cabffe5 100644\n> --- a/src/qcam/main_window.cpp\n> +++ b/src/qcam/main_window.cpp\n> @@ -75,6 +75,11 @@ MainWindow::MainWindow(CameraManager *cm, const OptionsParser::Options &options)\n>  \t\treturn;\n>  \t}\n>  \n> +\tif (options_.isSet(OptSavePath))\n> +\t\tdefaultPath_ = QString::fromUtf8(options_[OptSavePath].toString().c_str());\n> +\telse\n> +\t\tdefaultPath_ = QStandardPaths::writableLocation(QStandardPaths::PicturesLocation);\n\nAnd this would then become\n\n\tif (options_.isSet(OptSavePath))\n\t\tdefaultPath_ = QString::fromUtf8(options_[OptSavePath].toString().c_str());\n\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\n> +\n>  \tstartStopAction_->setChecked(true);\n>  }\n>  \n> @@ -507,9 +512,8 @@ void MainWindow::stopCapture()\n>  void MainWindow::saveImageAs()\n>  {\n>  \tQImage image = viewfinder_->getCurrentImage();\n> -\tQString defaultPath = QStandardPaths::writableLocation(QStandardPaths::PicturesLocation);\n>  \n> -\tQString filename = QFileDialog::getSaveFileName(this, \"Save Image\", defaultPath,\n> +\tQString filename = QFileDialog::getSaveFileName(this, \"Save Image\", defaultPath_,\n>  \t\t\t\t\t\t\t\"Image Files (*.png *.jpg *.jpeg)\");\n>  \tif (filename.isEmpty())\n>  \t\treturn;\n> diff --git a/src/qcam/main_window.h b/src/qcam/main_window.h\n> index c2040c0ebcd61bfa..7b8a185511e17a8f 100644\n> --- a/src/qcam/main_window.h\n> +++ b/src/qcam/main_window.h\n> @@ -33,6 +33,7 @@ class QAction;\n>  enum {\n>  \tOptCamera = 'c',\n>  \tOptHelp = 'h',\n> +\tOptSavePath = 'o',\n>  \tOptStream = 's',\n>  };\n>  \n> @@ -83,6 +84,7 @@ private:\n>  \n>  \t/* Options */\n>  \tconst OptionsParser::Options &options_;\n> +\tQString defaultPath_;\n>  \n>  \t/* Camera manager, camera, configuration and buffers */\n>  \tCameraManager *cm_;","headers":{"Return-Path":"<laurent.pinchart@ideasonboard.com>","Received":["from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id C6756613A8\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 30 Apr 2020 21:23:52 +0200 (CEST)","from pendragon.ideasonboard.com (81-175-216-236.bb.dnainternet.fi\n\t[81.175.216.236])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 3DCBD72C;\n\tThu, 30 Apr 2020 21:23:52 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"veSR5sWF\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1588274632;\n\tbh=l73wPeRu9bt94QYsQgZ9UcgY7WO9HVPCFnO6KPDZacY=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=veSR5sWF1ch6hoQUzaHn3tCJq+dno6ipnzt3/2Er94gMoHPPbaUaATUnv6IVzVj+w\n\tuaNh59lOB77a+JkO6hmCKbRubKFozPgyo0sOw9IyiyFsZwbWz0vybawjD7eDFiekNp\n\tq6bREv5QkGSsyR9WSWvjw2MwQjgGnpHIIdbd7hSQ=","Date":"Thu, 30 Apr 2020 22:23:50 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Niklas =?utf-8?q?S=C3=B6derlund?= <niklas.soderlund@ragnatech.se>","Cc":"libcamera-devel@lists.libcamera.org","Message-ID":"<20200430192350.GU5856@pendragon.ideasonboard.com>","References":"<20200430003604.2423018-1-niklas.soderlund@ragnatech.se>\n\t<20200430003604.2423018-4-niklas.soderlund@ragnatech.se>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","Content-Transfer-Encoding":"8bit","In-Reply-To":"<20200430003604.2423018-4-niklas.soderlund@ragnatech.se>","Subject":"Re: [libcamera-devel] [RFC/PATCH 3/5] qcam: Add an option to allow\n\tspecifying output path","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","X-List-Received-Date":"Thu, 30 Apr 2020 19:23:53 -0000"}}]