chore(clippy): config, dialog, menu
Fixes Clippy lints for: * src/config.rs * src/dialog.rs * src/menu.rs
This commit is contained in:
parent
8ff54d1522
commit
dddfc8a673
3 changed files with 41 additions and 51 deletions
|
|
@ -68,7 +68,7 @@ impl Favorite {
|
||||||
Self::Videos,
|
Self::Videos,
|
||||||
] {
|
] {
|
||||||
if let Some(favorite_path) = favorite.path_opt() {
|
if let Some(favorite_path) = favorite.path_opt() {
|
||||||
if &favorite_path == &path {
|
if favorite_path == path {
|
||||||
return favorite.clone();
|
return favorite.clone();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -157,13 +157,15 @@ impl<M: Send + 'static> Dialog<M> {
|
||||||
|
|
||||||
let (config_handler, config) = Config::load();
|
let (config_handler, config) = Config::load();
|
||||||
|
|
||||||
let mut settings = window::Settings::default();
|
let mut settings = window::Settings {
|
||||||
settings.decorations = false;
|
decorations: false,
|
||||||
settings.exit_on_close_request = false;
|
exit_on_close_request: false,
|
||||||
settings.min_size = Some(Size::new(360.0, 180.0));
|
min_size: Some(Size::new(360.0, 180.0)),
|
||||||
settings.resizable = true;
|
resizable: true,
|
||||||
settings.size = Size::new(1024.0, 640.0);
|
size: Size::new(1024.0, 640.0),
|
||||||
settings.transparent = true;
|
transparent: true,
|
||||||
|
..Default::default()
|
||||||
|
};
|
||||||
|
|
||||||
#[cfg(target_os = "linux")]
|
#[cfg(target_os = "linux")]
|
||||||
{
|
{
|
||||||
|
|
@ -296,6 +298,7 @@ struct Flags {
|
||||||
kind: DialogKind,
|
kind: DialogKind,
|
||||||
path_opt: Option<PathBuf>,
|
path_opt: Option<PathBuf>,
|
||||||
window_id: window::Id,
|
window_id: window::Id,
|
||||||
|
#[expect(dead_code)]
|
||||||
config_handler: Option<cosmic_config::Config>,
|
config_handler: Option<cosmic_config::Config>,
|
||||||
config: Config,
|
config: Config,
|
||||||
}
|
}
|
||||||
|
|
@ -324,6 +327,7 @@ enum Message {
|
||||||
SearchActivate,
|
SearchActivate,
|
||||||
SearchClear,
|
SearchClear,
|
||||||
SearchInput(String),
|
SearchInput(String),
|
||||||
|
#[allow(clippy::enum_variant_names)]
|
||||||
TabMessage(tab::Message),
|
TabMessage(tab::Message),
|
||||||
TabRescan(Location, Option<tab::Item>, Vec<tab::Item>),
|
TabRescan(Location, Option<tab::Item>, Vec<tab::Item>),
|
||||||
TabView(tab::View),
|
TabView(tab::View),
|
||||||
|
|
@ -598,7 +602,7 @@ impl App {
|
||||||
.data(Location::Recents)
|
.data(Location::Recents)
|
||||||
});
|
});
|
||||||
|
|
||||||
for (_favorite_i, favorite) in self.flags.config.favorites.iter().enumerate() {
|
for favorite in self.flags.config.favorites.iter() {
|
||||||
if let Some(path) = favorite.path_opt() {
|
if let Some(path) = favorite.path_opt() {
|
||||||
let name = if matches!(favorite, Favorite::Home) {
|
let name = if matches!(favorite, Favorite::Home) {
|
||||||
fl!("home")
|
fl!("home")
|
||||||
|
|
@ -974,11 +978,8 @@ impl Application for App {
|
||||||
ContextPage::Preview(..) => self.core.window.show_context,
|
ContextPage::Preview(..) => self.core.window.show_context,
|
||||||
_ => false,
|
_ => false,
|
||||||
};
|
};
|
||||||
elements.push(
|
elements
|
||||||
menu::dialog_menu(&self.tab, &self.key_binds, show_details)
|
.push(menu::dialog_menu(&self.tab, &self.key_binds, show_details).map(Message::from));
|
||||||
.map(Message::from)
|
|
||||||
.into(),
|
|
||||||
);
|
|
||||||
|
|
||||||
elements
|
elements
|
||||||
}
|
}
|
||||||
|
|
@ -1027,7 +1028,7 @@ impl Application for App {
|
||||||
return self.update(message);
|
return self.update(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(data) = self.nav_model.data::<MounterData>(entity).clone() {
|
if let Some(data) = self.nav_model.data::<MounterData>(entity) {
|
||||||
if let Some(mounter) = MOUNTERS.get(&data.0) {
|
if let Some(mounter) = MOUNTERS.get(&data.0) {
|
||||||
return mounter.mount(data.1.clone()).map(|_| message::none());
|
return mounter.mount(data.1.clone()).map(|_| message::none());
|
||||||
}
|
}
|
||||||
|
|
@ -1169,11 +1170,9 @@ impl Application for App {
|
||||||
let mut still_mounted = false;
|
let mut still_mounted = false;
|
||||||
for item in mounter_items.iter() {
|
for item in mounter_items.iter() {
|
||||||
if let Some(path) = item.path() {
|
if let Some(path) = item.path() {
|
||||||
if path == old_path {
|
if path == old_path && item.is_mounted() {
|
||||||
if item.is_mounted() {
|
still_mounted = true;
|
||||||
still_mounted = true;
|
break;
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1221,7 +1220,7 @@ impl Application for App {
|
||||||
let mut contains_change = false;
|
let mut contains_change = false;
|
||||||
for event in events.iter() {
|
for event in events.iter() {
|
||||||
for event_path in event.paths.iter() {
|
for event_path in event.paths.iter() {
|
||||||
if event_path.starts_with(&path) {
|
if event_path.starts_with(path) {
|
||||||
match event.kind {
|
match event.kind {
|
||||||
notify::EventKind::Modify(
|
notify::EventKind::Modify(
|
||||||
notify::event::ModifyKind::Metadata(_),
|
notify::event::ModifyKind::Metadata(_),
|
||||||
|
|
@ -1235,14 +1234,14 @@ impl Application for App {
|
||||||
for item in items.iter_mut() {
|
for item in items.iter_mut() {
|
||||||
if item.path_opt() == Some(event_path) {
|
if item.path_opt() == Some(event_path) {
|
||||||
//TODO: reload more, like mime types?
|
//TODO: reload more, like mime types?
|
||||||
match fs::metadata(&event_path) {
|
match fs::metadata(event_path) {
|
||||||
Ok(new_metadata) => {
|
Ok(new_metadata) => {
|
||||||
match &mut item.metadata {
|
if let ItemMetadata::Path {
|
||||||
ItemMetadata::Path {
|
metadata,
|
||||||
metadata,
|
..
|
||||||
..
|
} = &mut item.metadata
|
||||||
} => *metadata = new_metadata,
|
{
|
||||||
_ => {}
|
*metadata = new_metadata;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
|
|
@ -1322,12 +1321,9 @@ impl Application for App {
|
||||||
|
|
||||||
// If we are in directory mode, return the current directory
|
// If we are in directory mode, return the current directory
|
||||||
if self.flags.kind.is_dir() {
|
if self.flags.kind.is_dir() {
|
||||||
match &self.tab.location {
|
if let Location::Path(tab_path) = &self.tab.location {
|
||||||
Location::Path(tab_path) => {
|
self.result_opt = Some(DialogResult::Open(vec![tab_path.clone()]));
|
||||||
self.result_opt = Some(DialogResult::Open(vec![tab_path.clone()]));
|
return window::close(self.flags.window_id);
|
||||||
return window::close(self.flags.window_id);
|
|
||||||
}
|
|
||||||
_ => {}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1344,7 +1340,7 @@ impl Application for App {
|
||||||
if let DialogKind::SaveFile { filename } = &self.flags.kind {
|
if let DialogKind::SaveFile { filename } = &self.flags.kind {
|
||||||
if !filename.is_empty() {
|
if !filename.is_empty() {
|
||||||
if let Some(tab_path) = self.tab.location.path_opt() {
|
if let Some(tab_path) = self.tab.location.path_opt() {
|
||||||
let path = tab_path.join(&filename);
|
let path = tab_path.join(filename);
|
||||||
if path.is_dir() {
|
if path.is_dir() {
|
||||||
// cd to directory
|
// cd to directory
|
||||||
let message = Message::TabMessage(tab::Message::Location(
|
let message = Message::TabMessage(tab::Message::Location(
|
||||||
|
|
@ -1592,11 +1588,7 @@ impl Application for App {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
col = col.push(
|
col = col.push(self.tab.view(&self.key_binds).map(Message::TabMessage));
|
||||||
self.tab
|
|
||||||
.view(&self.key_binds)
|
|
||||||
.map(move |message| Message::TabMessage(message)),
|
|
||||||
);
|
|
||||||
|
|
||||||
col.into()
|
col.into()
|
||||||
}
|
}
|
||||||
|
|
|
||||||
20
src/menu.rs
20
src/menu.rs
|
|
@ -89,7 +89,7 @@ pub fn context_menu<'a>(
|
||||||
let mut selected_trash_only = false;
|
let mut selected_trash_only = false;
|
||||||
let mut selected_desktop_entry = None;
|
let mut selected_desktop_entry = None;
|
||||||
let mut selected_types: Vec<Mime> = vec![];
|
let mut selected_types: Vec<Mime> = vec![];
|
||||||
tab.items_opt().map(|items| {
|
if let Some(items) = tab.items_opt() {
|
||||||
for item in items.iter() {
|
for item in items.iter() {
|
||||||
if item.selected {
|
if item.selected {
|
||||||
selected += 1;
|
selected += 1;
|
||||||
|
|
@ -110,7 +110,7 @@ pub fn context_menu<'a>(
|
||||||
selected_types.push(item.mime.clone());
|
selected_types.push(item.mime.clone());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
};
|
||||||
selected_types.sort_unstable();
|
selected_types.sort_unstable();
|
||||||
selected_types.dedup();
|
selected_types.dedup();
|
||||||
selected_trash_only = selected_trash_only && selected == 1;
|
selected_trash_only = selected_trash_only && selected == 1;
|
||||||
|
|
@ -342,7 +342,7 @@ pub fn context_menu<'a>(
|
||||||
.into()
|
.into()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn dialog_menu<'a>(
|
pub fn dialog_menu(
|
||||||
tab: &Tab,
|
tab: &Tab,
|
||||||
key_binds: &HashMap<KeyBind, Action>,
|
key_binds: &HashMap<KeyBind, Action>,
|
||||||
show_details: bool,
|
show_details: bool,
|
||||||
|
|
@ -359,15 +359,13 @@ pub fn dialog_menu<'a>(
|
||||||
let in_trash = tab.location == Location::Trash;
|
let in_trash = tab.location == Location::Trash;
|
||||||
|
|
||||||
let mut selected_gallery = 0;
|
let mut selected_gallery = 0;
|
||||||
tab.items_opt().map(|items| {
|
if let Some(items) = tab.items_opt() {
|
||||||
for item in items.iter() {
|
for item in items.iter() {
|
||||||
if item.selected {
|
if item.selected && item.can_gallery() {
|
||||||
if item.can_gallery() {
|
selected_gallery += 1;
|
||||||
selected_gallery += 1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
};
|
||||||
|
|
||||||
MenuBar::new(vec![
|
MenuBar::new(vec![
|
||||||
menu::Tree::with_children(
|
menu::Tree::with_children(
|
||||||
|
|
@ -504,7 +502,7 @@ pub fn menu_bar<'a>(
|
||||||
let mut selected_dir = 0;
|
let mut selected_dir = 0;
|
||||||
let mut selected = 0;
|
let mut selected = 0;
|
||||||
let mut selected_gallery = 0;
|
let mut selected_gallery = 0;
|
||||||
tab_opt.and_then(|tab| tab.items_opt()).map(|items| {
|
if let Some(items) = tab_opt.and_then(|tab| tab.items_opt()) {
|
||||||
for item in items.iter() {
|
for item in items.iter() {
|
||||||
if item.selected {
|
if item.selected {
|
||||||
selected += 1;
|
selected += 1;
|
||||||
|
|
@ -516,7 +514,7 @@ pub fn menu_bar<'a>(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
};
|
||||||
|
|
||||||
MenuBar::new(vec![
|
MenuBar::new(vec![
|
||||||
menu::Tree::with_children(
|
menu::Tree::with_children(
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue