Files
GVFG_Standalone/samples/gvfg_qt_preview/mainwindow.h
T
Mark.lin d2657a69cb Split GVFG customer API and preview helper
Refactor GVFG into a pull-based customer API with internal debug diagnostics in gvfg_debug.h. Move preview rendering into the separate gvfg_preview helper DLL and update the Qt sample to link it explicitly. Clean legacy callback/preview docs and removed SDK-internal render/log helper sources from the core GVFG DLL.
2026-06-15 17:06:12 +08:00

67 lines
1.5 KiB
C++

#pragma once
#include <gvfg_capture.h>
#include <gvfg_preview.h>
#include <QString>
#include <QWidget>
#include <array>
#include <atomic>
#include <cstdint>
#include <thread>
class QCloseEvent;
class PreviewWindow;
class QTimer;
QT_BEGIN_NAMESPACE
namespace Ui
{
class MainWindow;
}
QT_END_NAMESPACE
class MainWindow final : public QWidget
{
Q_OBJECT
public:
explicit MainWindow(QWidget *parent = nullptr);
~MainWindow() override;
protected:
void closeEvent(QCloseEvent *event) override;
private:
void refreshDevices();
void showPreviewWindow();
void showFullscreenPreviewWindow();
bool openDevice();
void closeDevice();
void startCapture();
void stopCapture();
bool applyPreview();
void updatePreviewSourceSize(const gvfg_runtime_info_t &info);
void updatePreviewSourceSize();
void updateSignalStatus(bool writeLog);
void updateUiState();
void showError(const QString &apiName, gvfg_status_t status);
void appendLog(const QString &message);
void captureReadLoop();
void joinCaptureThread();
Ui::MainWindow *ui_ = nullptr;
PreviewWindow *previewWindow_ = nullptr;
std::array<gvfg_device_info_t, GVFG_MAX_DEVICES> devices_{};
int deviceCount_ = 0;
gvfg_handle handle_ = nullptr;
gvfg_preview_handle previewHandle_ = nullptr;
bool captureRunning_ = false;
std::atomic<bool> captureStop_{false};
std::thread captureThread_;
std::atomic<uint64_t> frameCount_{0};
QTimer *signalStatusTimer_ = nullptr;
QString lastSignalStatusText_;
};