From patchwork Sat Aug 6 19:04:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Utkarsh Tiwari X-Patchwork-Id: 16995 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 157DBBE173 for ; Sat, 6 Aug 2022 19:04:57 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id BFA166332B; Sat, 6 Aug 2022 21:04:56 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1659812696; bh=5iS60UGDecVEyrrgT3lKElBN6R9iQM81Khz3N/3B3JI=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=jRePL41aKyB3J2esUHzBgrqkYx3skdDjSuwwzL7NAs4Vd8JkbpQMWf9IfiWiThOCO gDulYZRqvA7ENot8VLlLc1AMzX/lDskF6aoWI5PUfnWN17NAKMT0VwVfKSZeOXAbGO brjwBOI5E+jXXnLEOo7FrxB5NhO0vMZVMmD0mK7nXpLjcqMgE51nXdZ4wDLugBmPJn jrJHVcQtiOjFWBRVDmPGsKVL2LSfT7rOfyOA6r5lboE2il68DZ7oLyp5ewNFs8d5Hm K+ByS06Y/SDrXre37tDcTgU1zB9Gq+3x32/DWaiJWsrJIPD3yMGPWp9MNjsmH2kzRQ jOF4cqdlu67xw== Received: from mail-pj1-x1036.google.com (mail-pj1-x1036.google.com [IPv6:2607:f8b0:4864:20::1036]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id C5FDC61FAC for ; Sat, 6 Aug 2022 21:04:54 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="F4lDk+3v"; dkim-atps=neutral Received: by mail-pj1-x1036.google.com with SMTP id 15-20020a17090a098f00b001f305b453feso11082375pjo.1 for ; Sat, 06 Aug 2022 12:04:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=/g1b3Wfsbg0FDtmfKPifPvuYv+phjnLqZvK2o34f6LA=; b=F4lDk+3vS9o+WD0z4H5OnPwMx1o1+45KzjlZp6U/frzKC9eBilsRMRpATH57YxZJjl Jp3PIhwLJg4LWtb+Sn0TTqlFWXWOPcngwghUnDi516IMs2y8bI80trOXJNNRh1BG3OFR X9NZzuru2T/H6FOOcmmjuX0OciJ8/wYpzyIgZA8rMZBmdnEEJaBgnWTNFuZWbug9cDEu 3hUFmPwaqlb33s8klAc/13mm1ZGyS0cafqX/jHg/z1ALLHrnOpTf4v5C/zqjq4nmCknK K6MgcZzjnvLpVFTiuRjcidn3bd+YbikU+9x3zvJmOP42klLuXYQS84xkzBzTzkiYepUL KcKg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=/g1b3Wfsbg0FDtmfKPifPvuYv+phjnLqZvK2o34f6LA=; b=FPE1AlAQ7G+aPT8yAWvipada0fhuhP5KuM7anyWzH72R+IyOU1XYo51r4QMZm1/EPI 5/kE93z3g+nHwa/oo3Oe57HT7LgVGirtZspJrIBRDzRX8qTnB4XCRSUi9mYIGOSM+Nec 06r3uRBjTpN5/DAOY7ZEk66VQ1vdcmMT8E3yJpUmxJeZn14JOuX4p60vqp9YQea1Lk44 zIHWugQFe+/O2OQADjOiyF1SMdRRtdaPimy2/+PPQPuuXGj5KWgnOe8tuxTKBn6h+pmH /HzP8fleqpou/hfkCj/4ZrVN3KZM2Mtqe+j5Z4aZZo8urDAwa6kAU/ofUlW7nwAEunv+ QIiA== X-Gm-Message-State: ACgBeo1i5wkrw+MaFb8VcAc7QjTLVqULFs6PCIXI0rPIB32oYeTqex4b J9AVrNakuWNEmGMYQudoTgQQ2qvhD6M= X-Google-Smtp-Source: AA6agR44/EhYbKguoMY90cGXe96vJU2nhhlOqM3VzciWJQ2uhiXMW3Ilf3NxXuJW1z0R/dIejrB0BA== X-Received: by 2002:a17:90b:1b07:b0:1f5:115c:79a4 with SMTP id nu7-20020a17090b1b0700b001f5115c79a4mr13504441pjb.166.1659812692848; Sat, 06 Aug 2022 12:04:52 -0700 (PDT) Received: from localhost.localdomain ([2404:bd00:3:daa9:adf3:a099:1bff:e55]) by smtp.gmail.com with ESMTPSA id z17-20020aa79911000000b0052f20d70845sm406025pff.150.2022.08.06.12.04.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 06 Aug 2022 12:04:52 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Sun, 7 Aug 2022 00:34:31 +0530 Message-Id: <20220806190433.59128-3-utkarsh02t@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220806190433.59128-1-utkarsh02t@gmail.com> References: <20220806190433.59128-1-utkarsh02t@gmail.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 2/4] qcam: Support Hotplug for Camera Selection Dialog X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Utkarsh Tiwari via libcamera-devel From: Utkarsh Tiwari Reply-To: Utkarsh Tiwari Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Currently if there is HotPlug event when the user is on the Camera selection dialog, the QComboBox didn't update to reflect the change. If the QDialog exists then alert it for the Hotplug event. The check for QDialog existance is done by QPointer. Signed-off-by: Utkarsh Tiwari Reviewed-by: Kieran Bingham --- src/qcam/cam_select_dialog.h | 14 ++++++++++++++ src/qcam/main_window.cpp | 6 ++++++ 2 files changed, 20 insertions(+) diff --git a/src/qcam/cam_select_dialog.h b/src/qcam/cam_select_dialog.h index c23bad59..ee65eb88 100644 --- a/src/qcam/cam_select_dialog.h +++ b/src/qcam/cam_select_dialog.h @@ -56,6 +56,20 @@ public: return cameraIdComboBox_->currentText().toStdString(); } + /* Hotplug / Unplug Support. */ + void cameraAdded(libcamera::Camera *camera) + { + cameraIdComboBox_->addItem(QString::fromStdString(camera->id())); + } + + void cameraRemoved(libcamera::Camera *camera) + { + int cameraIndex = cameraIdComboBox_->findText( + QString::fromStdString(camera->id())); + + cameraIdComboBox_->removeItem(cameraIndex); + } + private: libcamera::CameraManager *cm_; diff --git a/src/qcam/main_window.cpp b/src/qcam/main_window.cpp index 758e2c94..dd30817d 100644 --- a/src/qcam/main_window.cpp +++ b/src/qcam/main_window.cpp @@ -594,6 +594,9 @@ void MainWindow::processHotplug(HotplugEvent *e) if (event == HotplugEvent::HotPlug) { cameraCombo_->addItem(QString::fromStdString(camera->id())); + + if (camSelectDialog_) + camSelectDialog_->cameraAdded(camera); } else if (event == HotplugEvent::HotUnplug) { /* Check if the currently-streaming camera is removed. */ if (camera == camera_.get()) { @@ -605,6 +608,9 @@ void MainWindow::processHotplug(HotplugEvent *e) int camIndex = cameraCombo_->findText(QString::fromStdString(camera->id())); cameraCombo_->removeItem(camIndex); + + if (camSelectDialog_) + camSelectDialog_->cameraRemoved(camera); } }