!83 fix(power):Add battery charging and discharging time
From: @meizhigang Reviewed-by: @liubuguiii Signed-off-by: @liubuguiii
This commit is contained in:
commit
7808811bea
29
0001-fix-keyboard-Fix-ci-build-error.patch
Normal file
29
0001-fix-keyboard-Fix-ci-build-error.patch
Normal file
@ -0,0 +1,29 @@
|
||||
From a55744c5be2995753088a476aee4af1e3c6014ad Mon Sep 17 00:00:00 2001
|
||||
From: meizhigang <meizhigang@kylinsec.com.cn>
|
||||
Date: Fri, 21 Jul 2023 17:13:56 +0800
|
||||
Subject: [PATCH] fix(keyboard):Fix ci build error
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
- 修复ci编译报错
|
||||
---
|
||||
plugins/inputdevices/keyboard/keyboard-manager.cpp | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/plugins/inputdevices/keyboard/keyboard-manager.cpp b/plugins/inputdevices/keyboard/keyboard-manager.cpp
|
||||
index 734d310..40f24a1 100644
|
||||
--- a/plugins/inputdevices/keyboard/keyboard-manager.cpp
|
||||
+++ b/plugins/inputdevices/keyboard/keyboard-manager.cpp
|
||||
@@ -505,7 +505,7 @@ bool KeyboardManager::set_layouts(const std::vector<Glib::ustring> &layouts)
|
||||
if (join_layouts.length() <= 0)
|
||||
{
|
||||
join_layouts = DEFAULT_LAYOUT LAYOUT_JOIN_CHAR;
|
||||
- join_variants = LAYOUT_JOIN_CHAR;
|
||||
+ join_variants = std::string(LAYOUT_JOIN_CHAR);
|
||||
}
|
||||
|
||||
auto cmdline = fmt::format("{0} -layout {1} -variant {2}", SETXKBMAP, join_layouts, join_variants);
|
||||
--
|
||||
2.27.0
|
||||
|
||||
149
0001-fix-power-Add-battery-charging-and-discharging-time.patch
Normal file
149
0001-fix-power-Add-battery-charging-and-discharging-time.patch
Normal file
@ -0,0 +1,149 @@
|
||||
From 1296b7d210321c0ef14eb11a2c0cd76c0f51278f Mon Sep 17 00:00:00 2001
|
||||
From: meizhigang <meizhigang@kylinsec.com.cn>
|
||||
Date: Thu, 20 Jul 2023 17:17:16 +0800
|
||||
Subject: [PATCH] fix(power):Add battery charging and discharging time
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
- 添加电池充电和放电时间
|
||||
|
||||
Related #9506
|
||||
---
|
||||
plugins/power/tray/CMakeLists.txt | 3 ++-
|
||||
plugins/power/tray/po/zh_CN.po | 34 ++++++++++++++++++++++++++++++-
|
||||
plugins/power/tray/power-tray.cpp | 33 +++++++++++++++++++++++++++++-
|
||||
plugins/power/tray/power-tray.h | 3 +++
|
||||
4 files changed, 70 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/plugins/power/tray/CMakeLists.txt b/plugins/power/tray/CMakeLists.txt
|
||||
index f74aa08..353065d 100644
|
||||
--- a/plugins/power/tray/CMakeLists.txt
|
||||
+++ b/plugins/power/tray/CMakeLists.txt
|
||||
@@ -9,7 +9,8 @@ add_executable(
|
||||
${TARGET_NAME}
|
||||
${POWER_TRAY_H_FILES} ${POWER_TRAY_CPP_FILES}
|
||||
${PROJECT_SOURCE_DIR}/plugins/power/wrapper/power-upower.cpp
|
||||
- ${PROJECT_SOURCE_DIR}/plugins/power/wrapper/power-upower-device.cpp)
|
||||
+ ${PROJECT_SOURCE_DIR}/plugins/power/wrapper/power-upower-device.cpp
|
||||
+ ${PROJECT_SOURCE_DIR}/plugins/power/power-utils.cpp)
|
||||
|
||||
target_include_directories(${TARGET_NAME} PUBLIC ${GTKMM3_INCLUDE_DIRS})
|
||||
|
||||
diff --git a/plugins/power/tray/po/zh_CN.po b/plugins/power/tray/po/zh_CN.po
|
||||
index 436167c..377037d 100644
|
||||
--- a/plugins/power/tray/po/zh_CN.po
|
||||
+++ b/plugins/power/tray/po/zh_CN.po
|
||||
@@ -17,6 +17,38 @@ msgstr ""
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
|
||||
-#: ../power-tray.cpp:103
|
||||
+#: ../power-tray.cpp:132
|
||||
msgid "Remaining electricty: {0:.1f}%"
|
||||
msgstr "剩余电量:{0:.1f}%"
|
||||
+
|
||||
+#: ../power-tray.cpp:114
|
||||
+msgid "Remaining electricty: {0:.1f}%, approximately {1} until charged"
|
||||
+msgstr "剩余电量:{0:.1f}%,离充满大约{1}"
|
||||
+
|
||||
+#: ../power-tray.cpp:123
|
||||
+msgid "Remaining electricty: {0:.1f}%, approximately provides {1} runtime"
|
||||
+msgstr "剩余电量:{0:.1f}%,大约可使用{1}"
|
||||
+
|
||||
+#: ../plugins/power/power-utils.cpp:26
|
||||
+msgid "Less than 1 minute"
|
||||
+msgstr "小于1分钟"
|
||||
+
|
||||
+#: ../plugins/power/power-utils.cpp:30
|
||||
+msgid "{0} minute"
|
||||
+msgid_plural "{0} minutes"
|
||||
+msgstr[0] "{0}分钟"
|
||||
+
|
||||
+#: ../plugins/power/power-utils.cpp:38
|
||||
+msgid "{0} hour"
|
||||
+msgid_plural "{0} hours"
|
||||
+msgstr[0] "{0}小时"
|
||||
+
|
||||
+#: ../plugins/power/power-utils.cpp:44
|
||||
+msgid "hour"
|
||||
+msgid_plural "hours"
|
||||
+msgstr[0] "小时"
|
||||
+
|
||||
+#: ../plugins/power/power-utils.cpp:46
|
||||
+msgid "minute"
|
||||
+msgid_plural "minutes"
|
||||
+msgstr[0] "分钟"
|
||||
\ No newline at end of file
|
||||
diff --git a/plugins/power/tray/power-tray.cpp b/plugins/power/tray/power-tray.cpp
|
||||
index 69f9cee..3586f6c 100644
|
||||
--- a/plugins/power/tray/power-tray.cpp
|
||||
+++ b/plugins/power/tray/power-tray.cpp
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
#include <glib/gi18n.h>
|
||||
#include "plugins/power/wrapper/power-upower.h"
|
||||
+#include "plugins/power/power-utils.h"
|
||||
#include "power-i.h"
|
||||
|
||||
namespace Kiran
|
||||
@@ -98,11 +99,41 @@ void PowerTray::update_status_icon()
|
||||
}
|
||||
|
||||
// 对于电源和UPS设备需要显示电量
|
||||
- if (device_for_tray)
|
||||
+ this->update_status_icon_toolstip(device_for_tray);
|
||||
+}
|
||||
+
|
||||
+void PowerTray::update_status_icon_toolstip(std::shared_ptr<PowerUPowerDevice> device_for_tray)
|
||||
+{
|
||||
+ RETURN_IF_FALSE(device_for_tray);
|
||||
+
|
||||
+ switch (device_for_tray->get_props().state)
|
||||
+ {
|
||||
+ 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());
|
||||
+ 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());
|
||||
+ 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;
|
||||
+ }
|
||||
}
|
||||
|
||||
void PowerTray::delay_update_status_icon()
|
||||
diff --git a/plugins/power/tray/power-tray.h b/plugins/power/tray/power-tray.h
|
||||
index b496ba9..9a14a47 100644
|
||||
--- a/plugins/power/tray/power-tray.h
|
||||
+++ b/plugins/power/tray/power-tray.h
|
||||
@@ -35,6 +35,9 @@ public:
|
||||
// 更新托盘图标
|
||||
void update_status_icon();
|
||||
|
||||
+ // 更新托盘图标提示语
|
||||
+ void update_status_icon_toolstip(std::shared_ptr<PowerUPowerDevice> device_for_tray);
|
||||
+
|
||||
private:
|
||||
void init();
|
||||
|
||||
--
|
||||
2.27.0
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
Name: kiran-cc-daemon
|
||||
Version: 2.5.1
|
||||
Release: 15
|
||||
Release: 16
|
||||
Summary: DBus daemon for Kiran Desktop
|
||||
|
||||
License: MulanPSL-2.0
|
||||
@ -18,6 +18,8 @@ patch0009: 0001-fix-systeminfo-Adjusting-the-reading-method-of-cpu-i.patch
|
||||
Patch0010: 0001-feature-power-Compatiable-two-power-profile-daemon-w.patch
|
||||
Patch0011: 0001-fix-edid-Fix-the-problem-that-cannot-match-correct-m.patch
|
||||
Patch0012: 0001-fix-keyboard-Add-capslock-and-numlock-tips-switch.patch
|
||||
Patch0013: 0001-fix-power-Add-battery-charging-and-discharging-time.patch
|
||||
Patch0014: 0001-fix-keyboard-Fix-ci-build-error.patch
|
||||
|
||||
BuildRequires: cmake >= 3.2
|
||||
BuildRequires: pkgconfig(glibmm-2.4)
|
||||
@ -187,6 +189,10 @@ glib-compile-schemas /usr/share/glib-2.0/schemas &> /dev/nulls || :
|
||||
%{_libdir}/pkgconfig/kiran-cc-daemon.pc
|
||||
|
||||
%changelog
|
||||
* Fri Jul 21 2023 meizhigang <meizhigang@kylinsec.com.cn> - 2.5.1-16
|
||||
- KYOS-F: Add battery charging and discharging time (#9506)
|
||||
- KYOS-F: Fix ci build error
|
||||
|
||||
* Mon Jul 10 2023 meizhigang <meizhigang@kylinsec.com.cn> - 2.5.1-15
|
||||
- KYOS-F: Add capslock and numlock tips switch (#9379)
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user