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()));
+ connect(aw->m_resetScalingAct, SIGNAL(triggered()), this, SLOT(resetSize()));
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()));
+ connect(m_hotkeyToggleFullscreen, SIGNAL(activated()), aw->m_makeFullScreenAct, SLOT(toggle()));
m_exitFullScreen = new QAction(QIcon(":/fullscreenexit.png"), "Exit Fullscreen", this);
- m_exitFullScreen->setShortcut(Qt::Key_Escape);
connect(m_exitFullScreen, SIGNAL(triggered()), this, SLOT(escape()));
m_enterFullScreen = new QAction(QIcon(":/fullscreen.png"), "Show Fullscreen", this);
- m_enterFullScreen->setShortcut(Qt::Key_F);
connect(m_enterFullScreen, SIGNAL(triggered()), this, SLOT(fullScreen()));
m_frame.format = 0;
m_frame.size.setWidth(0);
m_fullscreenButton->setMaximumWidth(200);
m_fullscreenButton->setMinimumWidth(100);
hbox->addWidget(m_fullscreenButton, 1, Qt::AlignVCenter);
- connect(m_fullscreenButton, SIGNAL(clicked()), SLOT(fullScreen()));
+ connect(m_fullscreenButton, SIGNAL(clicked()), appWin->m_makeFullScreenAct, SLOT(toggle()));
vbox->addWidget(bottom, 0, Qt::AlignBottom);
vbox->getContentsMargins(&l, &t, &r, &b);
vbox->setSpacing(t+b);
void CaptureWin::resetSize()
{
- if (isFullScreen())
- toggleFullScreen();
- if (isMaximized())
- showNormal();
+ if (appWin->m_makeFullScreenAct->isChecked())
+ escape();
// Force resize even if no size change
QSize resetFrameSize = m_origFrameSize;
resetSize();
}
-void CaptureWin::mouseDoubleClickEvent( QMouseEvent * e )
+void CaptureWin::mouseDoubleClickEvent(QMouseEvent *e)
{
- toggleFullScreen();
+ appWin->m_makeFullScreenAct->toggle();
}
bool CaptureWin::eventFilter(QObject *target, QEvent *event)
return false;
}
-void CaptureWin::fullScreen()
+void CaptureWin::escape()
{
- toggleFullScreen();
+ appWin->m_makeFullScreenAct->setChecked(false);
}
-void CaptureWin::escape()
+void CaptureWin::fullScreen()
{
- if(isFullScreen())
- toggleFullScreen();
+ appWin->m_makeFullScreenAct->setChecked(true);
}
-void CaptureWin::toggleFullScreen()
+void CaptureWin::makeFullScreen(bool enable)
{
- if (isFullScreen()) {
+ if (enable) {
+ showFullScreen();
+ m_fullscreenButton->setText("Exit Fullscreen");
+ setStyleSheet("background-color:#000000;");
+ m_fullscreenButton->hide();
+ m_information.hide();
+ } else {
showNormal();
bottom->setMinimumHeight(0);
bottom->setMaximumHeight(height());
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::customMenuRequested(QPoint pos)
{
- QMenu *menu=new QMenu(this);
+ QMenu *menu = new QMenu(this);
if (isFullScreen()) {
menu->addAction(m_exitFullScreen);
virtual void setDisplayColorspace(unsigned colorspace) = 0;
virtual void setBlending(bool enable) = 0;
void setCropMethod(CropMethod crop);
- void toggleFullScreen();
+ void makeFullScreen(bool);
QAction *m_exitFullScreen;
QAction *m_enterFullScreen;
void customMenuRequested(QPoint pos);
private slots:
- void fullScreen();
void escape();
+ void fullScreen();
protected:
void closeEvent(QCloseEvent *event);
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");
m_resetScalingAct->setShortcut(Qt::CTRL+Qt::Key_F);
captureMenu->addAction(m_capStartAct);
captureMenu->addAction(m_showFramesAct);
captureMenu->addAction(m_scalingAct);
- captureMenu->addAction(m_resetScalingAct);
if (CaptureWinGL::isSupported()) {
m_renderMethod = QV4L2_RENDER_GL;
m_useGLAct->setStatusTip("Use GPU with OpenGL for video capture if set.");
m_useGLAct->setCheckable(true);
m_useGLAct->setChecked(true);
- connect(m_useGLAct, SIGNAL(triggered()), this, SLOT(setRenderMethod()));
+ connect(m_useGLAct, SIGNAL(toggled(bool)), this, SLOT(setRenderMethod(bool)));
captureMenu->addAction(m_useGLAct);
m_useBlendingAct = new QAction("Enable &Blending", this);
m_useBlendingAct->setStatusTip("Enable blending to test the alpha component in the image");
m_useBlendingAct->setCheckable(true);
m_useBlendingAct->setChecked(false);
- connect(m_useBlendingAct, SIGNAL(triggered()), this, SLOT(setBlending()));
+ connect(m_useBlendingAct, SIGNAL(toggled(bool)), this, SLOT(setBlending(bool)));
captureMenu->addAction(m_useBlendingAct);
} else {
m_renderMethod = QV4L2_RENDER_QT;
}
+ captureMenu->addAction(m_resetScalingAct);
- m_startFullScreenAct = new QAction(QIcon(":/fullscreen.png"), "Enter Fullscreen Mode", this);
- m_startFullScreenAct->setStatusTip("Start capturing in fullscreen mode");
- connect(m_startFullScreenAct, SIGNAL(triggered()), this, SLOT(startFullScreen()));
- captureMenu->addAction(m_startFullScreenAct);
- toolBar->addAction(m_startFullScreenAct);
+ m_makeFullScreenAct = new QAction(QIcon(":/fullscreen.png"), "Show Fullscreen", this);
+ m_makeFullScreenAct->setStatusTip("Capture in fullscreen mode");
+ m_makeFullScreenAct->setCheckable(true);
+ connect(m_makeFullScreenAct, SIGNAL(toggled(bool)), this, SLOT(makeFullScreen(bool)));
+ captureMenu->addAction(m_makeFullScreenAct);
+ toolBar->addAction(m_makeFullScreenAct);
#ifdef HAVE_ALSA
captureMenu->addSeparator();
setDevice(d.selectedFiles().first(), true);
}
-void ApplicationWindow::setRenderMethod()
+void ApplicationWindow::setRenderMethod(bool checked)
{
if (m_capStartAct->isChecked()) {
m_useGLAct->setChecked(m_renderMethod == QV4L2_RENDER_GL);
return;
}
- if (m_useGLAct->isChecked()) {
- m_renderMethod = QV4L2_RENDER_GL;
- } else {
- m_renderMethod = QV4L2_RENDER_QT;
- }
+ m_renderMethod = checked ? QV4L2_RENDER_GL : QV4L2_RENDER_QT;
m_useBlendingAct->setEnabled(m_renderMethod == QV4L2_RENDER_GL);
newCaptureWin();
}
-void ApplicationWindow::setBlending()
+void ApplicationWindow::setBlending(bool checked)
{
if (m_capture)
- m_capture->setBlending(m_useBlendingAct->isChecked());
+ m_capture->setBlending(checked);
}
void ApplicationWindow::setAudioBufferSize()
m_capture->setPixelAspectRatio(1.0);
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()
m_capture->setWindowSize(QSize(width, height));
m_capture->setFrame(m_capImage->width(), m_capImage->height(),
pixfmt, m_capImage->bits(), NULL, "No frame");
+ m_capture->makeFullScreen(m_makeFullScreenAct->isChecked());
if (showFrames())
m_capture->show();
}
}
-void ApplicationWindow::startFullScreen()
+void ApplicationWindow::makeFullScreen(bool checked)
{
- if (!m_capture || !m_capStartAct->isChecked()){
- newCaptureWin();
- m_capStartAct->setChecked(true);
- m_capture->toggleFullScreen();
- } else {
- m_capStartAct->setChecked(true);
- m_capture->toggleFullScreen();
- }
+ if (m_capture && m_capStartAct->isChecked())
+ m_capture->makeFullScreen(checked);
}
void ApplicationWindow::closeDevice()
V4L2_CTRL_FLAG_INACTIVE | \
V4L2_CTRL_FLAG_GRABBED)
+class CaptureWin;
+
class ApplicationWindow: public QMainWindow, public v4l2
{
Q_OBJECT
+ friend CaptureWin;
public:
ApplicationWindow();
virtual ~ApplicationWindow();
private slots:
void capStart(bool);
- void startFullScreen();
+ void makeFullScreen(bool);
void capFrame();
void ctrlEvent();
void snapshot();
void capVbiFrame();
void saveRaw(bool);
- void setRenderMethod();
- void setBlending();
+ void setRenderMethod(bool);
+ void setBlending(bool);
void changeAudioDevice();
// gui
QAction *m_showAllAudioAct;
QAction *m_audioBufferAct;
QAction *m_scalingAct;
- QAction *m_startFullScreenAct;
+ QAction *m_makeFullScreenAct;
QString m_filename;
QSignalMapper *m_sigMapper;
QTabWidget *m_tabs;