15 #include <qapplication.h> 22 #include <QMouseEvent> 30 QPixmap* hoverOverImage,
31 int setMethod,
int removalMethod,
32 int resetMethod,
int removalBeforeResetMethod,
33 int initDelay,
int accel) :
QLabel(parent,name)
48 setMouseTracking(
true);
59 setWindowFlags(Qt::WNoAutoErase);
68 connect(
timer, SIGNAL(timeout()),
this, SLOT(
animate()) );
130 pixStore =
new QImage(p.convertToImage());
215 int inc = (int)(ms/(
delay+1));
255 double alpha = ((double)
step) / 100.0;
256 int w = (int) ( w1 + (w2-w1)*alpha );
257 int h = (int) ( h1 + (h2-h1)*alpha );
260 QImage oldImg =
pixStore->scaled( w, h );
268 QImage tmpImage(w, h, maxDepth);
275 QRgb v1 = oldImg.pixel(x,y);
276 QRgb v2 = newImg.pixel(x,y);
277 int r = (int) (alpha* qRed(v2) + (1-alpha)*qRed(v1));
278 int g = (int) (alpha* qGreen(v2) + (1-alpha)*qGreen(v1));
279 int b = (int) (alpha* qBlue(v2) + (1-alpha)*qBlue(v1));
281 tmpImage.setPixel(x, y, qRgb(r,g,b) );
287 tmpPixmap.convertFromImage( tmpImage );
288 QLabel::setPixmap( tmpPixmap );
302 else if(
step != lastStep &&
312 QLabel::setPixmap( NULL );
319 QLabel::setPixmap( QPixmap::fromImage(*
pixStore) );
328 for(x = 0; x<
step; x++)
330 for(y = 0; y<
pixStore->height(); y++)
336 { tmpImage.setPixel( x, y,
pixStore->pixel(x,y) ); }
341 QPixmap tmpPixmap(step,
pixStore->height() );
342 tmpPixmap.convertFromImage( tmpImage );
343 QLabel::setPixmap( tmpPixmap );
453 QLabel::paintEvent(pe);
462 int minDim = r.width();
463 if(r.height() < minDim)
474 QImage resizedImage =
hoverOverImage->convertToImage().scaled(minDim, minDim);
475 QPixmap resizedPixmap(resizedImage);
476 r.setLeft( r.right() - resizedPixmap.width() );
477 r.setBottom( r.top() + resizedPixmap.height() );
479 p.drawPixmap( r, resizedPixmap);
510 QPainter* p =
new QPainter();
513 int minDim = r.width();
514 if(r.height() < minDim)
523 QImage resizedImage =
hoverOverImage->convertToImage().scaled(minDim, minDim);
524 QPixmap resizedPixmap(resizedImage);
525 r.setLeft( r.right() - resizedPixmap.width() );
526 r.setBottom( r.top() + resizedPixmap.height() );
529 if(r.contains( e->pos() ) )
548 setCursor( QCursor( Qt::PointingHandCursor ) );
556 setCursor( QCursor( Qt::ArrowCursor ) );
583 while(currAction != NULL && currAction->
getImage() == NULL)
591 if(currAction == NULL)
658 { this->next = next; }
void setPixmap(const QPixmap &p)
animates setting an image
void mouseReleaseEvent(QMouseEvent *)
void setNext(Action *next)
void paintEvent(QPaintEvent *pe)
void internalSetPixmap(const QPixmap &p)
void leaveEvent(QEvent *e)
void mousePress()
various mouse-click signals
void removePixmap(bool forceImmediate=false)
animates removing an image
void internalRemovePixmap(bool forceImmediate=false)
QMutex animatingBoolMutex
#define DISAPPEAR_IMMEDIATELY
void mouseMoveEvent(QMouseEvent *)
void setAnimationMethods(int setMethod=APPEAR_IMMEDIATELY, int removalMethod=DISAPPEAR_IMMEDIATELY, int resetMethod=APPEAR_IMMEDIATELY, int removalBeforeResetMethod=DISAPPEAR_IMMEDIATELY)
alter animation methods
void enterEvent(QEvent *e)
int removalBeforeResetMethod
Action * delayedActionHead
void mouseDoubleClickEvent(QMouseEvent *)
Action * delayedActionTail
void mousePressEvent(QMouseEvent *)
ALabel(QWidget *parent=0, const char *name=0, QPixmap *hoverOverImage=NULL, int setMethod=APPEAR_IMMEDIATELY, int removalMethod=DISAPPEAR_IMMEDIATELY, int resetMethod=APPEAR_IMMEDIATELY, int removalBeforeResetMethod=DISAPPEAR_IMMEDIATELY, int initDelay=130, int accel=50)
create the label, optionally set a hover-over image (only displayed when pixmap for label is set and ...
#define APPEAR_IMMEDIATELY
void animatePixmap()
begin animating the pixmap
void appendJob(QPixmap *pix)