fix bug 128215控制面板有线/无线按钮效果

This commit is contained in:
zhangyuanyuan1 2022-07-06 13:09:09 +08:00
parent 0153114412
commit ee491b775a
10 changed files with 57 additions and 9 deletions

View File

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

View File

@ -0,0 +1,14 @@
#include "grayinfobutton.h"
#include <QVariant>
#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);
}

View File

@ -0,0 +1,15 @@
#ifndef GRAYINFOBUTTON_H
#define GRAYINFOBUTTON_H
#include <QPushButton>
#include <QIcon>
class GrayInfoButton : public QPushButton
{
Q_OBJECT
public:
explicit GrayInfoButton(QWidget * parent = nullptr);
~GrayInfoButton() = default;
};
#endif // GRAYINFOBUTTON_H

View File

@ -2,8 +2,10 @@
SOURCES += \
$$PWD/AddBtn/addnetbtn.cpp \
$$PWD/AddBtn/grayinfobutton.cpp
HEADERS += \
$$PWD/AddBtn/addnetbtn.h \
$$PWD/AddBtn/grayinfobutton.h

View File

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

View File

@ -30,7 +30,8 @@
#include <QImage>
#include <QPainter>
#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;

View File

@ -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;

View File

@ -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;

View File

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

View File

@ -29,7 +29,8 @@
#include <QGSettings>
#include <QImage>
#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 = "";