-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdialog.cpp
More file actions
47 lines (41 loc) · 1.84 KB
/
dialog.cpp
File metadata and controls
47 lines (41 loc) · 1.84 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
#include "dialog.h"
void Dialog::setTransparency(QWidget* widget) {
QScreen* screen = widget->screen();
QRect widgetGeometry = widget->geometry();
QPixmap pixmap = screen->grabWindow(0,
widgetGeometry.x(),
widgetGeometry.y(),
widgetGeometry.width(),
widgetGeometry.height());
QGraphicsBlurEffect* blurEffect = new QGraphicsBlurEffect();
blurEffect->setBlurRadius(15);
blurEffect->setBlurHints(QGraphicsBlurEffect::QualityHint);
QGraphicsScene* scene = new QGraphicsScene();
QGraphicsPixmapItem item;
item.setPixmap(pixmap);
item.setGraphicsEffect(blurEffect);
scene->addItem(&item);
QImage res(QSize(widgetGeometry.width(), widgetGeometry.height()),
QImage::Format_ARGB32);
res.fill(Qt::transparent);
QPainter ptr(&res);
scene->render(&ptr, QRectF(), QRectF(0, 0, widgetGeometry.width(),
widgetGeometry.height()));
QPalette palette;
palette.setBrush(widget->backgroundRole(),
QBrush(QPixmap::fromImage(res)));
widget->setPalette(palette);
}
void Dialog::setWindowGeometry() {
QScreen* screen = this->screen();
QRect geometry = screen->geometry();
int width = 500, height = 350;
int x = (geometry.width() - width) / 2;
int y = (geometry.height() - height) / 2;
this->setGeometry(x, y, width, height);
}
Dialog::Dialog(QJsonObject* cfgObj, QString title, QString iconName) : Pane(nullptr,
cfgObj,
title,
iconName) {
}