update layout to better fit

This commit is contained in:
Maik Jurischka
2025-12-19 06:50:52 +01:00
parent 34148a592a
commit 7313592993
3 changed files with 18 additions and 18 deletions

View File

@@ -244,7 +244,7 @@ void GStreamerPipelineWidget::onQuickStart()
// Step 3: Start stream
m_socketClient->sendCommand("start_stream", QJsonObject(),
[this](const QJsonObject& response) {
updateStatus("Streaming started - Switch to Video Viewer tab and click 'Start Viewer'", true);
updateStatus("Streaming started - Click 'Start Viewer' on the left to view", true);
m_quickStartBtn->setEnabled(true);
m_quickStartBtn->setText("⚡ Quick Start (Auto Configure & Stream)");
},

View File

@@ -32,17 +32,17 @@ void MainWindow::setupUI()
m_pipelineWidget = new GStreamerPipelineWidget(m_socketClient, this);
m_cameraWidget = new CameraControlWidget(m_socketClient, this);
// Create tab widget for controls
// Create tab widget for controls on the right
QTabWidget* controlTabs = new QTabWidget(this);
controlTabs->addTab(m_pipelineWidget, "Pipeline Control");
controlTabs->addTab(m_cameraWidget, "Camera Control");
// Create vertical splitter: video on top, controls on bottom
QSplitter* mainSplitter = new QSplitter(Qt::Vertical, this);
// Create horizontal splitter: video on left (full height), controls on right
QSplitter* mainSplitter = new QSplitter(Qt::Horizontal, this);
mainSplitter->addWidget(m_videoWidget);
mainSplitter->addWidget(controlTabs);
mainSplitter->setStretchFactor(0, 3); // Video gets more space
mainSplitter->setStretchFactor(1, 1); // Controls get less space
mainSplitter->setStretchFactor(0, 2); // Video gets more space (2/3)
mainSplitter->setStretchFactor(1, 1); // Controls get less space (1/3)
// Set as central widget
setCentralWidget(mainSplitter);

View File

@@ -35,19 +35,15 @@ void VideoViewerWidget::initGStreamer()
void VideoViewerWidget::setupUI()
{
QVBoxLayout* mainLayout = new QVBoxLayout(this);
mainLayout->setContentsMargins(0, 0, 0, 0);
mainLayout->setSpacing(5);
// Video display container
QGroupBox* videoGroup = new QGroupBox("Video Display", this);
QVBoxLayout* videoLayout = new QVBoxLayout();
// Video display - no GroupBox for maximum space
m_videoDisplay = new QLabel(this);
m_videoDisplay->setMinimumSize(640, 480);
m_videoDisplay->setStyleSheet("background-color: black;");
m_videoDisplay->setStyleSheet("background-color: black; border: 1px solid #666;");
m_videoDisplay->setAlignment(Qt::AlignCenter);
m_videoDisplay->setScaledContents(true); // Enable scaling for zoom later
videoLayout->addWidget(m_videoDisplay);
videoGroup->setLayout(videoLayout);
m_videoDisplay->setScaledContents(false); // Disable for better aspect ratio control
// Controls
QGroupBox* controlGroup = new QGroupBox("Viewer Controls", this);
@@ -95,7 +91,8 @@ void VideoViewerWidget::setupUI()
controlLayout->addWidget(m_statusLabel);
controlGroup->setLayout(controlLayout);
mainLayout->addWidget(videoGroup, 1);
// Add to main layout: video takes most space, controls at bottom
mainLayout->addWidget(m_videoDisplay, 1);
mainLayout->addWidget(controlGroup);
setLayout(mainLayout);
@@ -413,7 +410,10 @@ void VideoViewerWidget::displayFrame(const QImage& frame)
firstFrame = false;
}
// Convert QImage to QPixmap and display in label
// Convert QImage to QPixmap and scale to fit label while keeping aspect ratio
QPixmap pixmap = QPixmap::fromImage(frame);
m_videoDisplay->setPixmap(pixmap.scaled(m_videoDisplay->size(), Qt::KeepAspectRatio, Qt::SmoothTransformation));
QPixmap scaledPixmap = pixmap.scaled(m_videoDisplay->size(),
Qt::KeepAspectRatio,
Qt::SmoothTransformation);
m_videoDisplay->setPixmap(scaledPixmap);
}