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();