From ca06d65e2ee81e81cfef10d74fe0b56ec620f671 Mon Sep 17 00:00:00 2001 From: zhangyuanyuan1 Date: Wed, 31 May 2023 10:02:27 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E6=8E=A7=E5=88=B6=E9=9D=A2?= =?UTF-8?q?=E6=9D=BF=E7=BD=91=E7=BB=9C=E9=A1=B9=E8=83=8C=E6=99=AF=E8=89=B2?= =?UTF-8?q?=E4=B8=BAbutton=E8=89=B2=E9=80=8F=E6=98=8E=E5=BA=A60.5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugins/component/AddBtn/addnetbtn.cpp | 7 ++++++- plugins/netconnect/lanitem.cpp | 7 ++++++- plugins/vpn/vpnitem.cpp | 12 ++++++++---- plugins/wlanconnect/wlanitem.cpp | 12 +++++------- 4 files changed, 25 insertions(+), 13 deletions(-) diff --git a/plugins/component/AddBtn/addnetbtn.cpp b/plugins/component/AddBtn/addnetbtn.cpp index 50ff8a19..7c2627de 100644 --- a/plugins/component/AddBtn/addnetbtn.cpp +++ b/plugins/component/AddBtn/addnetbtn.cpp @@ -34,7 +34,6 @@ AddNetBtn::AddNetBtn(bool isWlan, QWidget *parent) : QPushButton(parent) this->setMaximumSize(QSize(16777215, 60)); this->setProperty("useButtonPalette", true); this->setFlat(true); - this->setProperty("needTranslucent", true); QHBoxLayout *addLyt = new QHBoxLayout; @@ -85,6 +84,12 @@ void AddNetBtn::paintEvent(QPaintEvent *event) painter.setPen(Qt::NoPen); painter.setBrush(this->palette().base().color()); + QPalette pal = qApp->palette(); + QColor color = pal.color(QPalette::Button); + color.setAlphaF(0.5); + pal.setColor(QPalette::Button, color); + this->setPalette(pal); + QRect rect = this->rect(); QPainterPath path; diff --git a/plugins/netconnect/lanitem.cpp b/plugins/netconnect/lanitem.cpp index 0d93b368..ad85d06d 100644 --- a/plugins/netconnect/lanitem.cpp +++ b/plugins/netconnect/lanitem.cpp @@ -33,7 +33,6 @@ LanItem::LanItem(bool isAcitve, QWidget *parent) this->setMinimumSize(550, 58); this->setProperty("useButtonPalette", true); this->setFlat(true); - this->setProperty("needTranslucent", true); // setStyleSheet("QPushButton:!checked{background-color: palette(base)}"); QHBoxLayout *mLanLyt = new QHBoxLayout(this); mLanLyt->setContentsMargins(16,0,16,0); @@ -95,6 +94,12 @@ void LanItem::paintEvent(QPaintEvent *event) painter.setPen(Qt::NoPen); painter.setBrush(this->palette().base().color()); + QPalette pal = qApp->palette(); + QColor color = pal.color(QPalette::Button); + color.setAlphaF(0.5); + pal.setColor(QPalette::Button, color); + this->setPalette(pal); + QRect rect = this->rect(); painter.drawRect(rect); diff --git a/plugins/vpn/vpnitem.cpp b/plugins/vpn/vpnitem.cpp index df326693..c6d67550 100644 --- a/plugins/vpn/vpnitem.cpp +++ b/plugins/vpn/vpnitem.cpp @@ -20,6 +20,7 @@ #include "vpnitem.h" #include #include +#include #define FRAME_SPEED 150 #define LIMIT_TIME 60*1000 #define TOTAL_PAGE 8 @@ -34,7 +35,6 @@ VpnItem::VpnItem(bool bAcitve, QWidget *parent) this->setMinimumSize(550, 58); this->setProperty("useButtonPalette", true); this->setFlat(true); - this->setProperty("needTranslucent", true); QHBoxLayout *mLanLyt = new QHBoxLayout(this); mLanLyt->setContentsMargins(16,0,16,0); @@ -133,12 +133,16 @@ void VpnItem::onDeletetTriggered() void VpnItem::paintEvent(QPaintEvent *event) { - QPalette pal = this->palette(); - QPainter painter(this); painter.setRenderHint(QPainter:: Antialiasing, true); //设置渲染,启动反锯齿 painter.setPen(Qt::NoPen); - painter.setBrush(pal.color(QPalette::Base)); + painter.setBrush(this->palette().base().color()); + + QPalette pal = qApp->palette(); + QColor color = pal.color(QPalette::Button); + color.setAlphaF(0.5); + pal.setColor(QPalette::Button, color); + this->setPalette(pal); QRect rect = this->rect(); diff --git a/plugins/wlanconnect/wlanitem.cpp b/plugins/wlanconnect/wlanitem.cpp index 465f4295..8cb31ae1 100644 --- a/plugins/wlanconnect/wlanitem.cpp +++ b/plugins/wlanconnect/wlanitem.cpp @@ -35,7 +35,6 @@ WlanItem::WlanItem(bool bAcitve, bool isLock, QWidget *parent) this->setMinimumSize(550, 58); this->setProperty("useButtonPalette", true); this->setFlat(true); - this->setProperty("needTranslucent", true); QHBoxLayout *mLanLyt = new QHBoxLayout(this); mLanLyt->setContentsMargins(16,0,16,0); @@ -93,17 +92,16 @@ void WlanItem::stopLoading(){ void WlanItem::paintEvent(QPaintEvent *event) { -// QPalette pal = qApp->palette(); - QPainter painter(this); painter.setRenderHint(QPainter:: Antialiasing, true); //设置渲染,启动反锯齿 painter.setPen(Qt::NoPen); painter.setBrush(this->palette().base().color()); -// QColor color = pal.color(QPalette::Button); -// color.setAlphaF(0.5); -// pal.setColor(QPalette::Button, color); -// this->setPalette(pal); + QPalette pal = qApp->palette(); + QColor color = pal.color(QPalette::Button); + color.setAlphaF(0.5); + pal.setColor(QPalette::Button, color); + this->setPalette(pal); QRect rect = this->rect();