qcam: Pass camera manager to MainWindow class
Pass the CameraManager instance from the main() function to the MainWindow class instead of accessing it through CameraManager::instance(). This prepares for the removal of the CameraManager::instance() method. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
This commit is contained in:
parent
749dbd576f
commit
af49b18c81
3 changed files with 7 additions and 7 deletions
|
@ -73,7 +73,7 @@ int main(int argc, char **argv)
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
MainWindow *mainWindow = new MainWindow(options);
|
MainWindow *mainWindow = new MainWindow(cm, options);
|
||||||
mainWindow->show();
|
mainWindow->show();
|
||||||
ret = app.exec();
|
ret = app.exec();
|
||||||
delete mainWindow;
|
delete mainWindow;
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
|
|
||||||
using namespace libcamera;
|
using namespace libcamera;
|
||||||
|
|
||||||
MainWindow::MainWindow(const OptionsParser::Options &options)
|
MainWindow::MainWindow(CameraManager *cm, const OptionsParser::Options &options)
|
||||||
: options_(options), isCapturing_(false)
|
: options_(options), isCapturing_(false)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
|
@ -35,7 +35,7 @@ MainWindow::MainWindow(const OptionsParser::Options &options)
|
||||||
viewfinder_->setFixedSize(500, 500);
|
viewfinder_->setFixedSize(500, 500);
|
||||||
adjustSize();
|
adjustSize();
|
||||||
|
|
||||||
ret = openCamera();
|
ret = openCamera(cm);
|
||||||
if (!ret)
|
if (!ret)
|
||||||
ret = startCapture();
|
ret = startCapture();
|
||||||
|
|
||||||
|
@ -66,9 +66,8 @@ void MainWindow::updateTitle()
|
||||||
setWindowTitle(title_ + " : " + QString::number(fps, 'f', 2) + " fps");
|
setWindowTitle(title_ + " : " + QString::number(fps, 'f', 2) + " fps");
|
||||||
}
|
}
|
||||||
|
|
||||||
int MainWindow::openCamera()
|
int MainWindow::openCamera(CameraManager *cm)
|
||||||
{
|
{
|
||||||
CameraManager *cm = CameraManager::instance();
|
|
||||||
std::string cameraName;
|
std::string cameraName;
|
||||||
|
|
||||||
if (!options_.isSet(OptCamera)) {
|
if (!options_.isSet(OptCamera)) {
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
|
|
||||||
#include <libcamera/camera.h>
|
#include <libcamera/camera.h>
|
||||||
|
#include <libcamera/camera_manager.h>
|
||||||
#include <libcamera/stream.h>
|
#include <libcamera/stream.h>
|
||||||
|
|
||||||
#include "../cam/options.h"
|
#include "../cam/options.h"
|
||||||
|
@ -35,14 +36,14 @@ class MainWindow : public QMainWindow
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
MainWindow(const OptionsParser::Options &options);
|
MainWindow(CameraManager *cm, const OptionsParser::Options &options);
|
||||||
~MainWindow();
|
~MainWindow();
|
||||||
|
|
||||||
private Q_SLOTS:
|
private Q_SLOTS:
|
||||||
void updateTitle();
|
void updateTitle();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int openCamera();
|
int openCamera(CameraManager *cm);
|
||||||
|
|
||||||
int startCapture();
|
int startCapture();
|
||||||
void stopCapture();
|
void stopCapture();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue