Remove redundant code

This commit is contained in:
chenlelin 2021-04-10 16:08:45 +08:00
parent ddc35a9109
commit aa83bc0886
14 changed files with 146 additions and 134 deletions

View File

@ -42,12 +42,6 @@ ConfForm::ConfForm(QWidget *parent) :
//需要添加 void paintEvent(QPaintEvent *event) 函数
//this->setWindowIcon(QIcon::fromTheme("indicator-china-weather", QIcon(":/res/x/setup.png")) );
QPainterPath path;
auto rect = this->rect();
rect.adjust(1, 1, -1, -1);
path.addRoundedRect(rect, 6, 6);
setProperty("blurRegion", QRegion(path.toFillPolygon().toPolygon()));
labelQss = "QLabel{border:0px;color:rgba(255,255,255,0.97);background-color:transparent;}";
cbxQss = "QComboBox{padding-left:20px;font-size:13px;color:rgba(255,255,255,0.91);"
"border:1px solid rgba(255, 255, 255, 0.05);border-radius:4px;background:rgba(255,255,255,0.08);}"
@ -134,7 +128,6 @@ ConfForm::ConfForm(QWidget *parent) :
ui->leAddr_ipv6->setValidator(new QRegExpValidator(ipv6_rx, this));
setModal(false);
KWindowEffects::enableBlurBehind(this->winId(), true, QRegion(path.toFillPolygon().toPolygon()));
setEnableOfBtn();
}
@ -746,10 +739,14 @@ void ConfForm::paintEvent(QPaintEvent *event)
style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this);
QRect rect = this->rect();
rect.adjust(1, 1, -1, -1);
p.setRenderHint(QPainter::Antialiasing); // 反锯齿;
p.setBrush(opt.palette.color(QPalette::Base));
p.setOpacity(trans);
p.setPen(Qt::NoPen);
p.drawRoundedRect(rect, 6, 6);
QWidget::paintEvent(event);
QPainterPath path;
KWindowEffects::enableBlurBehind(this->winId(), true, QRegion(path.toFillPolygon().toPolygon()));
}

View File

@ -64,12 +64,6 @@ MainWindow::MainWindow(QWidget *parent) :
UseQssFile::setStyle("style.qss");
QPainterPath path;
auto rect = this->rect();
rect.adjust(1, 1, -1, -1);
path.addRoundedRect(rect, 6, 6);
setProperty("blurRegion", QRegion(path.toFillPolygon().toPolygon()));
editQssString(); //编辑部分控件QSS
createTopLanUI(); //创建顶部有线网item
createTopWifiUI(); //创建顶部无线网item
@ -127,8 +121,6 @@ MainWindow::MainWindow(QWidget *parent) :
ui->btnWifiList->setAttribute(Qt::WA_Hover,true);
ui->btnWifiList->installEventFilter(this);
KWindowEffects::enableBlurBehind(this->winId(), true, QRegion(path.toFillPolygon().toPolygon()));
hasWifiConnected = false;
numberForWifiScan = 0;
}
@ -3639,12 +3631,16 @@ void MainWindow::paintEvent(QPaintEvent *event)
opt.init(this);
QPainter p(this);
QRect rect = this->rect();
rect.adjust(1, 1, -1, -1);
p.setRenderHint(QPainter::Antialiasing); // 反锯齿;
p.setBrush(opt.palette.color(QPalette::Base));
p.setOpacity(trans);
p.setPen(Qt::NoPen);
p.drawRoundedRect(rect, 6, 6);
QWidget::paintEvent(event);
QPainterPath path;
KWindowEffects::enableBlurBehind(this->winId(), true, QRegion(path.toFillPolygon().toPolygon()));
}
bool MainWindow::event(QEvent *event)

View File

