Cockatrice 2026-10-19-Development-3.1.2-beta.2
A virtual tabletop for multiplayer card games
Loading...
Searching...
No Matches
PrintingSelectorCardOverlayWidget Class Reference

#include <printing_selector_card_overlay_widget.h>

Inheritance diagram for PrintingSelectorCardOverlayWidget:
[legend]
Collaboration diagram for PrintingSelectorCardOverlayWidget:
[legend]

Public Slots

void updateCardAmounts (int mainboardAmount, int sideboardAmount, int tokensboardAmount)

Signals

void cardPreferenceChanged ()

Public Member Functions

 PrintingSelectorCardOverlayWidget (QWidget *parent, AbstractTabDeckEditor *_deckEditor, DeckStateManager *_deckStateManager, QSlider *_cardSizeSlider, const ExactCard &_rootCard)
 Constructs a PrintingSelectorCardOverlayWidget for displaying a card overlay.

Protected Member Functions

void resizeEvent (QResizeEvent *event) override
 Resizes the overlay widget to match the card's size.
void enterEvent (QEnterEvent *event) override
 Handles the mouse enter event when the cursor enters the overlay widget area.
void leaveEvent (QEvent *event) override
 Handles the mouse leave event when the cursor leaves the overlay widget area.
void mousePressEvent (QMouseEvent *event) override
 Handles the mouse press event for right-clicks to show the context menu.
void customMenu (QPoint point)
 Creates and shows the card-overlay context menu.

Private Slots

void updateVisibility ()
 Sets the visibility of the widgets depending on the amounts and whether the mouse is hovering over.
void updatePinBadgeVisibility ()
 Updates the pin badge visibility and position based on the card's pinned state.

Private Member Functions

void initializePinBadge ()
 Initializes the pin badge overlay and loads its icon with DPI-aware rasterization.
void loadCustomImage ()
 Asks for an image file and installs it as the card's custom art.
void showPreviewForAction (QAction *action)
 Shows the hover preview for a highlighted printing entry in the Image Overrides submenu.
void refreshPreview ()
 Renders the hover preview for the currently highlighted printing.
void hidePreview ()
 Hides the hover preview and forgets the currently highlighted printing.

Private Attributes

CardInfoPictureWidget * cardInfoPicture
AllZonesCardAmountWidget * allZonesCardAmountWidget
QLabel * pinBadge = nullptr
AbstractTabDeckEditor * deckEditor
ExactCard rootCard
QLabel * cardOverridePreviewLabel = nullptr
ExactCard hoveredOverrideCard
QMenu * previewSourceMenu = nullptr
QAction * hoveredOverrideAction = nullptr

Constructor & Destructor Documentation

◆ PrintingSelectorCardOverlayWidget()

PrintingSelectorCardOverlayWidget::PrintingSelectorCardOverlayWidget ( QWidget * parent,
AbstractTabDeckEditor * _deckEditor,
DeckStateManager * deckStateManager,
QSlider * cardSizeSlider,
const ExactCard & _rootCard )
explicit

Constructs a PrintingSelectorCardOverlayWidget for displaying a card overlay.

This widget is responsible for showing the card's image and providing interactive features such as a context menu and the ability to adjust the card's scale. It includes the card's image as well as a widget that displays the card amounts in different zones (mainboard, sideboard, etc.).

Parameters
parentThe parent widget for this overlay.
_deckEditorThe TabDeckEditor instance for deck management.
deckStateManagerThe DeckStateManager instance providing deck data.
cardSizeSliderThe slider controlling the size of the card.
_rootCardThe root card object that contains information about the card.
Here is the call graph for this function:
Here is the caller graph for this function:

Member Function Documentation

◆ cardPreferenceChanged

void PrintingSelectorCardOverlayWidget::cardPreferenceChanged ( )
signal
Here is the call graph for this function:
Here is the caller graph for this function:

◆ customMenu()

void PrintingSelectorCardOverlayWidget::customMenu ( QPoint point)
protected

Creates and shows the card-overlay context menu.

The menu includes the card art preference (Pin/Unpin Printing), the Image Overrides submenu (Load Custom Image, Clear Custom Image, and one entry per alternate printing with a live preview), and the Show Related cards submenu.

Parameters
pointThe local position the menu should pop at.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ enterEvent()

void PrintingSelectorCardOverlayWidget::enterEvent ( QEnterEvent * event)
overrideprotected

Handles the mouse enter event when the cursor enters the overlay widget area.

When the cursor enters the widget, the card amount widget becomes visible regardless of whether the amounts are zero.

Parameters
eventThe event triggered when the mouse enters the widget.
Here is the call graph for this function:

◆ hidePreview()

void PrintingSelectorCardOverlayWidget::hidePreview ( )
private

Hides the hover preview and forgets the currently highlighted printing.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ initializePinBadge()

