Widget that displays an enlarged image of a card, loading the image based on the card's info or showing a default image.
More...
#include <card_info_picture_widget.h>
|
| 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.
|
Widget that displays an enlarged image of a card, loading the image based on the card's info or showing a default image.
This widget can optionally display a larger version of the card's image when hovered over, depending on the hoverToZoomEnabled parameter.
◆ CardInfoPictureWidget()
| CardInfoPictureWidget::CardInfoPictureWidget |
( |
QWidget * | parent = nullptr, |
|
|
bool | hoverToZoomEnabled = false, |
|
|
bool | raiseOnEnter = false ) |
|
explicit |
Constructs a CardInfoPictureWidget.
- Parameters
-
| parent | The parent widget, if any. |
| hoverToZoomEnabled | If this widget will spawn a larger widget when hovered over. |
Initializes the widget with a minimum height and sets the pixmap to a dirty state for initial loading.
◆ cardChanged
| void CardInfoPictureWidget::cardChanged |
( |
const ExactCard & | card | ) |
|
|
signal |
◆ cardClicked
| void CardInfoPictureWidget::cardClicked |
( |
| ) |
|
|
signal |
◆ cardScaleFactorChanged
| void CardInfoPictureWidget::cardScaleFactorChanged |
( |
int | _scale | ) |
|
|
signal |
◆ createAddToOpenDeckMenu()
| QMenu * CardInfoPictureWidget::createAddToOpenDeckMenu |
( |
| ) |
|
|
private |
◆ createRightClickMenu()
| QMenu * CardInfoPictureWidget::createRightClickMenu |
( |
| ) |
|
|
private |
◆ createViewRelatedCardsMenu()
| QMenu * CardInfoPictureWidget::createViewRelatedCardsMenu |
( |
| ) |
|
|
private |
◆ enterEvent()
| void CardInfoPictureWidget::enterEvent |
( |
QEnterEvent * | event | ) |
|
|
overrideprotected |
Starts the hover timer to show the enlarged pixmap on hover.
- Parameters
-
◆ getCard()
◆ getResizedPixmap()
| const QPixmap & CardInfoPictureWidget::getResizedPixmap |
( |
| ) |
const |
|
inlinenodiscardprotected |
◆ hideEvent()
| void CardInfoPictureWidget::hideEvent |
( |
QHideEvent * | event | ) |
|
|
overrideprotected |
◆ hoveredOnCard
| void CardInfoPictureWidget::hoveredOnCard |
( |
const ExactCard & | hoveredCard | ) |
|
|
signal |
◆ leaveEvent()
| void CardInfoPictureWidget::leaveEvent |
( |
QEvent * | event | ) |
|
|
overrideprotected |
Stops the hover timer and hides the enlarged pixmap when the mouse leaves.
- Parameters
-
◆ loadPixmap()
| void CardInfoPictureWidget::loadPixmap |
( |
| ) |
|
|
protected |
Loads the appropriate pixmap based on the current card info.
If info is valid, loads the card's image. Otherwise, loads a default card back image.
◆ mouseMoveEvent()
| void CardInfoPictureWidget::mouseMoveEvent |
( |
QMouseEvent * | event | ) |
|
|
overrideprotected |
Moves the enlarged pixmap widget to follow the mouse cursor.
- Parameters
-
| event | The mouse move event. |
◆ mousePressEvent()
| void CardInfoPictureWidget::mousePressEvent |
( |
QMouseEvent * | event | ) |
|
|
overrideprotected |
◆ moveEvent()
| void CardInfoPictureWidget::moveEvent |
( |
QMoveEvent * | event | ) |
|
|
overrideprotected |
◆ paintEvent()
| void CardInfoPictureWidget::paintEvent |
( |
QPaintEvent * | event | ) |
|
|
overrideprotected |
Custom paint event that draws the card image with rounded corners.
- Parameters
-
| event | The paint event (unused). |
Checks if the pixmap needs to be reloaded. Then, calculates the size and position for centering the scaled pixmap within the widget, applies rounded corners, and draws the pixmap.
◆ resizeEvent()
| void CardInfoPictureWidget::resizeEvent |
( |
QResizeEvent * | event | ) |
|
|
overrideprotected |
Handles widget resizing by updating the pixmap size.
- Parameters
-
| event | The resize event (unused). |
Calls updatePixmap() to ensure the image scales appropriately when the widget is resized.
◆ setCard
| void CardInfoPictureWidget::setCard |
( |
const ExactCard & | card | ) |
|
|
slot |
Sets the card to be displayed and updates the pixmap.
- Parameters
-
| card | A shared pointer to the card information (CardInfoPtr). |
Disconnects any existing signal connections from the previous card info and connects to the pixmapUpdated signal of the new card to automatically update the pixmap when the card image changes.
◆ setHoverToZoomEnabled
| void CardInfoPictureWidget::setHoverToZoomEnabled |
( |
bool | enabled | ) |
|
|
slot |
Sets the hover to zoom feature.
- Parameters
-
| enabled | If true, enables the hover-to-zoom functionality; otherwise, disables it. |
◆ setRaiseOnEnterEnabled
| void CardInfoPictureWidget::setRaiseOnEnterEnabled |
( |
bool | enabled | ) |
|
|
slot |
◆ setScaleFactor
| void CardInfoPictureWidget::setScaleFactor |
( |
int | scale | ) |
|
|
slot |
Sets the scale factor for the widget.
- Parameters
-
| scale | The scale factor to apply. |
Adjusts the widget's size according to the scale factor and updates the pixmap.
◆ showEnlargedPixmap()
| void CardInfoPictureWidget::showEnlargedPixmap |
( |
| ) |
const |
|
protected |
Displays the enlarged version of the card's pixmap near the cursor.
If card information is available, the enlarged pixmap is loaded, positioned near the cursor, and displayed.
◆ sizeHint()
| QSize CardInfoPictureWidget::sizeHint |
( |
| ) |
const |
|
nodiscardoverride |
Provides the recommended size for the widget based on the scale factor.
- Returns
- The recommended widget size.
◆ updatePixmap
| void CardInfoPictureWidget::updatePixmap |
( |
| ) |
|
|
slot |
Marks the pixmap as dirty and triggers a widget repaint.
Sets pixmapDirty to true, indicating that the pixmap needs to be reloaded before the next display.
◆ animation
| QPropertyAnimation* CardInfoPictureWidget::animation |
|
private |
◆ animationOffset
| const int CardInfoPictureWidget::animationOffset = 10 |
|
private |
◆ aspectRatio
◆ baseHeight
| int CardInfoPictureWidget::baseHeight = 200 |
|
private |
◆ baseWidth
| int CardInfoPictureWidget::baseWidth = 200 |
|
private |
◆ enlargedPixmapOffset
| int CardInfoPictureWidget::enlargedPixmapOffset = 10 |
|
private |
◆ enlargedPixmapWidget
◆ exactCard
◆ hoverActivateThresholdInMs
| int CardInfoPictureWidget::hoverActivateThresholdInMs = 500 |
|
private |
◆ hoverTimer
| QTimer* CardInfoPictureWidget::hoverTimer |
|
private |
◆ hoverToZoomEnabled
| bool CardInfoPictureWidget::hoverToZoomEnabled |
|
private |
◆ magicTheGatheringCardAspectRatio
| qreal CardInfoPictureWidget::magicTheGatheringCardAspectRatio = 1.396 |
|
private |
◆ originalPos
| QPoint CardInfoPictureWidget::originalPos |
|
private |
◆ pixmapDirty
| bool CardInfoPictureWidget::pixmapDirty |
|
private |
◆ raiseOnEnter
| bool CardInfoPictureWidget::raiseOnEnter |
|
private |
◆ resizedPixmap
| QPixmap CardInfoPictureWidget::resizedPixmap |
|
private |
◆ scaleFactor
| double CardInfoPictureWidget::scaleFactor = 100 |
|
private |
◆ yuGiOhCardAspectRatio
| qreal CardInfoPictureWidget::yuGiOhCardAspectRatio = 1.457 |
|
private |
The documentation for this class was generated from the following files: