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;