Cockatrice 2025-11-30-Development-2.11.0-beta.38
A cross-platform virtual tabletop for multiplayer card games
Loading...
Searching...
No Matches
CardInfoPictureWithTextOverlayWidget Class Reference

#include <card_info_picture_with_text_overlay_widget.h>

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

Signals

void imageClicked (QMouseEvent *event, CardInfoPictureWithTextOverlayWidget *instance)
Signals inherited from CardInfoPictureWidget
void hoveredOnCard (const ExactCard &hoveredCard)
void cardScaleFactorChanged (int _scale)
void cardChanged (const ExactCard &card)
void cardClicked ()

Public Member Functions

 CardInfoPictureWithTextOverlayWidget (QWidget *parent=nullptr, bool hoverToZoomEnabled=false, bool raiseOnEnter=false, const QColor &textColor=Qt::white, const QColor &outlineColor=Qt::black, int fontSize=12, Qt::Alignment alignment=Qt::AlignCenter)
 Constructs a CardPictureWithTextOverlay widget.
void setOverlayText (const QString &text)
 Sets the overlay text to be displayed on the card.
void setTextColor (const QColor &color)
 Sets the color of the overlay text.
void setOutlineColor (const QColor &color)
 Sets the outline color around the overlay text.
void setFontSize (int size)
 Sets the font size for the overlay text.
void setTextAlignment (Qt::Alignment alignment)
 Sets the alignment of the overlay text within the widget.
void setHighlighted (bool _highlighted)
QSize sizeHint () const override
 Provides the recommended size for this widget.
Public Member Functions inherited from CardInfoPictureWidget
 CardInfoPictureWidget (QWidget *parent=nullptr, bool hoverToZoomEnabled=false, bool raiseOnEnter=false)
 Constructs a CardInfoPictureWidget.
ExactCard getCard ()
QSize sizeHint () const override
 Provides the recommended size for the widget based on the scale factor.

Protected Member Functions

void paintEvent (QPaintEvent *event) override
 Paints the widget, including both the card image and the text overlay.
void mousePressEvent (QMouseEvent *event) override
QSize minimumSizeHint () const override
 Provides the minimum recommended size for this widget.
Protected Member Functions inherited from CardInfoPictureWidget
void resizeEvent (QResizeEvent *event) override
 Handles widget resizing by updating the pixmap size.
void paintEvent (QPaintEvent *) override
 Custom paint event that draws the card image with rounded corners.
void enterEvent (QEnterEvent *event) override
 Starts the hover timer to show the enlarged pixmap on hover.
void leaveEvent (QEvent *event) override
 Stops the hover timer and hides the enlarged pixmap when the mouse leaves.
void moveEvent (QMoveEvent *event) override
void mouseMoveEvent (QMouseEvent *event) override
 Moves the enlarged pixmap widget to follow the mouse cursor.
void mousePressEvent (QMouseEvent *event) override
void hideEvent (QHideEvent *event) override
void loadPixmap ()
 Loads the appropriate pixmap based on the current card info.
const QPixmap & getResizedPixmap () const
void showEnlargedPixmap () const
 Displays the enlarged version of the card's pixmap near the cursor.

Private Member Functions

void drawOutlinedText (QPainter &painter, const QRect &textRect, const QString &text, const QTextOption &textOption) const
 Draws text with an outline for visibility.

Private Attributes

QString overlayText
QColor textColor
QColor outlineColor
int fontSize
Qt::Alignment textAlignment
bool highlighted

Additional Inherited Members

Public Slots inherited from CardInfoPictureWidget
void setCard (const ExactCard &card)
 Sets the card to be displayed and updates the pixmap.
void setScaleFactor (int scale)
 Sets the scale factor for the widget.
void setHoverToZoomEnabled (bool enabled)
 Sets the hover to zoom feature.
void setRaiseOnEnterEnabled (bool enabled)
void updatePixmap ()
 Marks the pixmap as dirty and triggers a widget repaint.

Constructor & Destructor Documentation

◆ CardInfoPictureWithTextOverlayWidget()

