Show a patch.

GET /api/patches/3618/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 3618,
    "url": "https://patchwork.libcamera.org/api/patches/3618/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/3618/",
    "project": {
        "id": 1,
        "url": "https://patchwork.libcamera.org/api/projects/1/?format=api",
        "name": "libcamera",
        "link_name": "libcamera",
        "list_id": "libcamera_core",
        "list_email": "libcamera-devel@lists.libcamera.org",
        "web_url": "",
        "scm_url": "",
        "webscm_url": ""
    },
    "msgid": "<20200430003604.2423018-5-niklas.soderlund@ragnatech.se>",
    "date": "2020-04-30T00:36:03",
    "name": "[libcamera-devel,RFC/PATCH,4/5] qcam: Remove QFileDialog from JPEG capture",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": false,
    "hash": "554cc50a07120257c688c6bb176d265735a7e6f3",
    "submitter": {
        "id": 5,
        "url": "https://patchwork.libcamera.org/api/people/5/?format=api",
        "name": "Niklas Söderlund",
        "email": "niklas.soderlund@ragnatech.se"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/3618/mbox/",
    "series": [
        {
            "id": 855,
            "url": "https://patchwork.libcamera.org/api/series/855/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=855",
            "date": "2020-04-30T00:36:00",
            "name": "qcam: Add RAW capture support",
            "version": 1,
            "mbox": "https://patchwork.libcamera.org/series/855/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/3618/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/3618/checks/",
    "tags": {},
    "headers": {
        "Return-Path": "<niklas.soderlund@ragnatech.se>",
        "Received": [
            "from bin-mail-out-06.binero.net (bin-mail-out-06.binero.net\n\t[195.74.38.229])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id F1C5660AF5\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 30 Apr 2020 02:36:37 +0200 (CEST)",
            "from bismarck.berto.se (p4fca2392.dip0.t-ipconnect.de\n\t[79.202.35.146]) by bin-vsp-out-03.atm.binero.net (Halon) with ESMTPA\n\tid 8773b20a-8a7a-11ea-89d0-0050569116f7;\n\tThu, 30 Apr 2020 02:35:45 +0200 (CEST)"
        ],
        "X-Halon-ID": "8773b20a-8a7a-11ea-89d0-0050569116f7",
        "Authorized-sender": "niklas@soderlund.pp.se",
        "From": "=?utf-8?q?Niklas_S=C3=B6derlund?= <niklas.soderlund@ragnatech.se>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Thu, 30 Apr 2020 02:36:03 +0200",
        "Message-Id": "<20200430003604.2423018-5-niklas.soderlund@ragnatech.se>",
        "X-Mailer": "git-send-email 2.26.0",
        "In-Reply-To": "<20200430003604.2423018-1-niklas.soderlund@ragnatech.se>",
        "References": "<20200430003604.2423018-1-niklas.soderlund@ragnatech.se>",
        "MIME-Version": "1.0",
        "Content-Type": "text/plain; charset=UTF-8",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[libcamera-devel] [RFC/PATCH 4/5] qcam: Remove QFileDialog from\n\tJPEG capture",
        "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 00:36:38 -0000"
    },
    "content": "Instead of popping up a dialog to enter a filename to save use the\nsequence number and the default output directory to generate a path.\n\nSigned-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n---\n src/qcam/main_window.cpp | 40 +++++++++++++++++++++++++++-------------\n src/qcam/main_window.h   |  3 ++-\n 2 files changed, 29 insertions(+), 14 deletions(-)",
    "diff": "diff --git a/src/qcam/main_window.cpp b/src/qcam/main_window.cpp\nindex 470f78162cabffe5..f57aaf4a27e5f4ca 100644\n--- a/src/qcam/main_window.cpp\n+++ b/src/qcam/main_window.cpp\n@@ -8,6 +8,7 @@\n #include \"main_window.h\"\n \n #include <iomanip>\n+#include <sstream>\n #include <string>\n #include <sys/mman.h>\n \n@@ -146,8 +147,7 @@ int MainWindow::createToolbars()\n \taction = toolbar_->addAction(QIcon::fromTheme(\"document-save-as\",\n \t\t\t\t\t\t      QIcon(\":save.svg\")),\n \t\t\t\t     \"Save As...\");\n-\taction->setShortcut(QKeySequence::SaveAs);\n-\tconnect(action, &QAction::triggered, this, &MainWindow::saveImageAs);\n+\tconnect(action, &QAction::triggered, this, &MainWindow::saveViewfinder);\n \n \treturn 0;\n }\n@@ -509,18 +509,9 @@ void MainWindow::stopCapture()\n  * Image Save\n  */\n \n-void MainWindow::saveImageAs()\n+void MainWindow::saveViewfinder()\n {\n-\tQImage image = viewfinder_->getCurrentImage();\n-\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-\n-\tQImageWriter writer(filename);\n-\twriter.setQuality(95);\n-\twriter.write(image);\n+\tsaveViewfinder_ = true;\n }\n \n /* -----------------------------------------------------------------------------\n@@ -602,6 +593,29 @@ void MainWindow::processViewfinder(FrameBuffer *buffer)\n \n \t/* Render the frame on the viewfinder. */\n \tviewfinder_->render(buffer, &mappedBuffers_[buffer]);\n+\n+\t/* Save viewfinder to file if requested. */\n+\tif (saveViewfinder_) {\n+\t\tstd::string filename = defaultPath_.toStdString() + \"/picture-#.jpeg\";\n+\t\tsize_t pos;\n+\n+\t\tpos = filename.find_first_of('#');\n+\t\tif (pos != std::string::npos) {\n+\t\t\tstd::stringstream ss;\n+\t\t\tss << std::setw(6) << std::setfill('0')\n+\t\t\t   << buffer->metadata().sequence;\n+\t\t\tfilename.replace(pos, 1, ss.str());\n+\t\t}\n+\n+\t\tqInfo() << \"Saving viewfinder to\" << filename.c_str();\n+\n+\t\tQImage image = viewfinder_->getCurrentImage();\n+\t\tQImageWriter writer(QString::fromUtf8(filename.c_str()));\n+\t\twriter.setQuality(95);\n+\t\twriter.write(image);\n+\n+\t\tsaveViewfinder_ = false;\n+\t}\n }\n \n void MainWindow::queueRequest(FrameBuffer *buffer)\ndiff --git a/src/qcam/main_window.h b/src/qcam/main_window.h\nindex 7b8a185511e17a8f..580bcac146fabe07 100644\n--- a/src/qcam/main_window.h\n+++ b/src/qcam/main_window.h\n@@ -54,7 +54,7 @@ private Q_SLOTS:\n \tvoid switchCamera(int index);\n \tvoid toggleCapture(bool start);\n \n-\tvoid saveImageAs();\n+\tvoid saveViewfinder();\n \n \tvoid queueRequest(FrameBuffer *buffer);\n \n@@ -96,6 +96,7 @@ private:\n \n \t/* Capture state, buffers queue and statistics */\n \tbool isCapturing_;\n+\tbool saveViewfinder_;\n \tStream *vfStream_;\n \tStream *rawStream_;\n \tstd::map<Stream *, QQueue<FrameBuffer *>> freeBuffers_;\n",
    "prefixes": [
        "libcamera-devel",
        "RFC/PATCH",
        "4/5"
    ]
}