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 "KBlocksAnimDrop.h" |
12 | |
13 | KBlocksAnimDrop::KBlocksAnimDrop(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 | |
27 | KBlocksAnimDrop::~KBlocksAnimDrop() |
28 | { |
29 | delete mpTimeLine; |
30 | } |
31 | |
32 | void KBlocksAnimDrop::valueChanged(qreal value) |
33 | { |
34 | Q_UNUSED(value); |
35 | foreach(KBlocksSvgItem * pItem, mItemList) |
36 | { |
37 | pItem->execPosAnim(value); |
38 | } |
39 | } |
40 | |
41 | void KBlocksAnimDrop::endAnimation() |
42 | { |
43 | emit animationFinished(); |
44 | } |
45 | |