summaryrefslogtreecommitdiff
path: root/test/utils.cpp
diff options
context:
space:
mode:
authorUtkarsh Tiwari <utkarsh02t@gmail.com>2022-08-07 00:34:31 +0530
committerUtkarsh Tiwari <utkarsh02t@gmail.com>2022-09-05 12:12:02 +0530
commit923927ae45dd10be5c3c854d568dae6751ccb87e (patch)
tree343d8b15a514ade7ff5734c480f6d9d64a37f933 /test/utils.cpp
parentf03da23b56bed065dace3cf3e7bf027f700e1085 (diff)
qcam: Support Hotplug for Camera Selection Dialog
Currently if there is HotPlug event when the user is on the Camera selection dialog, the QComboBox doesn't update to reflect the change. Add support for hotplugging / unplugging cameras. Signed-off-by: Utkarsh Tiwari <utkarsh02t@gmail.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Diffstat (limited to 'test/utils.cpp')
0 files changed, 0 insertions, 0 deletions
7'>47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
/* SPDX-License-Identifier: GPL-2.0-or-later */
/*
 * Copyright (C) 2019, Google Inc.
 *
 * viewfinder_qt.h - qcam - QPainter-based ViewFinder
 */
#ifndef __QCAM_VIEWFINDER_QT_H__
#define __QCAM_VIEWFINDER_QT_H__

#include <QIcon>
#include <QImage>
#include <QList>
#include <QMutex>
#include <QSize>
#include <QWidget>

#include <libcamera/buffer.h>
#include <libcamera/formats.h>
#include <libcamera/pixel_format.h>

#include "format_converter.h"
#include "viewfinder.h"

class ViewFinderQt : public QWidget, public ViewFinder
{
	Q_OBJECT

public:
	ViewFinderQt(QWidget *parent);
	~ViewFinderQt();

	const QList<libcamera::PixelFormat> &nativeFormats() const override;

	int setFormat(const libcamera::PixelFormat &format, const QSize &size) override;
	void render(libcamera::FrameBuffer *buffer, MappedBuffer *map) override;
	void stop() override;

	QImage getCurrentImage() override;

Q_SIGNALS:
	void renderComplete(libcamera::FrameBuffer *buffer);

protected:
	void paintEvent(QPaintEvent *) override;
	QSize sizeHint() const override;

private:
	FormatConverter converter_;

	libcamera::PixelFormat format_;
	QSize size_;

	/* Camera stopped icon */
	QSize vfSize_;
	QIcon icon_;
	QPixmap pixmap_;

	/* Buffer and render image */
	libcamera::FrameBuffer *buffer_;
	QImage image_;
	QMutex mutex_; /* Prevent concurrent access to image_ */
};

#endif /* __QCAM_VIEWFINDER_QT_H__ */