-
Notifications
You must be signed in to change notification settings - Fork 1
/
window.cpp
79 lines (66 loc) · 2.03 KB
/
window.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
/****************** Includes ********************/
#include "window.h"
#include <QApplication>
#include <QCameraInfo>
/**************** Implementation ****************/
// Create window that shows stereo video signals from two frame-grabbers connected
window::window(QWidget *parent) : QWidget(parent)
{
// Window has 2x PAL resolution next to each other
resize( 720 * 2, 576 );
// Check if enough cameras are connected
const QList<QCameraInfo> cameras = QCameraInfo::availableCameras();
if( cameras.count() < 2 )
{
errLabel_p = new QLabel(this);
errLabel_p->setText("Error: Not enough cameras found");
return;
}
// Create left eye view and camera
viewLeft_p = new QCameraViewfinder(this);
camLeft_p = new QCamera(cameras[0], this);
camLeft_p->setViewfinder(viewLeft_p);
camLeft_p->start();
// Create right eye view and camera
viewRight_p = new QCameraViewfinder(this);
camRight_p = new QCamera(cameras[1], this);
camRight_p->setViewfinder(viewRight_p);
camRight_p->start();
// Handle layout
layout_p = new QHBoxLayout();
layout_p->addWidget(viewLeft_p);
layout_p->addWidget(viewRight_p);
layout_p->setSpacing(0);
layout_p->setMargin(0);
this->setLayout(layout_p);
// Install keyboard event filter
key_p = new keyReceiver();
installEventFilter(key_p);
// Connect signals to slots
connect(key_p, SIGNAL(event_Esc()), QApplication::instance(), SLOT(quit()) );
connect(key_p, SIGNAL(event_S()), this, SLOT(switchLeftRight()) );
connect(key_p, SIGNAL(event_F()), this, SLOT(stopFullScreen()) );
}
// Switch left and right viewfinder
void window::switchLeftRight( void )
{
if( layout_p->direction() == QBoxLayout::LeftToRight )
{
layout_p->setDirection( QBoxLayout::RightToLeft );
}
else
{
layout_p->setDirection( QBoxLayout::LeftToRight );
}
}
// Stop full screen mode and move screen to monitor 1
void window::stopFullScreen( void )
{
// Exit full screen mode
close();
// Open normal window mode (screen 1)
show();
resize( 720 * 2, 576);
move( 100, 100 );
}
// EOF