Cockatrice 2026-10-19-Development-3.1.2-beta.2
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
10#include <QLoggingCategory>
11#include <QMouseEvent>
12#include <QPixmap>
13#include <QPoint>
14#include <QWidget>
16#include <qtmetamacros.h>
17
19class QPropertyAnimation;
20class QTimer;
21
22inline Q_LOGGING_CATEGORY(CardInfoPictureWidgetLog, "card_info_picture_widget");
23
24class QMenu;
25
26class CardInfoPictureWidget : public QWidget
27{
28 Q_OBJECT
29
30public:
31 explicit CardInfoPictureWidget(QWidget *parent = nullptr,
32 bool hoverToZoomEnabled = false,
33 bool raiseOnEnter = false);
35 {
36 return exactCard;
37 }
38 [[nodiscard]] QSize sizeHint() const override;
39
40public slots:
41 void setCard(const ExactCard &card);
42 void setScaleFactor(int scale); // New slot for scaling
43 void setHoverToZoomEnabled(bool enabled);
44 void setRaiseOnEnterEnabled(bool enabled);
45 void updatePixmap();
46
47signals:
48 void hoveredOnCard(const ExactCard &hoveredCard);
49 void cardScaleFactorChanged(int _scale);
50 void cardChanged(const ExactCard &card);
51 void cardClicked(QMouseEvent *event, const ExactCard &card);
52
53protected:
54 void resizeEvent(QResizeEvent *event) override;
55 void paintEvent(QPaintEvent *) override;
56 void enterEvent(QEnterEvent *event) override;
57 void leaveEvent(QEvent *event) override;
58 void moveEvent(QMoveEvent *event) override;
59 void mouseMoveEvent(QMouseEvent *event) override;
60 void mousePressEvent(QMouseEvent *event) override;
61 void hideEvent(QHideEvent *event) override;
62 void loadPixmap();
63 [[nodiscard]] const QPixmap &getResizedPixmap() const
64 {
65 return resizedPixmap;
66 }
67 void showEnlargedPixmap();
69
70private:
72 double scaleFactor = 100;
77
79
80 QTimer *hoverTimer;
81 QPropertyAnimation *animation;
82 QPoint originalPos; // Store the original position
83
84 QMenu *createRightClickMenu();
87};
88
89#endif
Definition card_info_picture_enlarged_widget.h:19
void cardClicked(QMouseEvent *event, const ExactCard &card)
void setScaleFactor(int scale)
Sets the scale factor for the widget.
Definition card_info_picture_widget.cpp:163
CardInfoPictureWidget(QWidget *parent=nullptr, bool hoverToZoomEnabled=false, bool raiseOnEnter=false)
Constructs a CardInfoPictureWidget.
Definition card_info_picture_widget.cpp:74
void setCard(const ExactCard &card)
Sets the card to be displayed and updates the pixmap.
Definition card_info_picture_widget.cpp:114
bool hoverToZoomEnabled
Definition card_info_picture_widget.h:75
QPropertyAnimation * animation
Definition card_info_picture_widget.h:81
void leaveEvent(QEvent *event) override
Stops the hover timer and hides the enlarged pixmap when the mouse leaves.
Definition card_info_picture_widget.cpp:306
void cardChanged(const ExactCard &card)
const QPixmap & getResizedPixmap() const
Definition card_info_picture_widget.h:63
void showEnlargedPixmap()
Displays the enlarged version of the card's pixmap near the cursor.
Definition card_info_picture_widget.cpp:477
void hideEvent(QHideEvent *event) override
Definition card_info_picture_widget.cpp:375
void moveEvent(QMoveEvent *event) override
Definition card_info_picture_widget.cpp:324
QPixmap resizedPixmap
Definition card_info_picture_widget.h:73
ExactCard exactCard
Definition card_info_picture_widget.h:71
void mousePressEvent(QMouseEvent *event) override
Definition card_info_picture_widget.cpp:365
void resizeEvent(QResizeEvent *event) override
Handles widget resizing by updating the pixmap size.
Definition card_info_picture_widget.cpp:150
CardInfoPictureEnlargedWidget * enlargedPixmapWidget
Definition card_info_picture_widget.h:78
void enterEvent(QEnterEvent *event) override
Starts the hover timer to show the enlarged pixmap on hover.
Definition card_info_picture_widget.cpp:277
void hoveredOnCard(const ExactCard &hoveredCard)
bool raiseOnEnter
Definition card_info_picture_widget.h:76
bool pixmapDirty
Definition card_info_picture_widget.h:74
void mouseMoveEvent(QMouseEvent *event) override
Moves the enlarged pixmap widget to follow the mouse cursor.
Definition card_info_picture_widget.cpp:341
void updatePixmap()
Marks the pixmap as dirty and triggers a widget repaint.
Definition card_info_picture_widget.cpp:181
QMenu * createAddToOpenDeckMenu()
Definition card_info_picture_widget.cpp:440
void setHoverToZoomEnabled(bool enabled)
Sets the hover to zoom feature.
Definition card_info_picture_widget.cpp:133
QMenu * createRightClickMenu()
Definition card_info_picture_widget.cpp:381
void setRaiseOnEnterEnabled(bool enabled)
Definition card_info_picture_widget.cpp:139
QPoint originalPos
Definition card_info_picture_widget.h:82
QTimer * hoverTimer
Definition card_info_picture_widget.h:80
void loadPixmap()
Loads the appropriate pixmap based on the current card info.
Definition card_info_picture_widget.cpp:192
QSize sizeHint() const override
Provides the recommended size for the widget based on the scale factor.
Definition card_info_picture_widget.cpp:267
void paintEvent(QPaintEvent *) override
Custom paint event that draws the card image with rounded corners.
Definition card_info_picture_widget.cpp:211
void destroyEnlargedPixmapWidget()
Definition card_info_picture_widget.cpp:512
ExactCard getCard()
Definition card_info_picture_widget.h:34
void cardScaleFactorChanged(int _scale)
QMenu * createViewRelatedCardsMenu()
Definition card_info_picture_widget.cpp:395
double scaleFactor
Definition card_info_picture_widget.h:72
Represents a specific card instance, defined by its CardInfo and a particular printing.
Definition exact_card.h:24
Q_LOGGING_CATEGORY(CrashReportLog, "crash_report")