mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 15:22:43 +00:00 
			
		
		
		
	 9906f41e01
			
		
	
	
		9906f41e01
		
	
	
	
	
		
			
			Adding a context menu which lists configured keymaps and allows setting the active keymap
		
			
				
	
	
		
			34 lines
		
	
	
	
		
			721 B
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			34 lines
		
	
	
	
		
			721 B
		
	
	
	
		
			C++
		
	
	
	
	
	
| /*
 | |
|  * Copyright (c) 2022, the SerenityOS developers.
 | |
|  *
 | |
|  * SPDX-License-Identifier: BSD-2-Clause
 | |
|  */
 | |
| 
 | |
| #pragma once
 | |
| 
 | |
| #include <LibCore/FileWatcher.h>
 | |
| #include <LibGUI/ActionGroup.h>
 | |
| #include <LibGUI/Label.h>
 | |
| #include <LibGUI/Menu.h>
 | |
| #include <LibGUI/Window.h>
 | |
| 
 | |
| enum class ClearBackground {
 | |
|     No,
 | |
|     Yes
 | |
| };
 | |
| 
 | |
| class KeymapStatusWidget : public GUI::Label {
 | |
|     C_OBJECT(KeymapStatusWidget);
 | |
| 
 | |
|     virtual void mousedown_event(GUI::MouseEvent& event) override;
 | |
| 
 | |
|     void set_current_keymap(String const& keymap, ClearBackground clear_background = ClearBackground::Yes);
 | |
| 
 | |
| private:
 | |
|     RefPtr<GUI::Menu> m_context_menu;
 | |
|     String m_current_keymap;
 | |
| 
 | |
|     ErrorOr<void> refresh_menu();
 | |
| 
 | |
|     GUI::ActionGroup m_keymaps_group;
 | |
| };
 |