Cockatrice 2025-11-30-Development-2.11.0-beta.38
A cross-platform virtual tabletop for multiplayer card games
Loading...
Searching...
No Matches
card_info_picture_widget.h
Go to the documentation of this file.
1
6
7#ifndef CARD_INFO_PICTURE_H
8#define CARD_INFO_PICTURE_H
9
11
12#include <QPropertyAnimation>
13#include <QWidget>
15
16inline Q_LOGGING_CATEGORY(CardInfoPictureWidgetLog, "card_info_picture_widget");
17
19class QMenu;
20
21class CardInfoPictureWidget : public QWidget
22{
23 Q_OBJECT
24
25public:
26 explicit CardInfoPictureWidget(QWidget *parent = nullptr,
27 bool hoverToZoomEnabled = false,
28 bool raiseOnEnter = false);
30 {
31 return exactCard;
32 }
33 [[nodiscard]] QSize sizeHint() const override;
34
35public slots:
36 void setCard(const ExactCard &card);
37 void setScaleFactor(int scale); // New slot for scaling
38 void setHoverToZoomEnabled(bool enabled);
39 void setRaiseOnEnterEnabled(bool enabled);
40 void updatePixmap();
41
42signals:
43 void hoveredOnCard(const ExactCard &hoveredCard);
44 void cardScaleFactorChanged(int _scale);
45 void cardChanged(const ExactCard &card);
47
48protected:
49 void resizeEvent(QResizeEvent *event) override;
50 void paintEvent(QPaintEvent *) override;
51#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
52 void enterEvent(QEnterEvent *event) override; // Qt6 signature
53#else
54 void enterEvent(QEvent *event) override; // Qt5 signature
55#endif
56 void leaveEvent(QEvent *event) override;
57 void moveEvent(QMoveEvent *event) override;
58 void mouseMoveEvent(QMouseEvent *event) override;
59 void mousePressEvent(QMouseEvent *event) override;
60 void hideEvent(QHideEvent *event) override;
61 void loadPixmap();
62 [[nodiscard]] const QPixmap &getResizedPixmap() const
63 {
64 return resizedPixmap;
65 }
66 void showEnlargedPixmap() const;
67
68private:
71 qreal yuGiOhCardAspectRatio = 1.457;
73 int baseWidth = 200;
74 int baseHeight = 200;
75 double scaleFactor = 100;
83 QTimer *hoverTimer;
84 QPropertyAnimation *animation;
85 QPoint originalPos; // Store the original position
86 const int animationOffset = 10; // Adjust this for how much the widget moves up
87
88 QMenu *createRightClickMenu();
91};
92
93#endif
Q_LOGGING_CATEGORY(CardInfoPictureWidgetLog, "card_info_picture_widget")
Definition abstract_card_item.h:22
Definition card_info_picture_enlarged_widget.h:15
void setScaleFactor(int scale)
Sets the scale factor for the widget.
Definition card_info_picture_widget.cpp:124
CardInfoPictureWidget(QWidget *parent=nullptr, bool hoverToZoomEnabled=false, bool raiseOnEnter=false)
Constructs a CardInfoPictureWidget.
Definition card_info_picture_widget.cpp:34
void setCard(const ExactCard &card)
Sets the card to be displayed and updates the pixmap.
Definition card_info_picture_widget.cpp:75
bool hoverToZoomEnabled
Definition card_info_picture_widget.h:78
int hoverActivateThresholdInMs
Definition card_info_picture_widget.h:80
QPropertyAnimation * animation
Definition card_info_picture_widget.h:84
void leaveEvent(QEvent *event) override
Stops the hover timer and hides the enlarged pixmap when the mouse leaves.
Definition card_info_picture_widget.cpp:274
void cardChanged(const ExactCard &card)
const QPixmap & getResizedPixmap() const
Definition card_info_picture_widget.h:62
int enlargedPixmapOffset
Definition card_info_picture_widget.h:82
void hideEvent(QHideEvent *event) override
Definition card_info_picture_widget.cpp:345
void moveEvent(QMoveEvent *event) override
Definition card_info_picture_widget.cpp:292
QPixmap resizedPixmap
Definition card_info_picture_widget.h:76
ExactCard exactCard
Definition card_info_picture_widget.h:69
qreal aspectRatio
Definition card_info_picture_widget.h:72
void mousePressEvent(QMouseEvent *event) override
Definition card_info_picture_widget.cpp:333
void resizeEvent(QResizeEvent *event) override
Handles widget resizing by updating the pixmap size.
Definition card_info_picture_widget.cpp:111
CardInfoPictureEnlargedWidget * enlargedPixmapWidget
Definition card_info_picture_widget.h:81
void enterEvent(QEnterEvent *event) override
Starts the hover timer to show the enlarged pixmap on hover.
Definition card_info_picture_widget.cpp:242
void hoveredOnCard(const ExactCard &hoveredCard)
bool raiseOnEnter
Definition card_info_picture_widget.h:79
bool pixmapDirty
Definition card_info_picture_widget.h:77
void showEnlargedPixmap() const
Displays the enlarged version of the card's pixmap near the cursor.
Definition card_info_picture_widget.cpp:447
void mouseMoveEvent(QMouseEvent *event) override
Moves the enlarged pixmap widget to follow the mouse cursor.
Definition card_info_picture_widget.cpp:309
void updatePixmap()
Marks the pixmap as dirty and triggers a widget repaint.
Definition card_info_picture_widget.cpp:142
QMenu * createAddToOpenDeckMenu()
Definition card_info_picture_widget.cpp:410
qreal yuGiOhCardAspectRatio
Definition card_info_picture_widget.h:71
void setHoverToZoomEnabled(bool enabled)
Sets the hover to zoom feature.
Definition card_info_picture_widget.cpp:94
QMenu * createRightClickMenu()
Definition card_info_picture_widget.cpp:351
void setRaiseOnEnterEnabled(bool enabled)
Definition card_info_picture_widget.cpp:100
QPoint originalPos
Definition card_info_picture_widget.h:85
QTimer * hoverTimer
Definition card_info_picture_widget.h:83
void loadPixmap()
Loads the appropriate pixmap based on the current card info.
Definition card_info_picture_widget.cpp:153
qreal magicTheGatheringCardAspectRatio
Definition card_info_picture_widget.h:70
QSize sizeHint() const override
Provides the recommended size for the widget based on the scale factor.
Definition card_info_picture_widget.cpp:231
void paintEvent(QPaintEvent *) override
Custom paint event that draws the card image with rounded corners.
Definition card_info_picture_widget.cpp:172
const int animationOffset
Definition card_info_picture_widget.h:86
int baseWidth
Definition card_info_picture_widget.h:73
ExactCard getCard()
Definition card_info_picture_widget.h:29
int baseHeight
Definition card_info_picture_widget.h:74
void cardScaleFactorChanged(int _scale)
QMenu * createViewRelatedCardsMenu()
Definition card_info_picture_widget.cpp:365
double scaleFactor
Definition card_info_picture_widget.h:75
Represents a specific card instance, defined by its CardInfo and a particular printing.
Definition exact_card.h:19