1/***************************************************************************
2* KBlocks, a falling blocks game for KDE *
3* Copyright (C) 2009 Mauricio Piacentini <mauricio@tabuleiro.com> *
4* Zhongjie Cai <squall.leonhart.cai@gmail.com> *
5* *
6* This program is free software; you can redistribute it and/or modify *
7* it under the terms of the GNU General Public License as published by *
8* the Free Software Foundation; either version 2 of the License, or *
9* (at your option) any later version. *
10***************************************************************************/
11#include "KBlocksAnimFade.h"
12
13KBlocksAnimFade::KBlocksAnimFade(const QList<KBlocksSvgItem*> & items, int duration, QTimeLine::Direction direction)
14{
15 mItemList = items;
16
17 mpTimeLine = new QTimeLine(duration);
18 mpTimeLine->setFrameRange( 0, 30 );
19 mpTimeLine->setDirection(direction);
20
21 connect(mpTimeLine, SIGNAL(valueChanged(qreal)), SLOT(valueChanged(qreal)));
22 connect(mpTimeLine, SIGNAL(finished()), SLOT(endAnimation()));
23
24 mpTimeLine->start();
25}
26
27KBlocksAnimFade::~KBlocksAnimFade()
28{
29 delete mpTimeLine;
30}
31
32void KBlocksAnimFade::valueChanged(qreal value)
33{
34 foreach(KBlocksSvgItem * pItem, mItemList)
35 {
36 pItem->setOpacity(value);
37 }
38}
39
40void KBlocksAnimFade::endAnimation()
41{
42 emit animationFinished();
43}
44