mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 12:52:44 +00:00 
			
		
		
		
	LibGUI+Notification: Add mutable notifications
This commit puts all of the remaining pieces in place. This adds a mechanism to update the text, title, and icon of an image. If an image is not provided, the default ladybug will be shown.
This commit is contained in:
		
							parent
							
								
									147a2c4ca2
								
							
						
					
					
						commit
						8f6894d250
					
				
					 7 changed files with 119 additions and 7 deletions
				
			
		|  | @ -28,20 +28,17 @@ | |||
| #include <AK/HashMap.h> | ||||
| #include <AK/Vector.h> | ||||
| #include <LibGUI/BoxLayout.h> | ||||
| #include <LibGUI/Button.h> | ||||
| #include <LibGUI/Desktop.h> | ||||
| #include <LibGUI/Icon.h> | ||||
| #include <LibGUI/Label.h> | ||||
| #include <LibGUI/Widget.h> | ||||
| #include <LibGfx/Bitmap.h> | ||||
| #include <LibGfx/Font.h> | ||||
| #include <LibGfx/FontDatabase.h> | ||||
| #include <LibGfx/ShareableBitmap.h> | ||||
| 
 | ||||
| namespace NotificationServer { | ||||
| 
 | ||||
| static HashMap<u32, RefPtr<NotificationWindow>> s_windows; | ||||
| static const Gfx::Bitmap* default_image = GUI::Icon::default_icon("ladybug").bitmap_for_size(16); | ||||
| static const Gfx::Bitmap* default_image = Gfx::Bitmap::load_from_file("/res/icons/32x32/ladybug.png"); | ||||
| 
 | ||||
| void update_notification_window_locations() | ||||
| { | ||||
|  | @ -133,4 +130,19 @@ RefPtr<NotificationWindow> NotificationWindow::get_window_by_id(i32 id) | |||
|     return window.value_or(nullptr); | ||||
| } | ||||
| 
 | ||||
| void NotificationWindow::set_text(const String& value) | ||||
| { | ||||
|     m_text_label->set_text(value); | ||||
| } | ||||
| 
 | ||||
| void NotificationWindow::set_title(const String& value) | ||||
| { | ||||
|     m_title_label->set_text(value); | ||||
| } | ||||
| 
 | ||||
| void NotificationWindow::set_image(const Gfx::ShareableBitmap& image) | ||||
| { | ||||
|     m_image->set_bitmap(image.is_valid() ? image.bitmap() : default_image); | ||||
| } | ||||
| 
 | ||||
| } | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Nick Johnson
						Nick Johnson