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 display;
pub mod input; pub mod input;
pub mod networking; pub mod networking;
pub mod power;
pub mod sound; pub mod sound;
pub mod system; pub mod system;
pub mod time; pub mod time;
pub mod power;
#[derive(Clone, Debug)] #[derive(Clone, Debug)]
pub enum Message { pub enum Message {

View file

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