mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-07-10 12:23:58 -07:00
[TabDeckEditor] Refactor: consolidate add/decrement card signals (#6961)
This commit is contained in:
parent
3fa377a11c
commit
f52dc6dda8
10 changed files with 40 additions and 76 deletions
|
|
@ -139,32 +139,6 @@ void AbstractTabDeckEditor::decrementCard(const ExactCard &card, const QString &
|
|||
deckStateManager->decrementCard(card, zoneName);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Adds a card to the main deck or sideboard depending on Ctrl key.
|
||||
*/
|
||||
void AbstractTabDeckEditor::actAddCard(const ExactCard &card)
|
||||
{
|
||||
addCard(card, DECK_ZONE_MAIN);
|
||||
}
|
||||
|
||||
/** @brief Adds a card to the sideboard explicitly. */
|
||||
void AbstractTabDeckEditor::actAddCardToSideboard(const ExactCard &card)
|
||||
{
|
||||
addCard(card, DECK_ZONE_SIDE);
|
||||
}
|
||||
|
||||
/** @brief Decrements a card from the main deck. */
|
||||
void AbstractTabDeckEditor::actDecrementCard(const ExactCard &card)
|
||||
{
|
||||
decrementCard(card, DECK_ZONE_MAIN);
|
||||
}
|
||||
|
||||
/** @brief Decrements a card from the sideboard. */
|
||||
void AbstractTabDeckEditor::actDecrementCardFromSideboard(const ExactCard &card)
|
||||
{
|
||||
decrementCard(card, DECK_ZONE_SIDE);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Opens a deck in this tab.
|
||||
* @param deck The deck
|
||||
|
|
|
|||
|
|
@ -77,8 +77,8 @@ class QAction;
|
|||
*
|
||||
* **Key Methods:**
|
||||
*
|
||||
* - actAddCard(const ExactCard &card) — Adds a card to the deck.
|
||||
* - actDecrementCard(const ExactCard &card) — Removes a single instance of a card from the deck.
|
||||
* - addCard(const ExactCard &card, const QString &zoneName) — Adds a card to the deck.
|
||||
* - decrementCard(const ExactCard &card, const QString &zoneName) — Removes a single instance of a card from the deck.
|
||||
* - actRemoveCard() — Removes the currently selected card from the deck.
|
||||
* - actSaveDeckAs() — Performs a "Save As" action for the deck.
|
||||
* - updateCard(const ExactCard &card) — Updates the currently displayed card info in the dock.
|
||||
|
|
@ -163,18 +163,6 @@ public slots:
|
|||
*/
|
||||
void decrementCard(const ExactCard &card, const QString &zoneName);
|
||||
|
||||
/** @brief Adds a card to the main deck or sideboard based on Ctrl key. */
|
||||
void actAddCard(const ExactCard &card);
|
||||
|
||||
/** @brief Adds a card to the sideboard explicitly. */
|
||||
void actAddCardToSideboard(const ExactCard &card);
|
||||
|
||||
/** @brief Decrements a card from the main deck. */
|
||||
void actDecrementCard(const ExactCard &card);
|
||||
|
||||
/** @brief Decrements a card from the sideboard. */
|
||||
void actDecrementCardFromSideboard(const ExactCard &card);
|
||||
|
||||
/** @brief Opens a recently opened deck file. */
|
||||
void actOpenRecent(const QString &fileName);
|
||||
|
||||
|
|
|
|||
|
|
@ -168,22 +168,14 @@ void TabDeckEditorVisual::processMainboardCardClick(QMouseEvent *event,
|
|||
|
||||
// Alt + Right-click = decrement
|
||||
if (event->button() == Qt::RightButton && event->modifiers().testFlag(Qt::AltModifier)) {
|
||||
if (zoneName == DECK_ZONE_MAIN) {
|
||||
actDecrementCard(card);
|
||||
} else {
|
||||
actDecrementCardFromSideboard(card);
|
||||
}
|
||||
decrementCard(card, zoneName);
|
||||
// Keep selection intact.
|
||||
return;
|
||||
}
|
||||
|
||||
// Alt + Left click = increment
|
||||
if (event->button() == Qt::LeftButton && event->modifiers().testFlag(Qt::AltModifier)) {
|
||||
if (zoneName == DECK_ZONE_MAIN) {
|
||||
actAddCard(card);
|
||||
} else {
|
||||
actAddCardToSideboard(card);
|
||||
}
|
||||
addCard(card, zoneName);
|
||||
// Keep selection intact.
|
||||
return;
|
||||
}
|
||||
|
|
@ -224,12 +216,12 @@ void TabDeckEditorVisual::processCardClickDatabaseDisplay(QMouseEvent *event,
|
|||
{
|
||||
if (event->button() == Qt::LeftButton) {
|
||||
if (QApplication::keyboardModifiers() & Qt::ControlModifier) {
|
||||
actAddCardToSideboard(instance->getCard());
|
||||
addCard(instance->getCard(), DECK_ZONE_SIDE);
|
||||
} else {
|
||||
actAddCard(instance->getCard());
|
||||
addCard(instance->getCard(), DECK_ZONE_MAIN);
|
||||
}
|
||||
} else if (event->button() == Qt::RightButton) {
|
||||
actDecrementCard(instance->getCard());
|
||||
decrementCard(instance->getCard(), DECK_ZONE_MAIN);
|
||||
} else if (event->button() == Qt::MiddleButton) {
|
||||
deckDockWidget->actRemoveCard();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,8 +34,8 @@ TabDeckEditorVisualTabWidget::TabDeckEditorVisualTabWidget(QWidget *parent,
|
|||
&TabDeckEditorVisualTabWidget::onCardChanged);
|
||||
connect(visualDeckView, &VisualDeckEditorWidget::cardClicked, this,
|
||||
&TabDeckEditorVisualTabWidget::onCardClickedDeckEditor);
|
||||
connect(visualDeckView, &VisualDeckEditorWidget::cardAdditionRequested, deckEditor,
|
||||
&AbstractTabDeckEditor::actAddCard);
|
||||
connect(visualDeckView, &VisualDeckEditorWidget::cardAdditionRequested, this,
|
||||
&TabDeckEditorVisualTabWidget::actAddCard);
|
||||
|
||||
visualDatabaseDisplay =
|
||||
new VisualDatabaseDisplayWidget(this, deckEditor, _cardDatabaseModel, _cardDatabaseDisplayModel);
|
||||
|
|
@ -166,3 +166,15 @@ void TabDeckEditorVisualTabWidget::handleTabClose(int index)
|
|||
this->removeTab(index);
|
||||
delete tab;
|
||||
}
|
||||
|
||||
void TabDeckEditorVisualTabWidget::actAddCard(const ExactCard &card)
|
||||
{
|
||||
QString zoneName;
|
||||
if (QApplication::keyboardModifiers() & Qt::ControlModifier) {
|
||||
zoneName = DECK_ZONE_SIDE;
|
||||
} else {
|
||||
zoneName = DECK_ZONE_MAIN;
|
||||
}
|
||||
|
||||
deckEditor->addCard(card, zoneName);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -132,6 +132,12 @@ private slots:
|
|||
* @param index Index of the tab to close.
|
||||
*/
|
||||
void handleTabClose(int index);
|
||||
|
||||
/**
|
||||
* @brief Adds card to maindeck or side depending on whether ctrl is held
|
||||
* @param card
|
||||
*/
|
||||
void actAddCard(const ExactCard &card);
|
||||
};
|
||||
|
||||
#endif // TAB_DECK_EDITOR_VISUAL_TAB_WIDGET_H
|
||||
Loading…
Add table
Add a link
Reference in a new issue