qv4l2: added resize to frame size in Capture menu
authorBård Eirik Winther <bwinther@cisco.com>
Thu, 8 Aug 2013 11:31:25 +0000 (11:31 +0000)
committerHans Verkuil <hans.verkuil@cisco.com>
Thu, 8 Aug 2013 12:46:35 +0000 (14:46 +0200)
This will resize the CaptureWin to the original frame size.
It also works with maximized windows.

Signed-off-by: Bård Eirik Winther <bwinther@cisco.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
utils/qv4l2/capture-win.cpp
utils/qv4l2/capture-win.h
utils/qv4l2/qv4l2.cpp
utils/qv4l2/qv4l2.h

index 33f7084..3bd6549 100644 (file)
@@ -61,6 +61,18 @@ void CaptureWin::buildWindow(QWidget *videoSurface)
        vbox->setSpacing(b);
 }
 
+void CaptureWin::resetSize()
+{
+       if (isMaximized())
+               showNormal();
+
+       int w = m_curWidth;
+       int h = m_curHeight;
+       m_curWidth = -1;
+       m_curHeight = -1;
+       resize(w, h);
+}
+
 QSize CaptureWin::getMargins()
 {
        int l, t, r, b;
index dd19f2d..eea0335 100644 (file)
@@ -78,6 +78,9 @@ public:
        void enableScaling(bool enable);
        static QSize scaleFrameSize(QSize window, QSize frame);
 
+public slots:
+       void resetSize();
+
 protected:
        void closeEvent(QCloseEvent *event);
        void buildWindow(QWidget *videoSurface);
index 6258a93..3da99da 100644 (file)
@@ -142,11 +142,14 @@ ApplicationWindow::ApplicationWindow() :
        m_scalingAct->setCheckable(true);
        m_scalingAct->setChecked(true);
        connect(m_scalingAct, SIGNAL(toggled(bool)), this, SLOT(enableScaling(bool)));
+       m_resetScalingAct = new QAction("Resize to Frame Size", this);
+       m_resetScalingAct->setStatusTip("Resizes the capture window to match frame size");
 
        QMenu *captureMenu = menuBar()->addMenu("&Capture");
        captureMenu->addAction(m_capStartAct);
        captureMenu->addAction(m_showFramesAct);
        captureMenu->addAction(m_scalingAct);
+       captureMenu->addAction(m_resetScalingAct);
 
        if (CaptureWinGL::isSupported()) {
                m_renderMethod = QV4L2_RENDER_GL;
@@ -211,8 +214,6 @@ void ApplicationWindow::setDevice(const QString &device, bool rawOpen)
 
        newCaptureWin();
 
-       m_capture->setMinimumSize(150, 50);
-
        QWidget *w = new QWidget(m_tabs);
        m_genTab = new GeneralTab(device, *this, 4, w);
 
@@ -360,6 +361,7 @@ void ApplicationWindow::newCaptureWin()
 
        m_capture->enableScaling(m_scalingAct->isChecked());
         connect(m_capture, SIGNAL(close()), this, SLOT(closeCaptureWin()));
+       connect(m_resetScalingAct, SIGNAL(triggered()), m_capture, SLOT(resetSize()));
 }
 
 void ApplicationWindow::capVbiFrame()
index 1402673..179cecb 100644 (file)
@@ -187,6 +187,7 @@ private:
        QAction *m_showAllAudioAct;
        QAction *m_audioBufferAct;
        QAction *m_scalingAct;
+       QAction *m_resetScalingAct;
        QString m_filename;
        QSignalMapper *m_sigMapper;
        QTabWidget *m_tabs;