Cockatrice 2026-03-05-Development-2.11.0-beta.54
A 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();
68
69private:
71 double scaleFactor = 100;
76
78
79 QTimer *hoverTimer;
80 QPropertyAnimation *animation;
81 QPoint originalPos; // Store the original position
82
83 QMenu *createRightClickMenu();
86};
87
88#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:132
CardInfoPictureWidget(QWidget *parent=nullptr, bool hoverToZoomEnabled=false, bool raiseOnEnter=false)
Constructs a CardInfoPictureWidget.
Definition card_info_picture_widget.cpp:46
void setCard(const ExactCard &card)
Sets the card to be displayed and updates the pixmap.
Definition card_info_picture_widget.cpp:83
bool hoverToZoomEnabled
Definition card_info_picture_widget.h:74
QPropertyAnimation * animation
Definition card_info_picture_widget.h:80
void leaveEvent(QEvent *event) override
Stops the hover timer and hides the enlarged pixmap when the mouse leaves.
Definition card_info_picture_widget.cpp:282
void cardChanged(const ExactCard &card)
const QPixmap & getResizedPixmap() const
Definition card_info_picture_widget.h:62
void showEnlargedPixmap()
Displays the enlarged version of the card's pixmap near the cursor.
Definition card_info_picture_widget.cpp:455
void hideEvent(QHideEvent *event) override
Definition card_info_picture_widget.cpp:353
void moveEvent(QMoveEvent *event) override
Definition card_info_picture_widget.cpp:300
QPixmap resizedPixmap
Definition card_info_picture_widget.h:72
ExactCard exactCard
Definition card_info_picture_widget.h:70
void mousePressEvent(QMouseEvent *event) override
Definition card_info_picture_widget.cpp:341
void resizeEvent(QResizeEvent *event) override
Handles widget resizing by updating the pixmap size.
Definition card_info_picture_widget.cpp:119
CardInfoPictureEnlargedWidget * enlargedPixmapWidget
Definition card_info_picture_widget.h:77
void enterEvent(QEnterEvent *event) override
Starts the hover timer to show the enlarged pixmap on hover.
Definition card_info_picture_widget.cpp:250
void hoveredOnCard(const ExactCard &hoveredCard)
bool raiseOnEnter
Definition card_info_picture_widget.h:75
bool pixmapDirty
Definition card_info_picture_widget.h:73
void mouseMoveEvent(QMouseEvent *event) override
Moves the enlarged pixmap widget to follow the mouse cursor.
Definition card_info_picture_widget.cpp:317
void updatePixmap()
Marks the pixmap as dirty and triggers a widget repaint.
Definition card_info_picture_widget.cpp:150
QMenu * createAddToOpenDeckMenu()
Definition card_info_picture_widget.cpp:418
void setHoverToZoomEnabled(bool enabled)
Sets the hover to zoom feature.
Definition card_info_picture_widget.cpp:102
QMenu * createRightClickMenu()
Definition card_info_picture_widget.cpp:359
void setRaiseOnEnterEnabled(bool enabled)
Definition card_info_picture_widget.cpp:108
QPoint originalPos
Definition card_info_picture_widget.h:81
QTimer * hoverTimer
Definition card_info_picture_widget.h:79
void loadPixmap()
Loads the appropriate pixmap based on the current card info.
Definition card_info_picture_widget.cpp:161
QSize sizeHint() const override
Provides the recommended size for the widget based on the scale factor.
Definition card_info_picture_widget.cpp:239
void paintEvent(QPaintEvent *) override
Custom paint event that draws the card image with rounded corners.
Definition card_info_picture_widget.cpp:180
void destroyEnlargedPixmapWidget()
Definition card_info_picture_widget.cpp:490
ExactCard getCard()
Definition card_info_picture_widget.h:29
void cardScaleFactorChanged(int _scale)
QMenu * createViewRelatedCardsMenu()
Definition card_info_picture_widget.cpp:373
double scaleFactor
Definition card_info_picture_widget.h:71
Represents a specific card instance, defined by its CardInfo and a particular printing.
Definition exact_card.h:19