diff --git a/cockatrice/src/cardzone.cpp b/cockatrice/src/cardzone.cpp index ceaf08523..cb2c24ccf 100644 --- a/cockatrice/src/cardzone.cpp +++ b/cockatrice/src/cardzone.cpp @@ -86,13 +86,21 @@ void CardZone::mouseDoubleClickEvent(QGraphicsSceneMouseEvent */*event*/) doubleClickAction->trigger(); } +bool CardZone::showContextMenu(const QPoint &screenPos) +{ + if (menu) { + menu->exec(screenPos); + return true; + } + return false; +} + void CardZone::mousePressEvent(QGraphicsSceneMouseEvent *event) { if (event->button() == Qt::RightButton) { - if (menu) { - menu->exec(event->screenPos()); + if (showContextMenu(event->screenPos())) event->accept(); - } else + else event->ignore(); } else event->ignore(); diff --git a/cockatrice/src/cardzone.h b/cockatrice/src/cardzone.h index 7c159a707..31955b158 100644 --- a/cockatrice/src/cardzone.h +++ b/cockatrice/src/cardzone.h @@ -32,6 +32,7 @@ signals: void cardCountChanged(); public slots: void moveAllToZone(); + bool showContextMenu(const QPoint &screenPos); public: enum { Type = typeZone }; int type() const { return Type; } diff --git a/cockatrice/src/handcounter.cpp b/cockatrice/src/handcounter.cpp index aa1f9ce1e..f5210dd15 100644 --- a/cockatrice/src/handcounter.cpp +++ b/cockatrice/src/handcounter.cpp @@ -1,6 +1,7 @@ #include #include #include +#include #include "handcounter.h" #include "cardzone.h" @@ -48,3 +49,11 @@ void HandCounter::paint(QPainter *painter, const QStyleOptionGraphicsItem * /*op paintNumberEllipse(number, 24, Qt::white, -1, -1, painter); } + +void HandCounter::mousePressEvent(QGraphicsSceneMouseEvent *event) +{ + if (event->button() == Qt::RightButton) { + emit showContextMenu(event->screenPos()); + event->accept(); + } +} diff --git a/cockatrice/src/handcounter.h b/cockatrice/src/handcounter.h index 111d1c534..f7ef9608f 100644 --- a/cockatrice/src/handcounter.h +++ b/cockatrice/src/handcounter.h @@ -11,8 +11,12 @@ class HandCounter : public AbstractGraphicsItem { Q_OBJECT private: int number; +protected: + void mousePressEvent(QGraphicsSceneMouseEvent *event); public slots: void updateNumber(); +signals: + void showContextMenu(const QPoint &screenPos); public: enum { Type = typeOther }; int type() const { return Type; } diff --git a/cockatrice/src/player.cpp b/cockatrice/src/player.cpp index 054ef32a3..5f78b4d8b 100644 --- a/cockatrice/src/player.cpp +++ b/cockatrice/src/player.cpp @@ -90,6 +90,7 @@ Player::Player(ServerInfo_User *info, int _id, bool _local, TabGame *_parent) hand = new HandZone(this, _local || (_parent->getSpectator() && _parent->getSpectatorsSeeEverything()), (int) table->boundingRect().height(), this); connect(hand, SIGNAL(cardCountChanged()), handCounter, SLOT(updateNumber())); + connect(handCounter, SIGNAL(showContextMenu(const QPoint &)), hand, SLOT(showContextMenu(const QPoint &))); updateBoundingRect();