From: Anton Arbring Date: Fri, 18 Jul 2014 10:54:34 +0000 (+0200) Subject: qv4l2: added fullscreen functionality for capture window X-Git-Tag: v4l-utils-1.3.90~86 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=44c58951fc1ebafc06febcb77ce61567cfbe6fe9;p=platform%2Fupstream%2Fv4l-utils.git qv4l2: added fullscreen functionality for capture window One can enter fullscreen mode by a push button, the F key or by a double click. To go back to window mode; all the same options plus the escape key. An eventfilter is added to show a status bar when moving the mouse to the bottom of the screen while in fullscreen mode. Signed-off-by: Anton Arbring Signed-off-by: Hans Verkuil --- diff --git a/utils/qv4l2/capture-win.cpp b/utils/qv4l2/capture-win.cpp index 640b7f6..864b05d 100644 --- a/utils/qv4l2/capture-win.cpp +++ b/utils/qv4l2/capture-win.cpp @@ -40,7 +40,11 @@ CaptureWin::CaptureWin() connect(m_hotkeyClose, SIGNAL(activated()), this, SLOT(close())); m_hotkeyScaleReset = new QShortcut(Qt::CTRL+Qt::Key_F, this); connect(m_hotkeyScaleReset, SIGNAL(activated()), this, SLOT(resetSize())); - m_frame.format = 0; + m_hotkeyExitFullscreen = new QShortcut(Qt::Key_Escape, this); + connect(m_hotkeyExitFullscreen, SIGNAL(activated()), this, SLOT(escape())); + m_hotkeyToggleFullscreen = new QShortcut(Qt::Key_F, this); + connect(m_hotkeyToggleFullscreen, SIGNAL(activated()), this, SLOT(fullScreen())); + m_frame.format = 0; m_frame.size.setWidth(0); m_frame.size.setHeight(0); m_frame.planeData[0] = NULL; @@ -96,13 +100,26 @@ void CaptureWin::buildWindow(QWidget *videoSurface) QVBoxLayout *vbox = new QVBoxLayout(this); m_information.setText("No Frame"); vbox->addWidget(videoSurface, 2000); - vbox->addWidget(&m_information, 1, Qt::AlignBottom); + bottom = new QFrame(parentWidget()); + bottom->installEventFilter(this); + + hbox = new QHBoxLayout(bottom); + hbox->addWidget(&m_information, 1, Qt::AlignVCenter); + + m_fullscreenButton = new QPushButton("Show Fullscreen", bottom); + m_fullscreenButton->setMaximumWidth(200); + m_fullscreenButton->setMinimumWidth(100); + hbox->addWidget(m_fullscreenButton, 1, Qt::AlignVCenter); + connect(m_fullscreenButton, SIGNAL(clicked()), SLOT(fullScreen())); + vbox->addWidget(bottom, 0, Qt::AlignBottom); vbox->getContentsMargins(&l, &t, &r, &b); - vbox->setSpacing(b); + vbox->setSpacing(t+b); } void CaptureWin::resetSize() { + if (isFullScreen()) + toggleFullScreen(); if (isMaximized()) showNormal(); @@ -274,6 +291,63 @@ void CaptureWin::setPixelAspectRatio(double ratio) resetSize(); } +void CaptureWin::mouseDoubleClickEvent( QMouseEvent * e ) +{ + toggleFullScreen(); +} + +bool CaptureWin::eventFilter(QObject *target, QEvent *event) +{ + if (target == bottom && isFullScreen()) { + if (event->type() == QEvent::Enter) { + bottom->setStyleSheet("background-color:#bebebe;"); + bottom->setFixedHeight(75); + m_fullscreenButton->show(); + m_information.show(); + return true; + } + if (event->type() == QEvent::Leave && bottom->geometry().bottom() >= QCursor::pos().y()) { + bottom->setMinimumHeight(0); + bottom->setStyleSheet("background-color:#000000;"); + m_fullscreenButton->hide(); + m_information.hide(); + return true; + } + } + return false; +} + +void CaptureWin::fullScreen() +{ + toggleFullScreen(); +} + +void CaptureWin::escape() +{ + if(isFullScreen()) + toggleFullScreen(); +} + +void CaptureWin::toggleFullScreen() +{ + if (isFullScreen()) { + showNormal(); + bottom->setMinimumHeight(0); + bottom->setMaximumHeight(height()); + m_fullscreenButton->setText("Show Fullscreen"); + setStyleSheet("background-color:none;"); + bottom->setStyleSheet("background-color:none;"); + m_fullscreenButton->show(); + m_information.show(); + } else { + showFullScreen(); + m_fullscreenButton->setText("Exit Fullscreen"); + setStyleSheet("background-color:#000000;"); + m_fullscreenButton->hide(); + m_information.hide(); + } +} + void CaptureWin::closeEvent(QCloseEvent *event) { QWidget::closeEvent(event); diff --git a/utils/qv4l2/capture-win.h b/utils/qv4l2/capture-win.h index 3ba4755..54bb800 100644 --- a/utils/qv4l2/capture-win.h +++ b/utils/qv4l2/capture-win.h @@ -25,6 +25,7 @@ #include #include #include +#include enum CropMethod { // Crop Height @@ -70,6 +71,7 @@ public: virtual void setDisplayColorspace(unsigned colorspace) = 0; virtual void setBlending(bool enable) = 0; void setCropMethod(CropMethod crop); + void toggleFullScreen(); /** * @brief Set a frame into the capture window. @@ -147,8 +149,14 @@ public: public slots: void resetSize(); +private slots: + void fullScreen(); + void escape(); + protected: void closeEvent(QCloseEvent *event); + void mouseDoubleClickEvent(QMouseEvent *e); + bool eventFilter(QObject *target, QEvent *event); /** * @brief Get the amount of space outside the video frame. @@ -212,5 +220,10 @@ private: static CropMethod m_cropMethod; QShortcut *m_hotkeyClose; QShortcut *m_hotkeyScaleReset; + QShortcut *m_hotkeyExitFullscreen; + QShortcut *m_hotkeyToggleFullscreen; + QPushButton *m_fullscreenButton; + QHBoxLayout *hbox; + QFrame *bottom; }; #endif