Support shortcut for hand reveal actions (#6297)

* Support shortcut for hand reveal actions

* add docs
This commit is contained in:
RickyRister 2025-11-09 03:34:09 -08:00 committed by GitHub
parent 9f2ac78609
commit 4d652210dc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 55 additions and 13 deletions

View file

@ -66,6 +66,8 @@ CardMenu::CardMenu(Player *_player, const CardItem *_card, bool _shortcutsActive
aPlayFacedown = new QAction(this);
connect(aPlayFacedown, &QAction::triggered, playerActions, &PlayerActions::actPlayFacedown);
aRevealToAll = new QAction(this);
mCardCounters = new QMenu;
for (int i = 0; i < 6; ++i) {
@ -274,7 +276,7 @@ void CardMenu::createHandOrCustomZoneMenu()
QMenu *revealMenu = addMenu(tr("Re&veal to..."));
initContextualPlayersMenu(revealMenu);
initContextualPlayersMenu(revealMenu, aRevealToAll);
connect(revealMenu, &QMenu::triggered, player->getPlayerActions(), &PlayerActions::actReveal);
@ -301,9 +303,19 @@ void CardMenu::createHandOrCustomZoneMenu()
}
}
void CardMenu::initContextualPlayersMenu(QMenu *menu)
/**
* @brief Populates the menu with an action for each active player.
*
* The "all players" action is created separately, so it has to be passed into this function.
* It will be put at the top of the menu.
*
* @param menu The menu to add the player actions to.
* @param allPlayersAction The action for "all players".
*/
void CardMenu::initContextualPlayersMenu(QMenu *menu, QAction *allPlayersAction)
{
menu->addAction(tr("&All players"))->setData(-1);
allPlayersAction->setData(-1);
menu->addAction(allPlayersAction);
menu->addSeparator();
for (const auto &playerInfo : playersInfo) {
@ -431,6 +443,7 @@ void CardMenu::retranslateUi()
aPlay->setText(tr("&Play"));
aHide->setText(tr("&Hide"));
aPlayFacedown->setText(tr("Play &Face Down"));
aRevealToAll->setText(tr("&All players"));
//: Turn sideways or back again
aTap->setText(tr("&Tap / Untap"));
aDoesntUntap->setText(tr("Toggle &normal untapping"));
@ -466,6 +479,9 @@ void CardMenu::setShortcutsActive()
aHide->setShortcuts(shortcuts.getShortcut("Player/aHide"));
aPlay->setShortcuts(shortcuts.getShortcut("Player/aPlay"));
aPlayFacedown->setShortcuts(shortcuts.getShortcut("Player/aPlayFacedown"));
aRevealToAll->setShortcuts(shortcuts.getShortcut("Player/aRevealToAll"));
aTap->setShortcuts(shortcuts.getShortcut("Player/aTap"));
aDoesntUntap->setShortcuts(shortcuts.getShortcut("Player/aDoesntUntap"));
aFlip->setShortcuts(shortcuts.getShortcut("Player/aFlip"));
@ -480,9 +496,6 @@ void CardMenu::setShortcutsActive()
aSelectRow->setShortcuts(shortcuts.getShortcut("Player/aSelectRow"));
aSelectColumn->setShortcuts(shortcuts.getShortcut("Player/aSelectColumn"));
aPlayFacedown->setShortcuts(shortcuts.getShortcut("Player/aPlayFacedown"));
aPlay->setShortcuts(shortcuts.getShortcut("Player/aPlay"));
static const QStringList colorWords = {"Red", "Yellow", "Green", "Cyan", "Purple", "Magenta"};
for (int i = 0; i < aAddCounter.size(); i++) {
aAddCounter[i]->setShortcuts(shortcuts.getShortcut("Player/aCC" + colorWords[i]));