@ -23,12 +23,6 @@ WiFiConfigDialog::WiFiConfigDialog(QWidget *parent) :
this->setAttribute(Qt::WA_TranslucentBackground);
this->setWindowIcon(QIcon::fromTheme("kylin-network", QIcon(":/res/x/setup.png")) );
QPainterPath path;
auto rect = this->rect();
rect.adjust(1, 1, -1, -1);
path.addRoundedRect(rect, 6, 6);
setProperty("blurRegion", QRegion(path.toFillPolygon().toPolygon()));
ui->lbTitle->setText(tr("Input Wi-Fi Information Please")); //输入Wi-Fi名称和密码后点击确定
ui->lbWifiId->setText(tr("Wi-Fi ID")); //Wi-Fi连接名称
ui->lbWifiName->setText(tr("Wi-Fi Name")); //Wi-Fi名称
@ -49,8 +43,6 @@ WiFiConfigDialog::WiFiConfigDialog(QWidget *parent) :
ui->leWifiPassword->setContextMenuPolicy(Qt::NoContextMenu);
this->setEnableOfBtn();
KWindowEffects::enableBlurBehind(this->winId(), true, QRegion(path.toFillPolygon().toPolygon()));
}
WiFiConfigDialog::~WiFiConfigDialog()
@ -68,12 +60,16 @@ void WiFiConfigDialog::paintEvent(QPaintEvent *event)
style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this);
QRect rect = this->rect();
rect.adjust(1, 1, -1, -1);
p.setRenderHint(QPainter::Antialiasing); // 反锯齿;
p.setBrush(opt.palette.color(QPalette::Base));
p.setOpacity(trans);
p.setPen(Qt::NoPen);
p.drawRoundedRect(rect, 6, 6);
QWidget::paintEvent(event);
QPainterPath path;
KWindowEffects::enableBlurBehind(this->winId(), true, QRegion(path.toFillPolygon().toPolygon()));
}
//创建获取窗口透明度信息的GSetting的对象

View File

@ -72,13 +72,6 @@ WpaWifiDialog::WpaWifiDialog(QWidget *parent, MainWindow *mainWindow, QString co
connectionName = conname;
// configPath = getenv("HOME") + CONFIG_FILE;
QPainterPath path;
auto rect = this->rect();
rect.adjust(1, 1, -1, -1);
path.addRoundedRect(rect, 6, 6);
setProperty("blurRegion", QRegion(path.toFillPolygon().toPolygon()));
KWindowEffects::enableBlurBehind(this->winId(), true, QRegion(path.toFillPolygon().toPolygon()));
initUI();
initCombox();
initConnect();
@ -681,10 +674,14 @@ void WpaWifiDialog::paintEvent(QPaintEvent *event)
style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this);
QRect rect = this->rect();
rect.adjust(1, 1, -1, -1);
p.setRenderHint(QPainter::Antialiasing); // 反锯齿;
p.setBrush(opt.palette.color(QPalette::Base));
p.setOpacity(trans);
p.setPen(Qt::NoPen);
p.drawRoundedRect(rect, 6, 6);
QWidget::paintEvent(event);
QPainterPath path;
KWindowEffects::enableBlurBehind(this->winId(), true, QRegion(path.toFillPolygon().toPolygon()));
}

View File

@ -44,12 +44,6 @@ DlgHideWifi::DlgHideWifi(int type, MainWindow *mainWindow, QWidget *parent) :
this->setWindowIcon(QIcon::fromTheme("kylin-network", QIcon(":/res/x/setup.png")) );
//需要添加 void paintEvent(QPaintEvent *event) 函数
QPainterPath path;
auto rect = this->rect();
rect.adjust(1, 1, -1, -1);
path.addRoundedRect(rect, 6, 6);
setProperty("blurRegion", QRegion(path.toFillPolygon().toPolygon()));
MyQss objQss;
ui->lbBoder->setStyleSheet("QLabel{border-radius:6px;background-color:rgba(19,19,20,0.95);border:1px solid rgba(255, 255, 255, 0.05);}");
@ -102,8 +96,6 @@ DlgHideWifi::DlgHideWifi(int type, MainWindow *mainWindow, QWidget *parent) :
this->setFixedSize(432,358);
this->mw = mainWindow;
KWindowEffects::enableBlurBehind(this->winId(), true, QRegion(path.toFillPolygon().toPolygon()));
}
DlgHideWifi::~DlgHideWifi()
@ -362,10 +354,14 @@ void DlgHideWifi::paintEvent(QPaintEvent *event)
style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this);
QRect rect = this->rect();
rect.adjust(1, 1, -1, -1);
p.setRenderHint(QPainter::Antialiasing); // 反锯齿;
p.setBrush(opt.palette.color(QPalette::Base));
p.setOpacity(trans);
p.setPen(Qt::NoPen);
p.drawRoundedRect(rect, 6, 6);
QWidget::paintEvent(event);
QPainterPath path;
KWindowEffects::enableBlurBehind(this->winId(), true, QRegion(path.toFillPolygon().toPolygon()));
}

