mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 03:22:43 +00:00 
			
		
		
		
	ImageViewer: Add list of recently open files to the File menu :^)
This commit is contained in:
		
							parent
							
								
									5f23515796
								
							
						
					
					
						commit
						d0ba5f2ed7
					
				
					 3 changed files with 15 additions and 1 deletions
				
			
		|  | @ -8,6 +8,7 @@ | |||
| #include "MainWidget.h" | ||||
| #include "ViewWidget.h" | ||||
| #include <AK/URL.h> | ||||
| #include <LibConfig/Client.h> | ||||
| #include <LibCore/ArgsParser.h> | ||||
| #include <LibCore/System.h> | ||||
| #include <LibDesktop/Launcher.h> | ||||
|  | @ -40,6 +41,10 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) | |||
| 
 | ||||
|     auto app = TRY(GUI::Application::try_create(arguments)); | ||||
| 
 | ||||
|     Config::pledge_domain("ImageViewer"); | ||||
| 
 | ||||
|     app->set_config_domain(TRY(String::from_utf8("ImageViewer"sv))); | ||||
| 
 | ||||
|     TRY(Desktop::Launcher::add_allowed_handler_with_any_url("/bin/ImageViewer")); | ||||
|     TRY(Desktop::Launcher::add_allowed_handler_with_only_specific_urls("/bin/Help", { URL::create_with_file_scheme("/usr/share/man/man1/ImageViewer.md") })); | ||||
|     TRY(Desktop::Launcher::seal_allowlist()); | ||||
|  | @ -286,6 +291,13 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) | |||
|     TRY(file_menu->try_add_action(open_action)); | ||||
|     TRY(file_menu->try_add_action(delete_action)); | ||||
|     TRY(file_menu->try_add_separator()); | ||||
| 
 | ||||
|     TRY(file_menu->add_recent_files_list([&](auto& action) { | ||||
|         auto path = action.text(); | ||||
|         widget->set_path(path); | ||||
|         widget->load_from_file(path); | ||||
|     })); | ||||
| 
 | ||||
|     TRY(file_menu->try_add_action(quit_action)); | ||||
| 
 | ||||
|     auto image_menu = TRY(window->try_add_menu("&Image")); | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Andreas Kling
						Andreas Kling