mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 06:12:43 +00:00 
			
		
		
		
	Taskbar: Add a context menu to open clock settings from the clock widget
This commit is contained in:
		
							parent
							
								
									c64a5ccf29
								
							
						
					
					
						commit
						73fcaaeda4
					
				
					 2 changed files with 21 additions and 0 deletions
				
			
		|  | @ -6,10 +6,13 @@ | |||
| 
 | ||||
| #include "ClockWidget.h" | ||||
| #include <LibConfig/Client.h> | ||||
| #include <LibGUI/Action.h> | ||||
| #include <LibGUI/Menu.h> | ||||
| #include <LibGUI/Painter.h> | ||||
| #include <LibGUI/Process.h> | ||||
| #include <LibGUI/SeparatorWidget.h> | ||||
| #include <LibGUI/Window.h> | ||||
| #include <LibGfx/Bitmap.h> | ||||
| #include <LibGfx/Font/FontDatabase.h> | ||||
| #include <LibGfx/Palette.h> | ||||
| 
 | ||||
|  | @ -196,6 +199,22 @@ void ClockWidget::mousedown_event(GUI::MouseEvent& event) | |||
|     } | ||||
| } | ||||
| 
 | ||||
| void ClockWidget::context_menu_event(GUI::ContextMenuEvent& event) | ||||
| { | ||||
|     if (!m_context_menu) { | ||||
|         m_context_menu = GUI::Menu::construct(); | ||||
| 
 | ||||
|         auto settings_icon = MUST(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/settings.png"sv)); | ||||
|         auto open_clock_settings_action = GUI::Action::create("Clock &Settings", *settings_icon, [this](auto&) { | ||||
|             GUI::Process::spawn_or_show_error(window(), "/bin/ClockSettings"sv, Array { "--open-tab", "clock" }); | ||||
|         }); | ||||
| 
 | ||||
|         m_context_menu->add_action(open_clock_settings_action); | ||||
|     } | ||||
| 
 | ||||
|     m_context_menu->popup(event.screen_position()); | ||||
| } | ||||
| 
 | ||||
| void ClockWidget::open() | ||||
| { | ||||
|     jump_to_current_date(); | ||||
|  |  | |||
|  | @ -31,6 +31,7 @@ private: | |||
| 
 | ||||
|     virtual void paint_event(GUI::PaintEvent&) override; | ||||
|     virtual void mousedown_event(GUI::MouseEvent&) override; | ||||
|     virtual void context_menu_event(GUI::ContextMenuEvent&) override; | ||||
| 
 | ||||
|     void tick_clock() | ||||
|     { | ||||
|  | @ -52,6 +53,7 @@ private: | |||
|     RefPtr<GUI::Button> m_selected_calendar_button; | ||||
|     RefPtr<GUI::Button> m_jump_to_button; | ||||
|     RefPtr<GUI::Button> m_calendar_launcher; | ||||
|     RefPtr<GUI::Menu> m_context_menu; | ||||
|     RefPtr<Core::Timer> m_timer; | ||||
|     int m_time_width { 0 }; | ||||
|     Gfx::IntSize m_window_size { 158, 186 }; | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Timothy Flynn
						Timothy Flynn