fix: 修复系统主题变化后快捷面板电池颜色显示错误的问题

1、电池图标响应主题变化来重新设置图标
2、修改控制中心电池名称的文案

Log: 修改系统主题变化后快捷面板电池颜色显示错误的问题
Influence: 打开快捷面板,在控制中心更改系统颜色,观察快捷面板中系统电池图标是否跟随系统颜色变化
Bug: https://pms.uniontech.com/bug-view-184085.html
Change-Id: If02b8800b4d90696c2dc74ac43ebc230233f0f58
This commit is contained in:
donghualin 2023-02-01 13:29:58 +08:00
parent da1b436796
commit 5652e2a49a
2 changed files with 29 additions and 11 deletions

View File

@ -52,12 +52,8 @@ PowerPlugin::PowerPlugin(QObject *parent)
, m_preChargeTimer(new QTimer(this))
, m_quickPanel(nullptr)
{
m_tipsLabel->setVisible(false);
m_tipsLabel->setObjectName("power");
m_preChargeTimer->setInterval(DELAYTIME);
m_preChargeTimer->setSingleShot(true);
initQuickPanel();
connect(m_preChargeTimer,&QTimer::timeout,this,&PowerPlugin::refreshTipsData);
initUi();
initConnection();
}
const QString PowerPlugin::pluginName() const
@ -67,7 +63,7 @@ const QString PowerPlugin::pluginName() const
const QString PowerPlugin::pluginDisplayName() const
{
return tr("Power");
return tr("Battery");
}
QWidget *PowerPlugin::itemWidget(const QString &itemKey)
@ -100,6 +96,8 @@ void PowerPlugin::init(PluginProxyInterface *proxyInter)
m_proxyInter = proxyInter;
loadPlugin();
onThemeTypeChanged(DGuiApplicationHelper::instance()->themeType());
}
const QString PowerPlugin::itemCommand(const QString &itemKey)
@ -149,13 +147,12 @@ void PowerPlugin::setSortKey(const QString &itemKey, const int order)
QIcon PowerPlugin::icon(const DockPart &dockPart, DGuiApplicationHelper::ColorType themeType)
{
const QPixmap pixmap = m_powerStatusWidget->getBatteryIcon(themeType);
// 快捷面板使用m_quickPanel
if (dockPart == DockPart::QuickPanel) {
m_imageLabel->setPixmap(pixmap);
return QIcon();
}
const QPixmap pixmap = m_powerStatusWidget->getBatteryIcon(themeType);
static QIcon batteryIcon;
batteryIcon.detach();
batteryIcon.addPixmap(pixmap);
@ -289,8 +286,19 @@ void PowerPlugin::refreshTipsData()
}
}
void PowerPlugin::initQuickPanel()
void PowerPlugin::onThemeTypeChanged(DGuiApplicationHelper::ColorType themeType)
{
const QPixmap pixmap = m_powerStatusWidget->getBatteryIcon(themeType);
m_imageLabel->setPixmap(pixmap);
}
void PowerPlugin::initUi()
{
m_tipsLabel->setVisible(false);
m_tipsLabel->setObjectName("power");
m_preChargeTimer->setInterval(DELAYTIME);
m_preChargeTimer->setSingleShot(true);
m_quickPanel = new QWidget();
QVBoxLayout *layout = new QVBoxLayout(m_quickPanel);
layout->setAlignment(Qt::AlignVCenter);
@ -310,3 +318,9 @@ void PowerPlugin::initQuickPanel()
layout->addSpacing(7);
layout->addWidget(m_labelText);
}
void PowerPlugin::initConnection()
{
connect(m_preChargeTimer,&QTimer::timeout,this,&PowerPlugin::refreshTipsData);
connect(DGuiApplicationHelper::instance(), &DGuiApplicationHelper::themeTypeChanged, this, &PowerPlugin::onThemeTypeChanged);
}

View File

@ -61,8 +61,12 @@ private:
void updateBatteryVisible();
void loadPlugin();
void onGSettingsChanged(const QString &key);
void initUi();
void initConnection();
private slots:
void refreshTipsData();
void initQuickPanel();
void onThemeTypeChanged(DGuiApplicationHelper::ColorType themeType);
private:
bool m_pluginLoaded;