mirror of
				https://github.com/dolphin-emu/dolphin.git
				synced 2025-10-26 09:59:15 +00:00 
			
		
		
		
	A new class that derives from `QMenu` has been introduced. Menus of this `NonAutodismissibleMenu` type will stay visible when a _checkable_ action is triggered. This is convenient in menus that feature a series of check boxes that toggle visibility of third components (e.g. the **List Columns** menu), allowing the user to toggle several actions at once. For now, the new type is used in the top menu bar.
		
			
				
	
	
		
			28 lines
		
	
	
	
		
			540 B
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			28 lines
		
	
	
	
		
			540 B
		
	
	
	
		
			C++
		
	
	
	
	
	
| // Copyright 2025 Dolphin Emulator Project
 | |
| // SPDX-License-Identifier: GPL-2.0-or-later
 | |
| 
 | |
| #include "DolphinQt/QtUtils/NonAutodismissibleMenu.h"
 | |
| 
 | |
| #include <QAction>
 | |
| #include <QMouseEvent>
 | |
| 
 | |
| namespace QtUtils
 | |
| {
 | |
| 
 | |
| void NonAutodismissibleMenu::mouseReleaseEvent(QMouseEvent* const event)
 | |
| {
 | |
|   if (!event)
 | |
|     return;
 | |
| 
 | |
|   QAction* const action{activeAction()};
 | |
|   if (action && action->isEnabled() && action->isCheckable())
 | |
|   {
 | |
|     action->trigger();
 | |
|     event->accept();
 | |
|     return;
 | |
|   }
 | |
| 
 | |
|   QMenu::mouseReleaseEvent(event);
 | |
| }
 | |
| 
 | |
| }  // namespace QtUtils
 |