-
Notifications
You must be signed in to change notification settings - Fork 1
/
videowidget.cpp
47 lines (39 loc) · 1.17 KB
/
videowidget.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
#include "videowidget.h"
#include <QKeyEvent>
#include <QMouseEvent>
VideoWidget::VideoWidget(QWidget *parent)
: QVideoWidget(parent)
{
setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored);
QPalette p = palette();
p.setColor(QPalette::Window, Qt::black);
setPalette(p);
setAttribute(Qt::WA_OpaquePaintEvent);
}
// listen for keyboard clicks
void VideoWidget::keyPressEvent(QKeyEvent *event)
{
if (event->key() == Qt::Key_Escape && isFullScreen()) {
setFullScreen(false);
setGeometry(9, 9, 781, 491); //revert to the original size of the video
event->accept();
}
else if (event->key() == Qt::Key_Enter && event->modifiers() & Qt::Key_Alt) {
setFullScreen(!isFullScreen());
event->accept();
}
else {
QVideoWidget::keyPressEvent(event);
}
}
// listen for the double-click event and set the video to full screen
void VideoWidget::mouseDoubleClickEvent(QMouseEvent *event)
{
setFullScreen(true);
event->accept();
}
// listen for mouse clicks
void VideoWidget::mousePressEvent(QMouseEvent *event)
{
QVideoWidget::mousePressEvent(event);
}