nicer looking active player display
This commit is contained in:
parent
f2092b89e9
commit
cfd715cce9
3 changed files with 24 additions and 18 deletions
|
@ -726,6 +726,7 @@ void Player::showCardMenu(const QPoint &p)
|
||||||
void Player::setActive(bool _active)
|
void Player::setActive(bool _active)
|
||||||
{
|
{
|
||||||
active = _active;
|
active = _active;
|
||||||
|
table->setActive(active);
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -747,23 +748,6 @@ void Player::paint(QPainter *painter, const QStyleOptionGraphicsItem */*option*/
|
||||||
else
|
else
|
||||||
painter->fillRect(QRectF(0, 0, totalWidth, boundingRect().height()), QBrush(bgPixmap));
|
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->setFont(font);
|
||||||
painter->setPen(QPen(Qt::black));
|
painter->setPen(QPen(Qt::black));
|
||||||
painter->drawText(QRectF(0, 0, totalWidth, 40), Qt::AlignCenter, nameStr);
|
painter->drawText(QRectF(0, 0, totalWidth, 40), Qt::AlignCenter, nameStr);
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
#include "settingscache.h"
|
#include "settingscache.h"
|
||||||
|
|
||||||
TableZone::TableZone(Player *_p, QGraphicsItem *parent)
|
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(tableBgPathChanged()), this, SLOT(updateBgPixmap()));
|
||||||
connect(settingsCache, SIGNAL(economicGridChanged()), this, SLOT(reorganizeCards()));
|
connect(settingsCache, SIGNAL(economicGridChanged()), this, SLOT(reorganizeCards()));
|
||||||
|
@ -47,6 +47,26 @@ void TableZone::paint(QPainter *painter, const QStyleOptionGraphicsItem */*optio
|
||||||
if (player->getMirrored())
|
if (player->getMirrored())
|
||||||
separatorY = height - separatorY;
|
separatorY = height - separatorY;
|
||||||
painter->drawLine(QPointF(0, separatorY), QPointF(width, 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)
|
void TableZone::addCardImpl(CardItem *card, int _x, int _y)
|
||||||
|
|
|
@ -11,6 +11,7 @@ private:
|
||||||
int width, height;
|
int width, height;
|
||||||
int currentMinimumWidth;
|
int currentMinimumWidth;
|
||||||
QPixmap bgPixmap;
|
QPixmap bgPixmap;
|
||||||
|
bool active;
|
||||||
private slots:
|
private slots:
|
||||||
void updateBgPixmap();
|
void updateBgPixmap();
|
||||||
public slots:
|
public slots:
|
||||||
|
@ -36,6 +37,7 @@ public:
|
||||||
int getMinimumWidth() const { return currentMinimumWidth; }
|
int getMinimumWidth() const { return currentMinimumWidth; }
|
||||||
void setWidth(qreal _width);
|
void setWidth(qreal _width);
|
||||||
qreal getWidth() const { return width; }
|
qreal getWidth() const { return width; }
|
||||||
|
void setActive(bool _active) { active = _active; update(); }
|
||||||
protected:
|
protected:
|
||||||
void addCardImpl(CardItem *card, int x, int y);
|
void addCardImpl(CardItem *card, int x, int y);
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue