mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-09-23 10:05:10 -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
|
|
@ -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