Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions cosmic-settings/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -996,7 +996,7 @@ impl SettingsApp {
if section
.show_while
.as_ref()
.map_or(true, |func| func(model.as_ref()))
.is_none_or(|func| func(model.as_ref()))
{
sections_column.push(
(section.view_fn)(&self.pages, model.as_ref(), section)
Expand Down Expand Up @@ -1108,7 +1108,7 @@ impl SettingsApp {
if section
.show_while
.as_ref()
.map_or(true, |func| func(model.as_ref()))
.is_none_or(|func| func(model.as_ref()))
{
let section = (section.view_fn)(&self.pages, model.as_ref(), section)
.map(Message::PageMessage)
Expand Down
6 changes: 6 additions & 0 deletions cosmic-settings/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ pub struct Config {
state: cosmic_config::Config,
}

impl Default for Config {
fn default() -> Self {
Self::new()
}
}

impl Config {
pub fn new() -> Self {
let config = match cosmic_config::Config::new(NAME, 1) {
Expand Down
4 changes: 2 additions & 2 deletions cosmic-settings/src/pages/accessibility/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ pub fn vision() -> section::Section<crate::pages::Message> {
text::body(status_text).wrapping(Wrapping::Word),
page.wayland_available
.is_some()
.then_some(crate::pages::Message::Page(magnifier_entity).into()),
.then_some(crate::pages::Message::Page(magnifier_entity)),
)
})
.add(
Expand Down Expand Up @@ -270,7 +270,7 @@ pub fn vision() -> section::Section<crate::pages::Message> {
Some(page.screen_filter_selection as usize),
move |idx| {
let filter = ColorFilter::from_usize(idx).unwrap_or_default();
Message::SetScreenFilterSelection(filter).into()
Message::SetScreenFilterSelection(filter)
},
cosmic::iced::window::Id::RESERVED,
Message::Surface,
Expand Down
19 changes: 8 additions & 11 deletions cosmic-settings/src/pages/applications/default_apps.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,16 +187,13 @@ impl Page {
.iter()
.map(|m| m.essence_str())
.filter(|m| m.starts_with("audio"))
.chain(
[
"application/ogg",
"application/x-cue",
"application/x-ogg",
"audio/mp3",
"x-content/audio-cdda",
]
.into_iter(),
)
.chain([
"application/ogg",
"application/x-cue",
"application/x-ogg",
"audio/mp3",
"x-content/audio-cdda",
])
.collect();
&mime_types
}),
Expand Down Expand Up @@ -528,7 +525,7 @@ async fn load_defaults(assocs: &BTreeMap<Arc<str>, Arc<App>>, for_mimes: &[&str]

async fn xdg_mime_query_default(mime_type: &str) -> Option<String> {
let output = tokio::process::Command::new("xdg-mime")
.args(&["query", "default", mime_type])
.args(["query", "default", mime_type])
.output()
.await
.ok()?;
Expand Down
12 changes: 6 additions & 6 deletions cosmic-settings/src/pages/applications/startup_apps.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,9 @@ enum Context {
AddApplication(DirectoryType),
}

impl Into<Vec<PathBuf>> for DirectoryType {
fn into(self) -> Vec<PathBuf> {
match self {
impl From<DirectoryType> for Vec<PathBuf> {
fn from(val: DirectoryType) -> Self {
match val {
DirectoryType::User => vec![
dirs::config_dir()
.expect("config dir not found")
Expand Down Expand Up @@ -121,7 +121,7 @@ impl page::Page<crate::pages::Message> for Page {
Some(
cosmic::app::context_drawer(
self.add_application_context_view(directory_type.clone()),
crate::pages::Message::CloseContextDrawer.into(),
crate::pages::Message::CloseContextDrawer,
)
.title(fl!("startup-apps", "search-for-application"))
.header(search),
Expand Down Expand Up @@ -224,7 +224,7 @@ impl Page {
let directories: Vec<PathBuf> = directory_type.clone().into();

let directory_to_target =
directories.get(0).expect("Always at least one directory");
directories.first().expect("Always at least one directory");

_ = std::fs::create_dir_all(directory_to_target.as_path());

Expand Down Expand Up @@ -271,7 +271,7 @@ impl Page {
let directories: Vec<PathBuf> = directory_type.clone().into();

let directory_to_target =
directories.get(0).expect("Always at least one directory");
directories.first().expect("Always at least one directory");
if let Ok(exists) = std::fs::exists(directory_to_target.join(file_name.clone()))
{
if exists {
Expand Down
10 changes: 5 additions & 5 deletions cosmic-settings/src/pages/bluetooth/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -830,7 +830,7 @@ fn connected_devices() -> Section<crate::pages::Message> {
.model
.popup_device
.as_deref()
.map_or(false, |p| path.as_str() == p.as_str())
.is_some_and(|p| path.as_str() == p.as_str())
{
widget::popover(
widget::button::icon(widget::icon::from_name("view-more-symbolic"))
Expand Down Expand Up @@ -1012,29 +1012,29 @@ mod systemd {

pub fn activate_bluetooth() -> impl Future<Output = ()> + Send {
tokio::process::Command::new("pkexec")
.args(&["systemctl", "start", "bluetooth"])
.args(["systemctl", "start", "bluetooth"])
.status()
.map(|_| ())
}

pub fn enable_bluetooth() -> impl Future<Output = ()> + Send {
tokio::process::Command::new("pkexec")
.args(&["systemctl", "enable", "--now", "bluetooth"])
.args(["systemctl", "enable", "--now", "bluetooth"])
.status()
.map(|_| ())
}

pub fn is_bluetooth_enabled() -> bool {
std::process::Command::new("systemctl")
.args(&["is-enabled", "bluetooth"])
.args(["is-enabled", "bluetooth"])
.status()
.map(|status| status.success())
.unwrap_or(true)
}

pub fn is_bluetooth_active() -> bool {
std::process::Command::new("systemctl")
.args(&["is-active", "bluetooth"])
.args(["is-active", "bluetooth"])
.status()
.map(|status| status.success())
.unwrap_or(true)
Expand Down
4 changes: 2 additions & 2 deletions cosmic-settings/src/pages/desktop/appearance/drawer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ impl Content {
) -> Task<app::Message> {
match message {
FontMessage::FontLoaded(interface, mono) => {
return self.font_config.font_loaded(mono, interface);
self.font_config.font_loaded(mono, interface)
}
FontMessage::Search(input) => match context_view {
None => Task::none(),
Expand All @@ -141,7 +141,7 @@ impl Content {
return task;
}
}
return Task::none();
Task::none()
}
}
}
Expand Down
28 changes: 18 additions & 10 deletions cosmic-settings/src/pages/desktop/appearance/font_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,12 @@ pub fn load_font_families() -> (Vec<Arc<str>>, Vec<Arc<str>>) {
};

if face.monospaced {
if mono
.last()
.map_or(true, |name| &**name != font_name.as_str())
{
if mono.last().is_none_or(|name| &**name != font_name.as_str()) {
mono.push(Arc::from(font_name.as_str()));
}
} else if interface
.last()
.map_or(true, |name| &**name != font_name.as_str())
.is_none_or(|name| &**name != font_name.as_str())
{
interface.push(Arc::from(font_name.as_str()));
}
Expand Down Expand Up @@ -75,6 +72,12 @@ pub struct Model {
pub monospace_font: FontConfig,
}

impl Default for Model {
fn default() -> Self {
Self::new()
}
}

impl Model {
pub fn new() -> Model {
Model {
Expand Down Expand Up @@ -118,7 +121,7 @@ impl Model {
};

update_config(MONOSPACE_FONT, self.monospace_font.clone());
return None;
None
}
ContextView::SystemFont => {
self.interface_font = FontConfig {
Expand All @@ -131,9 +134,9 @@ impl Model {
tokio::spawn(async move {
set_gnome_font_name(font.as_ref()).await;
});
return None;
None
}
_ => return None,
_ => None,
}
}

Expand All @@ -148,7 +151,7 @@ impl Model {
fonts
.iter()
.filter(|f| f.to_lowercase().contains(&self.font_search))
.map(|f| f.clone())
.cloned()
.collect(),
);
}
Expand All @@ -175,7 +178,7 @@ impl Model {
callback: impl Fn(Arc<str>) -> super::Message,
) -> Element<'_, super::Message> {
let svg_accent = Rc::new(|theme: &cosmic::Theme| svg::Style {
color: Some(theme.cosmic().accent_color().into()),
color: Some(theme.cosmic().accent_text_color().into()),
});

let (mut families, current_font) = match *context_view {
Expand All @@ -195,6 +198,11 @@ impl Model {
list.add(
settings::item_row(vec![
widget::text::body(&**family)
.class(if selected {
cosmic::theme::Text::Accent
} else {
cosmic::theme::Text::Default
})
.wrapping(Wrapping::Word)
.width(cosmic::iced::Length::Fill)
.into(),
Expand Down
2 changes: 1 addition & 1 deletion cosmic-settings/src/pages/desktop/appearance/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ impl Page {
theme_staged = self
.theme_manager
.selected_customizer_mut()
.set_accent(Some(c).map(Srgb::from));
.set_accent(Some(Srgb::from(c)));
}

Message::Reset => {
Expand Down
31 changes: 14 additions & 17 deletions cosmic-settings/src/pages/desktop/appearance/mode_and_colors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ pub fn section() -> Section<crate::pages::Message> {

let mut section = settings::section()
.title(&section.title)
.add(theme_mode(&page, section, &label_keys))
.add(auto_switch(&page, section, &label_keys))
.add(accent_color_palette(&page, section, &label_keys))
.add(application_background(&page, section, &label_keys))
.add(container_background(&page, section, &label_keys))
.add(interface_text(&page, section, &label_keys))
.add(control_tint(&page, section, &label_keys))
.add(theme_mode(page, section, &label_keys))
.add(auto_switch(page, section, &label_keys))
.add(accent_color_palette(page, section, &label_keys))
.add(application_background(page, section, &label_keys))
.add(container_background(page, section, &label_keys))
.add(interface_text(page, section, &label_keys))
.add(control_tint(page, section, &label_keys))
.add(
settings::item::builder(&descriptions[label_keys["window_hint_toggle"]])
.toggler(
Expand Down Expand Up @@ -196,16 +196,13 @@ fn accent_color_palette<'a>(
let mut accent_palette_row = Vec::with_capacity(accent.len());

for &color in accent {
accent_palette_row.push(
color_button(
Some(Message::PaletteAccent(color.into())),
color.into(),
cur_accent == color,
48,
48,
)
.into(),
);
accent_palette_row.push(color_button(
Some(Message::PaletteAccent(color.into())),
color.into(),
cur_accent == color,
48,
48,
));
}

accent_palette_row.push(
Expand Down
10 changes: 5 additions & 5 deletions cosmic-settings/src/pages/desktop/appearance/theme_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ impl From<(Option<Config>, Option<Config>, Option<Vec<Srgba>>)> for ThemeCustomi
custom_window_hint: None,
};

if let None = customizer.accent_palette {
if customizer.accent_palette.is_none() {
let palette = customizer.builder.0.palette.as_ref();
customizer.accent_palette = Some(vec![
palette.accent_blue,
Expand Down Expand Up @@ -159,7 +159,7 @@ impl Default for Manager {
}

impl Manager {
pub fn build_theme<'a>(&mut self, stage: ThemeStaged) -> Task<app::Message> {
pub fn build_theme(&mut self, stage: ThemeStaged) -> Task<app::Message> {
macro_rules! theme_transaction {
($config:ident, $current_theme:ident, $new_theme:ident, { $($name:ident;)+ }) => {
let tx = $config.transaction();
Expand Down Expand Up @@ -194,10 +194,10 @@ impl Manager {
None
};

let mut data = std::iter::once(current).chain(other.into_iter());
let mut data = std::iter::once(current).chain(other);

cosmic::task::future(async move {
while let Some((builder, config)) = data.next() {
for (builder, config) in data.by_ref() {
if let Some(config) = config {
let current_theme = match Theme::get_entry(&config) {
Ok(theme) => theme,
Expand Down Expand Up @@ -277,7 +277,7 @@ impl Manager {

#[inline]
pub fn custom_window_hint(&self) -> &Option<Srgb> {
&self.selected_customizer().custom_window_hint()
self.selected_customizer().custom_window_hint()
}

#[inline]
Expand Down
2 changes: 1 addition & 1 deletion cosmic-settings/src/pages/desktop/dock/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ impl Page {
}
Message::Inner(inner) => {
if let inner::Message::Surface(a) = inner {
return cosmic::task::message(crate::app::Message::Surface(a));
cosmic::task::message(crate::app::Message::Surface(a))
} else {
self.inner
.update(inner)
Expand Down
8 changes: 4 additions & 4 deletions cosmic-settings/src/pages/desktop/panel/applets_inner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -590,7 +590,7 @@ impl Applet<'static> {
}
}

impl<'a> Applet<'a> {
impl Applet<'_> {
fn into_owned(self) -> Applet<'static> {
Applet {
id: Cow::from(self.id.into_owned()),
Expand Down Expand Up @@ -641,7 +641,7 @@ impl<'a, Message: 'static + Clone> AppletReorderList<'a, Message> {
.into_iter()
.map(|info| {
let id_clone = info.id.to_string();
let is_dragged = active_dnd.as_ref().map_or(false, |dnd| dnd.id == info.id);
let is_dragged = active_dnd.as_ref().is_some_and(|dnd| dnd.id == info.id);

let content = if is_dragged {
row::with_capacity(0).height(Length::Fixed(32.0))
Expand Down Expand Up @@ -859,8 +859,8 @@ pub fn dnd_icon(info: Applet<'static>, layout: &layout::Layout) -> AppletReorder
}
}

impl<'a, Message: 'static> Widget<Message, cosmic::Theme, cosmic::Renderer>
for AppletReorderList<'a, Message>
impl<Message: 'static> Widget<Message, cosmic::Theme, cosmic::Renderer>
for AppletReorderList<'_, Message>
where
Message: Clone,
{
Expand Down
Loading