{"id":17012,"url":"https://patchwork.libcamera.org/api/patches/17012/?format=json","web_url":"https://patchwork.libcamera.org/patch/17012/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/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":"<20220807154002.91607-1-utkarsh02t@gmail.com>","date":"2022-08-07T15:40:02","name":"[libcamera-devel,v2.1,3/4] qcam: MainWindow: Replace cameraCombo_ with camSelectDialog","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"63e82d4f1c41a7bb42804c29bbffc6427462fc2f","submitter":{"id":114,"url":"https://patchwork.libcamera.org/api/people/114/?format=json","name":"Utkarsh Tiwari","email":"utkarsh02t@gmail.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/17012/mbox/","series":[{"id":3383,"url":"https://patchwork.libcamera.org/api/series/3383/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=3383","date":"2022-08-07T15:40:02","name":null,"version":1,"mbox":"https://patchwork.libcamera.org/series/3383/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/17012/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/17012/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 68D3FC3272\n\tfor <parsemail@patchwork.libcamera.org>;\n\tSun,  7 Aug 2022 15:40:23 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id D392963327;\n\tSun,  7 Aug 2022 17:40:22 +0200 (CEST)","from mail-pg1-x535.google.com (mail-pg1-x535.google.com\n\t[IPv6:2607:f8b0:4864:20::535])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 8BF9963312\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSun,  7 Aug 2022 17:40:20 +0200 (CEST)","by mail-pg1-x535.google.com with SMTP id 73so6566121pgb.9\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSun, 07 Aug 2022 08:40:20 -0700 (PDT)","from localhost.localdomain ([2404:bd00:3:d2bc:d9f0:4d1:f1a2:ade])\n\tby smtp.gmail.com with ESMTPSA id\n\tw3-20020a17090a6b8300b001f4e8dbed8csm9055843pjj.7.2022.08.07.08.40.16\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tSun, 07 Aug 2022 08:40:18 -0700 (PDT)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1659886822;\n\tbh=K6yTNq9W8bpNVicgBdGQnuNqkSC8a2n+cuPHN4KR0ag=;\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=Vw0RvJUYdBjfNtCcpXSBsO5QyLRzurCEyxsFOoxeu55sphfnzj1OzG1zGJzjMqWKz\n\tuSZapSbLMP8yRZ45hiqF6OMQ8boeQJorhiJeXlflE+9JM09dSSBf2dXwsBSjxv8VRJ\n\tTpmTWMy5BdKkUAdE+LR4kghKhCqcni//L2qNKC3+sZInLGbJetkF4Yo/PeamX+pVFl\n\tPqY1T8ufDKXbWIVJ11jJyasCveregEi3NdehY1RKIIS+npai1/ue9Zt8YTCD9nvoi/\n\tFB+YE2wkGeKINSokrLVTTQqd/jHM/ksGi7bc3ZymbKqz11XS1ndddujrYh2wemeSrk\n\t3AC2Bf6NLRslA==","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=wmaDYH9DIjUXsNGf+aQEiWFKdlIdCjQIpa/XcBfSS9M=;\n\tb=Oa00bzdxNuUiHjYkuYBcxnGNodeaYwUOvlutj+2tlDG0pZP0wNsD/z8DP4UAI06ssq\n\tGTWd+L4e7FfnN54jKLSK4Rx93WYn2uzKIxeOc3Tnnlig7X7Bt9ugzuub6NfjVNUYMlA1\n\tKA927pa/Zt2D0AicjY29mXTiBndFng1o/zMeItGUNFxZR7Lit1230RlRavII04I5b43N\n\tme2cthx1bLpxHgwm09+U6fgCaNIsP+Ptp8CHrirFzpPCiFr4w92v5hVpHyXUR0eftIkD\n\t9zBcO2drCbzOIVwJWPEH/AsUEX5QbKZ4W124+zhqXW5btbw1Q9KJspazuvkY1UJM6LgR\n\tB0YQ=="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (2048-bit key; \n\tunprotected) header.d=gmail.com header.i=@gmail.com\n\theader.b=\"Oa00bzdx\"; 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=wmaDYH9DIjUXsNGf+aQEiWFKdlIdCjQIpa/XcBfSS9M=;\n\tb=4AtCoaDxkFsHy5wBJ+ObcljwU+jDYm5Gciet4yp5BeVYTZ7Ugm8Iu4fIyjEEVe34tE\n\tk9o8ZKMJPb70oqwLZi243VgcTtnguVFc6edeimxU3x8srJP/PsPND8Veb3h0kmsiQaIv\n\tfwXeqDjh+HSr7EU7MKNMp2Ai7whsXjpiI+l6xf2S3URj8Aq4DP3BZ7lYPqsoIOWbJ3Jd\n\t5jM8fxIVNAtXP8eqebkj+C2ft7dsTLm52zqd9mH++SNLjAy+HihGiqb0wmws5HSqTeVj\n\tuqc86UqbdB6ASmGhLW1LF/HFV/f5GBG+T46EFpMWUp4Z3ohd5gGACgrp5J+GYgZ8l6X5\n\tkhHw==","X-Gm-Message-State":"ACgBeo2lxy587EkeV+61SLJy9gVfu5i3E0IL2DUB9fNTV8y4i3LeAN2l\n\tI5qGoBRrVXTA00vmjyGYmACqhm58QZ4=","X-Google-Smtp-Source":"AA6agR63ziX0/PwgE2dCTSEfLoaE38TK8egtIlGy0mi58XhyIHhkV9rWqKK62isctnjRP9NiYdJqTQ==","X-Received":"by 2002:a63:8bc7:0:b0:41c:d1e1:7fb2 with SMTP id\n\tj190-20020a638bc7000000b0041cd1e17fb2mr12577364pge.281.1659886818635; \n\tSun, 07 Aug 2022 08:40:18 -0700 (PDT)","To":"libcamera-devel@lists.libcamera.org","Date":"Sun,  7 Aug 2022 21:10:02 +0530","Message-Id":"<20220807154002.91607-1-utkarsh02t@gmail.com>","X-Mailer":"git-send-email 2.25.1","In-Reply-To":"<20220806190433.59128-4-utkarsh02t@gmail.com>","References":"<20220806190433.59128-4-utkarsh02t@gmail.com>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH v2.1 3/4] qcam: MainWindow: Replace\n\tcameraCombo_ with camSelectDialog","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 camSelectDialog. 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>\n---\nDifference from v2 :\n\tremove redudant function getCurrentCamera, its job can be done by\n\tgetCameraId()\n src/qcam/main_window.cpp | 41 ++++++++++++++++++++--------------------\n src/qcam/main_window.h   |  5 +++--\n 2 files changed, 23 insertions(+), 23 deletions(-)","diff":"diff --git a/src/qcam/main_window.cpp b/src/qcam/main_window.cpp\nindex dd30817d..98c22b71 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+\tcameraSwitchButton_ = new QPushButton;\n+\tconnect(cameraSwitchButton_, &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(cameraSwitchButton_);\n \n \ttoolbar_->addSeparator();\n \n@@ -260,14 +257,19 @@ 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-\tconst std::shared_ptr<Camera> &cam = cameras[index];\n+\tif (camera_) {\n+\t\tif (newCameraId == camera_->id())\n+\t\t\treturn;\n+\t}\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@@ -292,9 +294,12 @@ std::string MainWindow::chooseCamera()\n {\n \tcamSelectDialog_ = new CamSelectDialog(cm_, this);\n \n-\tif (camSelectDialog_->exec() == QDialog::Accepted)\n-\t\treturn camSelectDialog_->getCameraId();\n-\telse\n+\tif (camSelectDialog_->exec() == QDialog::Accepted) {\n+\t\tstd::string cameraId = camSelectDialog_->getCameraId();\n+\t\tcameraSwitchButton_->setText(QString::fromStdString(cameraId));\n+\n+\t\treturn cameraId;\n+\t} else\n \t\treturn std::string();\n }\n \n@@ -327,8 +332,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+\tcameraSwitchButton_->setText(QString::fromStdString(cameraName));\n \n \treturn 0;\n }\n@@ -593,8 +598,6 @@ void MainWindow::processHotplug(HotplugEvent *e)\n \tHotplugEvent::PlugEvent event = e->hotplugEvent();\n \n \tif (event == HotplugEvent::HotPlug) {\n-\t\tcameraCombo_->addItem(QString::fromStdString(camera->id()));\n-\n \t\tif (camSelectDialog_)\n \t\t\tcamSelectDialog_->cameraAdded(camera);\n \t} else if (event == HotplugEvent::HotUnplug) {\n@@ -603,12 +606,8 @@ void MainWindow::processHotplug(HotplugEvent *e)\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\tif (camSelectDialog_)\n \t\t\tcamSelectDialog_->cameraRemoved(camera);\n \t}\ndiff --git a/src/qcam/main_window.h b/src/qcam/main_window.h\nindex 6d80b5be..fe0f5938 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 *cameraSwitchButton_;\n \tQAction *saveRaw_;\n \tViewFinder *viewfinder_;\n \n","prefixes":["libcamera-devel","v2.1","3/4"]}