diff --git a/cockatrice/src/player.cpp b/cockatrice/src/player.cpp index f6211562..beadbb39 100644 --- a/cockatrice/src/player.cpp +++ b/cockatrice/src/player.cpp @@ -726,6 +726,7 @@ void Player::showCardMenu(const QPoint &p) void Player::setActive(bool _active) { active = _active; + table->setActive(active); update(); } @@ -747,23 +748,6 @@ void Player::paint(QPainter *painter, const QStyleOptionGraphicsItem */*option*/ else painter->fillRect(QRectF(0, 0, totalWidth, boundingRect().height()), QBrush(bgPixmap)); - if (getActive()) { - QFontMetrics fm(font); - double w = fm.width(nameStr) * 1.7; - double h = fm.height() * 1.7; - if (w < h) - w = h; - - painter->setPen(Qt::transparent); - QRadialGradient grad(QPointF(0.5, 0.5), 0.5); - grad.setCoordinateMode(QGradient::ObjectBoundingMode); - grad.setColorAt(0, QColor(150, 200, 150, 255)); - grad.setColorAt(0.7, QColor(150, 200, 150, 255)); - grad.setColorAt(1, QColor(150, 150, 150, 0)); - painter->setBrush(QBrush(grad)); - - painter->drawEllipse(QRectF(((double) (totalWidth - w)) / 2, 0, w, h)); - } painter->setFont(font); painter->setPen(QPen(Qt::black)); painter->drawText(QRectF(0, 0, totalWidth, 40), Qt::AlignCenter, nameStr); diff --git a/cockatrice/src/tablezone.cpp b/cockatrice/src/tablezone.cpp index 40a4866c..41b1b6c7 100644 --- a/cockatrice/src/tablezone.cpp +++ b/cockatrice/src/tablezone.cpp @@ -6,7 +6,7 @@ #include "settingscache.h" TableZone::TableZone(Player *_p, QGraphicsItem *parent) - : CardZone(_p, "table", true, false, true, parent) + : CardZone(_p, "table", true, false, true, parent), active(false) { connect(settingsCache, SIGNAL(tableBgPathChanged()), this, SLOT(updateBgPixmap())); connect(settingsCache, SIGNAL(economicGridChanged()), this, SLOT(reorganizeCards())); @@ -47,6 +47,26 @@ void TableZone::paint(QPainter *painter, const QStyleOptionGraphicsItem */*optio if (player->getMirrored()) separatorY = height - separatorY; painter->drawLine(QPointF(0, separatorY), QPointF(width, separatorY)); + + if (active) { + QColor color1(255, 255, 255, 150); + QColor color2(255, 255, 255, 0); + QLinearGradient grad1(0, 0, 0, 1); + grad1.setCoordinateMode(QGradient::ObjectBoundingMode); + grad1.setColorAt(0, color1); + grad1.setColorAt(1, color2); + painter->fillRect(QRectF(0, 0, width, 10), QBrush(grad1)); + + grad1.setFinalStop(1, 0); + painter->fillRect(QRectF(0, 0, 10, height), QBrush(grad1)); + + grad1.setStart(0, 1); + grad1.setFinalStop(0, 0); + painter->fillRect(QRectF(0, height - 10, width, 10), QBrush(grad1)); + + grad1.setStart(1, 0); + painter->fillRect(QRectF(width - 10, 0, 10, height), QBrush(grad1)); + } } void TableZone::addCardImpl(CardItem *card, int _x, int _y) diff --git a/cockatrice/src/tablezone.h b/cockatrice/src/tablezone.h index d543ae32..b528cafb 100644 --- a/cockatrice/src/tablezone.h +++ b/cockatrice/src/tablezone.h @@ -11,6 +11,7 @@ private: int width, height; int currentMinimumWidth; QPixmap bgPixmap; + bool active; private slots: void updateBgPixmap(); public slots: @@ -36,6 +37,7 @@ public: int getMinimumWidth() const { return currentMinimumWidth; } void setWidth(qreal _width); qreal getWidth() const { return width; } + void setActive(bool _active) { active = _active; update(); } protected: void addCardImpl(CardItem *card, int x, int y); };