Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Donald Haase
Cockatrice
Commits
3211801e
Commit
3211801e
authored
Oct 16, 2011
by
Max-Wilhelm Bruker
Browse files
show hand context menu when hand counter is rightclicked
parent
683c57bb
Changes
5
Hide whitespace changes
Inline
Side-by-side
cockatrice/src/cardzone.cpp
View file @
3211801e
...
@@ -86,13 +86,21 @@ void CardZone::mouseDoubleClickEvent(QGraphicsSceneMouseEvent */*event*/)
...
@@ -86,13 +86,21 @@ void CardZone::mouseDoubleClickEvent(QGraphicsSceneMouseEvent */*event*/)
doubleClickAction
->
trigger
();
doubleClickAction
->
trigger
();
}
}
bool
CardZone
::
showContextMenu
(
const
QPoint
&
screenPos
)
{
if
(
menu
)
{
menu
->
exec
(
screenPos
);
return
true
;
}
return
false
;
}
void
CardZone
::
mousePressEvent
(
QGraphicsSceneMouseEvent
*
event
)
void
CardZone
::
mousePressEvent
(
QGraphicsSceneMouseEvent
*
event
)
{
{
if
(
event
->
button
()
==
Qt
::
RightButton
)
{
if
(
event
->
button
()
==
Qt
::
RightButton
)
{
if
(
menu
)
{
if
(
showContextMenu
(
event
->
screenPos
()))
menu
->
exec
(
event
->
screenPos
());
event
->
accept
();
event
->
accept
();
}
else
else
event
->
ignore
();
event
->
ignore
();
}
else
}
else
event
->
ignore
();
event
->
ignore
();
...
...
cockatrice/src/cardzone.h
View file @
3211801e
...
@@ -32,6 +32,7 @@ signals:
...
@@ -32,6 +32,7 @@ signals:
void
cardCountChanged
();
void
cardCountChanged
();
public
slots
:
public
slots
:
void
moveAllToZone
();
void
moveAllToZone
();
bool
showContextMenu
(
const
QPoint
&
screenPos
);
public:
public:
enum
{
Type
=
typeZone
};
enum
{
Type
=
typeZone
};
int
type
()
const
{
return
Type
;
}
int
type
()
const
{
return
Type
;
}
...
...
cockatrice/src/handcounter.cpp
View file @
3211801e
#include
<QPainter>
#include
<QPainter>
#include
<QSvgRenderer>
#include
<QSvgRenderer>
#include
<QPixmapCache>
#include
<QPixmapCache>
#include
<QGraphicsSceneMouseEvent>
#include
"handcounter.h"
#include
"handcounter.h"
#include
"cardzone.h"
#include
"cardzone.h"
...
@@ -48,3 +49,11 @@ void HandCounter::paint(QPainter *painter, const QStyleOptionGraphicsItem * /*op
...
@@ -48,3 +49,11 @@ void HandCounter::paint(QPainter *painter, const QStyleOptionGraphicsItem * /*op
paintNumberEllipse
(
number
,
24
,
Qt
::
white
,
-
1
,
-
1
,
painter
);
paintNumberEllipse
(
number
,
24
,
Qt
::
white
,
-
1
,
-
1
,
painter
);
}
}
void
HandCounter
::
mousePressEvent
(
QGraphicsSceneMouseEvent
*
event
)
{
if
(
event
->
button
()
==
Qt
::
RightButton
)
{
emit
showContextMenu
(
event
->
screenPos
());
event
->
accept
();
}
}
cockatrice/src/handcounter.h
View file @
3211801e
...
@@ -11,8 +11,12 @@ class HandCounter : public AbstractGraphicsItem {
...
@@ -11,8 +11,12 @@ class HandCounter : public AbstractGraphicsItem {
Q_OBJECT
Q_OBJECT
private:
private:
int
number
;
int
number
;
protected:
void
mousePressEvent
(
QGraphicsSceneMouseEvent
*
event
);
public
slots
:
public
slots
:
void
updateNumber
();
void
updateNumber
();
signals:
void
showContextMenu
(
const
QPoint
&
screenPos
);
public:
public:
enum
{
Type
=
typeOther
};
enum
{
Type
=
typeOther
};
int
type
()
const
{
return
Type
;
}
int
type
()
const
{
return
Type
;
}
...
...
cockatrice/src/player.cpp
View file @
3211801e
...
@@ -90,6 +90,7 @@ Player::Player(ServerInfo_User *info, int _id, bool _local, TabGame *_parent)
...
@@ -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
);
hand
=
new
HandZone
(
this
,
_local
||
(
_parent
->
getSpectator
()
&&
_parent
->
getSpectatorsSeeEverything
()),
(
int
)
table
->
boundingRect
().
height
(),
this
);
connect
(
hand
,
SIGNAL
(
cardCountChanged
()),
handCounter
,
SLOT
(
updateNumber
()));
connect
(
hand
,
SIGNAL
(
cardCountChanged
()),
handCounter
,
SLOT
(
updateNumber
()));
connect
(
handCounter
,
SIGNAL
(
showContextMenu
(
const
QPoint
&
)),
hand
,
SLOT
(
showContextMenu
(
const
QPoint
&
)));
updateBoundingRect
();
updateBoundingRect
();
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment