fix: prevent time remaining showing 0 after unplugging
This commit is contained in:
parent
25064dff8a
commit
e55d59ed94
1 changed files with 12 additions and 10 deletions
|
|
@ -504,16 +504,18 @@ impl cosmic::Application for CosmicBatteryApplet {
|
||||||
} = theme::active().cosmic().spacing;
|
} = theme::active().cosmic().spacing;
|
||||||
|
|
||||||
let name = text::body(fl!("battery"));
|
let name = text::body(fl!("battery"));
|
||||||
let description = text::caption(if !self.on_battery {
|
let description = text::caption(
|
||||||
format!("{:.0}%", self.battery_percent)
|
if !self.on_battery || self.time_remaining == Duration::from_secs(0u64) {
|
||||||
} else {
|
format!("{:.0}%", self.battery_percent)
|
||||||
format!(
|
} else {
|
||||||
"{} {} ({:.0}%)",
|
format!(
|
||||||
format_duration(self.time_remaining),
|
"{} {} ({:.0}%)",
|
||||||
fl!("until-empty"),
|
format_duration(self.time_remaining),
|
||||||
self.battery_percent
|
fl!("until-empty"),
|
||||||
)
|
self.battery_percent
|
||||||
});
|
)
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
let mut content = vec![
|
let mut content = vec![
|
||||||
padded_control(
|
padded_control(
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue