mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-06-15 03:28:49 -07:00
Non-QObject polymorphic interface with setShortcutsActive(), setShortcutsInactive(), and retranslateUi(). Uses regular multiple inheritance to avoid diamond inheritance with Qt's MOC. All zone menus, SayMenu, and AbstractCounter implement this interface. PlayerMenu manages them via a managedComponents list with two template helpers (addManagedMenu/registerManagedComponent), replacing individual if-guarded lifecycle calls with a single polymorphic loop. SayMenu now owns its shortcut and translation lifecycle instead of having PlayerMenu manage its title and shortcuts externally. Counters are iterated via Player::getCounters() rather than managedComponents to avoid duplicating the authoritative owner's map.
32 lines
1.1 KiB
C++
32 lines
1.1 KiB
C++
/**
|
|
* @file abstract_player_component.h
|
|
* @ingroup GameMenusPlayers
|
|
* @brief Polymorphic interface for player-bound UI components managed by PlayerMenu.
|
|
*/
|
|
|
|
#ifndef COCKATRICE_ABSTRACT_PLAYER_COMPONENT_H
|
|
#define COCKATRICE_ABSTRACT_PLAYER_COMPONENT_H
|
|
|
|
/**
|
|
* @brief Interface for player-bound UI components that need shortcut and translation lifecycle management.
|
|
*
|
|
* Not a QObject — avoids diamond inheritance with Qt's MOC. Each concrete component
|
|
* inherits QObject through its Qt base class (QMenu, TearOffMenu, QGraphicsItem, etc.)
|
|
* and this interface through regular multiple inheritance.
|
|
*/
|
|
class AbstractPlayerComponent
|
|
{
|
|
public:
|
|
virtual ~AbstractPlayerComponent() = default;
|
|
|
|
/// Bind keyboard shortcuts. Called when this player gains focus.
|
|
virtual void setShortcutsActive() = 0;
|
|
|
|
/// Unbind keyboard shortcuts. Called when this player loses focus.
|
|
virtual void setShortcutsInactive() = 0;
|
|
|
|
/// Retranslate all user-visible strings. Called on language change.
|
|
virtual void retranslateUi() = 0;
|
|
};
|
|
|
|
#endif // COCKATRICE_ABSTRACT_PLAYER_COMPONENT_H
|