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-03-14 09:02:41 +00:00
|
|
|
// using namespace std;
|
2007-01-28 02:24:46 +00:00
|
|
|
|
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-30 19:13:00 +00:00
|
|
|
flipCardsAction1 = FALSE;
|
|
|
|
|
flipCardsAction2 = FALSE;
|
2007-01-28 01:28:19 +00:00
|
|
|
|
2007-01-30 19:13:00 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
// rotationIntervall = 0.03;
|
|
|
|
|
|
2007-01-29 00:53:20 +00:00
|
|
|
isFlipside = FALSE;
|
|
|
|
|
|
2007-01-30 19:13:00 +00:00
|
|
|
front = new QPixmap;
|
2007-02-01 23:46:34 +00:00
|
|
|
flipside = new QPixmap;
|
2007-01-30 19:13:00 +00:00
|
|
|
|
2007-01-29 23:57:11 +00:00
|
|
|
fadeOutTimer = new QTimer;
|
2007-01-30 19:13:00 +00:00
|
|
|
connect(fadeOutTimer, SIGNAL(timeout()), this, SLOT(nextFadeOutFrame()));
|
|
|
|
|
flipCardsTimer = new QTimer;
|
|
|
|
|
connect(flipCardsTimer, SIGNAL(timeout()), this, SLOT(nextFlipCardsFrame()));
|
2007-01-28 01:28:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
MyCardsPixmapLabel::~MyCardsPixmapLabel()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2007-01-28 14:48:18 +00:00
|
|
|
void MyCardsPixmapLabel::startFadeOut(int speed) {
|
|
|
|
|
|
2007-01-30 19:13:00 +00:00
|
|
|
|
|
|
|
|
frameOpacity = 0.0;
|
|
|
|
|
|
2007-01-28 14:48:18 +00:00
|
|
|
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 14:48:18 +00:00
|
|
|
}
|
2007-01-28 02:24:46 +00:00
|
|
|
|
|
|
|
|
}
|
2007-01-28 01:28:19 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
void MyCardsPixmapLabel::nextFadeOutFrame() {
|
|
|
|
|
|
2007-03-29 22:58:04 +00:00
|
|
|
if (frameOpacity < 0.75) {
|
2007-01-28 14:48:18 +00:00
|
|
|
frameOpacity += opacityRaiseIntervall;
|
2007-01-28 01:28:19 +00:00
|
|
|
update();
|
|
|
|
|
}
|
2007-01-28 02:24:46 +00:00
|
|
|
else {
|
2007-03-30 12:44:16 +00:00
|
|
|
|
2007-01-29 23:57:11 +00:00
|
|
|
fadeOutTimer->stop();
|
2007-03-30 12:44:16 +00:00
|
|
|
// fadeOutAction = FALSE;
|
2007-01-28 02:24:46 +00:00
|
|
|
}
|
2007-01-28 01:28:19 +00:00
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2007-01-30 19:13:00 +00:00
|
|
|
void MyCardsPixmapLabel::startFlipCards(int speed, QPixmap frontPix, QPixmap *flipsidePix) {
|
2007-01-29 23:57:11 +00:00
|
|
|
|
2007-01-31 01:17:13 +00:00
|
|
|
QLabel::setPixmap(frontPix);
|
|
|
|
|
|
2007-01-30 19:13:00 +00:00
|
|
|
frameFlipCardsAction1Size = 1.0;
|
|
|
|
|
frameFlipCardsAction2Size = 0.0;
|
|
|
|
|
|
|
|
|
|
*front = frontPix;
|
|
|
|
|
flipside = flipsidePix;
|
|
|
|
|
|
2007-01-31 01:17:13 +00:00
|
|
|
if(speed <= 4) { flipCardsScaleIntervall = 0.1; }
|
|
|
|
|
if(speed > 4 && speed <= 6) { flipCardsScaleIntervall = 0.20; }
|
|
|
|
|
if(speed > 6 && speed <= 8) { flipCardsScaleIntervall = 0.25; }
|
|
|
|
|
if(speed > 8 && speed <= 10) { flipCardsScaleIntervall = 0.5; }
|
|
|
|
|
//
|
|
|
|
|
|
2007-01-30 19:13:00 +00:00
|
|
|
if(speed != 11) {
|
|
|
|
|
flipCardsAction1 = TRUE;
|
|
|
|
|
flipCardsTimer->start(40);
|
|
|
|
|
}
|
2007-01-29 23:57:11 +00:00
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MyCardsPixmapLabel::nextFlipCardsFrame() {
|
|
|
|
|
|
2007-01-30 19:13:00 +00:00
|
|
|
if (frameFlipCardsAction1Size > 0.1 ) {
|
|
|
|
|
//erst flipside verkleinern
|
|
|
|
|
frameFlipCardsAction1Size -= flipCardsScaleIntervall;
|
|
|
|
|
update();
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
if(flipCardsAction1) {
|
|
|
|
|
flipCardsAction1 = FALSE;
|
|
|
|
|
flipCardsAction2 = TRUE;
|
|
|
|
|
}
|
|
|
|
|
else {
|
2007-01-31 01:17:13 +00:00
|
|
|
//dann front vergrößern
|
2007-01-30 19:13:00 +00:00
|
|
|
if (frameFlipCardsAction2Size < 0.9 ) {
|
|
|
|
|
|
|
|
|
|
frameFlipCardsAction2Size += flipCardsScaleIntervall;
|
|
|
|
|
update();
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
flipCardsAction2 = FALSE;
|
|
|
|
|
flipCardsTimer->stop();
|
|
|
|
|
}
|
2007-01-29 23:57:11 +00:00
|
|
|
|
2007-01-30 19:13:00 +00:00
|
|
|
}
|
|
|
|
|
}
|
2007-01-29 23:57:11 +00:00
|
|
|
}
|
|
|
|
|
|
2007-02-01 23:46:34 +00:00
|
|
|
void MyCardsPixmapLabel::setPixmap(const QPixmap &pic, const bool flipsideIs) {
|
2007-01-29 00:53:20 +00:00
|
|
|
|
|
|
|
|
QLabel::setPixmap(pic);
|
2007-02-01 23:46:34 +00:00
|
|
|
isFlipside = flipsideIs;
|
2007-01-29 00:53:20 +00:00
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2007-01-28 01:28:19 +00:00
|
|
|
void MyCardsPixmapLabel::paintEvent(QPaintEvent * event) {
|
|
|
|
|
|
2007-01-30 19:13:00 +00:00
|
|
|
if (!(flipCardsAction1 || flipCardsAction2)) {
|
|
|
|
|
QLabel::paintEvent(event);
|
|
|
|
|
}
|
2007-01-28 01:28:19 +00:00
|
|
|
|
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));
|
2007-01-31 21:43:33 +00:00
|
|
|
// painter.setBrush(palette().color(QPalette::Background));
|
2007-01-28 02:24:46 +00:00
|
|
|
// painter.setBrush(QColor(0,0,0));
|
|
|
|
|
|
|
|
|
|
painter.setOpacity(frameOpacity);
|
|
|
|
|
// painter.drawRect(this->geometry());
|
2007-03-27 16:02:23 +00:00
|
|
|
if(objectName().contains("pixmapLabel_card"))
|
|
|
|
|
painter.drawRect(-1,-1,81,112);
|
2007-01-28 02:24:46 +00:00
|
|
|
else
|
2007-03-27 16:02:23 +00:00
|
|
|
painter.drawRect(-1,-1,80,115);
|
2007-01-28 02:24:46 +00:00
|
|
|
|
|
|
|
|
}
|
2007-01-30 19:13:00 +00:00
|
|
|
|
|
|
|
|
if (flipCardsAction1) {
|
|
|
|
|
QPainter painter2(this);
|
2007-02-01 23:46:34 +00:00
|
|
|
QPixmap tmpFlipside = flipside->scaled(width(), height(), Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
|
|
|
|
|
QPointF center(tmpFlipside.width()/2.0, tmpFlipside.height()/2.0);
|
2007-01-30 19:13:00 +00:00
|
|
|
|
|
|
|
|
painter2.translate(center);
|
|
|
|
|
painter2.scale(frameFlipCardsAction1Size ,1);
|
|
|
|
|
painter2.translate(-center);
|
2007-02-01 23:46:34 +00:00
|
|
|
painter2.drawPixmap(0,0, tmpFlipside);
|
2007-01-30 19:13:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (flipCardsAction2) {
|
|
|
|
|
QPainter painter3(this);
|
2007-02-01 23:46:34 +00:00
|
|
|
QPixmap tmpFront = front->scaled(width(), height(), Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
|
|
|
|
|
QPointF center(tmpFront.width()/2.0, tmpFront.height()/2.0);
|
2007-01-30 19:13:00 +00:00
|
|
|
|
|
|
|
|
painter3.translate(center);
|
|
|
|
|
painter3.scale(frameFlipCardsAction2Size ,1);
|
|
|
|
|
painter3.translate(-center);
|
|
|
|
|
|
2007-02-01 23:46:34 +00:00
|
|
|
painter3.drawPixmap(0,0, tmpFront);
|
2007-01-30 19:13:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-01-28 01:28:19 +00:00
|
|
|
}
|
2007-03-30 12:44:16 +00:00
|
|
|
|
|
|
|
|
// bool MyCardsPixmapLabel::event ( QEvent * event ) {
|
|
|
|
|
//
|
|
|
|
|
// if(event->type() == QEvent::MouseMove) { event->ignore(); }
|
|
|
|
|
// QLabel::event(event);
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|