Separate the SDK and Qt sample build projects
Compared with f612cfd:
- Move the capture SDK, private IOCTL wrapper, and optional preview helper under GVFG_SDK with an independent top-level CMake project and version source.
- Move the Qt preview application into GVFG_Qt_Sample and consume prebuilt SDK DLLs and compiler-specific import libraries through imported CMake targets instead of compiling SDK sources as subdirectories.
- Resolve Qt Creator configuration-specific SDK build directories automatically, copy the three runtime DLLs beside the sample executable, and keep missing MSVC or MinGW artifacts as explicit configure errors.
- Update Release and Debug packaging scripts to read SDK and sample outputs separately, and update the repository build instructions for the two-project workflow.
- Preserve the pre-existing uncommitted device display-name suffix change outside this commit.
Validation: independent MSVC SDK configure/build and independent Qt MSVC sample configure/build passed; the sample build graph contains no SDK implementation sources; git diff --check passed. No MinGW link, runtime launch, capture, audio playback, or hardware validation was run.
This commit is contained in:
@@ -0,0 +1,148 @@
|
||||
#include "previewwindow.h"
|
||||
#include "ui_previewwindow.h"
|
||||
|
||||
#include <QGuiApplication>
|
||||
#include <QCloseEvent>
|
||||
#include <QKeyEvent>
|
||||
#include <QMouseEvent>
|
||||
#include <QScreen>
|
||||
#include <QSize>
|
||||
#include <algorithm>
|
||||
|
||||
PreviewWindow::PreviewWindow(QWidget *parent)
|
||||
: QWidget(parent), ui_(new Ui::PreviewWindow)
|
||||
{
|
||||
ui_->setupUi(this);
|
||||
ui_->verticalLayout->setContentsMargins(0, 0, 0, 0);
|
||||
ui_->verticalLayout->setSpacing(0);
|
||||
ui_->previewHost->setAttribute(Qt::WA_NativeWindow, true);
|
||||
ui_->previewHost->setStyleSheet(QStringLiteral("background: black;"));
|
||||
}
|
||||
|
||||
PreviewWindow::~PreviewWindow()
|
||||
{
|
||||
delete ui_;
|
||||
}
|
||||
|
||||
void *PreviewWindow::nativePreviewHandle() const
|
||||
{
|
||||
return reinterpret_cast<void *>(ui_->previewHost->winId());
|
||||
}
|
||||
|
||||
void PreviewWindow::setSourceSize(int sourceWidth, int sourceHeight)
|
||||
{
|
||||
if (sourceWidth <= 0 || sourceHeight <= 0)
|
||||
return;
|
||||
|
||||
if (sourceWidth_ == sourceWidth && sourceHeight_ == sourceHeight && isVisible())
|
||||
return;
|
||||
|
||||
sourceWidth_ = sourceWidth;
|
||||
sourceHeight_ = sourceHeight;
|
||||
|
||||
if (isFullScreen())
|
||||
return;
|
||||
|
||||
QScreen *targetScreen = screen();
|
||||
if (!targetScreen)
|
||||
targetScreen = QGuiApplication::primaryScreen();
|
||||
|
||||
ui_->previewHost->setMinimumSize(QSize(1, 1));
|
||||
ui_->previewHost->setMaximumSize(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX);
|
||||
|
||||
const QSize currentHostSize = ui_->previewHost->size();
|
||||
const QSize windowOverhead = size() - currentHostSize;
|
||||
|
||||
QSize targetSize(sourceWidth, sourceHeight);
|
||||
if (targetScreen)
|
||||
{
|
||||
const QSize maxSize = targetScreen->availableGeometry().size() - windowOverhead - QSize(16, 48);
|
||||
const QSize boundedSize(std::max(320, maxSize.width()), std::max(180, maxSize.height()));
|
||||
if (targetSize.width() > boundedSize.width() || targetSize.height() > boundedSize.height())
|
||||
targetSize.scale(boundedSize, Qt::KeepAspectRatio);
|
||||
}
|
||||
|
||||
resize(targetSize + windowOverhead);
|
||||
}
|
||||
|
||||
void PreviewWindow::closePreview()
|
||||
{
|
||||
closeAllowed_ = true;
|
||||
emit previewVisibilityChanged(false);
|
||||
close();
|
||||
}
|
||||
|
||||
void PreviewWindow::showPreview(int sourceWidth, int sourceHeight)
|
||||
{
|
||||
closeAllowed_ = false;
|
||||
setSourceSize(sourceWidth, sourceHeight);
|
||||
if (isFullScreen())
|
||||
showNormal();
|
||||
show();
|
||||
emit previewVisibilityChanged(true);
|
||||
raise();
|
||||
activateWindow();
|
||||
}
|
||||
|
||||
void PreviewWindow::showFullscreenPreview(int sourceWidth, int sourceHeight)
|
||||
{
|
||||
closeAllowed_ = false;
|
||||
setSourceSize(sourceWidth, sourceHeight);
|
||||
enterFullscreen();
|
||||
emit previewVisibilityChanged(true);
|
||||
}
|
||||
|
||||
void PreviewWindow::enterFullscreen()
|
||||
{
|
||||
showFullScreen();
|
||||
raise();
|
||||
activateWindow();
|
||||
}
|
||||
|
||||
void PreviewWindow::exitFullscreen()
|
||||
{
|
||||
if (!isFullScreen())
|
||||
return;
|
||||
|
||||
showNormal();
|
||||
raise();
|
||||
activateWindow();
|
||||
}
|
||||
|
||||
void PreviewWindow::closeEvent(QCloseEvent *event)
|
||||
{
|
||||
if (closeAllowed_)
|
||||
{
|
||||
event->accept();
|
||||
return;
|
||||
}
|
||||
|
||||
hide();
|
||||
emit previewVisibilityChanged(false);
|
||||
event->ignore();
|
||||
}
|
||||
|
||||
void PreviewWindow::keyPressEvent(QKeyEvent *event)
|
||||
{
|
||||
if (event->key() == Qt::Key_Escape && isFullScreen())
|
||||
{
|
||||
exitFullscreen();
|
||||
event->accept();
|
||||
return;
|
||||
}
|
||||
|
||||
if (event->key() == Qt::Key_F11)
|
||||
{
|
||||
isFullScreen() ? exitFullscreen() : enterFullscreen();
|
||||
event->accept();
|
||||
return;
|
||||
}
|
||||
|
||||
QWidget::keyPressEvent(event);
|
||||
}
|
||||
|
||||
void PreviewWindow::mouseDoubleClickEvent(QMouseEvent *event)
|
||||
{
|
||||
isFullScreen() ? exitFullscreen() : enterFullscreen();
|
||||
event->accept();
|
||||
}
|
||||
Reference in New Issue
Block a user