mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 14:42:44 +00:00 
			
		
		
		
	Userland: Add GUI::Window::add_menu() and use it everywhere
Applications previously had to create a GUI::Menubar object, add menus to it, and then call GUI::Window::set_menubar(). This patch introduces GUI::Window::add_menu() which creates the menubar automatically and adds items to it. Application code becomes slightly simpler as a result. :^)
This commit is contained in:
		
							parent
							
								
									a4fdb7f029
								
							
						
					
					
						commit
						687a12d7fb
					
				
					 58 changed files with 187 additions and 311 deletions
				
			
		|  | @ -309,8 +309,7 @@ int main(int argc, char** argv) | |||
|         }, | ||||
|         &process_table_view); | ||||
| 
 | ||||
|     auto menubar = GUI::Menubar::construct(); | ||||
|     auto& file_menu = menubar->add_menu("&File"); | ||||
|     auto& file_menu = window->add_menu("&File"); | ||||
|     file_menu.add_action(GUI::CommonActions::make_quit_action([](auto&) { | ||||
|         GUI::Application::the()->quit(); | ||||
|     })); | ||||
|  | @ -328,7 +327,7 @@ int main(int argc, char** argv) | |||
|             process_context_menu->popup(event.screen_position(), process_properties_action); | ||||
|     }; | ||||
| 
 | ||||
|     auto& frequency_menu = menubar->add_menu("F&requency"); | ||||
|     auto& frequency_menu = window->add_menu("F&requency"); | ||||
|     GUI::ActionGroup frequency_action_group; | ||||
|     frequency_action_group.set_exclusive(true); | ||||
| 
 | ||||
|  | @ -346,11 +345,9 @@ int main(int argc, char** argv) | |||
|     make_frequency_action(3, true); | ||||
|     make_frequency_action(5); | ||||
| 
 | ||||
|     auto& help_menu = menubar->add_menu("&Help"); | ||||
|     auto& help_menu = window->add_menu("&Help"); | ||||
|     help_menu.add_action(GUI::CommonActions::make_about_action("System Monitor", app_icon, window)); | ||||
| 
 | ||||
|     window->set_menubar(move(menubar)); | ||||
| 
 | ||||
|     process_table_view.on_activation = [&](auto&) { | ||||
|         if (process_properties_action->is_enabled()) | ||||
|             process_properties_action->activate(); | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Andreas Kling
						Andreas Kling