1 Star 0 Fork 17

liubuguiii/src-kiran-cc-daemon

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
0012-fix-power-Fix-battery-charging-and-discharging-time.patch 3.52 KB
一键复制 编辑 原始数据 按行查看 历史
From d24efc2aec6c4fbc00a4536998caf30553dc1e9b Mon Sep 17 00:00:00 2001
From: meizhigang <meizhigang@kylinsec.com.cn>
Date: Tue, 9 Apr 2024 14:09:04 +0800
Subject: [PATCH 13/14] fix(power):Fix battery charging and discharging time
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
- 适配电池充电和放电时间
Related #28618
---
plugins/power/tray/power-tray.cpp | 41 ++++++++++++++++++++-----------
1 file changed, 26 insertions(+), 15 deletions(-)
diff --git a/plugins/power/tray/power-tray.cpp b/plugins/power/tray/power-tray.cpp
index 8f76bcb..c372ef9 100644
--- a/plugins/power/tray/power-tray.cpp
+++ b/plugins/power/tray/power-tray.cpp
@@ -107,30 +107,41 @@ void PowerTray::update_status_icon_toolstip(std::shared_ptr<PowerUPowerDevice> d
{
case UP_DEVICE_STATE_CHARGING:
{
- auto time_to_full_text = PowerUtils::get_time_translation(device_for_tray->get_props().time_to_full);
- auto tooltip_text = fmt::format(_("Remaining electricty: {0:.1f}%, approximately {1} until charged"),
- device_for_tray->get_props().percentage,
- time_to_full_text);
- gtk_status_icon_set_tooltip_text(this->status_icon_, tooltip_text.c_str());
+ auto time_to_full = device_for_tray->get_props().time_to_full;
+ if (time_to_full > 0)
+ {
+ auto time_to_full_text = PowerUtils::get_time_translation(time_to_full);
+ auto tooltip_text = fmt::format(_("Remaining electricty: {0:.1f}%, approximately {1} until charged"),
+ device_for_tray->get_props().percentage,
+ time_to_full_text);
+ gtk_status_icon_set_tooltip_text(this->status_icon_, tooltip_text.c_str());
+
+ return;
+ }
break;
}
case UP_DEVICE_STATE_DISCHARGING:
{
- auto time_to_empty_text = PowerUtils::get_time_translation(device_for_tray->get_props().time_to_empty);
- auto tooltip_text = fmt::format(_("Remaining electricty: {0:.1f}%, approximately provides {1} runtime"),
- device_for_tray->get_props().percentage,
- time_to_empty_text);
- gtk_status_icon_set_tooltip_text(this->status_icon_, tooltip_text.c_str());
+ auto time_to_empty = device_for_tray->get_props().time_to_empty;
+ if (time_to_empty > 0)
+ {
+ auto time_to_empty_text = PowerUtils::get_time_translation(time_to_empty);
+ auto tooltip_text = fmt::format(_("Remaining electricty: {0:.1f}%, approximately provides {1} runtime"),
+ device_for_tray->get_props().percentage,
+ time_to_empty_text);
+ gtk_status_icon_set_tooltip_text(this->status_icon_, tooltip_text.c_str());
+
+ return;
+ }
break;
}
case UP_DEVICE_STATE_FULLY_CHARGED:
default:
- {
- auto tooltip_text = fmt::format(_("Remaining electricty: {0:.1f}%"), device_for_tray->get_props().percentage);
- gtk_status_icon_set_tooltip_text(this->status_icon_, tooltip_text.c_str());
- }
- break;
+ break;
}
+
+ auto tooltip_text = fmt::format(_("Remaining electricty: {0:.1f}%"), device_for_tray->get_props().percentage);
+ gtk_status_icon_set_tooltip_text(this->status_icon_, tooltip_text.c_str());
}
void PowerTray::delay_update_status_icon()
--
2.27.0
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/liubuguiii/src-kiran-cc-daemon.git
git@gitee.com:liubuguiii/src-kiran-cc-daemon.git
liubuguiii
src-kiran-cc-daemon
src-kiran-cc-daemon
master

搜索帮助