mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 16:52: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
				
			
		|  | @ -12,4 +12,4 @@ set(SOURCES | |||
| ) | ||||
| 
 | ||||
| serenity_app(ImageViewer ICON filetype-image) | ||||
| target_link_libraries(ImageViewer PRIVATE LibCore LibDesktop LibGUI LibGfx LibImageDecoderClient LibMain) | ||||
| target_link_libraries(ImageViewer PRIVATE LibCore LibDesktop LibGUI LibGfx LibConfig LibImageDecoderClient LibMain) | ||||
|  |  | |||
|  | @ -16,6 +16,7 @@ | |||
| #include <LibCore/MappedFile.h> | ||||
| #include <LibCore/MimeData.h> | ||||
| #include <LibCore/Timer.h> | ||||
| #include <LibGUI/Application.h> | ||||
| #include <LibGUI/MessageBox.h> | ||||
| #include <LibGfx/Bitmap.h> | ||||
| #include <LibGfx/Orientation.h> | ||||
|  | @ -196,6 +197,7 @@ void ViewWidget::load_from_file(DeprecatedString const& path) | |||
|     } | ||||
| 
 | ||||
|     m_path = Core::DeprecatedFile::real_path_for(path); | ||||
|     GUI::Application::the()->set_most_recently_open_file(String::from_utf8(path).release_value_but_fixme_should_propagate_errors()); | ||||
|     reset_view(); | ||||
| } | ||||
| 
 | ||||
|  |  | |||
|  | @ -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