-
Notifications
You must be signed in to change notification settings - Fork 0
/
QDockMaskWidget.cpp
58 lines (52 loc) · 1.06 KB
/
QDockMaskWidget.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
#include "QDockMaskWidget.h"
QDockMaskWidget::QDockMaskWidget(QWidget* parent)
: QWidget(parent)
{
setAttribute(Qt::WA_InputMethodTransparent);
setAttribute(Qt::WA_TransparentForMouseEvents);
setPalette(QColor(0, 0, 255, 100));
setAutoFillBackground(true);
}
QDockMaskWidget::~QDockMaskWidget()
{
}
void QDockMaskWidget::showOnDockArea(DockArea area)
{
QRect rc = parentWidget()->rect();
switch (area)
{
case LeftArea:
rc.setWidth(rc.width() * 3 / 10);
break;
case CenterLeftArea:
rc.setWidth(rc.width() / 2);
break;
case TopArea:
rc.setHeight(rc.height() * 3 / 10);
break;
case CenterTopArea:
rc.setHeight(rc.height() / 2);
break;
case RightArea:
rc.setLeft(rc.left() + rc.width() * 7 / 10);
break;
case CenterRightArea:
rc.setLeft(rc.left() + rc.width() / 2);
break;
case BottomArea:
rc.setTop(rc.top() + rc.height() * 7 / 10);
break;
case CenterBottomArea:
rc.setTop(rc.top() + rc.height() / 2);
break;
case CenterArea:
break;
default:
hide();
return;
}
move(rc.topLeft());
resize(rc.size());
show();
raise();
}