View File

@ -20,6 +20,7 @@
#include "dlghidewifieapfast.h"
#include "ui_dlghidewifieapfast.h"
#include "kylinheadfile.h"
#include "src/kylin-dbus-interface.h"
#include <sys/syslog.h>
@ -34,12 +35,6 @@ DlgHideWifiEapFast::DlgHideWifiEapFast(int type, QWidget *parent) :
this->setAttribute(Qt::WA_TranslucentBackground);
//需要添加 void paintEvent(QPaintEvent *event) 函数
QPainterPath path;
auto rect = this->rect();
rect.adjust(1, 1, -1, -1);
path.addRoundedRect(rect, 6, 6);
setProperty("blurRegion", QRegion(path.toFillPolygon().toPolygon()));
this->setStyleSheet("QWidget{border-radius:6px;background-color:rgba(19,19,20,0.7);border:1px solid rgba(255, 255, 255, 0.05);}");
MyQss objQss;
@ -154,8 +149,6 @@ DlgHideWifiEapFast::DlgHideWifiEapFast(int type, QWidget *parent) :
ui->btnConnect->setEnabled(false);
this->setFixedSize(432,673);
KWindowEffects::enableBlurBehind(this->winId(), true, QRegion(path.toFillPolygon().toPolygon()));
}
DlgHideWifiEapFast::~DlgHideWifiEapFast()
@ -343,9 +336,23 @@ void DlgHideWifiEapFast::on_lePassword_textEdited(const QString &arg1)
void DlgHideWifiEapFast::paintEvent(QPaintEvent *event)
{
KylinDBus mkylindbus;
double trans = mkylindbus.getTransparentData();
QStyleOption opt;
opt.init(this);
QPainter p(this);
style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this);
QWidget::paintEvent(event);
opt.init(this);
QPainter p(this);
style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this);
QRect rect = this->rect();
rect.adjust(1, 1, -1, -1);
p.setRenderHint(QPainter::Antialiasing); // 反锯齿;
p.setBrush(opt.palette.color(QPalette::Base));
p.setOpacity(trans);
p.setPen(Qt::NoPen);
p.drawRoundedRect(rect, 6, 6);
QWidget::paintEvent(event);
QPainterPath path;
KWindowEffects::enableBlurBehind(this->winId(), true, QRegion(path.toFillPolygon().toPolygon()));
}

View File

