From ee491b775a8a616cd37ae6a07c78ffa0908ce8cb Mon Sep 17 00:00:00 2001 From: zhangyuanyuan1 Date: Wed, 6 Jul 2022 13:09:09 +0800 Subject: [PATCH] =?UTF-8?q?fix=20bug=20128215=E6=8E=A7=E5=88=B6=E9=9D=A2?= =?UTF-8?q?=E6=9D=BF=E6=9C=89=E7=BA=BF/=E6=97=A0=E7=BA=BF=E6=8C=89?= =?UTF-8?q?=E9=92=AE=E6=95=88=E6=9E=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugins/component/AddBtn/addnetbtn.cpp | 5 +++++ plugins/component/AddBtn/grayinfobutton.cpp | 14 ++++++++++++++ plugins/component/AddBtn/grayinfobutton.h | 15 +++++++++++++++ plugins/component/addbtn.pri | 2 ++ plugins/netconnect/lanitem.cpp | 7 ++++++- plugins/netconnect/lanitem.h | 5 +++-- plugins/netconnect/netconnect.cpp | 4 ++-- plugins/wlanconnect/wlanconnect.cpp | 2 +- plugins/wlanconnect/wlanitem.cpp | 7 ++++++- plugins/wlanconnect/wlanitem.h | 5 +++-- 10 files changed, 57 insertions(+), 9 deletions(-) create mode 100644 plugins/component/AddBtn/grayinfobutton.cpp create mode 100644 plugins/component/AddBtn/grayinfobutton.h diff --git a/plugins/component/AddBtn/addnetbtn.cpp b/plugins/component/AddBtn/addnetbtn.cpp index 40ff3bac..f186a922 100644 --- a/plugins/component/AddBtn/addnetbtn.cpp +++ b/plugins/component/AddBtn/addnetbtn.cpp @@ -34,6 +34,11 @@ AddNetBtn::AddNetBtn(bool isWlan, QWidget *parent) : QPushButton(parent) this->setMaximumSize(QSize(16777215, 60)); this->setProperty("useButtonPalette", true); this->setFlat(true); + QPalette pal = this->palette(); + QColor color = pal.color(QPalette::Button); + color.setAlphaF(0.5); + pal.setColor(QPalette::Button, color); + this->setPalette(pal); QHBoxLayout *addLyt = new QHBoxLayout; QLabel *iconLabel = new QLabel(); diff --git a/plugins/component/AddBtn/grayinfobutton.cpp b/plugins/component/AddBtn/grayinfobutton.cpp new file mode 100644 index 00000000..79367a9f --- /dev/null +++ b/plugins/component/AddBtn/grayinfobutton.cpp @@ -0,0 +1,14 @@ +#include "grayinfobutton.h" + +#include + +#define BUTTON_SIZE 36,36 +#define ICON_SIZE 16,16 + +GrayInfoButton::GrayInfoButton(QWidget *parent): QPushButton(parent) +{ + this->setFixedSize(BUTTON_SIZE); + this->setIcon(QIcon::fromTheme("preferences-system-details-symbolic")); + this->setProperty("useButtonPalette", true); + this->setFlat(true); +} diff --git a/plugins/component/AddBtn/grayinfobutton.h b/plugins/component/AddBtn/grayinfobutton.h new file mode 100644 index 00000000..707fa087 --- /dev/null +++ b/plugins/component/AddBtn/grayinfobutton.h @@ -0,0 +1,15 @@ +#ifndef GRAYINFOBUTTON_H +#define GRAYINFOBUTTON_H + +#include +#include + +class GrayInfoButton : public QPushButton +{ + Q_OBJECT +public: + explicit GrayInfoButton(QWidget * parent = nullptr); + ~GrayInfoButton() = default; +}; + +#endif // GRAYINFOBUTTON_H diff --git a/plugins/component/addbtn.pri b/plugins/component/addbtn.pri index c22c6e7c..f3961167 100644 --- a/plugins/component/addbtn.pri +++ b/plugins/component/addbtn.pri @@ -2,8 +2,10 @@ SOURCES += \ $$PWD/AddBtn/addnetbtn.cpp \ + $$PWD/AddBtn/grayinfobutton.cpp HEADERS += \ $$PWD/AddBtn/addnetbtn.h \ + $$PWD/AddBtn/grayinfobutton.h diff --git a/plugins/netconnect/lanitem.cpp b/plugins/netconnect/lanitem.cpp index b61e4693..a8903cf3 100644 --- a/plugins/netconnect/lanitem.cpp +++ b/plugins/netconnect/lanitem.cpp @@ -31,6 +31,11 @@ LanItem::LanItem(bool isAcitve, QWidget *parent) this->setMinimumSize(550, 58); this->setProperty("useButtonPalette", true); this->setFlat(true); + QPalette pal = this->palette(); + QColor color = pal.color(QPalette::Button); + color.setAlphaF(0.5); + pal.setColor(QPalette::Button, color); + this->setPalette(pal); // setStyleSheet("QPushButton:!checked{background-color: palette(base)}"); QHBoxLayout *mLanLyt = new QHBoxLayout(this); mLanLyt->setContentsMargins(16,0,16,0); @@ -41,7 +46,7 @@ LanItem::LanItem(bool isAcitve, QWidget *parent) statusLabel = new QLabel(this); statusLabel->setAlignment(Qt::AlignRight | Qt::AlignVCenter); // statusLabel->setMinimumSize(36,36); - infoLabel = new InfoButton(this); + infoLabel = new GrayInfoButton(this); mLanLyt->addWidget(iconLabel); mLanLyt->addWidget(titileLabel,Qt::AlignLeft); mLanLyt->addStretch(); diff --git a/plugins/netconnect/lanitem.h b/plugins/netconnect/lanitem.h index 6bdfa854..ea1b1355 100644 --- a/plugins/netconnect/lanitem.h +++ b/plugins/netconnect/lanitem.h @@ -30,7 +30,8 @@ #include #include #include "fixlabel.h" -#include "infobutton.h" +//#include "infobutton.h" +#include "../component/AddBtn/grayinfobutton.h" class LanItem : public QPushButton { @@ -39,7 +40,7 @@ public: ~LanItem(); public: QLabel * iconLabel = nullptr; - InfoButton * infoLabel = nullptr; + GrayInfoButton * infoLabel = nullptr; FixLabel * titileLabel = nullptr; QLabel * statusLabel = nullptr; diff --git a/plugins/netconnect/netconnect.cpp b/plugins/netconnect/netconnect.cpp index 2dbe580c..4bc29246 100644 --- a/plugins/netconnect/netconnect.cpp +++ b/plugins/netconnect/netconnect.cpp @@ -438,7 +438,7 @@ void NetConnect::addLanItem(ItemFrame *frame, QString devName, QStringList infoL lanItem->uuid = infoList.at(1); lanItem->dbusPath = infoList.at(2); - connect(lanItem->infoLabel, &InfoButton::clicked, this, [=]{ + connect(lanItem->infoLabel, &GrayInfoButton::clicked, this, [=]{ // open landetail page if (!m_interface->isValid()) { return; @@ -707,7 +707,7 @@ void NetConnect::addOneLanFrame(ItemFrame *frame, QString deviceName, QStringLis lanItem->uuid = connUuid; lanItem->dbusPath = connDbusPath; - connect(lanItem->infoLabel, &InfoButton::clicked, this, [=]{ + connect(lanItem->infoLabel, &GrayInfoButton::clicked, this, [=]{ // open landetail page if (!m_interface->isValid()) { return; diff --git a/plugins/wlanconnect/wlanconnect.cpp b/plugins/wlanconnect/wlanconnect.cpp index 62a6e935..8a824af3 100644 --- a/plugins/wlanconnect/wlanconnect.cpp +++ b/plugins/wlanconnect/wlanconnect.cpp @@ -1026,7 +1026,7 @@ void WlanConnect::addOneWlanFrame(ItemFrame *frame, QString deviceName, QString wlanItem->statusLabel->setText(""); } - connect(wlanItem->infoLabel, &InfoButton::clicked, this, [=]{ + connect(wlanItem->infoLabel, &GrayInfoButton::clicked, this, [=]{ // open detail page if (!m_interface->isValid()) { return; diff --git a/plugins/wlanconnect/wlanitem.cpp b/plugins/wlanconnect/wlanitem.cpp index 9ea091b1..01d8b269 100644 --- a/plugins/wlanconnect/wlanitem.cpp +++ b/plugins/wlanconnect/wlanitem.cpp @@ -33,6 +33,11 @@ WlanItem::WlanItem(bool bAcitve, bool isLock, QWidget *parent) this->setMinimumSize(550, 58); this->setProperty("useButtonPalette", true); this->setFlat(true); + QPalette pal = this->palette(); + QColor color = pal.color(QPalette::Button); + color.setAlphaF(0.5); + pal.setColor(QPalette::Button, color); + this->setPalette(pal); QHBoxLayout *mLanLyt = new QHBoxLayout(this); mLanLyt->setContentsMargins(16,0,16,0); mLanLyt->setSpacing(16); @@ -41,7 +46,7 @@ WlanItem::WlanItem(bool bAcitve, bool isLock, QWidget *parent) statusLabel = new QLabel(this); statusLabel->setAlignment(Qt::AlignRight | Qt::AlignVCenter); // statusLabel->setMinimumSize(36,36); - infoLabel = new InfoButton(this); + infoLabel = new GrayInfoButton(this); mLanLyt->addWidget(iconLabel); mLanLyt->addWidget(titileLabel,Qt::AlignLeft); mLanLyt->addStretch(); diff --git a/plugins/wlanconnect/wlanitem.h b/plugins/wlanconnect/wlanitem.h index 3bfff005..035daccf 100644 --- a/plugins/wlanconnect/wlanitem.h +++ b/plugins/wlanconnect/wlanitem.h @@ -29,7 +29,8 @@ #include #include #include "fixlabel.h" -#include "infobutton.h" +//#include "infobutton.h" +#include "../component/AddBtn/grayinfobutton.h" class WlanItem : public QPushButton { @@ -38,7 +39,7 @@ public: ~WlanItem(); public: QLabel * iconLabel = nullptr; - InfoButton * infoLabel = nullptr; + GrayInfoButton * infoLabel = nullptr; FixLabel * titileLabel = nullptr; QLabel * statusLabel = nullptr; QString uuid = "";