mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-07-07 05:53:59 -07:00
feat(command-zone): add abstract zone menu base class
Introduce AbstractZoneMenu - a base class for zone-specific context menus that provides common functionality. This abstraction: - Reduces code duplication across zone menu implementations - Establishes consistent menu behavior patterns - Provides foundation for CommandZoneMenu implementation Small foundational commit to keep the menu hierarchy clean.
This commit is contained in:
parent
6e83d64622
commit
54e7ee1b42
1 changed files with 54 additions and 0 deletions
54
cockatrice/src/game/player/menu/abstract_zone_menu.h
Normal file
54
cockatrice/src/game/player/menu/abstract_zone_menu.h
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
/**
|
||||
* @file abstract_zone_menu.h
|
||||
* @ingroup GameMenusZones
|
||||
* @brief Abstract interface for zone menus with common shortcut management.
|
||||
*
|
||||
* This interface enables polymorphic iteration over heterogeneous menu types
|
||||
* for keyboard shortcut activation/deactivation and UI translation.
|
||||
*/
|
||||
|
||||
#ifndef COCKATRICE_ABSTRACT_ZONE_MENU_H
|
||||
#define COCKATRICE_ABSTRACT_ZONE_MENU_H
|
||||
|
||||
/**
|
||||
* @class AbstractZoneMenu
|
||||
* @brief Interface for zone menus that support keyboard shortcuts and translation.
|
||||
*
|
||||
* Provides a common contract for menus that need to:
|
||||
* - Activate/deactivate keyboard shortcuts based on game focus
|
||||
* - Update UI text when language changes
|
||||
*
|
||||
* Menus implementing this interface can be stored polymorphically
|
||||
* in PlayerMenu for batch operations.
|
||||
*/
|
||||
class AbstractZoneMenu
|
||||
{
|
||||
public:
|
||||
virtual ~AbstractZoneMenu() = default;
|
||||
|
||||
/**
|
||||
* @brief Enable keyboard shortcuts for this menu's actions.
|
||||
*
|
||||
* Called when this player becomes the active/focused player.
|
||||
* Implementations should apply shortcut keys to their QActions.
|
||||
*/
|
||||
virtual void setShortcutsActive() = 0;
|
||||
|
||||
/**
|
||||
* @brief Disable keyboard shortcuts for this menu's actions.
|
||||
*
|
||||
* Called when focus moves away from this player.
|
||||
* Implementations should clear shortcut keys from their QActions.
|
||||
*/
|
||||
virtual void setShortcutsInactive() = 0;
|
||||
|
||||
/**
|
||||
* @brief Update all translatable text in the menu.
|
||||
*
|
||||
* Called when the application language changes.
|
||||
* Implementations should update menu titles, action text, and tooltips.
|
||||
*/
|
||||
virtual void retranslateUi() = 0;
|
||||
};
|
||||
|
||||
#endif // COCKATRICE_ABSTRACT_ZONE_MENU_H
|
||||
Loading…
Add table
Add a link
Reference in a new issue