-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmaskmainwidget.cpp
More file actions
127 lines (112 loc) · 4.34 KB
/
maskmainwidget.cpp
File metadata and controls
127 lines (112 loc) · 4.34 KB
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
116
117
118
119
120
121
122
123
124
125
126
127
#include "maskmainwidget.h"
#include <QAction>
#include <QtPrintSupport/QPrintEngine>
#include <QPaintEvent>
maskmainwidget::maskmainwidget(QWidget *parent) :
QWidget(parent)
{
setMinimumSize(1360,734);
//resize(1290,730);
resize(1360,734);
mainlayout = new QVBoxLayout(this);
m_upwidget = new upwidget(this);
m_downwidget = new downwidget(this);
m_upwidget->setGeometry(0,0,m_upwidget->width(),m_upwidget->height());
m_downwidget->setGeometry(0,130,m_downwidget->width(),m_downwidget->height());
//this->maxsize();
//m_downwidget->m_stackwidget->setGeometry(QRect(0,0,1290,600));
//m_downwidget->m_stackwidget->setGeometry(QRect(0,0,m_downwidget->width(),m_downwidget->height()));
// connect(this,SIGNAL(signalsize(QSize)),m_downwidget,SLOT(slotmax(QSize)));
}
void maskmainwidget::slotmax(QSize maxsize)
{
qDebug()<<"12345";
resize(this->maximumSize());
//resize(maxsize);
m_upwidget->isMax_ = true;
m_upwidget->setGeometry(0,0,maximumSize().width(),130);
m_downwidget->isMax_ = true;
//m_upwidget->setStyleSheet("background-color:black");
//m_downwidget->setGeometry(0,130,maximumSize().width(),(maximumSize().height()-130));
m_downwidget->setStyleSheet("background-color:red");
m_downwidget->m_stackwidget->setGeometry(QRect(2,2,m_downwidget->width()-4,(m_downwidget->height()- 134)));
maxsize = this->size();
signalsize(maxsize);
}
void maskmainwidget::paintEvent(QPaintEvent *event)
{
m_backgroundpixmap = new QPixmap;
QPainter painter(this);
if(this->isMaximized()) //窗口最大化则不用绘制阴影
{
QPainterPath path;
path.setFillRule(Qt::WindingFill);
path.addRect(5, 5, this->width()-10, this->height()-10);
painter.setRenderHint(QPainter::Antialiasing, true);
painter.fillPath(path, QBrush(Qt::white));
QColor color(0, 0, 0, 50);
for(int i=0; i<5; i++)
{
QPainterPath path;
path.setFillRule(Qt::WindingFill);
path.addRect(5-i, 5-i, this->width()-(5-i)*2, this->height()-(5-i)*2);
color.setAlpha(100 - qSqrt(i)*50);
painter.setPen(color);
painter.drawPath(path);
}
mainlayout->setMargin(5);
m_upwidget->setGeometry(0,0,1675,m_upwidget->height());
m_downwidget->setGeometry(0,130,m_downwidget->width(),m_downwidget->height());
m_downwidget->m_stackwidget->setGeometry(QRect(0,0,1290,600));
// painter.drawPixmap(5,5,rect().width()-10,rect().height()-10,m_backgroundpixmap);
}
else
{
QPainterPath path;
path.setFillRule(Qt::WindingFill);
path.addRect(5, 5, this->width()-10, this->height()-10);
painter.setRenderHint(QPainter::Antialiasing, true);
painter.fillPath(path, QBrush(Qt::white));
QColor color(0, 0, 0, 50);
for(int i=0; i<5; i++)
{
QPainterPath path;
path.setFillRule(Qt::WindingFill);
path.addRect(5-i, 5-i, this->width()-(5-i)*2, this->height()-(5-i)*2);
color.setAlpha(100 - qSqrt(i)*50);
painter.setPen(color);
painter.drawPath(path);
}
mainlayout->setMargin(5);
m_upwidget->setGeometry(0,0,this->maximumWidth(),m_upwidget->height());
m_downwidget->setGeometry(0,130,this->maximumWidth(),(this->maximumHeight()- m_upwidget->height()));
m_downwidget->m_stackwidget->setGeometry(QRect(0,0,this->maximumWidth(),(this->maximumHeight()- m_upwidget->height())));
// m_upwidget->setGeometry(0,0,1675,m_upwidget->height());
// m_downwidget->setGeometry(0,130,this->maximumWidth(),m_downwidget->height());
// m_downwidget->m_stackwidget->setGeometry(QRect(0,0,1290,600));
// painter.drawPixmap(rect(),m_backgroundpixmap);
}
}
//void maskmainwidget::mousePressEvent(QMouseEvent * event )
//{
// //只能是鼠标左键移动和改变大小
// if(event->button() == Qt::LeftButton)
// {
// mouse_press = true;
// }
// //窗口移动距离
// move_point = event->globalPos() - pos();
//}
//void maskmainwidget::mouseReleaseEvent(QMouseEvent *)
//{
// mouse_press= false;
//}
//void maskmainwidget::mouseMoveEvent(QMouseEvent *event)
//{
// //移动窗口
// if(mouse_press)
// {
// QPoint move_pos = event->globalPos();
// move(move_pos - move_point);
// }
//}