From 460705c4015aca1606e6f8735941b72d0a470747 Mon Sep 17 00:00:00 2001 From: donghualin Date: Thu, 8 Dec 2022 11:13:16 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E9=BB=91=E8=89=B2?= =?UTF-8?q?=E8=83=8C=E6=99=AF=E4=B8=8B=E8=93=9D=E7=89=99=E5=88=97=E8=A1=A8?= =?UTF-8?q?=E5=90=8D=E7=A7=B0=E9=A2=9C=E8=89=B2=E6=98=BE=E7=A4=BA=E9=94=99?= =?UTF-8?q?=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 蓝牙设备名称对应的DLabel增加主题变化后改变颜色 Log: Influence: 改变主题,观察蓝牙列表设备名称的颜色是否改变 Bug: https://pms.uniontech.com/bug-view-167961.html Change-Id: I7a22e77688aa8767eb6e3439d9885cd871945cde --- plugins/bluetooth/componments/bluetoothapplet.cpp | 14 +++++++++++++- plugins/bluetooth/componments/bluetoothapplet.h | 5 +++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/plugins/bluetooth/componments/bluetoothapplet.cpp b/plugins/bluetooth/componments/bluetoothapplet.cpp index 550721711..645aba307 100644 --- a/plugins/bluetooth/componments/bluetoothapplet.cpp +++ b/plugins/bluetooth/componments/bluetoothapplet.cpp @@ -60,8 +60,9 @@ SettingLabel::SettingLabel(QString text, QWidget *parent) p.setColor(QPalette::Background, Qt::transparent); this->setPalette(p); - m_label->setForegroundRole(QPalette::BrightText); + onThemeTypeChanged(DGuiApplicationHelper::instance()->themeType()); updateEnabledStatus(); + connect(DGuiApplicationHelper::instance(), &DGuiApplicationHelper::themeTypeChanged, this, &SettingLabel::onThemeTypeChanged); } void SettingLabel::addButton(QWidget *button, int space) @@ -80,6 +81,17 @@ void SettingLabel::updateEnabledStatus() m_label->setPalette(p); } +void SettingLabel::onThemeTypeChanged(DGuiApplicationHelper::ColorType themeType) +{ + QPalette palette = m_label->palette(); + if (themeType == DGuiApplicationHelper::ColorType::LightType) + palette.setColor(QPalette::BrightText, Qt::black); + else + palette.setColor(QPalette::BrightText, Qt::white); + + m_label->setPalette(palette); +} + void SettingLabel::changeEvent(QEvent *event) { if (event->type() == QEvent::EnabledChange) diff --git a/plugins/bluetooth/componments/bluetoothapplet.h b/plugins/bluetooth/componments/bluetoothapplet.h index 2eada4c6f..87f1b7ca2 100644 --- a/plugins/bluetooth/componments/bluetoothapplet.h +++ b/plugins/bluetooth/componments/bluetoothapplet.h @@ -28,6 +28,7 @@ #include #include +#include #include "org_deepin_dde_airplanemode1.h" @@ -47,6 +48,7 @@ class DListView; DWIDGET_END_NAMESPACE DWIDGET_USE_NAMESPACE +DGUI_USE_NAMESPACE using DBusAirplaneMode = org::deepin::dde::AirplaneMode1; @@ -68,6 +70,9 @@ protected: void updateEnabledStatus(); +private Q_SLOTS: + void onThemeTypeChanged(DGuiApplicationHelper::ColorType themeType); + private: DLabel *m_label; QHBoxLayout *m_layout;