qv4l2: reset size after changing aspect ratios or scaling mode
authorHans Verkuil <hans.verkuil@cisco.com>
Fri, 11 Jul 2014 13:36:50 +0000 (15:36 +0200)
committerHans Verkuil <hans.verkuil@cisco.com>
Fri, 11 Jul 2014 13:36:50 +0000 (15:36 +0200)
When the video or pixel aspect ratio is changed by the user, or if
scaling is enabled/disabled, reset the window size to the optimal
size. This behavior is much more natural.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
utils/qv4l2/capture-win.cpp

index 4b89944..640b7f6 100644 (file)
@@ -175,8 +175,7 @@ void CaptureWin::updateSize()
 void CaptureWin::setCropMethod(CropMethod crop)
 {
        m_cropMethod = crop;
-       QResizeEvent event (QSize(width(), height()), QSize(width(), height()));
-       QCoreApplication::sendEvent(this, &event);
+       resetSize();
 }
 
 QSize CaptureWin::pixelAspectFrameSize(QSize size)
@@ -210,8 +209,7 @@ void CaptureWin::enableScaling(bool enable)
                QWidget::setMinimumSize(MIN_WIN_SIZE_WIDTH, MIN_WIN_SIZE_HEIGHT);
        }
        m_enableScaling = enable;
-       QResizeEvent event (QSize(width(), height()), QSize(width(), height()));
-       QCoreApplication::sendEvent(this, &event);
+       resetSize();
 }
 
 void CaptureWin::setWindowSize(QSize frameSize)
@@ -273,8 +271,7 @@ QSize CaptureWin::scaleFrameSize(QSize window, QSize frame)
 void CaptureWin::setPixelAspectRatio(double ratio)
 {
        m_pixelAspectRatio = ratio;
-       QResizeEvent event(QSize(width(), height()), QSize(width(), height()));
-       QCoreApplication::sendEvent(this, &event);
+       resetSize();
 }
 
 void CaptureWin::closeEvent(QCloseEvent *event)