From 7dfc7184b1081aa4043771ed82bf4c2b70f06525 Mon Sep 17 00:00:00 2001 From: Kirill Bulatov Date: Tue, 9 Apr 2024 22:51:59 +0200 Subject: [PATCH] Use task icons for all kinds of tasks (#10333) image image Release Notes: - Added more icons to task modal --- crates/tasks_ui/src/modal.rs | 40 +++++++++++++++----------------- crates/ui/src/components/icon.rs | 2 ++ 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/crates/tasks_ui/src/modal.rs b/crates/tasks_ui/src/modal.rs index 19571a9b6d..4c0a4d0e38 100644 --- a/crates/tasks_ui/src/modal.rs +++ b/crates/tasks_ui/src/modal.rs @@ -284,29 +284,27 @@ impl PickerDelegate for TasksModalDelegate { let candidates = self.candidates.as_ref()?; let hit = &self.matches[ix]; let (source_kind, _) = &candidates[hit.candidate_id]; - let language_name = if let TaskSourceKind::Language { name } = source_kind { - Some(name) - } else { - None - }; let highlighted_location = HighlightedText { text: hit.string.clone(), highlight_positions: hit.positions.clone(), char_count: hit.string.chars().count(), }; - let language_icon = language_name - .and_then(|language| { - let language = language.to_lowercase(); - file_icons::FileIcons::get(cx).get_type_icon(&language) - }) - .map(|icon_path| Icon::from_path(icon_path)); + let base_item = ListItem::new(SharedString::from(format!("tasks-modal-{ix}"))) + .inset(true) + .spacing(ListItemSpacing::Sparse); + let icon = match source_kind { + TaskSourceKind::UserInput => Some(Icon::new(IconName::Terminal)), + TaskSourceKind::AbsPath { .. } => Some(Icon::new(IconName::Settings)), + TaskSourceKind::Worktree { .. } => Some(Icon::new(IconName::FileTree)), + TaskSourceKind::Language { name } => file_icons::FileIcons::get(cx) + .get_type_icon(&name.to_lowercase()) + .map(|icon_path| Icon::from_path(icon_path)), + }; Some( - ListItem::new(SharedString::from(format!("tasks-modal-{ix}"))) - .inset(true) - .spacing(ListItemSpacing::Sparse) - .map(|this| { - let this = if matches!(source_kind, TaskSourceKind::UserInput) { + base_item + .map(|item| { + let item = if matches!(source_kind, TaskSourceKind::UserInput) { let task_index = hit.candidate_id; let delete_button = div().child( IconButton::new("delete", IconName::Close) @@ -323,14 +321,14 @@ impl PickerDelegate for TasksModalDelegate { })) .tooltip(|cx| Tooltip::text("Delete an one-shot task", cx)), ); - this.end_hover_slot(delete_button) + item.end_hover_slot(delete_button) } else { - this + item }; - if let Some(icon) = language_icon { - this.end_slot(icon) + if let Some(icon) = icon { + item.end_slot(icon) } else { - this + item } }) .selected(selected) diff --git a/crates/ui/src/components/icon.rs b/crates/ui/src/components/icon.rs index e637c64b8c..63a440253f 100644 --- a/crates/ui/src/components/icon.rs +++ b/crates/ui/src/components/icon.rs @@ -104,6 +104,7 @@ pub enum IconName { Return, ReplyArrowRight, ReplyArrowLeft, + Settings, Screen, SelectAll, Shift, @@ -200,6 +201,7 @@ impl IconName { IconName::Return => "icons/return.svg", IconName::ReplyArrowRight => "icons/reply_arrow_right.svg", IconName::ReplyArrowLeft => "icons/reply_arrow_left.svg", + IconName::Settings => "icons/file_icons/settings.svg", IconName::Screen => "icons/desktop.svg", IconName::SelectAll => "icons/select_all.svg", IconName::Shift => "icons/shift.svg",