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
5 changed files with 55 additions and 13 deletions

View File

@@ -543,6 +543,9 @@ private:
{"Player/aSelectColumn", ShortcutKey(QT_TRANSLATE_NOOP("shortcutsTab", "Select All Cards in Column"),
parseSequenceString("Ctrl+Shift+C"),
ShortcutGroup::Playing_Area)},
{"Player/aRevealToAll", ShortcutKey(QT_TRANSLATE_NOOP("shortcutsTab", "Reveal Selected Cards to All Players"),
parseSequenceString(""),
ShortcutGroup::Playing_Area)},
{"Player/aMoveToBottomLibrary", ShortcutKey(QT_TRANSLATE_NOOP("shortcutsTab", "Bottom of Library"),
parseSequenceString("Ctrl+B"),
ShortcutGroup::Move_selected)},
@@ -681,6 +684,13 @@ private:
{"Player/aSortHandByManaValue", ShortcutKey(QT_TRANSLATE_NOOP("shortcutsTab", "Sort Hand by Mana Value"),
parseSequenceString(""),
ShortcutGroup::Hand)},
{"Player/aRevealHandToAll", ShortcutKey(QT_TRANSLATE_NOOP("shortcutsTab", "Reveal Hand to All Players"),
parseSequenceString(""),
ShortcutGroup::Hand)},
{"Player/aRevealRandomHandCardToAll",
ShortcutKey(QT_TRANSLATE_NOOP("shortcutsTab", "Reveal Random Card to All Players"),
parseSequenceString(""),
ShortcutGroup::Hand)},
{"Player/aRotateViewCW", ShortcutKey(QT_TRANSLATE_NOOP("shortcutsTab", "Rotate View Clockwise"),
parseSequenceString(""),
ShortcutGroup::Gameplay)},

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]));

View File

@@ -26,6 +26,7 @@ public:
QMenu *mCardCounters;
QAction *aPlay, *aPlayFacedown;
QAction *aRevealToAll;
QAction *aHide;
QAction *aClone;
QAction *aSelectAll, *aSelectRow, *aSelectColumn;
@@ -45,7 +46,7 @@ private:
void addRelatedCardActions();
void retranslateUi();
void initContextualPlayersMenu(QMenu *menu);
void initContextualPlayersMenu(QMenu *menu, QAction *allPlayersAction);
void setShortcutsActive();
void addRelatedCardView();
};

View File

@@ -38,10 +38,22 @@ HandMenu::HandMenu(Player *_player, PlayerActions *actions, QWidget *parent) : T
mRevealHand = addMenu(QString());
connect(mRevealHand, &QMenu::aboutToShow, this, &HandMenu::populateRevealHandMenuWithActivePlayers);
aRevealHandToAll = new QAction(this);
aRevealHandToAll->setData(-1);
connect(aRevealHandToAll, &QAction::triggered, this, &HandMenu::onRevealHandTriggered);
mRevealRandomHandCard = addMenu(QString());
connect(mRevealRandomHandCard, &QMenu::aboutToShow, this,
&HandMenu::populateRevealRandomHandCardMenuWithActivePlayers);
aRevealRandomHandCardToAll = new QAction(this);
aRevealRandomHandCardToAll->setData(-1);
connect(aRevealRandomHandCardToAll, &QAction::triggered, this, &HandMenu::onRevealRandomHandCardTriggered);
// We still need to add these actions to menu here so that the shortcuts are active right away
mRevealHand->addAction(aRevealHandToAll);
mRevealRandomHandCard->addAction(aRevealRandomHandCardToAll);
addSeparator();
aMulligan = new QAction(this);
@@ -101,7 +113,10 @@ void HandMenu::retranslateUi()
aMoveHandToRfg->setText(tr("&Exile"));
mRevealHand->setTitle(tr("&Reveal hand to..."));
aRevealHandToAll->setText(tr("All players"));
mRevealRandomHandCard->setTitle(tr("Reveal r&andom card to..."));
aRevealRandomHandCardToAll->setText(tr("All players"));
}
}
@@ -113,6 +128,8 @@ void HandMenu::setShortcutsActive()
aSortHandByType->setShortcuts(shortcuts.getShortcut("Player/aSortHandByType"));
aSortHandByManaValue->setShortcuts(shortcuts.getShortcut("Player/aSortHandByManaValue"));
aMulligan->setShortcuts(shortcuts.getShortcut("Player/aMulligan"));
aRevealHandToAll->setShortcuts(shortcuts.getShortcut("Player/aRevealHandToAll"));
aRevealRandomHandCardToAll->setShortcuts(shortcuts.getShortcut("Player/aRevealRandomHandCardToAll"));
}
void HandMenu::setShortcutsInactive()
@@ -122,15 +139,15 @@ void HandMenu::setShortcutsInactive()
aSortHandByType->setShortcut(QKeySequence());
aSortHandByManaValue->setShortcut(QKeySequence());
aMulligan->setShortcut(QKeySequence());
aRevealHandToAll->setShortcut(QKeySequence());
aRevealRandomHandCardToAll->setShortcut(QKeySequence());
}
void HandMenu::populateRevealHandMenuWithActivePlayers()
{
mRevealHand->clear();
QAction *allPlayers = mRevealHand->addAction(tr("&All players"));
allPlayers->setData(-1);
connect(allPlayers, &QAction::triggered, this, &HandMenu::onRevealHandTriggered);
mRevealHand->addAction(aRevealHandToAll);
mRevealHand->addSeparator();
@@ -148,9 +165,7 @@ void HandMenu::populateRevealRandomHandCardMenuWithActivePlayers()
{
mRevealRandomHandCard->clear();
QAction *allPlayers = mRevealRandomHandCard->addAction(tr("&All players"));
allPlayers->setData(-1);
connect(allPlayers, &QAction::triggered, this, &HandMenu::onRevealRandomHandCardTriggered);
mRevealRandomHandCard->addAction(aRevealRandomHandCardToAll);
mRevealRandomHandCard->addSeparator();

View File

@@ -53,7 +53,10 @@ private:
QAction *aSortHandByManaValue = nullptr;
QMenu *mRevealHand = nullptr;
QAction *aRevealHandToAll = nullptr;
QMenu *mRevealRandomHandCard = nullptr;
QAction *aRevealRandomHandCardToAll = nullptr;
QMenu *mMoveHandMenu = nullptr;
QAction *aMoveHandToTopLibrary = nullptr;