@ -20,6 +20,7 @@
#include "dlghidewifieapleap.h"
#include "ui_dlghidewifieapleap.h"
#include "kylinheadfile.h"
#include "src/kylin-dbus-interface.h"
#include <sys/syslog.h>
@ -34,12 +35,6 @@ DlgHideWifiEapLeap::DlgHideWifiEapLeap(int type, QWidget *parent) :
this->setAttribute(Qt::WA_TranslucentBackground);
//需要添加 void paintEvent(QPaintEvent *event) 函数
QPainterPath path;
auto rect = this->rect();
rect.adjust(1, 1, -1, -1);
path.addRoundedRect(rect, 6, 6);
setProperty("blurRegion", QRegion(path.toFillPolygon().toPolygon()));
this->setStyleSheet("QWidget{border-radius:6px;background-color:rgba(19,19,20,0.7);border:1px solid rgba(255, 255, 255, 0.05);}");
MyQss objQss;
@ -124,8 +119,6 @@ DlgHideWifiEapLeap::DlgHideWifiEapLeap(int type, QWidget *parent) :
ui->btnConnect->setEnabled(false);
this->setFixedSize(432,487);
KWindowEffects::enableBlurBehind(this->winId(), true, QRegion(path.toFillPolygon().toPolygon()));
}
DlgHideWifiEapLeap::~DlgHideWifiEapLeap()
@ -283,9 +276,23 @@ void DlgHideWifiEapLeap::on_lePassword_textEdited(const QString &arg1)
void DlgHideWifiEapLeap::paintEvent(QPaintEvent *event)
{
KylinDBus mkylindbus;
double trans = mkylindbus.getTransparentData();
QStyleOption opt;
opt.init(this);
QPainter p(this);
style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this);
QWidget::paintEvent(event);
opt.init(this);
QPainter p(this);
style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this);
QRect rect = this->rect();
rect.adjust(1, 1, -1, -1);
p.setRenderHint(QPainter::Antialiasing); // 反锯齿;
p.setBrush(opt.palette.color(QPalette::Base));
p.setOpacity(trans);
p.setPen(Qt::NoPen);
p.drawRoundedRect(rect, 6, 6);
QWidget::paintEvent(event);
QPainterPath path;
KWindowEffects::enableBlurBehind(this->winId(), true, QRegion(path.toFillPolygon().toPolygon()));
}

View File

@ -41,12 +41,6 @@ DlgHideWifiEapPeap::DlgHideWifiEapPeap(int type, int beUsed, MainWindow *mainWin
this->setWindowIcon(QIcon::fromTheme("kylin-network", QIcon(":/res/x/setup.png")) );
//需要添加 void paintEvent(QPaintEvent *event) 函数
QPainterPath path;
auto rect = this->rect();
rect.adjust(1, 1, -1, -1);
path.addRoundedRect(rect, 6, 6);
setProperty("blurRegion", QRegion(path.toFillPolygon().toPolygon()));
MyQss objQss;
ui->lbBoder->setStyleSheet("QLabel{border-radius:6px;background-color:rgba(19,19,20,0.95);border:1px solid rgba(255, 255, 255, 0.05);}");
@ -157,8 +151,6 @@ DlgHideWifiEapPeap::DlgHideWifiEapPeap(int type, int beUsed, MainWindow *mainWin
this->setFixedSize(432,700);
this->mw = mainWindow;
KWindowEffects::enableBlurBehind(this->winId(), true, QRegion(path.toFillPolygon().toPolygon()));
}
DlgHideWifiEapPeap::~DlgHideWifiEapPeap()
@ -536,10 +528,14 @@ void DlgHideWifiEapPeap::paintEvent(QPaintEvent *event)
style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this);
QRect rect = this->rect();
rect.adjust(1, 1, -1, -1);
p.setRenderHint(QPainter::Antialiasing); // 反锯齿;
p.setBrush(opt.palette.color(QPalette::Base));
p.setOpacity(trans);
p.setPen(Qt::NoPen);
p.drawRoundedRect(rect, 6, 6);
QWidget::paintEvent(event);
QPainterPath path;
KWindowEffects::enableBlurBehind(this->winId(), true, QRegion(path.toFillPolygon().toPolygon()));
}

View File

