@@ -71,6 +71,7 @@ pub struct AppConfig {
71
71
pub rebuild_on_changes : bool ,
72
72
pub auto_update_check : bool ,
73
73
pub watch_patterns : Vec < Glob > ,
74
+ pub recent_projects : Vec < PathBuf > ,
74
75
75
76
#[ serde( skip) ]
76
77
pub objects : Vec < ProjectObject > ,
@@ -102,6 +103,7 @@ impl Default for AppConfig {
102
103
rebuild_on_changes : true ,
103
104
auto_update_check : true ,
104
105
watch_patterns : DEFAULT_WATCH_PATTERNS . iter ( ) . map ( |s| Glob :: new ( s) . unwrap ( ) ) . collect ( ) ,
106
+ recent_projects : vec ! [ ] ,
105
107
objects : vec ! [ ] ,
106
108
object_nodes : vec ! [ ] ,
107
109
watcher_change : false ,
@@ -115,6 +117,11 @@ impl Default for AppConfig {
115
117
116
118
impl AppConfig {
117
119
pub fn set_project_dir ( & mut self , path : PathBuf ) {
120
+ self . recent_projects . retain ( |p| p != & path) ;
121
+ if self . recent_projects . len ( ) > 9 {
122
+ self . recent_projects . truncate ( 9 ) ;
123
+ }
124
+ self . recent_projects . insert ( 0 , path. clone ( ) ) ;
118
125
self . project_dir = Some ( path) ;
119
126
self . target_obj_dir = None ;
120
127
self . base_obj_dir = None ;
@@ -351,6 +358,23 @@ impl eframe::App for App {
351
358
egui:: TopBottomPanel :: top ( "top_panel" ) . show ( ctx, |ui| {
352
359
egui:: menu:: bar ( ui, |ui| {
353
360
ui. menu_button ( "File" , |ui| {
361
+ let recent_projects = if let Ok ( guard) = config. read ( ) {
362
+ guard. recent_projects . clone ( )
363
+ } else {
364
+ vec ! [ ]
365
+ } ;
366
+ if recent_projects. is_empty ( ) {
367
+ ui. add_enabled ( false , egui:: Button :: new ( "Recent Projects…" ) ) ;
368
+ } else {
369
+ ui. menu_button ( "Recent Projects…" , |ui| {
370
+ for path in recent_projects {
371
+ if ui. button ( format ! ( "{}" , path. display( ) ) ) . clicked ( ) {
372
+ config. write ( ) . unwrap ( ) . set_project_dir ( path) ;
373
+ ui. close_menu ( ) ;
374
+ }
375
+ }
376
+ } ) ;
377
+ }
354
378
if ui. button ( "Appearance…" ) . clicked ( ) {
355
379
* show_appearance_config = !* show_appearance_config;
356
380
ui. close_menu ( ) ;
0 commit comments