-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdsplitedwindow.cpp
116 lines (93 loc) · 2.81 KB
/
dsplitedwindow.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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
#include "dsplitedwindow.h"
#include "dsplitedbar.h"
#include <QResizeEvent>
LDA_BEGIN_NAMESPACE
DSplitedWindow::DSplitedWindow(QWidget *parent, bool blur, DBlurEffectWidget::BlendMode blendMode) : QWidget(parent)
{
this->setAttribute(Qt::WA_TranslucentBackground);
m_leftw = new DBlurEffectWidget(this);
m_rightw = new QWidget(this);
m_rightw->setStyleSheet("background-color: white;");
m_leftw->setFixedSize(m_leftwidth, this->height());
m_rightw->setFixedSize(this->width() - m_leftwidth, this->height());
m_rightw->move(m_leftwidth, 0);
m_leftw->move(0,0);
m_leftw->setBlendMode(blendMode);
m_leftw->setBlurEnabled(blur);
m_bar = new DSplitedBar(this);
m_bar->setBlurBackground(true);
}
QWidget *DSplitedWindow::leftWidget() const {return m_leftw;}
QWidget *DSplitedWindow::rightWidget() const {return m_rightw;}
void DSplitedWindow::resizeEvent(QResizeEvent *e) {
int tmp_w = e->size().width() - m_leftwidth;
if (m_rightw != nullptr) {
m_rightw->setFixedSize(tmp_w, e->size().height());
}
if (m_bottomw != nullptr) {
m_bottomw->setFixedWidth(tmp_w);
m_bottomw->move(m_leftwidth, e->size().height() - m_bottomw->height());
}
m_leftw->setFixedHeight(e->size().height());
m_bar->setFixedWidth(e->size().width());
QWidget::resizeEvent(e);
}
int DSplitedWindow::leftAreaWidth() {return m_leftwidth;}
void DSplitedWindow::setLeftAreaWidth(int width)
{
m_leftw->setFixedWidth(width);
m_leftwidth = width;
m_rightw->move(width, 0);
}
void DSplitedWindow::setRightWidget(QWidget *w)
{
w->setParent(this);
if (isOriginal == true) {
m_rightw->~QWidget();
isOriginal = false;
}
m_rightw = w;
m_rightw->move(m_leftwidth, 0);
m_bar->raise();
if (m_bottomw != nullptr) {
m_bottomw->raise();
}
}
DSplitedBar *DSplitedWindow::splitedbar() const
{
return m_bar;
}
QWidget *DSplitedWindow::bottomWidget() const
{
return m_bottomw;
}
void DSplitedWindow::setBottomWidget(QWidget *w)
{
w->setParent(this);
w->raise();
m_bottomw = w;
m_bar->raise();
update();
}
void DSplitedWindow::switchFullScreen()
{
if (forceFullScreen || !window()->windowState().testFlag(Qt::WindowFullScreen)) {
window()->setWindowState(windowState() | Qt::WindowFullScreen);
} else {
window()->setWindowState(windowState() & ~Qt::WindowFullScreen);
}
}
void DSplitedWindow::enableForceFullScreen(bool force)
{
forceFullScreen = force;
switchFullScreen();
}
void DSplitedWindow::setFullScreen(bool full)
{
if (full || !window()->windowState().testFlag(Qt::WindowFullScreen)) {
window()->setWindowState(windowState() | Qt::WindowFullScreen);
} else {
window()->setWindowState(windowState() & ~Qt::WindowFullScreen);
}
}
LDA_END_NAMESPACE