Patch Detail
Show a patch.
GET /api/patches/2789/?format=api
{ "id": 2789, "url": "https://patchwork.libcamera.org/api/patches/2789/?format=api", "web_url": "https://patchwork.libcamera.org/patch/2789/", "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": "<20200206150504.24204-4-kieran.bingham@ideasonboard.com>", "date": "2020-02-06T15:05:01", "name": "[libcamera-devel,3/6] qcam: Introduce a toolbar and camera switching", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": false, "hash": "2a6ac765fdbb97adfbde033549714feecae84814", "submitter": { "id": 4, "url": "https://patchwork.libcamera.org/api/people/4/?format=api", "name": "Kieran Bingham", "email": "kieran.bingham@ideasonboard.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/2789/mbox/", "series": [ { "id": 663, "url": "https://patchwork.libcamera.org/api/series/663/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=663", "date": "2020-02-06T15:04:58", "name": "qcam: Provide an initial toolbar", "version": 1, "mbox": "https://patchwork.libcamera.org/series/663/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/2789/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/2789/checks/", "tags": {}, "headers": { "Return-Path": "<kieran.bingham@ideasonboard.com>", "Received": [ "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id D18A7600FB\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 6 Feb 2020 16:05:10 +0100 (CET)", "from localhost.localdomain\n\t(cpc89242-aztw30-2-0-cust488.18-1.cable.virginm.net [86.31.129.233])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 6C2C21291;\n\tThu, 6 Feb 2020 16:05:10 +0100 (CET)" ], "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1581001510;\n\tbh=pgfhyHX8wYkZ26Ema3OsuMR/BT1/hG5NhNo2pPjP2Q0=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=b64mPuiE/Kh+yDa1jjDC3h5WDe5RU3XET9L2wZjGZDenZxx+Nhm72s2MelFG//gWd\n\tIqPyJTwuM2qHhLb3ld0vBkbRYap5KO2hcMTGwRz2TrEc1TbhdQuYF3sfzLJp6PBbIo\n\te1nUtsG6mqtIPqe14WovHNxcPaSJR0r5I746180c=", "From": "Kieran Bingham <kieran.bingham@ideasonboard.com>", "To": "LibCamera Devel <libcamera-devel@lists.libcamera.org>", "Date": "Thu, 6 Feb 2020 15:05:01 +0000", "Message-Id": "<20200206150504.24204-4-kieran.bingham@ideasonboard.com>", "X-Mailer": "git-send-email 2.20.1", "In-Reply-To": "<20200206150504.24204-1-kieran.bingham@ideasonboard.com>", "References": "<20200206150504.24204-1-kieran.bingham@ideasonboard.com>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [PATCH 3/6] qcam: Introduce a toolbar and camera\n\tswitching", "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, 06 Feb 2020 15:05:11 -0000" }, "content": "Implement a quit button, and a list of cameras.\n\nSelecting a different camera from the Toolbar will stop the current\nstream, and start streaming the chosen camera device if it can be\nacquired.\n\nSigned-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n---\n src/qcam/main_window.cpp | 60 ++++++++++++++++++++++++++++++++++++++++\n src/qcam/main_window.h | 4 +++\n 2 files changed, 64 insertions(+)", "diff": "diff --git a/src/qcam/main_window.cpp b/src/qcam/main_window.cpp\nindex b51a16de199d..1c7260f32d0a 100644\n--- a/src/qcam/main_window.cpp\n+++ b/src/qcam/main_window.cpp\n@@ -13,6 +13,8 @@\n #include <QCoreApplication>\n #include <QInputDialog>\n #include <QTimer>\n+#include <QToolBar>\n+#include <QToolButton>\n \n #include <libcamera/camera_manager.h>\n #include <libcamera/version.h>\n@@ -27,6 +29,8 @@ MainWindow::MainWindow(CameraManager *cm, const OptionsParser::Options &options)\n {\n \tint ret;\n \n+\tcreateToolbars(cm);\n+\n \ttitle_ = \"QCam \" + QString::fromStdString(CameraManager::version());\n \tsetWindowTitle(title_);\n \tconnect(&titleTimer_, SIGNAL(timeout()), this, SLOT(updateTitle()));\n@@ -53,6 +57,31 @@ MainWindow::~MainWindow()\n \t}\n }\n \n+int MainWindow::createToolbars(CameraManager *cm)\n+{\n+\tQAction *action;\n+\n+\ttoolbar_ = addToolBar(\"\");\n+\n+\taction = toolbar_->addAction(\"Quit\");\n+\tconnect(action, &QAction::triggered, this, &MainWindow::quit);\n+\n+\tQAction *cameraAction = new QAction(\"&Cameras\", this);\n+\ttoolbar_->addAction(cameraAction);\n+\n+\tQToolButton *cameraButton = dynamic_cast<QToolButton *>(toolbar_->widgetForAction(cameraAction));\n+\n+\tcameraButton->setPopupMode(QToolButton::InstantPopup);\n+\n+\tfor (const std::shared_ptr<Camera> &cam : cm->cameras()) {\n+\t\taction = new QAction(QString::fromStdString(cam->name()));\n+\t\tcameraButton->addAction(action);\n+\t\tconnect(action, &QAction::triggered, this, [=]() { this->setCamera(cam); });\n+\t}\n+\n+\treturn 0;\n+}\n+\n void MainWindow::quit()\n {\n \tQTimer::singleShot(0, QCoreApplication::instance(),\n@@ -72,6 +101,37 @@ void MainWindow::updateTitle()\n \tsetWindowTitle(title_ + \" : \" + QString::number(fps, 'f', 2) + \" fps\");\n }\n \n+int MainWindow::setCamera(const std::shared_ptr<Camera> &cam)\n+{\n+\tstd::cout << \"Chose \" << cam->name() << std::endl;\n+\n+\tif (cam->acquire()) {\n+\t\tstd::cout << \"Failed to acquire camera\" << std::endl;\n+\t\treturn -EBUSY;\n+\t}\n+\n+\tstd::cout << \"Switching to camera \" << cam->name() << std::endl;\n+\n+\tstopCapture();\n+\tcamera_->release();\n+\n+\t/*\n+\t * If we don't disconnect this signal, it will persist (and get\n+\t * re-added and thus duplicated later if we ever switch back to an\n+\t * previously streamed camera). This causes all sorts of pain.\n+\t *\n+\t * Perhaps releasing a camera should disconnect all (public?) connected\n+\t * signals forcefully!\n+\t */\n+\tcamera_->requestCompleted.disconnect(this, &MainWindow::requestComplete);\n+\tcamera_ = cam;\n+\tcamera_->requestCompleted.connect(this, &MainWindow::requestComplete);\n+\n+\tstartCapture();\n+\n+\treturn 0;\n+}\n+\n std::string MainWindow::chooseCamera(CameraManager *cm)\n {\n \tQStringList cameras;\ndiff --git a/src/qcam/main_window.h b/src/qcam/main_window.h\nindex a11443b30b37..f7c96fdd5c30 100644\n--- a/src/qcam/main_window.h\n+++ b/src/qcam/main_window.h\n@@ -44,7 +44,10 @@ private Q_SLOTS:\n \tvoid quit();\n \tvoid updateTitle();\n \n+\tint setCamera(const std::shared_ptr<Camera> &cam);\n+\n private:\n+\tint createToolbars(CameraManager *cm);\n \tstd::string chooseCamera(CameraManager *cm);\n \tint openCamera(CameraManager *cm);\n \n@@ -71,6 +74,7 @@ private:\n \tuint32_t previousFrames_;\n \tuint32_t framesCaptured_;\n \n+\tQToolBar *toolbar_;\n \tViewFinder *viewfinder_;\n \tstd::map<int, std::pair<void *, unsigned int>> mappedBuffers_;\n };\n", "prefixes": [ "libcamera-devel", "3/6" ] }