1
1
use std:: path:: { Path , PathBuf } ;
2
2
use std:: time:: Duration ;
3
3
4
- use egui:: { CursorIcon , RichText , Ui } ;
4
+ use egui:: { CursorIcon , Label , RichText , Ui } ;
5
5
use egui_dock:: DockState ;
6
6
use rfd:: FileDialog ;
7
7
@@ -98,7 +98,12 @@ impl TemplateApp {
98
98
. filter ( |s| s. 1 . is_some ( ) )
99
99
. map ( |s| ( s. 0 , s. 1 . unwrap ( ) . to_string_lossy ( ) ) )
100
100
{
101
- if ui. button ( file. 1 ) . on_hover_cursor ( CursorIcon :: PointingHand ) . clicked ( ) {
101
+ if ui
102
+ . button ( file. 1 )
103
+ . on_hover_text ( file. 0 . to_string_lossy ( ) )
104
+ . on_hover_cursor ( CursorIcon :: PointingHand )
105
+ . clicked ( )
106
+ {
102
107
return Some ( file. 0 . to_path_buf ( ) ) ;
103
108
}
104
109
}
@@ -121,12 +126,20 @@ impl eframe::App for TemplateApp {
121
126
ui. close_menu ( ) ;
122
127
}
123
128
124
- ui. menu_button ( "Open Recent" , |ui| {
125
- if let Some ( ref file_to_open) = self . recent_file_menu ( ui) {
126
- self . open_file ( Some ( & file_to_open) ) ;
127
- ui. close_menu ( ) ;
128
- }
129
- } ) ;
129
+ if self . recent_files . is_empty ( ) {
130
+ ui. add_enabled ( false , Label :: new ( "Open Recent" ) ) ;
131
+ } else {
132
+ ui. menu_button ( "Open Recent" , |ui| {
133
+ if let Some ( ref file_to_open) = self . recent_file_menu ( ui) {
134
+ self . open_file ( Some ( & file_to_open) ) ;
135
+ ui. close_menu ( ) ;
136
+ }
137
+ } ) ;
138
+ }
139
+
140
+ if ui. button ( "Clear Recent Files" ) . clicked ( ) {
141
+ self . recent_files . clear ( ) ;
142
+ }
130
143
131
144
ui. separator ( ) ;
132
145
@@ -153,7 +166,7 @@ impl eframe::App for TemplateApp {
153
166
} ) ;
154
167
} ) ;
155
168
156
- if self . tree . main_surface ( ) . num_tabs ( ) > 0 {
169
+ if self . tree . main_surface ( ) . num_tabs ( ) > 0 {
157
170
egui_dock:: DockArea :: new ( & mut self . tree ) . show ( ctx, & mut LogViewTabViewer { } )
158
171
} else {
159
172
egui:: CentralPanel :: default ( ) . show ( ctx, |ui| {
0 commit comments