diff --git a/plugins/component/AddBtn/addnetbtn.cpp b/plugins/component/AddBtn/addnetbtn.cpp index 58413083..e47ea2dc 100644 --- a/plugins/component/AddBtn/addnetbtn.cpp +++ b/plugins/component/AddBtn/addnetbtn.cpp @@ -34,11 +34,7 @@ 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(); @@ -62,7 +58,6 @@ AddNetBtn::AddNetBtn(bool isWlan, QWidget *parent) : QPushButton(parent) addLyt->addStretch(); this->setLayout(addLyt); - } AddNetBtn::~AddNetBtn() @@ -84,13 +79,18 @@ void AddNetBtn::leaveEvent(QEvent *event){ void AddNetBtn::paintEvent(QPaintEvent *event) { - QPalette pal = this->palette(); + QPalette pal = qApp->palette(); QPainter painter(this); painter.setRenderHint(QPainter:: Antialiasing, true); //设置渲染,启动反锯齿 painter.setPen(Qt::NoPen); painter.setBrush(pal.color(QPalette::Base)); + 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 a8903cf3..60be4130 100644 --- a/plugins/netconnect/lanitem.cpp +++ b/plugins/netconnect/lanitem.cpp @@ -18,6 +18,8 @@ * */ #include "lanitem.h" +#include + #define FRAME_SPEED 150 #define LIMIT_TIME 60*1000 #define TOTAL_PAGE 8 @@ -31,11 +33,6 @@ 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); @@ -44,6 +41,7 @@ LanItem::LanItem(bool isAcitve, QWidget *parent) iconLabel->setProperty("useIconHighlightEffect", 0x2); titileLabel = new FixLabel(this); statusLabel = new QLabel(this); + statusLabel->setProperty("useIconHighlightEffect", 0x2); statusLabel->setAlignment(Qt::AlignRight | Qt::AlignVCenter); // statusLabel->setMinimumSize(36,36); infoLabel = new GrayInfoButton(this); @@ -91,13 +89,18 @@ void LanItem::stopLoading(){ void LanItem::paintEvent(QPaintEvent *event) { - QPalette pal = this->palette(); + QPalette pal = qApp->palette(); QPainter painter(this); painter.setRenderHint(QPainter:: Antialiasing, true); //设置渲染,启动反锯齿 painter.setPen(Qt::NoPen); painter.setBrush(pal.color(QPalette::Base)); + 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/proxy/proxy.cpp b/plugins/proxy/proxy.cpp index 0e89d9e5..f2ade081 100644 --- a/plugins/proxy/proxy.cpp +++ b/plugins/proxy/proxy.cpp @@ -45,7 +45,7 @@ #define PROXY_HOST_KEY "host" #define PROXY_PORT_KEY "port" - +#define THEME_SCHAME "org.ukui.style" #define FRAME_LAYOUT_MARGINS 16,0,16,0 #define FRAME_LAYOUT_SPACING 8 #define LABEL_WIDTH 136 @@ -1160,18 +1160,22 @@ void Proxy::setAppListFrameUi(QWidget *widget) m_allowAppProxyLabel->setText(tr("The following applications are allowed to use this configuration:")); //允许以下应用使用该配置: m_appListWidget = new QListWidget(m_appListFrame); m_appListWidget->setMinimumHeight(240); - m_appListWidget->setBackgroundRole(QPalette::Base); m_appListWidget->setFocusPolicy(Qt::FocusPolicy::NoFocus); m_appListWidget->setFrameShape(QFrame::Shape::Panel); appListLayout->addWidget(m_allowAppProxyLabel); appListLayout->addWidget(m_appListWidget); - QPalette mpal(m_appListWidget->palette()); - mpal.setColor(QPalette::Base, qApp->palette().base().color()); - mpal.setColor(QPalette::AlternateBase, qApp->palette().alternateBase().color()); - m_appListWidget->setAlternatingRowColors(true); - m_appListWidget->setPalette(mpal); + onPaletteChanged(); + const QByteArray style_id(THEME_SCHAME); + if (QGSettings::isSchemaInstalled(style_id)) { + QGSettings * styleGsettings = new QGSettings(style_id, QByteArray(), this); + connect(styleGsettings, &QGSettings::changed, this, [=](QString key){ + if ("styleName" == key) { + onPaletteChanged(); + } + }); + } } void Proxy::appProxyInfoPadding() @@ -1269,6 +1273,16 @@ void Proxy::onAppProxyConfEditFinished() } } +void Proxy::onPaletteChanged() +{ + QPalette mpal(m_appListWidget->palette()); + mpal.setColor(QPalette::Base, qApp->palette().base().color()); + mpal.setColor(QPalette::AlternateBase, qApp->palette().alternateBase().color()); + m_appListWidget->setBackgroundRole(QPalette::Base); + m_appListWidget->setAlternatingRowColors(true); + m_appListWidget->setPalette(mpal); +} + void Proxy::onappProxyEnableChanged(bool enable) { m_proxyTypeFrame->setVisible(enable); diff --git a/plugins/proxy/proxy.h b/plugins/proxy/proxy.h index 48d9cc30..e2cb2c11 100644 --- a/plugins/proxy/proxy.h +++ b/plugins/proxy/proxy.h @@ -277,6 +277,7 @@ private slots: void onipEditStateChanged(); //IP地址无效提示 void onAppProxyConfChanged(); //应用代理配置信息变化 void onAppProxyConfEditFinished(); + void onPaletteChanged(); // void onCancelBtnClicked(); // void onSaveBtnClicked(); // void setBtnEnable(); diff --git a/plugins/wlanconnect/wlanitem.cpp b/plugins/wlanconnect/wlanitem.cpp index 4cb535d8..aff3c0d6 100644 --- a/plugins/wlanconnect/wlanitem.cpp +++ b/plugins/wlanconnect/wlanitem.cpp @@ -19,6 +19,7 @@ */ #include "wlanitem.h" #include +#include #define FRAME_SPEED 150 #define LIMIT_TIME 60*1000 #define TOTAL_PAGE 8 @@ -33,11 +34,7 @@ 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); @@ -45,6 +42,7 @@ WlanItem::WlanItem(bool bAcitve, bool isLock, QWidget *parent) iconLabel->setProperty("useIconHighlightEffect", 0x2); titileLabel = new FixLabel(this); statusLabel = new QLabel(this); + statusLabel->setProperty("useIconHighlightEffect", 0x2); statusLabel->setAlignment(Qt::AlignRight | Qt::AlignVCenter); // statusLabel->setMinimumSize(36,36); infoLabel = new GrayInfoButton(this); @@ -64,7 +62,6 @@ WlanItem::WlanItem(bool bAcitve, bool isLock, QWidget *parent) waitTimer = new QTimer(this); connect(waitTimer, &QTimer::timeout, this, &WlanItem::updateIcon); - } WlanItem::~WlanItem() @@ -94,13 +91,18 @@ void WlanItem::stopLoading(){ void WlanItem::paintEvent(QPaintEvent *event) { - QPalette pal = this->palette(); + QPalette pal = qApp->palette(); QPainter painter(this); painter.setRenderHint(QPainter:: Antialiasing, true); //设置渲染,启动反锯齿 painter.setPen(Qt::NoPen); painter.setBrush(pal.color(QPalette::Base)); + QColor color = pal.color(QPalette::Button); + color.setAlphaF(0.5); + pal.setColor(QPalette::Button, color); + this->setPalette(pal); + QRect rect = this->rect(); #if 0 diff --git a/src/frontend/tab-pages/wlanpage.cpp b/src/frontend/tab-pages/wlanpage.cpp index 888db27b..598ba54b 100644 --- a/src/frontend/tab-pages/wlanpage.cpp +++ b/src/frontend/tab-pages/wlanpage.cpp @@ -959,6 +959,7 @@ void WlanPage::onConnectionStateChanged(QString uuid, if (ssid.isEmpty()) { qDebug()<< LOG_FLAG << "ssid or devicename is empty" << "devicename"<< devName <<"ssid"<breakNetworkConnect(uuid, devName, ssid); return; }