-
Notifications
You must be signed in to change notification settings - Fork 2
/
cvideodlg.cpp
77 lines (61 loc) · 1.53 KB
/
cvideodlg.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
#include <QPainter>
#include "cvideodlg.h"
#include "qt4phonedlg.h"
CVideoDlg::CVideoDlg(QtPhoneDlg *dlg)
: QDialog(0)
{
ui.setupUi(this);
installEventFilter(this);
setWindowFlags(windowFlags() | Qt::WindowMinMaxButtonsHint);
p_dlg = dlg;
}
CVideoDlg::~CVideoDlg()
{
}
void CVideoDlg::closeEvent(QCloseEvent *ev)
{
p_dlg->slot_ShowVideoPanels(false);
}
bool CVideoDlg::eventFilter(QObject *obj, QEvent *event)
{
static int on_off = 0;
if (event->type() == QEvent::MouseButtonDblClick)
{
if(!on_off)
showFullScreen();
else
showNormal();
on_off = 1 - on_off;
return true;
}
if (event->type() == QEvent::Paint)
{
if(m_image.isNull())
return false;
QPainter painter(this);
QRect tRect = geometry();
QSize tSize = size();
m_mutex.lock();
// printf("image(%d, %d), size(%d,%d), geo(%d, %d)\n",
// m_image.width(), m_image.height(),
// tSize.width(), tSize.height(),
// tRect.width(), tRect.height()
// );
if(m_image.width()>tSize.width() || m_image.height()>tSize.height())
{
resize(m_image.size());
painter.drawImage(0,0, m_image);
}
else
{
QImage m_imageNew = m_image.scaled(tRect.width(), tRect.height(), Qt::KeepAspectRatio);
int x,y;
x = (m_imageNew.width()>tSize.width()) ? 0 : (tSize.width() - m_imageNew.width()) / 2;
y = (m_imageNew.height()>tSize.height()) ? 0 : (tSize.height() - m_imageNew.height()) / 2;
painter.drawImage(x, y, m_imageNew);
}
m_mutex.unlock();
return true;
}
return QObject::eventFilter(obj, event);
}