Files
pokerth/src/gui/qt/gametable/myavatarlabel.cpp
T

78 lines
1.8 KiB
C++
Raw Normal View History

2008-05-05 07:46:19 +00:00
//
// C++ Implementation: mycardspixmaplabel
//
// Description:
//
//
// Author: FThauer FHammer <f.thauer@web.de>, (C) 2007
//
// Copyright: See COPYING file that comes with this distribution
//
//
#include "mysetlabel.h"
#include "gametableimpl.h"
2008-10-17 19:39:27 +00:00
#include "session.h"
#include "playerinterface.h"
#include "game.h"
2008-05-05 07:46:19 +00:00
using namespace std;
MyAvatarLabel::MyAvatarLabel(QGroupBox* parent)
: QLabel(parent)
{
myContextMenu = new QMenu;
2008-11-19 22:12:33 +00:00
action_VoteForKick = new QAction(QIcon(":/gfx/list_remove_user.png"), tr("Start vote to kick this user"), myContextMenu);
2008-09-23 08:15:33 +00:00
myContextMenu->addAction(action_VoteForKick);
2008-05-05 07:46:19 +00:00
2008-10-12 19:36:46 +00:00
connect( action_VoteForKick, SIGNAL ( triggered() ), this, SLOT ( sendTriggerVoteOnKickSignal() ) );
2008-05-05 07:46:19 +00:00
}
MyAvatarLabel::~MyAvatarLabel()
{
}
2008-09-23 08:15:33 +00:00
void MyAvatarLabel::contextMenuEvent ( QContextMenuEvent *event ) {
2008-05-05 07:46:19 +00:00
2008-10-17 19:39:27 +00:00
Game *currentGame = myW->getSession()->getCurrentGame();
2008-10-17 19:39:27 +00:00
PlayerListConstIterator it_c;
int activePlayerCounter=0;
for (it_c=currentGame->getSeatsList()->begin(); it_c!=currentGame->getSeatsList()->end(); it_c++) {
if((*it_c)->getMyActiveStatus()) activePlayerCounter++;
}
2008-12-08 21:50:43 +00:00
if(activePlayerCounter > 2 && !voteRunning ) setVoteOnKickContextMenuEnabled(TRUE);
else setVoteOnKickContextMenuEnabled(FALSE);
2008-10-17 19:39:27 +00:00
int i=0;
for (it_c=currentGame->getSeatsList()->begin(); it_c!=currentGame->getSeatsList()->end(); it_c++) {
if(myContextMenuEnabled && myId != 0 && myId == i && (*it_c)->getMyActiveStatus() )
showContextMenu(event->globalPos());
i++;
}
2008-05-05 07:46:19 +00:00
}
2008-09-23 08:15:33 +00:00
void MyAvatarLabel::showContextMenu(const QPoint &pos) {
2008-05-05 07:46:19 +00:00
2008-09-23 08:15:33 +00:00
myContextMenu->popup(pos);
}
2008-10-12 19:36:46 +00:00
void MyAvatarLabel::sendTriggerVoteOnKickSignal()
2008-09-23 08:15:33 +00:00
{
2008-10-12 19:36:46 +00:00
myW->triggerVoteOnKick(myId);
}
void MyAvatarLabel::setEnabledContextMenu(bool b)
{
myContextMenuEnabled = b;
2008-05-05 07:46:19 +00:00
}
2008-11-17 16:02:11 +00:00
void MyAvatarLabel::setVoteOnKickContextMenuEnabled(bool b)
{
action_VoteForKick->setEnabled(b);
}