fix: cargo fmt

This commit is contained in:
Ashley Wulber 2024-05-22 15:48:40 -04:00 committed by Ashley Wulber
parent 0fb2611a4c
commit 2f54c11604
2 changed files with 32 additions and 33 deletions

View file

@ -7,10 +7,10 @@ pub mod desktop;
pub mod display;
pub mod input;
pub mod networking;
pub mod power;
pub mod sound;
pub mod system;
pub mod time;
pub mod power;
#[derive(Clone, Debug)]
pub enum Message {

View file

@ -1,7 +1,7 @@
use cosmic_settings_page::{self as page, section, Section};
use backend::PowerProfile;
use cosmic::iced::widget;
use cosmic::{widget::settings, Apply};
use cosmic_settings_page::{self as page, section, Section};
use slotmap::SlotMap;
pub mod backend;
@ -14,7 +14,7 @@ impl page::Page<crate::pages::Message> for Page {
page::Info::new("power", "battery-symbolic")
.title(fl!("power"))
.description(fl!("power", "desc"))
}
}
fn content(
&self,
@ -38,46 +38,45 @@ impl Page {
}
}
fn profiles() -> Section<crate::pages::Message> {
Section::default()
.title(fl!("power-profiles"))
.descriptions(vec![fl!("power", "desc").into()])
.view::<Page>(|_binder, page, section| {
let runtime = tokio::runtime::Runtime::new().unwrap();
.title(fl!("power-profiles"))
.descriptions(vec![fl!("power", "desc").into()])
.view::<Page>(|_binder, page, section| {
let runtime = tokio::runtime::Runtime::new().unwrap();
let profiles = backend::get_power_profiles();
let profiles = backend::get_power_profiles();
let current_profile = runtime.block_on(backend::get_current_power_profile());
let current_profile = runtime.block_on(backend::get_current_power_profile());
let mut section = settings::view_section(&section.title);
let mut section = settings::view_section(&section.title);
let mut widgets = Vec::new();
let mut widgets = Vec::new();
for profile in profiles {
let selected = if current_profile == profile {
Some(true)
} else {
None
};
for profile in profiles {
let selected = if current_profile == profile {
Some(true)
} else {
None
};
let widget = widget::Radio::new("", true, selected, |_| {
Message::PowerProfileChange(profile.clone())
});
let item = settings::item::builder(profile.title())
.description(profile.description())
.control(widget);
widgets.push(item);
}
let widget = widget::Radio::new("", true, selected, |_| {
Message::PowerProfileChange(profile.clone())
});
let item = settings::item::builder(profile.title())
.description(profile.description())
.control(widget);
widgets.push(item);
}
for item in widgets {
section = section.add(item);
}
for item in widgets {
section = section.add(item);
}
section
.apply(cosmic::Element::from)
.map(crate::pages::Message::Power)
})
section
.apply(cosmic::Element::from)
.map(crate::pages::Message::Power)
})
}
impl page::AutoBind<crate::pages::Message> for Page {}