@@ -88,41 +88,65 @@ pub fn draw_quick_actions(ui: &mut egui::Ui, state: &mut HomeSettings) {
8888 egui:: ScrollArea :: vertical ( )
8989 . id_salt ( "quick_actions_scroll" )
9090 . show ( ui, |ui| {
91- for action in & state. quick_actions {
92- ui. push_id ( & action. id , |ui| {
93- let ( rect, response) = ui. allocate_exact_size ( item_size, egui:: Sense :: click ( ) ) ;
94-
95- let visuals = ui. style ( ) . interact ( & response) ;
96- if response. hovered ( ) || response. is_pointer_button_down_on ( ) {
97- ui. painter ( )
98- . rect_filled ( rect. shrink ( 2.0 ) , 6.0 , visuals. bg_fill ) ;
99- }
91+ action_button ( ui, item_size, icons:: regular:: FOLDER , "File(s)" , || {
92+ println ! ( "Files clicked" ) ;
93+ } ) ;
10094
101- let inner_rect = rect . shrink ( 6.0 ) ;
102-
103- ui . scope_builder ( egui :: UiBuilder :: new ( ) . max_rect ( inner_rect ) , |ui| {
104- ui . with_layout (
105- egui :: Layout :: top_down_justified ( egui :: Align :: Center ) ,
106- |ui | {
107- ui . add_space ( 2.0 ) ;
108- ui . label ( egui :: RichText :: new ( & action . icon ) . size ( 22.0 ) ) ;
109- ui . add (
110- egui :: Label :: new ( egui :: RichText :: new ( & action . label ) . small ( ) )
111- . wrap_mode ( egui :: TextWrapMode :: Truncate ) ,
112- ) ;
113- } ,
114- ) ;
115- } ) ;
95+ action_button (
96+ ui ,
97+ item_size ,
98+ icons :: regular :: PLUGS_CONNECTED ,
99+ "Connections" ,
100+ | | {
101+ println ! ( "Connections clicked" ) ;
102+ } ,
103+ ) ;
104+
105+ action_button ( ui , item_size , icons :: regular :: TERMINAL , "Terminal" , || {
106+ println ! ( "Terminal clicked" ) ;
107+ } ) ;
108+ } ) ;
109+ }
116110
117- if response. clicked ( ) {
118- println ! ( "Quick action clicked: {}" , action. id) ;
119- }
120- response. on_hover_text ( & action. label ) ;
111+ fn action_button (
112+ ui : & mut egui:: Ui ,
113+ size : egui:: Vec2 ,
114+ icon : & str ,
115+ label : & str ,
116+ on_click : impl FnOnce ( ) ,
117+ ) {
118+ ui. push_id ( format ! ( "quick_action_{}" , label. to_lowercase( ) ) , |ui| {
119+ let ( rect, response) = ui. allocate_exact_size ( size, egui:: Sense :: click ( ) ) ;
121120
122- ui. add_space ( 4.0 ) ;
123- } ) ;
124- }
121+ let visuals = ui. style ( ) . interact ( & response) ;
122+
123+ if response. hovered ( ) || response. is_pointer_button_down_on ( ) {
124+ ui. painter ( )
125+ . rect_filled ( rect. shrink ( 2.0 ) , 6.0 , visuals. bg_fill ) ;
126+ }
127+
128+ let inner_rect = rect. shrink ( 6.0 ) ;
129+
130+ ui. scope_builder ( egui:: UiBuilder :: new ( ) . max_rect ( inner_rect) , |ui| {
131+ ui. with_layout (
132+ egui:: Layout :: top_down_justified ( egui:: Align :: Center ) ,
133+ |ui| {
134+ ui. add_space ( 2.0 ) ;
135+ ui. label ( egui:: RichText :: new ( icon) . size ( 22.0 ) ) ;
136+ ui. add (
137+ egui:: Label :: new ( egui:: RichText :: new ( label) . small ( ) )
138+ . wrap_mode ( egui:: TextWrapMode :: Truncate ) ,
139+ ) ;
140+ } ,
141+ ) ;
125142 } ) ;
143+
144+ if response. clicked ( ) {
145+ on_click ( ) ;
146+ }
147+
148+ ui. add_space ( 4.0 ) ;
149+ } ) ;
126150}
127151
128152fn draw_recent_files ( ui : & mut egui:: Ui , state : & mut HomeSettings ) {
@@ -269,15 +293,17 @@ fn draw_favorite_folders(
269293 . id_salt ( folder. path . to_string_lossy ( ) )
270294 . open ( expand)
271295 . show ( ui, |ui| {
272- if ui
273- . add (
274- Button :: new ( RichText :: new ( icons:: regular:: TRASH ) . size ( 12.0 ) )
275- . small ( ) ,
276- )
277- . on_hover_text ( "Remove folder" )
278- . clicked ( )
279- {
280- remove_path = Some ( folder. path . clone ( ) ) ;
296+ if state. favorite_search . is_empty ( ) {
297+ if ui
298+ . add (
299+ Button :: new ( RichText :: new ( icons:: regular:: TRASH ) . size ( 12.0 ) )
300+ . small ( ) ,
301+ )
302+ . on_hover_text ( "Remove folder" )
303+ . clicked ( )
304+ {
305+ remove_path = Some ( folder. path . clone ( ) ) ;
306+ }
281307 }
282308
283309 for ( file_name, size_info) in & folder. files {
0 commit comments