diff options
author | Kieran Bingham <kieran.bingham@ideasonboard.com> | 2020-02-07 16:18:03 +0000 |
---|---|---|
committer | Kieran Bingham <kieran.bingham@ideasonboard.com> | 2020-02-14 12:34:25 +0000 |
commit | 871879eb7356d532c4ed7791ec22cf5ae9f005e8 (patch) | |
tree | 3586b3c2d5f249b7ebd9562b24b2d4c2bacfe3bd /src/qcam/main_window.cpp | |
parent | de584a58f787c4b30485bb592776a8c0b8dc0100 (diff) |
qcam: Store CameraManager as class member
Intialise a local copy of the CameraManager instance to ease
access to the CameraManager which is frequently utilised.
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Diffstat (limited to 'src/qcam/main_window.cpp')
-rw-r--r-- | src/qcam/main_window.cpp | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/src/qcam/main_window.cpp b/src/qcam/main_window.cpp index 38d70633..2ed84cac 100644 --- a/src/qcam/main_window.cpp +++ b/src/qcam/main_window.cpp @@ -23,7 +23,7 @@ using namespace libcamera; MainWindow::MainWindow(CameraManager *cm, const OptionsParser::Options &options) - : options_(options), allocator_(nullptr), isCapturing_(false) + : options_(options), cm_(cm), allocator_(nullptr), isCapturing_(false) { int ret; @@ -35,7 +35,7 @@ MainWindow::MainWindow(CameraManager *cm, const OptionsParser::Options &options) setCentralWidget(viewfinder_); adjustSize(); - ret = openCamera(cm); + ret = openCamera(); if (!ret) ret = startCapture(); @@ -66,15 +66,15 @@ void MainWindow::updateTitle() setWindowTitle(title_ + " : " + QString::number(fps, 'f', 2) + " fps"); } -std::string MainWindow::chooseCamera(CameraManager *cm) +std::string MainWindow::chooseCamera() { QStringList cameras; bool result; - if (cm->cameras().size() == 1) - return cm->cameras()[0]->name(); + if (cm_->cameras().size() == 1) + return cm_->cameras()[0]->name(); - for (const std::shared_ptr<Camera> &cam : cm->cameras()) + for (const std::shared_ptr<Camera> &cam : cm_->cameras()) cameras.append(QString::fromStdString(cam->name())); QString name = QInputDialog::getItem(this, "Select Camera", @@ -86,19 +86,19 @@ std::string MainWindow::chooseCamera(CameraManager *cm) return name.toStdString(); } -int MainWindow::openCamera(CameraManager *cm) +int MainWindow::openCamera() { std::string cameraName; if (options_.isSet(OptCamera)) cameraName = static_cast<std::string>(options_[OptCamera]); else - cameraName = chooseCamera(cm); + cameraName = chooseCamera(); if (cameraName == "") return -EINVAL; - camera_ = cm->get(cameraName); + camera_ = cm_->get(cameraName); if (!camera_) { std::cout << "Camera " << cameraName << " not found" << std::endl; |