-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmylabel.cpp
62 lines (45 loc) · 1.38 KB
/
mylabel.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
#include "mylabel.h"
#include "Singleton.h"
#include "mediaplay.h"
#include <QTimer>
#include <QMouseEvent>
MyLabel::MyLabel(QWidget *parent) : QLabel(parent)
, m_pAlgorithmConfig(new AlgorithmConfig(this))
{
setMouseTracking(true);
setAutoFillBackground(true);
m_pAlgorithmConfig->hide();
//设置画面拉伸
setScaledContents(true);
QPalette palette;
palette.setColor(QPalette::Background, QColor(0,0,0));
this->setPalette(palette);
/*********************播放控制界面处理**********************/
m_pPlayControl = new PlayControlWidget(this);
//默认隐藏
m_pPlayControl->hide();
//初始化播放类,设置显示label
std::shared_ptr<MediaPlay> media = Singleton<MediaPlay>::GetInstance();
media->SetShowLabel(this);
}
void MyLabel::resizeEvent(QResizeEvent *event)
{
m_pPlayControl->setGeometry(0, this->height() - m_pPlayControl->height(), this->width(), m_pPlayControl->height());
m_pAlgorithmConfig->setGeometry(0, 0, this->width(), m_pAlgorithmConfig->height());
QLabel::resizeEvent(event);
}
void MyLabel::mouseMoveEvent(QMouseEvent *event)
{
if (m_pPlayControl->isHidden())
{
m_pPlayControl->show();
}
if (event->y() < (m_pAlgorithmConfig->height() + 5))
{
if (m_pAlgorithmConfig->isHidden())
{
m_pAlgorithmConfig->show();
}
}
QLabel::mouseMoveEvent(event);
}