Files
pokerth/src/gui/qt/cards/mycardspixmaplabel.cpp
T

117 lines
2.3 KiB
C++
Raw Normal View History

2007-01-28 01:28: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 "mycardspixmaplabel.h"
2007-01-28 02:24:46 +00:00
using namespace std;
2007-01-28 01:28:19 +00:00
MyCardsPixmapLabel::MyCardsPixmapLabel(QFrame* parent)
: QLabel(parent)
{
2007-01-28 02:24:46 +00:00
fadeOutAction = FALSE;
2007-01-28 01:28:19 +00:00
frameOpacity = 0.0;
opacityRaiseIntervall = 0.01;
2007-01-28 01:28:19 +00:00
2007-01-29 00:53:20 +00:00
isFlipside = FALSE;
2007-01-29 23:57:11 +00:00
fadeOutTimer = new QTimer;
2007-01-28 01:28:19 +00:00
connect(timer, SIGNAL(timeout()), this, SLOT(nextFadeOutFrame()));
}
MyCardsPixmapLabel::~MyCardsPixmapLabel()
{
}
void MyCardsPixmapLabel::startFadeOut(int speed) {
if(speed <= 4) { opacityRaiseIntervall = 0.01; }
if(speed > 4 && speed <= 7) { opacityRaiseIntervall = 0.02; }
if(speed > 7 && speed <= 10) { opacityRaiseIntervall = 0.04; }
if(speed != 11) {
fadeOutAction = TRUE;
frameOpacity = 0.0;
2007-01-29 23:57:11 +00:00
fadeOutTimer->start(40);
}
2007-01-28 02:24:46 +00:00
}
2007-01-28 01:28:19 +00:00
void MyCardsPixmapLabel::nextFadeOutFrame() {
if (frameOpacity < 0.65) {
frameOpacity += opacityRaiseIntervall;
2007-01-28 01:28:19 +00:00
update();
}
2007-01-28 02:24:46 +00:00
else {
2007-01-29 23:57:11 +00:00
fadeOutTimer->stop();
2007-01-28 02:24:46 +00:00
fadeOutAction = FALSE;
}
2007-01-28 01:28:19 +00:00
}
2007-01-29 23:57:11 +00:00
void MyCardsPixmapLabel::startFlipCards(int speed) {
// if(speed <= 4) { opacityRaiseIntervall = 0.01; }
// if(speed > 4 && speed <= 7) { opacityRaiseIntervall = 0.02; }
// if(speed > 7 && speed <= 10) { opacityRaiseIntervall = 0.04; }
//
// if(speed != 11) {
// fadeOutAction = TRUE;
// frameOpacity = 0.0;
// timer->start(40);
// }
}
void MyCardsPixmapLabel::nextFlipCardsFrame() {
// if (frameOpacity < 0.65) {
// frameOpacity += opacityRaiseIntervall;
// update();
// }
// else {
// timer->stop();
// fadeOutAction = FALSE;
// }
}
2007-01-29 00:53:20 +00:00
void MyCardsPixmapLabel::setPixmap(const QPixmap &pic, const bool flipside) {
QLabel::setPixmap(pic);
isFlipside = flipside;
}
2007-01-28 01:28:19 +00:00
void MyCardsPixmapLabel::paintEvent(QPaintEvent * event) {
QLabel::paintEvent(event);
2007-01-28 02:24:46 +00:00
if (fadeOutAction) {
2007-01-28 01:28:19 +00:00
2007-01-28 02:24:46 +00:00
QPainter painter(this);
// painter.setPen(QColor(74,131,83));
painter.setBrush(QColor(74,131,83));
// painter.setBrush(QColor(0,0,0));
painter.setOpacity(frameOpacity);
// painter.drawRect(this->geometry());
if(objectName()=="pixmapLabel_card0b" || objectName()=="pixmapLabel_card0a")
painter.drawRect(-1,-1,81,113);
else
painter.drawRect(-1,-1,58,81);
}
2007-01-28 01:28:19 +00:00
}