Cockatrice/cockatrice/src/interface/widgets/cards/card_info_picture_widget.h
RickyRister 5cc5767c87
[CardInfoPictureWidget] Refactor constant fields to static const (#6575)
* [CardInfoPictureWidget] Refactor constant fields to static const

* rename constants

* reformat

* comment out unused
2026-01-27 20:50:19 -05:00

88 lines
2.4 KiB
C++

/**
* @file card_info_picture_widget.h
* @ingroup CardWidgets
* @brief TODO: Document this.
*/
#ifndef CARD_INFO_PICTURE_H
#define CARD_INFO_PICTURE_H
#include "card_info_picture_enlarged_widget.h"
#include <QPropertyAnimation>
#include <QWidget>
#include <libcockatrice/card/printing/exact_card.h>
inline Q_LOGGING_CATEGORY(CardInfoPictureWidgetLog, "card_info_picture_widget");
class AbstractCardItem;
class QMenu;
class CardInfoPictureWidget : public QWidget
{
Q_OBJECT
public:
explicit CardInfoPictureWidget(QWidget *parent = nullptr,
bool hoverToZoomEnabled = false,
bool raiseOnEnter = false);
ExactCard getCard()
{
return exactCard;
}
[[nodiscard]] QSize sizeHint() const override;
public slots:
void setCard(const ExactCard &card);
void setScaleFactor(int scale); // New slot for scaling
void setHoverToZoomEnabled(bool enabled);
void setRaiseOnEnterEnabled(bool enabled);
void updatePixmap();
signals:
void hoveredOnCard(const ExactCard &hoveredCard);
void cardScaleFactorChanged(int _scale);
void cardChanged(const ExactCard &card);
void cardClicked();
protected:
void resizeEvent(QResizeEvent *event) override;
void paintEvent(QPaintEvent *) override;
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
void enterEvent(QEnterEvent *event) override; // Qt6 signature
#else
void enterEvent(QEvent *event) override; // Qt5 signature
#endif
void leaveEvent(QEvent *event) override;
void moveEvent(QMoveEvent *event) override;
void mouseMoveEvent(QMouseEvent *event) override;
void mousePressEvent(QMouseEvent *event) override;
void hideEvent(QHideEvent *event) override;
void loadPixmap();
[[nodiscard]] const QPixmap &getResizedPixmap() const
{
return resizedPixmap;
}
void showEnlargedPixmap();
void destroyEnlargedPixmapWidget();
private:
ExactCard exactCard;
double scaleFactor = 100;
QPixmap resizedPixmap;
bool pixmapDirty;
bool hoverToZoomEnabled;
bool raiseOnEnter;
CardInfoPictureEnlargedWidget *enlargedPixmapWidget = nullptr;
QTimer *hoverTimer;
QPropertyAnimation *animation;
QPoint originalPos; // Store the original position
QMenu *createRightClickMenu();
QMenu *createViewRelatedCardsMenu();
QMenu *createAddToOpenDeckMenu();
};
#endif