@ -20,6 +20,7 @@
#include "dlghidewifieappwd.h"
#include "ui_dlghidewifieappwd.h"
#include "kylinheadfile.h"
#include "src/kylin-dbus-interface.h"
#include <sys/syslog.h>
@ -34,12 +35,6 @@ DlgHideWifiEapPwd::DlgHideWifiEapPwd(int type, QWidget *parent) :
this->setAttribute(Qt::WA_TranslucentBackground);
//需要添加 void paintEvent(QPaintEvent *event) 函数
QPainterPath path;
auto rect = this->rect();
rect.adjust(1, 1, -1, -1);
path.addRoundedRect(rect, 6, 6);
setProperty("blurRegion", QRegion(path.toFillPolygon().toPolygon()));
this->setStyleSheet("QWidget{border-radius:6px;background-color:rgba(19,19,20,0.7);border:1px solid rgba(255, 255, 255, 0.05);}");
MyQss objQss;
@ -125,8 +120,6 @@ DlgHideWifiEapPwd::DlgHideWifiEapPwd(int type, QWidget *parent) :
ui->btnConnect->setEnabled(false);
this->setFixedSize(432,487);
KWindowEffects::enableBlurBehind(this->winId(), true, QRegion(path.toFillPolygon().toPolygon()));
}
DlgHideWifiEapPwd::~DlgHideWifiEapPwd()
@ -284,9 +277,23 @@ void DlgHideWifiEapPwd::on_lePassword_textEdited(const QString &arg1)
void DlgHideWifiEapPwd::paintEvent(QPaintEvent *event)
{
KylinDBus mkylindbus;
double trans = mkylindbus.getTransparentData();
QStyleOption opt;
opt.init(this);
QPainter p(this);
style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this);
QWidget::paintEvent(event);
opt.init(this);
QPainter p(this);
style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this);
QRect rect = this->rect();
rect.adjust(1, 1, -1, -1);
p.setRenderHint(QPainter::Antialiasing); // 反锯齿;
p.setBrush(opt.palette.color(QPalette::Base));
p.setOpacity(trans);
p.setPen(Qt::NoPen);
p.drawRoundedRect(rect, 6, 6);
QWidget::paintEvent(event);
QPainterPath path;
KWindowEffects::enableBlurBehind(this->winId(), true, QRegion(path.toFillPolygon().toPolygon()));
}

View File

@ -40,12 +40,6 @@ DlgHideWifiEapTls::DlgHideWifiEapTls(int type, int beUsed, MainWindow *mainWindo
this->setWindowIcon(QIcon::fromTheme("kylin-network", QIcon(":/res/x/setup.png")) );
//需要添加 void paintEvent(QPaintEvent *event) 函数
QPainterPath path;
auto rect = this->rect();
rect.adjust(1, 1, -1, -1);
path.addRoundedRect(rect, 6, 6);
setProperty("blurRegion", QRegion(path.toFillPolygon().toPolygon()));
MyQss objQss;
ui->lbBoder->setStyleSheet("QLabel{border-radius:6px;background-color:rgba(19,19,20,0.95);border:1px solid rgba(255, 255, 255, 0.05);}");
@ -145,8 +139,6 @@ DlgHideWifiEapTls::DlgHideWifiEapTls(int type, int beUsed, MainWindow *mainWindo
this->setFixedSize(432,705);
this->mw = mainWindow;
KWindowEffects::enableBlurBehind(this->winId(), true, QRegion(path.toFillPolygon().toPolygon()));
}
DlgHideWifiEapTls::~DlgHideWifiEapTls()
@ -645,10 +637,14 @@ void DlgHideWifiEapTls::paintEvent(QPaintEvent *event)
style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this);
QRect rect = this->rect();
rect.adjust(1, 1, -1, -1);
p.setRenderHint(QPainter::Antialiasing); // 反锯齿;
p.setBrush(opt.palette.color(QPalette::Base));
p.setOpacity(trans);
p.setPen(Qt::NoPen);
p.drawRoundedRect(rect, 6, 6);
QWidget::paintEvent(event);
QPainterPath path;
KWindowEffects::enableBlurBehind(this->winId(), true, QRegion(path.toFillPolygon().toPolygon()));
}

View File

@ -20,6 +20,7 @@
#include "dlghidewifieapttls.h"
#include "ui_dlghidewifieapttls.h"
#include "kylinheadfile.h"
#include "src/kylin-dbus-interface.h"
#include <sys/syslog.h>
@ -34,12 +35,6 @@ DlgHideWifiEapTTLS::DlgHideWifiEapTTLS(int type, QWidget *parent) :
this->setAttribute(Qt::WA_TranslucentBackground);
//需要添加 void paintEvent(QPaintEvent *event) 函数
QPainterPath path;
auto rect = this->rect();
rect.adjust(1, 1, -1, -1);
path.addRoundedRect(rect, 6, 6);
setProperty("blurRegion", QRegion(path.toFillPolygon().toPolygon()));
this->setStyleSheet("QWidget{border-radius:6px;background-color:rgba(19,19,20,0.7);border:1px solid rgba(255, 255, 255, 0.05);}");
MyQss objQss;
@ -159,8 +154,6 @@ DlgHideWifiEapTTLS::DlgHideWifiEapTTLS(int type, QWidget *parent) :
ui->btnConnect->setEnabled(false);
this->setFixedSize(432,665);
KWindowEffects::enableBlurBehind(this->winId(), true, QRegion(path.toFillPolygon().toPolygon()));
}
DlgHideWifiEapTTLS::~DlgHideWifiEapTTLS()
@ -450,9 +443,23 @@ void DlgHideWifiEapTTLS::on_lePwd_textEdited(const QString &arg1)
void DlgHideWifiEapTTLS::paintEvent(QPaintEvent *event)
{
KylinDBus mkylindbus;
double trans = mkylindbus.getTransparentData();
QStyleOption opt;
opt.init(this);
QPainter p(this);
style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this);
QWidget::paintEvent(event);
opt.init(this);
QPainter p(this);
style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this);
QRect rect = this->rect();
rect.adjust(1, 1, -1, -1);
p.setRenderHint(QPainter::Antialiasing); // 反锯齿;
p.setBrush(opt.palette.color(QPalette::Base));
p.setOpacity(trans);
p.setPen(Qt::NoPen);
p.drawRoundedRect(rect, 6, 6);
QWidget::paintEvent(event);
QPainterPath path;
KWindowEffects::enableBlurBehind(this->winId(), true, QRegion(path.toFillPolygon().toPolygon()));
}

View File

@ -19,6 +19,7 @@
#include "ui_dlghidewifileap.h"
#include "kylinheadfile.h"
#include "src/kylin-dbus-interface.h"
#include <sys/syslog.h>
@ -32,12 +33,6 @@ DlgHideWifiLeap::DlgHideWifiLeap(QWidget *parent) :
this->setAttribute(Qt::WA_TranslucentBackground);
//需要添加 void paintEvent(QPaintEvent *event) 函数
QPainterPath path;
auto rect = this->rect();
rect.adjust(1, 1, -1, -1);
path.addRoundedRect(rect, 6, 6);
setProperty("blurRegion", QRegion(path.toFillPolygon().toPolygon()));
this->setStyleSheet("QWidget{border-radius:6px;background-color:rgba(19,19,20,0.7);border:1px solid rgba(255, 255, 255, 0.05);}");
MyQss objQss;
@ -105,8 +100,6 @@ DlgHideWifiLeap::DlgHideWifiLeap(QWidget *parent) :
ui->btnConnect->setEnabled(false);
this->setFixedSize(432,434);
KWindowEffects::enableBlurBehind(this->winId(), true, QRegion(path.toFillPolygon().toPolygon()));
}
DlgHideWifiLeap::~DlgHideWifiLeap()
@ -230,9 +223,23 @@ void DlgHideWifiLeap::on_lePassword_textEdited(const QString &arg1)
void DlgHideWifiLeap::paintEvent(QPaintEvent *event)
{
KylinDBus mkylindbus;
double trans = mkylindbus.getTransparentData();
QStyleOption opt;
opt.init(this);
QPainter p(this);
style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this);
QWidget::paintEvent(event);
opt.init(this);
QPainter p(this);
style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this);
QRect rect = this->rect();
rect.adjust(1, 1, -1, -1);
p.setRenderHint(QPainter::Antialiasing); // 反锯齿;
p.setBrush(opt.palette.color(QPalette::Base));
p.setOpacity(trans);
p.setPen(Qt::NoPen);
p.drawRoundedRect(rect, 6, 6);
QWidget::paintEvent(event);
QPainterPath path;
KWindowEffects::enableBlurBehind(this->winId(), true, QRegion(path.toFillPolygon().toPolygon()));
}

View File