CardInfoPictureWithTextOverlayWidget::CardInfoPictureWithTextOverlayWidget ( QWidget * parent = nullptr,
bool hoverToZoomEnabled = false,
bool raiseOnEnter = false,
const QColor & textColor = Qt::white,
const QColor & outlineColor = Qt::black,
int fontSize = 12,
Qt::Alignment alignment = Qt::AlignCenter )
explicit

Constructs a CardPictureWithTextOverlay widget.

Parameters
parentThe parent widget.
hoverToZoomEnabledIf this widget will spawn a larger widget when hovered over.
raiseOnEnterIf this widget will raise slightly when entered.
textColorThe color of the overlay text.
outlineColorThe color of the outline around the text.
fontSizeThe font size of the overlay text.
alignmentThe alignment of the text within the overlay.

Sets the widget's size policy and default border style.

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

Member Function Documentation

◆ drawOutlinedText()

void CardInfoPictureWithTextOverlayWidget::drawOutlinedText ( QPainter & painter,
const QRect & textRect,
const QString & text,
const QTextOption & textOption ) const
private

Draws text with an outline for visibility.

Parameters
painterThe painter to draw the text.
textRectThe rectangle area to draw the text in.
textThe text to display.
textOptionThe text layout options, such as alignment.

Draws an outline around the text to enhance readability before drawing the main text.

Here is the caller graph for this function:

◆ imageClicked

void CardInfoPictureWithTextOverlayWidget::imageClicked ( QMouseEvent * event,
CardInfoPictureWithTextOverlayWidget * instance )
signal
Here is the call graph for this function:
Here is the caller graph for this function:

◆ minimumSizeHint()

QSize CardInfoPictureWithTextOverlayWidget::minimumSizeHint ( ) const
nodiscardoverrideprotected

Provides the minimum recommended size for this widget.

Returns
The minimum widget size.
Here is the call graph for this function:

◆ mousePressEvent()

void CardInfoPictureWithTextOverlayWidget::mousePressEvent ( QMouseEvent * event)
overrideprotected
Here is the call graph for this function:

◆ paintEvent()

void CardInfoPictureWithTextOverlayWidget::paintEvent ( QPaintEvent * event)
overrideprotected

Paints the widget, including both the card image and the text overlay.

Parameters
eventThe paint event.

Draws the card image first, then overlays text on top. The text is wrapped and centered within the image.

Here is the call graph for this function:

◆ setFontSize()

void CardInfoPictureWithTextOverlayWidget::setFontSize ( int size)

Sets the font size for the overlay text.

Parameters
sizeThe new font size.

◆ setHighlighted()

void CardInfoPictureWithTextOverlayWidget::setHighlighted ( bool _highlighted)

◆ setOutlineColor()

void CardInfoPictureWithTextOverlayWidget::setOutlineColor ( const QColor & color)

Sets the outline color around the overlay text.

Parameters
colorThe new outline color.

◆ setOverlayText()

void CardInfoPictureWithTextOverlayWidget::setOverlayText ( const QString & text)

Sets the overlay text to be displayed on the card.

Parameters
textThe text to overlay.

Updates the widget to display the new overlay text.

◆ setTextAlignment()

void CardInfoPictureWithTextOverlayWidget::setTextAlignment ( Qt::Alignment alignment)

Sets the alignment of the overlay text within the widget.

Parameters
alignmentThe new text alignment.

◆ setTextColor()

void CardInfoPictureWithTextOverlayWidget::setTextColor ( const QColor & color)

Sets the color of the overlay text.

Parameters
colorThe new text color.

◆ sizeHint()

QSize CardInfoPictureWithTextOverlayWidget::sizeHint ( ) const
nodiscardoverride

Provides the recommended size for this widget.

Returns
The suggested widget size.
Here is the call graph for this function:

Member Data Documentation

◆ fontSize

int CardInfoPictureWithTextOverlayWidget::fontSize
private

◆ highlighted

bool CardInfoPictureWithTextOverlayWidget::highlighted
private

◆ outlineColor

QColor CardInfoPictureWithTextOverlayWidget::outlineColor
private

◆ overlayText

QString CardInfoPictureWithTextOverlayWidget::overlayText
private

◆ textAlignment

Qt::Alignment CardInfoPictureWithTextOverlayWidget::textAlignment
private

◆ textColor

QColor CardInfoPictureWithTextOverlayWidget::textColor
private

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