Don't hide PrintingSelector button widgets if the deck contains a card from the set.

This commit is contained in:
Lukas Brübach 2024-11-27 23:52:35 +01:00 committed by ZeldaZach
parent 7ad2972c4d
commit 279aa8c836
No known key found for this signature in database
3 changed files with 35 additions and 2 deletions

View file

@ -48,6 +48,16 @@ AllZonesCardAmountWidget::AllZonesCardAmountWidget(QWidget *parent,
setMouseTracking(true);
}
int AllZonesCardAmountWidget::getMainboardAmount()
{
return buttonBoxMainboard->countCardsInZone(DECK_ZONE_MAIN);
}
int AllZonesCardAmountWidget::getSideboardAmount()
{
return buttonBoxSideboard->countCardsInZone(DECK_ZONE_SIDE);
}
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
void AllZonesCardAmountWidget::enterEvent(QEnterEvent *event)
#else

View file

@ -18,6 +18,8 @@ public:
QTreeView *deckView,
CardInfoPtr rootCard,
CardInfoPerSet setInfoForCard);
int getMainboardAmount();
int getSideboardAmount();
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
void enterEvent(QEnterEvent *event) override;
#else

View file

@ -37,7 +37,12 @@ PrintingSelectorCardOverlayWidget::PrintingSelectorCardOverlayWidget(QWidget *pa
new AllZonesCardAmountWidget(this, deckEditor, deckModel, deckView, setCard, setInfoForCard);
allZonesCardAmountWidget->raise(); // Ensure it's on top of the picture
allZonesCardAmountWidget->setVisible(false);
// Set initial visibility based on amounts
if (allZonesCardAmountWidget->getMainboardAmount() > 0 || allZonesCardAmountWidget->getSideboardAmount() > 0) {
allZonesCardAmountWidget->setVisible(true);
} else {
allZonesCardAmountWidget->setVisible(false);
}
// Attempt to cast the parent to PrintingSelectorCardDisplayWidget
if (const auto *parentWidget = qobject_cast<PrintingSelectorCardDisplayWidget *>(parent)) {
@ -74,13 +79,29 @@ void PrintingSelectorCardOverlayWidget::enterEvent(QEvent *event)
#endif
{
QWidget::enterEvent(event);
allZonesCardAmountWidget->setVisible(true);
deckEditor->updateCardInfo(setCard);
// Check if either mainboard or sideboard amount is greater than 0
if (allZonesCardAmountWidget->getMainboardAmount() > 0 || allZonesCardAmountWidget->getSideboardAmount() > 0) {
// Don't change visibility if amounts are greater than 0
return;
}
// Show the widget if amounts are 0
allZonesCardAmountWidget->setVisible(true);
}
void PrintingSelectorCardOverlayWidget::leaveEvent(QEvent *event)
{
QWidget::leaveEvent(event);
// Check if either mainboard or sideboard amount is greater than 0
if (allZonesCardAmountWidget->getMainboardAmount() > 0 || allZonesCardAmountWidget->getSideboardAmount() > 0) {
// Don't hide the widget if amounts are greater than 0
return;
}
// Hide the widget if amounts are 0
allZonesCardAmountWidget->setVisible(false);
}