From patchwork Mon Jul 11 16:53:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Utkarsh Tiwari X-Patchwork-Id: 16594 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 0CFCFBE173 for ; Mon, 11 Jul 2022 16:53:37 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 71D566331A; Mon, 11 Jul 2022 18:53:36 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1657558416; bh=mjLINYTD0Y6yoG9AzSGOz7/l66qv4O7EMXMYRLEeot0=; h=To:Date:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=cst1EkjLAEERK+U27znjYtXMx7mPfGJB811BlU4BMBkSpAefOWqYNJoRiTNtToreL /mS8u0kHXOzhsqZy89+9ahdlUYtjqAUHHgxVh0AOixop0MoiO9CTnpUOnWVzgTpYuN zTn5Hj7Y2Tn78OuLKEMPjF6ocHRM5qAks3+AoOu0S0WyCAz86BhsPQbx7DunxWnyeZ sb2fpKM0/WiInBpJfqSdnrh2PSRNVehLeGQE2o/asBSEet7F49lrrFRCVCi1MZqVny mXWVNdjqx3szFVO+DPlZbqAeAgT7Tulp0cbfeXFKA5Q5Gshoa41KugB2IlhTwFg/Ax fA1SY1fVMynUQ== Received: from mail-pl1-x62f.google.com (mail-pl1-x62f.google.com [IPv6:2607:f8b0:4864:20::62f]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id AD1AE63312 for ; Mon, 11 Jul 2022 18:53:35 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="WzjF+//c"; dkim-atps=neutral Received: by mail-pl1-x62f.google.com with SMTP id r6so2489913plg.3 for ; Mon, 11 Jul 2022 09:53:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=7DaV2orSq1zEmH6H81yyBIWw8/tLMAksvlEp/OMRSZI=; b=WzjF+//cBJke/pDtoGznq1reZh/8r+w+s13rmjkYS9+YKnj+sXp1fARxbPZ331DGRO D+gV3F2xuEhJffC8DocJeTnCHVHdqnbZQqnGYDeVeSP+91sntk96pBAEuAGRrIPIS2yy HiB044TWIT9AVEwG8g21YXiExhfzleFU5TcgQf4siZy+EvSkq/1xqWuqttvq4WzIv2zS 02HcKQrId96KMPU3NTkbY4eGSsAzQX1smslCKfnvE7Vk6cGZucgJ1E7br4SKPAG06wPj 7HfPmLq0CdCdwOJkXw4QiirzMzioaZgdIRU1aHLe5OSsoel8UOjq9hwl349oThV+kCfk B8oA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=7DaV2orSq1zEmH6H81yyBIWw8/tLMAksvlEp/OMRSZI=; b=fMwN4jNEsHb752wRda4JBbni62njZ/waEpCNXUgzGSECfhVbkB5BbCC5iEF1I4MNHf h0z1WSvS0bkXpVwJWfQ0KPrM4IVlSzvEYqcx7OrstNVz1r0X9MAQ/QY9OwxJi5jrZpVI 0JAoXt3s3g7Lit4ekwlDcPYo7mtHPCxHVaNAnBP7gQNiKXXzpO4GGBwWt+fvgSbcSjo7 9uE4YQGG/D44Zf3tCsDfDOmFrfY0o6jvAdk4yJ3aW2LYE0TFaKsSblC6d9GdCepaNrfD Q7JMQlU0LxzYq54dte2BVErr+eo6SFzaEGNVkCYpjz2AXLO6sqF4qQTBEUZyBVOWg1ZO Kpxg== X-Gm-Message-State: AJIora8rWb5wJCtj13cQPEIm/XLeIOR2GxVNK21VLQmBFIkOH0i5TtvU 1wGnSKhGRo16MZePKFKMaWNVisFGB0kWmw== X-Google-Smtp-Source: AGRyM1uJmPc6wQ93+1JO+6eurDT3dKgcY6Y9W2srkIxO11opvF365R2Ulzcow0A9567Il/bvdvb7Qw== X-Received: by 2002:a17:902:f546:b0:16b:e4c7:671b with SMTP id h6-20020a170902f54600b0016be4c7671bmr19516883plf.129.1657558413854; Mon, 11 Jul 2022 09:53:33 -0700 (PDT) Received: from localhost.localdomain ([2406:3003:2005:1c27:a546:e276:c41e:ea9b]) by smtp.gmail.com with ESMTPSA id 195-20020a6217cc000000b0050dc762818csm4991301pfx.102.2022.07.11.09.53.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Jul 2022 09:53:33 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Tue, 12 Jul 2022 00:53:27 +0800 Message-Id: <20220711165327.675198-1-utkarsh02t@gmail.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH] qcam: Centralize toggling of Capture Script Action 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" Centralize the use of scriptExecAction_ in a single function toggleScriptAction(). Call toggleScriptAction() with a true value to reset script_ and set the icon to show availability to load script to the user. Call with a false value to set the icon to show the stopping icon. Signed-off-by: Utkarsh Tiwari --- This patch applies on top of series https://lists.libcamera.org/pipermail/libcamera-devel/2022-June/031151.html src/qcam/main_window.cpp | 26 ++++++++++++++++++-------- src/qcam/main_window.h | 2 ++ 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/src/qcam/main_window.cpp b/src/qcam/main_window.cpp index a13a8b34..d4b3d629 100644 --- a/src/qcam/main_window.cpp +++ b/src/qcam/main_window.cpp @@ -161,8 +161,7 @@ MainWindow::MainWindow(CameraManager *cm, const OptionsParser::Options &options) } /* Show stopping availability. */ - scriptExecAction_->setIcon(QIcon(":x-square.svg")); - scriptExecAction_->setText("Stop Script execution"); + toggleScriptAction(false); } startStopAction_->setChecked(true); @@ -252,6 +251,8 @@ int MainWindow::createToolbars() QIcon(":file.svg")), "Open Capture Script"); connect(action, &QAction::triggered, this, &MainWindow::chooseScript); + + /* Do not operate directly call toggleScriptAction */ scriptExecAction_ = action; return 0; @@ -289,10 +290,7 @@ void MainWindow::chooseScript() * This is the second valid press of load script button, * It indicates stopping, Stop and set button for new script. */ - script_.reset(); - scriptExecAction_->setIcon(QIcon::fromTheme("document-open", - QIcon(":file.svg"))); - scriptExecAction_->setText("Open Capture Script"); + toggleScriptAction(true); return; } @@ -323,14 +321,26 @@ void MainWindow::chooseScript() * Valid script verified * Set the button to indicate stopping availibility. */ - scriptExecAction_->setIcon(QIcon(":x-square.svg")); - scriptExecAction_->setText("Stop Script execution"); + toggleScriptAction(false); /* Start capture again if we were capturing before. */ if (wasCapturing) toggleCapture(true); } +void MainWindow::toggleScriptAction(bool showAvailable) +{ + if (showAvailable) { + script_.reset(); + scriptExecAction_->setIcon(QIcon::fromTheme("document-open", + QIcon(":file.svg"))); + scriptExecAction_->setText("Open Capture Script"); + } else { + scriptExecAction_->setIcon(QIcon(":x-square.svg")); + scriptExecAction_->setText("Stop Script execution"); + } +} + /* ----------------------------------------------------------------------------- * Camera Selection */ diff --git a/src/qcam/main_window.h b/src/qcam/main_window.h index 4d19ab64..6f131b17 100644 --- a/src/qcam/main_window.h +++ b/src/qcam/main_window.h @@ -90,6 +90,8 @@ private: void chooseScript(); + void toggleScriptAction(bool showAvailable); + /* UI elements */ QToolBar *toolbar_; QAction *startStopAction_;