{"id":16957,"url":"https://patchwork.libcamera.org/api/1.1/patches/16957/?format=json","web_url":"https://patchwork.libcamera.org/patch/16957/","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":"<20220803175517.175332-3-utkarsh02t@gmail.com>","date":"2022-08-03T17:55:15","name":"[libcamera-devel,2/4] qcam: Support Hotplug for Camera Selection Dialog","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"343d60bd57434f314a2238ac8303dd9d28074ee3","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/16957/mbox/","series":[{"id":3370,"url":"https://patchwork.libcamera.org/api/1.1/series/3370/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=3370","date":"2022-08-03T17:55:13","name":"Improve Camera Selection GUI in QCam","version":1,"mbox":"https://patchwork.libcamera.org/series/3370/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/16957/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/16957/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 8E8A3C3272\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed,  3 Aug 2022 17:55:32 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 5403263314;\n\tWed,  3 Aug 2022 19:55:32 +0200 (CEST)","from mail-pl1-x632.google.com (mail-pl1-x632.google.com\n\t[IPv6:2607:f8b0:4864:20::632])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 71FC16330F\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed,  3 Aug 2022 19:55:29 +0200 (CEST)","by mail-pl1-x632.google.com with SMTP id m2so10317455pls.4\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 03 Aug 2022 10:55:29 -0700 (PDT)","from localhost.localdomain ([2404:bd00:3:d5b8:ad21:c99c:170f:1ae])\n\tby smtp.gmail.com with ESMTPSA id\n\tf3-20020a170902860300b0016357fd0fd1sm2193343plo.69.2022.08.03.10.55.26\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tWed, 03 Aug 2022 10:55:27 -0700 (PDT)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1659549332;\n\tbh=mLNMta3UTbSk0u2plTVn/eUohw6nx91/CTpD+fKK8eo=;\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=YQq93Ei4ao5WoLLXQECe8cs9eS160024s071akJ9momeeNM+hORSC8/TSf13BiB/u\n\tUTwChDeSb84yp5E89+CLPoqoLNRZvFANsefXF+OFNayTCG7psTIW+9DIGBnxvAFzbF\n\tYZqXIL2zPirodmIyKBziHV2AqUJPttnAn/bq5y3XMfQtr0PX84c4b85YIhilFz+xTo\n\tjDP/nQXJvQ760Dd+mDjjQPTEh0te2F5cr6isXo758VyP+7J/kuq1I8Zy116mJVkT3S\n\ti+KSa8aC7Vh5TyuYttQQpdD9UsCS0QZkgM441q9FJTsgquWQJ6JG7ix/XYkpRZJnB4\n\tjy1tZ3tvvZ7+A==","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=hS3ONz0uAfI7pW5e9nnmNXa/0jwY6YBiygvILYUDxa8=;\n\tb=qMrflREHdpzOVP73q+5P4RruPrmXfxG0qvxTfioImcLaOeFSdJ8qRcgZRuko+knKp+\n\tkBmz53FIJjtpLPpPFKxbFpf4vWylFwnNial3A7h/E6wTxxpnOBPRPWhgplwpGzsjI3sR\n\tFyTu1ib6S4FGAr7lxRC0DM2ZklIc3NzT6BijEBFlSL+MIlVDxP/bmKeVwPDZCfhg/IbG\n\tPVgMlb7QYBGPEL5vDOKeTi43QDODWJe+HDsOQI3yDnADP7xlLL3QNdZCAi1k7yrN3CLy\n\tdojpntQnc/wXiNMo6oGbEuJ4/+JSvt4Ysi/3MlWEBzaaY5BrdY0U0yP6ZLhChYeo4fXR\n\t+3VA=="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (2048-bit key; \n\tunprotected) header.d=gmail.com header.i=@gmail.com\n\theader.b=\"qMrflREH\"; 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=hS3ONz0uAfI7pW5e9nnmNXa/0jwY6YBiygvILYUDxa8=;\n\tb=YPHxBCG2cob+r1aTBHOaEGB1hTjN+/t+LZao0Zma0v1dw3ViDuCw1qlpgkRSi5TJJB\n\txn//qkfwg0LGPf4jbG4TPHzy9XuzquvZmMd5hsX+2YMbc9eT/PIOlm9V9zCZpnmtrwLZ\n\t3woU5L5MfDXQmSr/KRR12J3SzPrNFtjAtXDDXRJ7TQoMLVEyYA+CrROzzAJR4Z24tHsO\n\tdy2gmz7nnuioFqPVmQzCVZABcwnL5586DHY6+1Doa7JWGP5dBTPmIiPDFsl+1+NWKjas\n\tqsLZH44heakzS/7GOcN59/LVtlTrXm3v5fFuxo7wxb+hfTpnhNKCDvvN3WGGUJSk1yEm\n\taQzA==","X-Gm-Message-State":"ACgBeo2hpymnjOHk7GiXrfNXfHToPuvnI9N28b/9ogfhepvqLUbnCO2j\n\t5Fnk1f3szDk+eNoYvwqBYVcKrsXFGGM=","X-Google-Smtp-Source":"AA6agR6vBQrbZ4Eh/SYtkiTxc2syP+VYICSEBzhfe27ajb+SA9zNA+j0dM4IJdU6mWZstopD15WwqA==","X-Received":"by 2002:a17:902:e5c6:b0:16e:f3b6:ddb5 with SMTP id\n\tu6-20020a170902e5c600b0016ef3b6ddb5mr13940766plf.122.1659549327768; \n\tWed, 03 Aug 2022 10:55:27 -0700 (PDT)","To":"libcamera-devel@lists.libcamera.org","Date":"Wed,  3 Aug 2022 23:25:15 +0530","Message-Id":"<20220803175517.175332-3-utkarsh02t@gmail.com>","X-Mailer":"git-send-email 2.25.1","In-Reply-To":"<20220803175517.175332-1-utkarsh02t@gmail.com>","References":"<20220803175517.175332-1-utkarsh02t@gmail.com>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH 2/4] qcam: Support Hotplug for Camera\n\tSelection Dialog","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":"Currently if there is HotPlug event when the user is on the Camera\nselection dialog, the QComboBox didn't update to reflect the change.\n\nIf the cameraIdComboBox_ contains a valid QComboBox then update it to\nreflect the HotPlug change. Check the validity of QComboBox pointer by\nguarding it with a QPointer.\n\nSigned-off-by: Utkarsh Tiwari <utkarsh02t@gmail.com>\n---\n src/qcam/main_window.cpp | 23 +++++++++++++++--------\n src/qcam/main_window.h   |  4 ++++\n 2 files changed, 19 insertions(+), 8 deletions(-)","diff":"diff --git a/src/qcam/main_window.cpp b/src/qcam/main_window.cpp\nindex 7761a6c6..80a73b68 100644\n--- a/src/qcam/main_window.cpp\n+++ b/src/qcam/main_window.cpp\n@@ -293,18 +293,15 @@ void MainWindow::switchCamera(int index)\n \n std::string MainWindow::chooseCamera()\n {\n-\tQStringList cameras;\n \tstd::string result;\n \n \t/* Present a dialog box to pick a camera. */\n \tQDialog *cameraSelectDialog = new QDialog(this);\n \n \t/* Setup a QComboBox to display camera Ids. */\n+\tcameraIdComboBox_ = new QComboBox;\n \tfor (const std::shared_ptr<Camera> &cam : cm_->cameras())\n-\t\tcameras.push_back(QString::fromStdString(cam->id()));\n-\n-\tQComboBox *cameraIdComboBox = new QComboBox;\n-\tcameraIdComboBox->addItems(cameras);\n+\t\tcameraIdComboBox_->addItem(QString::fromStdString(cam->id()));\n \n \t/* Setup QDialogButtonBox. */\n \tQDialogButtonBox *dialogButtonBox = new QDialogButtonBox;\n@@ -313,7 +310,7 @@ std::string MainWindow::chooseCamera()\n \n \tconnect(dialogButtonBox, &QDialogButtonBox::accepted,\n \t\tthis, [&]() {\n-\t\t\tresult = cameraIdComboBox->currentText().toStdString();\n+\t\t\tresult = cameraIdComboBox_->currentText().toStdString();\n \t\t\tcameraSelectDialog->accept();\n \t\t});\n \n@@ -325,7 +322,7 @@ std::string MainWindow::chooseCamera()\n \n \t/* Setup the layout for the dialog. */\n \tQFormLayout *cameraSelectLayout = new QFormLayout(cameraSelectDialog);\n-\tcameraSelectLayout->addRow(\"Camera: \", cameraIdComboBox);\n+\tcameraSelectLayout->addRow(\"Camera: \", cameraIdComboBox_);\n \tcameraSelectLayout->addWidget(dialogButtonBox);\n \n \tcameraSelectDialog->exec();\n@@ -628,7 +625,12 @@ 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+\t\tQString cameraId = QString::fromStdString(camera->id());\n+\t\tcameraCombo_->addItem(cameraId);\n+\n+\t\t/* Update cameraIdCombox_ to include the new camera. */\n+\t\tif (cameraIdComboBox_)\n+\t\t\tcameraIdComboBox_->addItem(cameraId);\n \t} else if (event == HotplugEvent::HotUnplug) {\n \t\t/* Check if the currently-streaming camera is removed. */\n \t\tif (camera == camera_.get()) {\n@@ -638,6 +640,11 @@ void MainWindow::processHotplug(HotplugEvent *e)\n \t\t\tcameraCombo_->setCurrentIndex(0);\n \t\t}\n \n+\t\tif (cameraIdComboBox_) {\n+\t\t\tint cameraIdIndex = cameraIdComboBox_->findText(QString::fromStdString(camera_->id()));\n+\t\t\tcameraIdComboBox_->removeItem(cameraIdIndex);\n+\t\t}\n+\n \t\tint camIndex = cameraCombo_->findText(QString::fromStdString(camera->id()));\n \t\tcameraCombo_->removeItem(camIndex);\n \t}\ndiff --git a/src/qcam/main_window.h b/src/qcam/main_window.h\nindex fc70920f..b8122eb9 100644\n--- a/src/qcam/main_window.h\n+++ b/src/qcam/main_window.h\n@@ -23,7 +23,9 @@\n #include <QMainWindow>\n #include <QMutex>\n #include <QObject>\n+#include <QPointer>\n #include <QQueue>\n+#include <QStringList>\n #include <QTimer>\n \n #include \"../cam/stream_options.h\"\n@@ -99,6 +101,8 @@ private:\n \tQString title_;\n \tQTimer titleTimer_;\n \n+\tQPointer<QComboBox> cameraIdComboBox_;\n+\n \t/* Options */\n \tconst OptionsParser::Options &options_;\n \n","prefixes":["libcamera-devel","2/4"]}