@ -19,6 +19,7 @@
#include "ui_dlghidewifiwep.h"
#include "kylinheadfile.h"
#include "src/kylin-dbus-interface.h"
#include <sys/syslog.h>
@ -33,12 +34,6 @@ DlgHideWifiWep::DlgHideWifiWep(int type, QWidget *parent) :
this->setAttribute(Qt::WA_TranslucentBackground);
//需要添加 void paintEvent(QPaintEvent *event) 函数
QPainterPath path;
auto rect = this->rect();
rect.adjust(1, 1, -1, -1);
path.addRoundedRect(rect, 6, 6);
setProperty("blurRegion", QRegion(path.toFillPolygon().toPolygon()));
this->setStyleSheet("QWidget{border-radius:6px;background-color:rgba(19,19,20,0.7);border:1px solid rgba(255, 255, 255, 0.05);}");
MyQss objQss;
@ -125,8 +120,6 @@ DlgHideWifiWep::DlgHideWifiWep(int type, QWidget *parent) :
ui->btnConnect->setEnabled(false);
this->setFixedSize(432,493);
KWindowEffects::enableBlurBehind(this->winId(), true, QRegion(path.toFillPolygon().toPolygon()));
}
DlgHideWifiWep::~DlgHideWifiWep()
@ -232,9 +225,23 @@ void DlgHideWifiWep::on_leNetName_textEdited(const QString &arg1)
void DlgHideWifiWep::paintEvent(QPaintEvent *event)
{
KylinDBus mkylindbus;
double trans = mkylindbus.getTransparentData();
QStyleOption opt;
opt.init(this);
QPainter p(this);
style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this);
QWidget::paintEvent(event);
opt.init(this);
QPainter p(this);
style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this);
QRect rect = this->rect();
rect.adjust(1, 1, -1, -1);
p.setRenderHint(QPainter::Antialiasing); // 反锯齿;
p.setBrush(opt.palette.color(QPalette::Base));
p.setOpacity(trans);
p.setPen(Qt::NoPen);
p.drawRoundedRect(rect, 6, 6);
QWidget::paintEvent(event);
QPainterPath path;
KWindowEffects::enableBlurBehind(this->winId(), true, QRegion(path.toFillPolygon().toPolygon()));
}

View File

@ -43,12 +43,6 @@ DlgHideWifiWpa::DlgHideWifiWpa(int type, MainWindow *mainWindow, QWidget *parent
this->setWindowIcon(QIcon::fromTheme("kylin-network", QIcon(":/res/x/setup.png")) );
//需要添加 void paintEvent(QPaintEvent *event) 函数
QPainterPath path;
auto rect = this->rect();
rect.adjust(1, 1, -1, -1);
path.addRoundedRect(rect, 6, 6);
setProperty("blurRegion", QRegion(path.toFillPolygon().toPolygon()));
MyQss objQss;
ui->lbBoder->setStyleSheet("QLabel{border-radius:6px;background-color:rgba(19,19,20,0.95);border:1px solid rgba(255, 255, 255, 0.05);}");
@ -112,8 +106,6 @@ DlgHideWifiWpa::DlgHideWifiWpa(int type, MainWindow *mainWindow, QWidget *parent
this->setFixedSize(432,397);
this->mw = mainWindow;
KWindowEffects::enableBlurBehind(this->winId(), true, QRegion(path.toFillPolygon().toPolygon()));
}
DlgHideWifiWpa::~DlgHideWifiWpa()
@ -434,10 +426,14 @@ void DlgHideWifiWpa::paintEvent(QPaintEvent *event)
style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this);
QRect rect = this->rect();
rect.adjust(1, 1, -1, -1);
p.setRenderHint(QPainter::Antialiasing); // 反锯齿;
p.setBrush(opt.palette.color(QPalette::Base));
p.setOpacity(trans);
p.setPen(Qt::NoPen);
p.drawRoundedRect(rect, 6, 6);
QWidget::paintEvent(event);
QPainterPath path;
KWindowEffects::enableBlurBehind(this->winId(), true, QRegion(path.toFillPolygon().toPolygon()));
}