From patchwork Wed Aug 10 15:03:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Utkarsh Tiwari X-Patchwork-Id: 17073 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 77C32C3272 for ; Wed, 10 Aug 2022 15:04:14 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 2EE7963340; Wed, 10 Aug 2022 17:04:14 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1660143854; bh=qytBWn/jAHqKVs+wfUAlvvbyclouipgE2JQ+P8k0rmU=; 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=yBfcpDrJrhxSp+l4LSbF2CXXM3O6Qh9XfODyeuAglTdiyK9jfFEmDFgqnXe/iweO0 jjTednZoKvhvCjcKFICGxy0DjBcG99ASbjMYq2pJsd3m0otDvlj1645woHo/iCbCIb LrAEOylo+I6KV8D9vBgxtdeSdW7l74y4oUjjl+G83XkL7uF6IAmcUzHhCu0fPUamyG pxNTifNtP2Xk+kcEjNTCLkQWMtc92Ef1IGDetO8WUuMd/6IZ1vBT6BdC2gHQJnAuVE 2gKB+0k2NvYvLPS11VY/ChjdOnlVXxhibBtKZpNyjPYASxLWiWC0XI8SbsKzmnhmTy Ft+4+CDweXeNw== Received: from mail-pf1-x42b.google.com (mail-pf1-x42b.google.com [IPv6:2607:f8b0:4864:20::42b]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 843F56333D for ; Wed, 10 Aug 2022 17:04:12 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="Jx2azNbM"; dkim-atps=neutral Received: by mail-pf1-x42b.google.com with SMTP id f192so13938807pfa.9 for ; Wed, 10 Aug 2022 08:04:12 -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=kx1n1X+NqDdSrABkSCaBRoZD7PnoXHnF4Drty4LDWhI=; b=Jx2azNbMCGbCbJkCYx8sKRtcRUA+/8ityRp39f6VUkzevP3vzHCKIUJWB4bmGglx95 qO8pjYR5voIN3+z7oWtcJAUJzM/85drIGFEyUrD5QocOeHrFN8COC4LtTT7wN4Y0twm7 mfSFdldpceBt/PJe+dnQFPbnyx2rP2D4HxnKkfMnsJs7DbIsrYde7OlHrQGEASibHPyv 4c+w8OZRKCeXXikGrn8fyhj6aUrdMJYIHHOv38qGprsD9VXIGxwfNwvi0tVoIfT4h6do CX4HjTSm6JJObTC1olgOPwUe98+WzW9r2mNOHInc7W0Kqcr2FcaCv2Nv9PHLoFYc042/ nV9Q== 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=kx1n1X+NqDdSrABkSCaBRoZD7PnoXHnF4Drty4LDWhI=; b=nLWRvuiwp7SiOLARy3onc3D3LflfV30xJMrvs8KkHfG/Y99dcIxmfD/tTl+qbVYTcK PEDR/FOlJBDxZgq8mnudEi269szWoZmqcIUosCjQunsMXqKB0uao8x3w3QREURnIFKMz JF+q6gH81OidJRzVdTpY+aq6HvrGJ37pvsKWNgFQuZ+wVsisvdsZmuHOGr/JUsRTFc2Q i1+tu9TvQX6WAKjSIyQCzq7qlieu/WYWZ3mMba+2DizHhO9W5FobEUxFA/bcuhIqbGDC pH07PDr0aVFhn3Xbn6Gq/G72IrnNBvKK+zoKl4HVTZuaxRb8a6bFxPSZNv9RKTj9EeDL 7G/w== X-Gm-Message-State: ACgBeo1P2XfXvZT+5KHuo2JnsgPFy967dL6tevue8HLxT7wVdVHNGvz5 roJh1nY5YiAYD6y8lLZmOLgrVoPPC2k= X-Google-Smtp-Source: AA6agR5sOXzNCgUK9dVPk12jzVv2TqoUMWjkDjfvNtUZF3VPrukX+VTUj/NVFoQpjXfI37bgO1nWHA== X-Received: by 2002:aa7:8096:0:b0:52d:d5f6:2ea6 with SMTP id v22-20020aa78096000000b0052dd5f62ea6mr28456817pff.0.1660143850861; Wed, 10 Aug 2022 08:04:10 -0700 (PDT) Received: from localhost.localdomain ([2404:bd00:3:d2bc:2a55:4cae:bf8f:f4ed]) by smtp.gmail.com with ESMTPSA id b3-20020a1709027e0300b0016f1319d2a7sm12882624plm.297.2022.08.10.08.04.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Aug 2022 08:04:10 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Wed, 10 Aug 2022 20:33:48 +0530 Message-Id: <20220810150349.414043-8-utkarsh02t@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220810150349.414043-1-utkarsh02t@gmail.com> References: <20220810150349.414043-1-utkarsh02t@gmail.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v8 7/8] qcam: CamSelectDialog: Display Capture script path 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" Display the path of the selected capture script in a thinner font. Signed-off-by: Utkarsh Tiwari --- Difference: 1. The scriptPathLabel_ has a fixed parent now captureWidget src/qcam/cam_select_dialog.cpp | 39 ++++++++++++++++++++++++++++------ src/qcam/cam_select_dialog.h | 7 +++++- src/qcam/main_window.cpp | 3 ++- 3 files changed, 40 insertions(+), 9 deletions(-) diff --git a/src/qcam/cam_select_dialog.cpp b/src/qcam/cam_select_dialog.cpp index 0db0a5bd..3286c433 100644 --- a/src/qcam/cam_select_dialog.cpp +++ b/src/qcam/cam_select_dialog.cpp @@ -19,10 +19,12 @@ #include #include #include +#include CameraSelectorDialog::CameraSelectorDialog(libcamera::CameraManager *cameraManager, - bool isScriptRunning, QWidget *parent) - : QDialog(parent), cm_(cameraManager), isScriptRunning_(isScriptRunning) + bool isScriptRunning, std::string scriptPath, QWidget *parent) + : QDialog(parent), cm_(cameraManager), + isScriptRunning_(isScriptRunning), scriptPath_(scriptPath) { /* Use a QFormLayout for the dialog. */ QFormLayout *layout = new QFormLayout(this); @@ -40,14 +42,31 @@ CameraSelectorDialog::CameraSelectorDialog(libcamera::CameraManager *cameraManag connect(cameraIdComboBox_, &QComboBox::currentTextChanged, this, &CameraSelectorDialog::handleCameraChange); + /* Setup widget for capture script button. */ + QWidget *captureWidget = new QWidget; + captureWidgetLayout_ = new QVBoxLayout(captureWidget); + captureWidgetLayout_->setMargin(0); + captureScriptButton_ = new QPushButton; connect(captureScriptButton_, &QPushButton::clicked, this, &CameraSelectorDialog::handleCaptureScriptButton); + captureWidgetLayout_->addWidget(captureScriptButton_); + + /* Use a thinner font to indicate script info. */ + QFont smallFont; + smallFont.setWeight(QFont::Thin); + + scriptPathLabel_ = new QLabel(captureWidget); + scriptPathLabel_->setFont(smallFont); + scriptPathLabel_->setWordWrap(true); /* Display the action that would be performed when button is clicked. */ - if (isScriptRunning_) + if (isScriptRunning_) { captureScriptButton_->setText("Stop"); - else + + scriptPathLabel_->setText(QString::fromStdString(scriptPath_)); + captureWidgetLayout_->addWidget(scriptPathLabel_); + } else captureScriptButton_->setText("Open"); /* Setup the QDialogButton Box */ @@ -64,7 +83,7 @@ CameraSelectorDialog::CameraSelectorDialog(libcamera::CameraManager *cameraManag layout->addRow("Camera:", cameraIdComboBox_); layout->addRow("Location:", cameraLocation_); layout->addRow("Model:", cameraModel_); - layout->addRow("Capture Script:", captureScriptButton_); + layout->addRow("Capture Script:", captureWidget); layout->addWidget(buttonBox); } @@ -139,16 +158,22 @@ void CameraSelectorDialog::handleCaptureScriptButton() Q_EMIT stopCaptureScript(); isScriptRunning_ = false; captureScriptButton_->setText("Open"); + + captureWidgetLayout_->removeWidget(scriptPathLabel_); } else { selectedScriptPath_ = QFileDialog::getOpenFileName(this, "Run Capture Script", QDir::currentPath(), "Capture Script (*.yaml)") .toStdString(); - if (!selectedScriptPath_.empty()) + if (!selectedScriptPath_.empty()) { captureScriptButton_->setText("Loaded"); - else + scriptPathLabel_->setText(QString::fromStdString(selectedScriptPath_)); + captureWidgetLayout_->addWidget(scriptPathLabel_); + } else { captureScriptButton_->setText("Open"); + captureWidgetLayout_->removeWidget(scriptPathLabel_); + } } } diff --git a/src/qcam/cam_select_dialog.h b/src/qcam/cam_select_dialog.h index bbdf897e..72dfbb14 100644 --- a/src/qcam/cam_select_dialog.h +++ b/src/qcam/cam_select_dialog.h @@ -18,13 +18,15 @@ #include #include #include +#include +#include class CameraSelectorDialog : public QDialog { Q_OBJECT public: CameraSelectorDialog(libcamera::CameraManager *cameraManager, - bool isScriptRunning, QWidget *parent); + bool isScriptRunning, std::string scriptPath, QWidget *parent); ~CameraSelectorDialog() = default; @@ -62,5 +64,8 @@ private: QComboBox *cameraIdComboBox_; QLabel *cameraLocation_; QLabel *cameraModel_; + + QVBoxLayout *captureWidgetLayout_; QPushButton *captureScriptButton_; + QLabel *scriptPathLabel_; }; diff --git a/src/qcam/main_window.cpp b/src/qcam/main_window.cpp index 3c7c3173..753e1af9 100644 --- a/src/qcam/main_window.cpp +++ b/src/qcam/main_window.cpp @@ -339,7 +339,8 @@ std::string MainWindow::chooseCamera() /* Construct the selection dialog, only the first time. */ if (!cameraSelectorDialog_) - cameraSelectorDialog_ = new CameraSelectorDialog(cm_, scriptRunning, this); + cameraSelectorDialog_ = new CameraSelectorDialog(cm_, scriptRunning, + scriptPath_, this); connect(cameraSelectorDialog_, &CameraSelectorDialog::stopCaptureScript, this, &MainWindow::stopCaptureScript);