-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpWindow.h
88 lines (61 loc) · 1.56 KB
/
pWindow.h
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
80
81
82
83
84
85
86
87
88
#ifndef _pWindow_H
#define _pWindow_h
#include <QtWidgets/QWidget>
#include <QtWidgets/QLabel>
#include <QMovie>
#include <thread>
class pWindow : public QWidget
{
Q_OBJECT
public :
pWindow(const QString &image_path, QWidget *parent = nullptr) : QWidget{ parent }, width{ 700 }, height{ 400 }
{
// set position
setToCenter();
// set ui
this->setWindowFlag(Qt::FramelessWindowHint);
this->setStyleSheet(QString{ "background-color:rgb(255,255,255);" });
// set connection
QObject::connect(this, SIGNAL(_close()), this, SLOT(close()));
// set label
QLabel *label1 = new QLabel{ this };
QLabel *label2 = new QLabel{ this };
QMovie *movie = new QMovie{ image_path };
label1->setGeometry(100, 0, 250, 400);
label1->setMovie(movie);
label2->setGeometry(width - 250 - 40, 0, 250, 400);
label2->setMovie(movie);
label1->show();
label2->show();
movie->start();
}
~pWindow() {}
void connect(QWidget *w)
{
QObject::connect(this, SIGNAL(_callMainWindow()), w, SLOT(show()));
}
void _show(long millisec)
{
this->show();
std::thread td{ [&]()
{
std::this_thread::sleep_for(std::chrono::milliseconds{millisec});
this->_close();
this->_callMainWindow();
} };
td.detach();
}
signals :
void _close();
void _callMainWindow();
private :
int width;
int height;
void setToCenter(void)
{
int x = 1920 / 2;
int y = 1080 / 2;
this->setGeometry(x - width / 2, y - height / 2, width, height);
}
};
#endif // end _pWindow_H