50 lines
1.2 KiB
C++
50 lines
1.2 KiB
C++
#ifndef TIERCARD_H
|
|
#define TIERCARD_H
|
|
|
|
#include "aspectratiopixmaplabel.hpp"
|
|
|
|
#include <QWidget>
|
|
#include <QLabel>
|
|
#include <QColor>
|
|
|
|
#include <unordered_map>
|
|
|
|
class TierCard : public QWidget
|
|
{
|
|
Q_OBJECT
|
|
public:
|
|
using IdType = uint32_t;
|
|
inline static const char* MimeType = "application/x-tiercard";
|
|
TierCard(TierCard const&) = delete;
|
|
~TierCard();
|
|
static TierCard* create(QWidget *parent = nullptr);
|
|
static TierCard* clone(TierCard *other, QWidget* parent = nullptr);
|
|
static TierCard* getFromId(IdType id);
|
|
void setText(QString str);
|
|
QString getText() const;
|
|
void setImage(const QPixmap img);
|
|
QPixmap getImage() const;
|
|
IdType getId() const;
|
|
void setBgColor(QColor color);
|
|
QColor getBgColor();
|
|
// QColor bg_color() const;
|
|
|
|
protected:
|
|
void mousePressEvent(QMouseEvent* event);
|
|
|
|
private:
|
|
explicit TierCard(IdType id, QWidget *parent = nullptr);
|
|
QWidget* background;
|
|
AspectRatioPixmapLabel* image;
|
|
QLabel* textLabel;
|
|
QLabel* idLabel;
|
|
QColor bgColor;
|
|
static IdType getAvailableId();
|
|
static void releaseId(IdType id);
|
|
inline static std::unordered_map<IdType, TierCard*> idMap;
|
|
|
|
signals:
|
|
};
|
|
|
|
#endif // TIERCARD_H
|