#pragma once #include #include #include #include #include #include #include #include #include "v4l2worker.h" class VideoWidget : public QWidget { Q_OBJECT public: explicit VideoWidget(QWidget *parent = nullptr); ~VideoWidget(); public: void shutdown(); // safe to call multiple times, called from MainWindow::closeEvent public slots: void onNewFrame(const QImage &frame); void clearFrame(); // blanks the preview (used on ANSI clear-screen) private slots: void onStartStop(); void onFreeze(bool frozen); void onScreenshot(); void refreshDeviceList(); protected: void paintEvent(QPaintEvent *event) override; void resizeEvent(QResizeEvent *event) override; private: void setupUi(); void startCapture(); void stopCapture(); void updateScaled(); QThread *m_thread = nullptr; V4l2Worker *m_worker = nullptr; QImage m_frame; QImage m_scaled; bool m_frozen = false; bool m_running = false; bool m_shutdownDone = false; QComboBox *m_deviceCombo = nullptr; QPushButton *m_startBtn = nullptr; QPushButton *m_freezeBtn = nullptr; QPushButton *m_screenshotBtn = nullptr; QLabel *m_infoLabel = nullptr; };