123456789101112131415161718192021222324252627282930 |
- #include "DieItem.h"
- #include <QPen>
- DieItem::DieItem(int row, int col, PICK_DIE_STATUS status, qreal size, QGraphicsItem* parent)
- : QGraphicsRectItem(parent), row(row), col(col), status(status) {
- setRect(0, 0, size, size); // 设置单元格大小
- setBrush(getColorByStatus(status));
- // 设置边框(Pen)
- setPen(QPen(QColor(0, 0, 0), 0.5)); // 黑色边框,宽度为0.5
- }
- QColor DieItem::getColorByStatus(PICK_DIE_STATUS status) {
- switch (status) {
- case DIE_EXIST: return QColor(0, 102, 255); // 蓝色
- case NO_EXIST: return QColor(200, 200, 200); // 浅灰
- case PICK_ING: return QColor(255, 255, 0); // 黄色
- case SKIP_DIE: return QColor(128, 128, 128); // 深灰
- case EDGE_DIE: return QColor(255, 165, 0); // 橙色
- default: return QColor(0, 0, 0);
- }
- }
- int DieItem::getRow() const {
- return row;
- }
- int DieItem::getCol() const {
- return col;
- }
|