mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 15:42:44 +00:00 
			
		
		
		
	GDialog: If no parent window is provided, center dialog on screen.
This commit is contained in:
		
							parent
							
								
									3a2f10fbbe
								
							
						
					
					
						commit
						9d2b46f396
					
				
					 1 changed files with 5 additions and 2 deletions
				
			
		|  | @ -1,5 +1,6 @@ | |||
| #include <LibGUI/GDialog.h> | ||||
| #include <LibGUI/GEventLoop.h> | ||||
| #include <LibGUI/GDesktop.h> | ||||
| 
 | ||||
| GDialog::GDialog(CObject* parent) | ||||
|     : GWindow(parent) | ||||
|  | @ -16,12 +17,14 @@ int GDialog::exec() | |||
| { | ||||
|     ASSERT(!m_event_loop); | ||||
|     m_event_loop = make<GEventLoop>(); | ||||
|     auto new_rect = rect(); | ||||
|     if (parent() && parent()->is_window()) { | ||||
|         auto& parent_window = *static_cast<GWindow*>(parent()); | ||||
|         auto new_rect = rect(); | ||||
|         new_rect.center_within(parent_window.rect()); | ||||
|         set_rect(new_rect); | ||||
|     } else { | ||||
|         new_rect.center_within(GDesktop::the().rect()); | ||||
|     } | ||||
|     set_rect(new_rect); | ||||
|     show(); | ||||
|     auto result = m_event_loop->exec(); | ||||
|     m_event_loop = nullptr; | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Andreas Kling
						Andreas Kling