{"id":17055,"url":"https://patchwork.libcamera.org/api/1.1/patches/17055/?format=json","web_url":"https://patchwork.libcamera.org/patch/17055/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/1.1/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20220809205042.344923-4-utkarsh02t@gmail.com>","date":"2022-08-09T20:50:37","name":"[libcamera-devel,v7,3/8] qcam: MainWindow: Replace cameraCombo_ with CameraSelectorDialog","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"8d41a5e87d50eaabf685e72ea1bffddf0adec843","submitter":{"id":114,"url":"https://patchwork.libcamera.org/api/1.1/people/114/?format=json","name":"Utkarsh Tiwari","email":"utkarsh02t@gmail.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/17055/mbox/","series":[{"id":3400,"url":"https://patchwork.libcamera.org/api/1.1/series/3400/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=3400","date":"2022-08-09T20:50:34","name":"Introduce capture scripts to qcam","version":7,"mbox":"https://patchwork.libcamera.org/series/3400/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/17055/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/17055/checks/","tags":{},"headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id D1BDCBE173\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue,  9 Aug 2022 20:51:03 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 91AC363335;\n\tTue,  9 Aug 2022 22:51:03 +0200 (CEST)","from mail-pj1-x102d.google.com (mail-pj1-x102d.google.com\n\t[IPv6:2607:f8b0:4864:20::102d])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 7C66763330\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue,  9 Aug 2022 22:51:02 +0200 (CEST)","by mail-pj1-x102d.google.com with SMTP id\n\to5-20020a17090a3d4500b001ef76490983so117591pjf.2\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 09 Aug 2022 13:51:02 -0700 (PDT)","from localhost.localdomain ([2404:bd00:3:d2bc:2358:3bcd:fb4f:cbb7])\n\tby smtp.gmail.com with ESMTPSA id\n\td3-20020a623603000000b0052d981e7842sm301936pfa.208.2022.08.09.13.50.58\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tTue, 09 Aug 2022 13:51:00 -0700 (PDT)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1660078263;\n\tbh=O0zffZEsQGLvkgsJV0VrElWOOtCbYO+RXg5NRXzZw4g=;\n\th=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:\n\tFrom;\n\tb=y8WMx6vPXeefvBkoj3uY4ZH3N7dI3tiEHtU/z7qK2u3mhmsWB3bUoF3FFHMV/n1yS\n\tAKZOyzjvs+AMjuuIimx31sFom6FaKs438bLyypbVVJ7eLrvaLw1EYXYVa0G8gh+g1b\n\t5AjjNtYUtHe1I/KX+6aAkuypJiwxpnhmjUQ9Ker77dRIs229bEiKUA8WiW/gxAuMx3\n\t69uo6Qw+wGkBVgkQIF7QI2i5rMZ0Zt76cMkOmN8gSIEpu4BuBvuSooAaW/SWEPmL9O\n\t1BkhRu+3pomP181E7lElM7LuDYl9Z7T8DDZmsO2x4ZWmRpFaYc6hi2Kb/HXJFG/oqc\n\tXCMYFPGF4NdfQ==","v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112;\n\th=content-transfer-encoding:mime-version:references:in-reply-to\n\t:message-id:date:subject:cc:to:from:from:to:cc;\n\tbh=y/7tBegz/tztP0/ebOqZEEH7T7DW+fI884vXr5casuw=;\n\tb=ltuJG+dorHyXkzg2hwnUB4FBJinA7GBfk5JwiJEFnm1WFcIcS5oNW6LGZREDvNS9cj\n\tur1DWvBR6knqGXiGuhMhwfy5xGciLOXsVTslWlHhdEVncsoO8jGwyJ5WGzHGygmrTGON\n\tcA4J74bO4VoEsxjgV0ZjXmpZOUZViGI+ZWSnsbov23qNcUAaZ8+LQgyybi4sz8DALkEa\n\tgnDEJG1/4fsVffwmGgmhaApxYHhjLYPc24zbRNaZp4wJomKX0V9Lbb26TreKlcdnzNC1\n\tUmcdJsp1nK2tC8y0YqJyHthaQQu7cShbSut72dVmH6qaOLXykT9xNXgxrQWnS5rpRqi6\n\t4Lkw=="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (2048-bit key; \n\tunprotected) header.d=gmail.com header.i=@gmail.com\n\theader.b=\"ltuJG+do\"; dkim-atps=neutral","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20210112;\n\th=content-transfer-encoding:mime-version:references:in-reply-to\n\t:message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc;\n\tbh=y/7tBegz/tztP0/ebOqZEEH7T7DW+fI884vXr5casuw=;\n\tb=0mfOY6WytnyMuzC7cq+SwA7LzrYmwl9vo6Dk9tsAxTik5r1urnCD2LWYm6VHIypmxo\n\t0C/7y5fG1lt94FSs8NBXKsmADZ2lowwZPIckGvZfKvzPM9y8FuYdHSBPZfaZvoiuapQG\n\tZw8LGVdC1/u3JwVbfAyAJJIEeGvvR0dRnGFO0iIsSPGGdxDjyDFoPI2kRwKfnh4KFwch\n\t2ZKW+UiuEAbgjoGJ1L530kv073BzrTvApNdqn1qRZhHS6Geas8tCFWGVJEzvQqRhM+S6\n\tbK10x+6zHZFRi8KhjG3qwYzXSqaQURTuutT66Pq5MnmJfBR2t5o1hrLWOii+t8tIJLbl\n\tgAhQ==","X-Gm-Message-State":"ACgBeo3OiTuWH8jaDtj2Exabhpcpu7/8lQZpiP0qQGZ2JTiKudshChSq\n\thMUdbyxFs6gsN2oKoNve5UdZdl11rGU=","X-Google-Smtp-Source":"AA6agR5YgmSRh8l2DuIxZvsrkU2XPvrOQvPIclJocUeKZsdFTOvSAYN0h90iq6yVUfmS/UfCyuVsPw==","X-Received":"by 2002:a17:902:ea03:b0:16f:2506:bfd5 with SMTP id\n\ts3-20020a170902ea0300b0016f2506bfd5mr24597020plg.21.1660078260726; \n\tTue, 09 Aug 2022 13:51:00 -0700 (PDT)","To":"libcamera-devel@lists.libcamera.org","Date":"Wed, 10 Aug 2022 02:20:37 +0530","Message-Id":"<20220809205042.344923-4-utkarsh02t@gmail.com>","X-Mailer":"git-send-email 2.25.1","In-Reply-To":"<20220809205042.344923-1-utkarsh02t@gmail.com>","References":"<20220809205042.344923-1-utkarsh02t@gmail.com>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH v7 3/8] qcam: MainWindow: Replace\n\tcameraCombo_ with CameraSelectorDialog","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>","From":"Utkarsh Tiwari via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>","Reply-To":"Utkarsh Tiwari <utkarsh02t@gmail.com>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"Replace the cameraCombo_ on the toolbar with a QPushButton which\ndisplays the CameraSelectorDialog. This would allow the user to view\ninformation about the camera when switching.\n\nThe QPushButton text is set to the camera Id currently in use.\n\nSigned-off-by: Utkarsh Tiwari <utkarsh02t@gmail.com>\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n---\nDifference:\n\t1. cameraSwitchButton_ to cameraSelectButton_\n src/qcam/main_window.cpp | 44 +++++++++++++++++++---------------------\n src/qcam/main_window.h   |  5 +++--\n 2 files changed, 24 insertions(+), 25 deletions(-)","diff":"diff --git a/src/qcam/main_window.cpp b/src/qcam/main_window.cpp\nindex 377b4650..15b150ec 100644\n--- a/src/qcam/main_window.cpp\n+++ b/src/qcam/main_window.cpp\n@@ -193,14 +193,11 @@ int MainWindow::createToolbars()\n \tconnect(action, &QAction::triggered, this, &MainWindow::quit);\n \n \t/* Camera selector. */\n-\tcameraCombo_ = new QComboBox();\n-\tconnect(cameraCombo_, QOverload<int>::of(&QComboBox::activated),\n+\tcameraSelectButton_ = new QPushButton;\n+\tconnect(cameraSelectButton_, &QPushButton::clicked,\n \t\tthis, &MainWindow::switchCamera);\n \n-\tfor (const std::shared_ptr<Camera> &cam : cm_->cameras())\n-\t\tcameraCombo_->addItem(QString::fromStdString(cam->id()));\n-\n-\ttoolbar_->addWidget(cameraCombo_);\n+\ttoolbar_->addWidget(cameraSelectButton_);\n \n \ttoolbar_->addSeparator();\n \n@@ -260,14 +257,18 @@ void MainWindow::updateTitle()\n  * Camera Selection\n  */\n \n-void MainWindow::switchCamera(int index)\n+void MainWindow::switchCamera()\n {\n \t/* Get and acquire the new camera. */\n-\tconst auto &cameras = cm_->cameras();\n-\tif (static_cast<unsigned int>(index) >= cameras.size())\n+\tstd::string newCameraId = chooseCamera();\n+\n+\tif (newCameraId.empty())\n+\t\treturn;\n+\n+\tif (camera_ && newCameraId == camera_->id())\n \t\treturn;\n \n-\tconst std::shared_ptr<Camera> &cam = cameras[index];\n+\tconst std::shared_ptr<Camera> &cam = cm_->get(newCameraId);\n \n \tif (cam->acquire()) {\n \t\tqInfo() << \"Failed to acquire camera\" << cam->id().c_str();\n@@ -300,9 +301,12 @@ std::string MainWindow::chooseCamera()\n \tif (options_.isSet(OptCamera))\n \t\treturn static_cast<std::string>(options_[OptCamera]);\n \n-\tif (cameraSelectorDialog_->exec() == QDialog::Accepted)\n-\t\treturn cameraSelectorDialog_->getCameraId();\n-\telse\n+\tif (cameraSelectorDialog_->exec() == QDialog::Accepted) {\n+\t\tstd::string cameraId = cameraSelectorDialog_->getCameraId();\n+\t\tcameraSelectButton_->setText(QString::fromStdString(cameraId));\n+\n+\t\treturn cameraId;\n+\t} else\n \t\treturn std::string();\n }\n \n@@ -326,8 +330,8 @@ int MainWindow::openCamera()\n \t\treturn -EBUSY;\n \t}\n \n-\t/* Set the combo-box entry with the currently selected Camera. */\n-\tcameraCombo_->setCurrentText(QString::fromStdString(cameraName));\n+\t/* Set the camera switch button with the currently selected Camera id. */\n+\tcameraSelectButton_->setText(QString::fromStdString(cameraName));\n \n \treturn 0;\n }\n@@ -591,22 +595,16 @@ void MainWindow::processHotplug(HotplugEvent *e)\n \tCamera *camera = e->camera();\n \tHotplugEvent::PlugEvent event = e->hotplugEvent();\n \n-\tif (event == HotplugEvent::HotPlug) {\n-\t\tcameraCombo_->addItem(QString::fromStdString(camera->id()));\n-\n+\tif (event == HotplugEvent::HotPlug)\n \t\tcameraSelectorDialog_->cameraAdded(camera);\n-\t} else if (event == HotplugEvent::HotUnplug) {\n+\telse if (event == HotplugEvent::HotUnplug) {\n \t\t/* Check if the currently-streaming camera is removed. */\n \t\tif (camera == camera_.get()) {\n \t\t\ttoggleCapture(false);\n \t\t\tcamera_->release();\n \t\t\tcamera_.reset();\n-\t\t\tcameraCombo_->setCurrentIndex(0);\n \t\t}\n \n-\t\tint camIndex = cameraCombo_->findText(QString::fromStdString(camera->id()));\n-\t\tcameraCombo_->removeItem(camIndex);\n-\n \t\tcameraSelectorDialog_->cameraRemoved(camera);\n \t}\n }\ndiff --git a/src/qcam/main_window.h b/src/qcam/main_window.h\nindex b01d2e59..bbdbb21c 100644\n--- a/src/qcam/main_window.h\n+++ b/src/qcam/main_window.h\n@@ -24,6 +24,7 @@\n #include <QMutex>\n #include <QObject>\n #include <QPointer>\n+#include <QPushButton>\n #include <QQueue>\n #include <QTimer>\n \n@@ -61,7 +62,7 @@ private Q_SLOTS:\n \tvoid quit();\n \tvoid updateTitle();\n \n-\tvoid switchCamera(int index);\n+\tvoid switchCamera();\n \tvoid toggleCapture(bool start);\n \n \tvoid saveImageAs();\n@@ -91,7 +92,7 @@ private:\n \t/* UI elements */\n \tQToolBar *toolbar_;\n \tQAction *startStopAction_;\n-\tQComboBox *cameraCombo_;\n+\tQPushButton *cameraSelectButton_;\n \tQAction *saveRaw_;\n \tViewFinder *viewfinder_;\n \n","prefixes":["libcamera-devel","v7","3/8"]}