Show a patch.

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

{
    "id": 3272,
    "url": "https://patchwork.libcamera.org/api/patches/3272/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/3272/",
    "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": "<20200323173559.21109-7-laurent.pinchart@ideasonboard.com>",
    "date": "2020-03-23T17:35:44",
    "name": "[libcamera-devel,v2,06/21] qcam: main_window: Replace start and stop actions with a toggle action",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": false,
    "hash": "11fb8a0e73a6919e5e85b8e47fcd57c28ef03a2f",
    "submitter": {
        "id": 2,
        "url": "https://patchwork.libcamera.org/api/people/2/?format=api",
        "name": "Laurent Pinchart",
        "email": "laurent.pinchart@ideasonboard.com"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/3272/mbox/",
    "series": [
        {
            "id": 762,
            "url": "https://patchwork.libcamera.org/api/series/762/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=762",
            "date": "2020-03-23T17:35:38",
            "name": "qcam: Bypass format conversion when not required",
            "version": 2,
            "mbox": "https://patchwork.libcamera.org/series/762/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/3272/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/3272/checks/",
    "tags": {},
    "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 9895C60417\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 23 Mar 2020 18:36:18 +0100 (CET)",
            "from pendragon.bb.dnainternet.fi (81-175-216-236.bb.dnainternet.fi\n\t[81.175.216.236])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 1A15E308\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 23 Mar 2020 18:36:18 +0100 (CET)"
        ],
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1584984978;\n\tbh=KviRyMViYIPNum4+T1mlXXg5Bc3HJHWIRECGIb01JqU=;\n\th=From:To:Subject:Date:In-Reply-To:References:From;\n\tb=R5OGwbM7mXzjCVj7mRHxjFvdz0pCEsqxh5sov9adAqhVB6YjL8PPgrDQ9M7ZHciPB\n\tEWDEDVSX/sp2luoyR0T0annnf9KmegSAG18zCk3RKjzXBROM49U6QRHe6gjk5CVZGq\n\tWPjWaZXhLs9Kfh2Vjj35LExODVMEz2QyIqlWXCBY=",
        "From": "Laurent Pinchart <laurent.pinchart@ideasonboard.com>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Mon, 23 Mar 2020 19:35:44 +0200",
        "Message-Id": "<20200323173559.21109-7-laurent.pinchart@ideasonboard.com>",
        "X-Mailer": "git-send-email 2.24.1",
        "In-Reply-To": "<20200323173559.21109-1-laurent.pinchart@ideasonboard.com>",
        "References": "<20200323173559.21109-1-laurent.pinchart@ideasonboard.com>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[libcamera-devel] [PATCH v2 06/21] qcam: main_window: Replace start\n\tand stop actions with a toggle action",
        "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": "Mon, 23 Mar 2020 17:36:22 -0000"
    },
    "content": "The main window toolbar contains a start button and a stop button. This\nallows starting an already started camera (which is currently not\nhandled and results in an error) or stopping an already stopped camera.\nReplace the two actions with a single start/stop toggle action,\npreventing UI misuse and reducing confusion.\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n---\nChanges since v1:\n\n- Switch between play and stop icons\n---\n src/qcam/main_window.cpp | 34 ++++++++++++++++++++++++----------\n src/qcam/main_window.h   | 13 ++++++++++---\n 2 files changed, 34 insertions(+), 13 deletions(-)",
    "diff": "diff --git a/src/qcam/main_window.cpp b/src/qcam/main_window.cpp\nindex 805690d5006a..74b8748c3347 100644\n--- a/src/qcam/main_window.cpp\n+++ b/src/qcam/main_window.cpp\n@@ -15,7 +15,6 @@\n #include <QComboBox>\n #include <QCoreApplication>\n #include <QFileDialog>\n-#include <QIcon>\n #include <QImage>\n #include <QImageWriter>\n #include <QInputDialog>\n@@ -63,11 +62,10 @@ MainWindow::MainWindow(CameraManager *cm, const OptionsParser::Options &options)\n \tadjustSize();\n \n \tret = openCamera();\n-\tif (!ret)\n-\t\tret = startCapture();\n-\n \tif (ret < 0)\n \t\tquit();\n+\n+\tstartStopAction_->setChecked(true);\n }\n \n MainWindow::~MainWindow()\n@@ -113,11 +111,13 @@ int MainWindow::createToolbars()\n \n \ttoolbar_->addSeparator();\n \n-\taction = toolbar_->addAction(QIcon(\":play-circle.svg\"), \"start\");\n-\tconnect(action, &QAction::triggered, this, &MainWindow::startCapture);\n+\ticonPlay_ = QIcon(\":play-circle.svg\");\n+\ticonStop_ = QIcon(\":stop-circle.svg\");\n \n-\taction = toolbar_->addAction(QIcon(\":stop-circle.svg\"), \"stop\");\n-\tconnect(action, &QAction::triggered, this, &MainWindow::stopCapture);\n+\taction = toolbar_->addAction(iconPlay_, \"Start Capture\");\n+\taction->setCheckable(true);\n+\tconnect(action, &QAction::toggled, this, &MainWindow::toggleCapture);\n+\tstartStopAction_ = action;\n \n \taction = toolbar_->addAction(QIcon(\":save.svg\"), \"saveAs\");\n \tconnect(action, &QAction::triggered, this, &MainWindow::saveImageAs);\n@@ -159,12 +159,12 @@ void MainWindow::switchCamera(int index)\n \n \tstd::cout << \"Switching to camera \" << cam->name() << std::endl;\n \n-\tstopCapture();\n+\tstartStopAction_->setChecked(false);\n \n \tcamera_->release();\n \tcamera_ = cam;\n \n-\tstartCapture();\n+\tstartStopAction_->setChecked(true);\n }\n \n std::string MainWindow::chooseCamera()\n@@ -217,6 +217,19 @@ int MainWindow::openCamera()\n \treturn 0;\n }\n \n+void MainWindow::toggleCapture(bool start)\n+{\n+\tif (start) {\n+\t\tstartCapture();\n+\t\tstartStopAction_->setIcon(iconStop_);\n+\t\tstartStopAction_->setText(\"Stop Capture\");\n+\t} else {\n+\t\tstopCapture();\n+\t\tstartStopAction_->setIcon(iconPlay_);\n+\t\tstartStopAction_->setText(\"Start Capture\");\n+\t}\n+}\n+\n int MainWindow::startCapture()\n {\n \tint ret;\n@@ -322,6 +335,7 @@ int MainWindow::startCapture()\n \t}\n \n \tisCapturing_ = true;\n+\n \treturn 0;\n \n error_disconnect:\ndiff --git a/src/qcam/main_window.h b/src/qcam/main_window.h\nindex c623120d5894..34a090cc463e 100644\n--- a/src/qcam/main_window.h\n+++ b/src/qcam/main_window.h\n@@ -10,6 +10,7 @@\n #include <memory>\n \n #include <QElapsedTimer>\n+#include <QIcon>\n #include <QMainWindow>\n #include <QMutex>\n #include <QObject>\n@@ -26,6 +27,7 @@\n \n using namespace libcamera;\n \n+class QAction;\n class ViewFinder;\n \n enum {\n@@ -49,9 +51,7 @@ private Q_SLOTS:\n \tvoid updateTitle();\n \n \tvoid switchCamera(int index);\n-\n-\tint startCapture();\n-\tvoid stopCapture();\n+\tvoid toggleCapture(bool start);\n \n \tvoid saveImageAs();\n \n@@ -60,11 +60,17 @@ private:\n \tstd::string chooseCamera();\n \tint openCamera();\n \n+\tint startCapture();\n+\tvoid stopCapture();\n+\n \tvoid requestComplete(Request *request);\n \tvoid processCapture();\n \tint display(FrameBuffer *buffer);\n \tvoid queueRequest(FrameBuffer *buffer);\n \n+\tQIcon iconPlay_;\n+\tQIcon iconStop_;\n+\n \tQString title_;\n \tQTimer titleTimer_;\n \n@@ -87,6 +93,7 @@ private:\n \tQQueue<FrameBuffer *> doneQueue_;\n \n \tQToolBar *toolbar_;\n+\tQAction *startStopAction_;\n \tViewFinder *viewfinder_;\n \tstd::map<int, std::pair<void *, unsigned int>> mappedBuffers_;\n };\n",
    "prefixes": [
        "libcamera-devel",
        "v2",
        "06/21"
    ]
}