Cockatrice 2026-09-01-Development-3.1.0-beta.10
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);
46 void cardClicked(QMouseEvent *event, const ExactCard &card);
47
48protected:
49 void resizeEvent(QResizeEvent *event) override;
50 void paintEvent(QPaintEvent *) override;
51 void enterEvent(QEnterEvent *event) override;
52 void leaveEvent(QEvent *event) override;
53 void moveEvent(QMoveEvent *event) override;
54 void mouseMoveEvent(QMouseEvent *event) override;
55 void mousePressEvent(QMouseEvent *event) override;
56 void hideEvent(QHideEvent *event) override;
57 void loadPixmap();
58 [[nodiscard]] const QPixmap &getResizedPixmap() const
59 {
60 return resizedPixmap;
61 }
62 void showEnlargedPixmap();
64
65private:
67 double scaleFactor = 100;
72
74
75 QTimer *hoverTimer;
76 QPropertyAnimation *animation;
77 QPoint originalPos; // Store the original position
78
79 QMenu *createRightClickMenu();
82};
83
84#endif
Q_LOGGING_CATEGORY(CardInfoPictureWidgetLog, "card_info_picture_widget")
Definition abstract_card_item.h:21
Definition card_info_picture_enlarged_widget.h:15
void cardClicked(QMouseEvent *event, const ExactCard &card)
void setScaleFactor(int scale)
Sets the scale factor for the widget.
Definition card_info_picture_widget.cpp:134
CardInfoPictureWidget(QWidget *parent=nullptr, bool hoverToZoomEnabled=false, bool raiseOnEnter=false)
Constructs a CardInfoPictureWidget.
Definition card_info_picture_widget.cpp:47
void setCard(const ExactCard &card)
Sets the card to be displayed and updates the pixmap.
Definition card_info_picture_widget.cpp:85
bool hoverToZoomEnabled
Definition card_info_picture_widget.h:70
QPropertyAnimation * animation
Definition card_info_picture_widget.h:76
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:58
void showEnlargedPixmap()
Displays the enlarged version of the card's pixmap near the cursor.
Definition card_info_picture_widget.cpp:453
void hideEvent(QHideEvent *event) override
Definition card_info_picture_widget.cpp:351
void moveEvent(QMoveEvent *event) override
Definition card_info_picture_widget.cpp:300
QPixmap resizedPixmap
Definition card_info_picture_widget.h:68
ExactCard exactCard
Definition card_info_picture_widget.h:66
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:121
CardInfoPictureEnlargedWidget * enlargedPixmapWidget
Definition card_info_picture_widget.h:73
void enterEvent(QEnterEvent *event) override
Starts the hover timer to show the enlarged pixmap on hover.
Definition card_info_picture_widget.cpp:253
void hoveredOnCard(const ExactCard &hoveredCard)
bool raiseOnEnter
Definition card_info_picture_widget.h:71
bool pixmapDirty
Definition card_info_picture_widget.h:69
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:152
QMenu * createAddToOpenDeckMenu()
Definition card_info_picture_widget.cpp:416
void setHoverToZoomEnabled(bool enabled)
Sets the hover to zoom feature.
Definition card_info_picture_widget.cpp:104
QMenu * createRightClickMenu()
Definition card_info_picture_widget.cpp:357
void setRaiseOnEnterEnabled(bool enabled)
Definition card_info_picture_widget.cpp:110
QPoint originalPos
Definition card_info_picture_widget.h:77
QTimer * hoverTimer
Definition card_info_picture_widget.h:75
void loadPixmap()
Loads the appropriate pixmap based on the current card info.
Definition card_info_picture_widget.cpp:163
QSize sizeHint() const override
Provides the recommended size for the widget based on the scale factor.
Definition card_info_picture_widget.cpp:243
void paintEvent(QPaintEvent *) override
Custom paint event that draws the card image with rounded corners.
Definition card_info_picture_widget.cpp:182
void destroyEnlargedPixmapWidget()
Definition card_info_picture_widget.cpp:488
ExactCard getCard()
Definition card_info_picture_widget.h:29
void cardScaleFactorChanged(int _scale)
QMenu * createViewRelatedCardsMenu()
Definition card_info_picture_widget.cpp:371
double scaleFactor
Definition card_info_picture_widget.h:67
Represents a specific card instance, defined by its CardInfo and a particular printing.
Definition exact_card.h:19