void PrintingSelectorCardOverlayWidget::initializePinBadge ( )
private

Initializes the pin badge overlay and loads its icon with DPI-aware rasterization.

The icon is rasterized once using the label's device pixel ratio so it stays crisp on HiDPI displays. The resulting pixmap is cached on the QLabel and simply shown/hidden when needed. If the SVG cannot be read, a textual fallback badge is created instead.

Here is the caller graph for this function:

◆ leaveEvent()

void PrintingSelectorCardOverlayWidget::leaveEvent ( QEvent * event)
overrideprotected

Handles the mouse leave event when the cursor leaves the overlay widget area.

When the cursor leaves the widget, the card amount widget is hidden if all of the mainboard, sideboard, and tokensboard amounts are zero.

Parameters
eventThe event triggered when the mouse leaves the widget.
Here is the call graph for this function:

◆ loadCustomImage()

void PrintingSelectorCardOverlayWidget::loadCustomImage ( )
private

Asks for an image file and installs it as the card's custom art.

Unreadable files answer with a visible warning instead of a silent no-op.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ mousePressEvent()

void PrintingSelectorCardOverlayWidget::mousePressEvent ( QMouseEvent * event)
overrideprotected

Handles the mouse press event for right-clicks to show the context menu.

If the right mouse button is pressed, a custom context menu will appear. For other mouse buttons, the event is passed to the base class for default handling.

Parameters
eventThe mouse event triggered by the user.
Here is the call graph for this function:

◆ refreshPreview()

void PrintingSelectorCardOverlayWidget::refreshPreview ( )
private

Renders the hover preview for the currently highlighted printing.

The preview shows the loading placeholder while the art is pending and swaps in the real art when it resolves. The label is positioned against its already-resized geometry so the first-ever show at the screen's edges stays fully on-screen.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ resizeEvent()

void PrintingSelectorCardOverlayWidget::resizeEvent ( QResizeEvent * event)
overrideprotected

Resizes the overlay widget to match the card's size.

This method ensures that the amount widget matches the card's size when the overlay widget is resized. It also resizes the card info picture widget to match the new size.

Parameters
eventThe resize event triggered when the widget is resized.

◆ showPreviewForAction()

void PrintingSelectorCardOverlayWidget::showPreviewForAction ( QAction * action)
private

Shows the hover preview for a highlighted printing entry in the Image Overrides submenu.

QMenu::hovered fires on keyboard highlight too, so the preview appears when arrows walk onto a printing entry, not only under the mouse.

Non-printing entries (e.g., Load Custom Image, Clear Custom Image) hide the preview.

Parameters
actionThe action that was highlighted.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ updateCardAmounts

void PrintingSelectorCardOverlayWidget::updateCardAmounts ( int mainboardAmount,
int sideboardAmount,
int tokensboardAmount )
slot
Here is the call graph for this function:
Here is the caller graph for this function:

◆ updatePinBadgeVisibility

void PrintingSelectorCardOverlayWidget::updatePinBadgeVisibility ( )
privateslot

Updates the pin badge visibility and position based on the card's pinned state.

This method checks whether the current card printing is pinned and updates the pin badge accordingly. If the card is pinned, the badge is made visible and positioned in the top-right corner of the card image with appropriate margins. If the card is not pinned, the badge is hidden.

The method is called whenever the card preference changes or the card size is adjusted via the slider to ensure the badge remains properly positioned.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ updateVisibility

void PrintingSelectorCardOverlayWidget::updateVisibility ( )
privateslot

Sets the visibility of the widgets depending on the amounts and whether the mouse is hovering over.

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ allZonesCardAmountWidget

AllZonesCardAmountWidget* PrintingSelectorCardOverlayWidget::allZonesCardAmountWidget
private

◆ cardInfoPicture

CardInfoPictureWidget* PrintingSelectorCardOverlayWidget::cardInfoPicture
private

◆ cardOverridePreviewLabel

QLabel* PrintingSelectorCardOverlayWidget::cardOverridePreviewLabel = nullptr
private

◆ deckEditor

AbstractTabDeckEditor* PrintingSelectorCardOverlayWidget::deckEditor
private

◆ hoveredOverrideAction

QAction* PrintingSelectorCardOverlayWidget::hoveredOverrideAction = nullptr
private

◆ hoveredOverrideCard

ExactCard PrintingSelectorCardOverlayWidget::hoveredOverrideCard
private

◆ pinBadge

QLabel* PrintingSelectorCardOverlayWidget::pinBadge = nullptr
private

◆ previewSourceMenu

QMenu* PrintingSelectorCardOverlayWidget::previewSourceMenu = nullptr
private

◆ rootCard

ExactCard PrintingSelectorCardOverlayWidget::rootCard
private

The documentation for this class was generated from the following files: