added yellow border to cards being moused over
This commit is contained in:
parent
55e7feeebe
commit
179f1fe14b
2 changed files with 13 additions and 1 deletions
|
@ -13,7 +13,7 @@
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
|
|
||||||
AbstractCardItem::AbstractCardItem(const QString &_name, Player *_owner, QGraphicsItem *parent)
|
AbstractCardItem::AbstractCardItem(const QString &_name, Player *_owner, QGraphicsItem *parent)
|
||||||
: ArrowTarget(_owner, parent), info(db->getCard(_name)), infoWidget(0), name(_name), tapped(false), tapAngle(0)
|
: ArrowTarget(_owner, parent), info(db->getCard(_name)), infoWidget(0), name(_name), tapped(false), tapAngle(0), isHovered(false)
|
||||||
{
|
{
|
||||||
setCursor(Qt::OpenHandCursor);
|
setCursor(Qt::OpenHandCursor);
|
||||||
setFlag(ItemIsSelectable);
|
setFlag(ItemIsSelectable);
|
||||||
|
@ -132,6 +132,9 @@ void AbstractCardItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *
|
||||||
if (isSelected()) {
|
if (isSelected()) {
|
||||||
painter->setPen(Qt::red);
|
painter->setPen(Qt::red);
|
||||||
painter->drawRect(QRectF(0.5, 0.5, CARD_WIDTH - 1, CARD_HEIGHT - 1));
|
painter->drawRect(QRectF(0.5, 0.5, CARD_WIDTH - 1, CARD_HEIGHT - 1));
|
||||||
|
} else if (isHovered) {
|
||||||
|
painter->setPen(Qt::yellow);
|
||||||
|
painter->drawRect(QRectF(0.5, 0.5, CARD_WIDTH - 1, CARD_HEIGHT - 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
painter->restore();
|
painter->restore();
|
||||||
|
@ -209,9 +212,16 @@ void AbstractCardItem::processHoverEvent()
|
||||||
void AbstractCardItem::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
|
void AbstractCardItem::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
|
||||||
{
|
{
|
||||||
processHoverEvent();
|
processHoverEvent();
|
||||||
|
isHovered = true;
|
||||||
QGraphicsItem::hoverEnterEvent(event);
|
QGraphicsItem::hoverEnterEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AbstractCardItem::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
|
||||||
|
{
|
||||||
|
isHovered = false;
|
||||||
|
QGraphicsItem::hoverLeaveEvent(event);
|
||||||
|
}
|
||||||
|
|
||||||
QVariant AbstractCardItem::itemChange(QGraphicsItem::GraphicsItemChange change, const QVariant &value)
|
QVariant AbstractCardItem::itemChange(QGraphicsItem::GraphicsItemChange change, const QVariant &value)
|
||||||
{
|
{
|
||||||
if (change == ItemSelectedHasChanged) {
|
if (change == ItemSelectedHasChanged) {
|
||||||
|
|
|
@ -22,6 +22,7 @@ protected:
|
||||||
QString color;
|
QString color;
|
||||||
private:
|
private:
|
||||||
QTimer *animationTimer;
|
QTimer *animationTimer;
|
||||||
|
bool isHovered;
|
||||||
private slots:
|
private slots:
|
||||||
void animationEvent();
|
void animationEvent();
|
||||||
void pixmapUpdated();
|
void pixmapUpdated();
|
||||||
|
@ -51,6 +52,7 @@ protected:
|
||||||
void mousePressEvent(QGraphicsSceneMouseEvent *event);
|
void mousePressEvent(QGraphicsSceneMouseEvent *event);
|
||||||
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
|
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
|
||||||
void hoverEnterEvent(QGraphicsSceneHoverEvent *event);
|
void hoverEnterEvent(QGraphicsSceneHoverEvent *event);
|
||||||
|
void hoverLeaveEvent(QGraphicsSceneHoverEvent *event);
|
||||||
QVariant itemChange(QGraphicsItem::GraphicsItemChange change, const QVariant &value);
|
QVariant itemChange(QGraphicsItem::GraphicsItemChange change, const QVariant &value);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue