~ubuntu-branches/ubuntu/saucy/kblocks/saucy-proposed

« back to all changes in this revision

Viewing changes to KBlocksAnimFade.cpp

  • Committer: Package Import Robot
  • Author(s): Jonathan Riddell
  • Date: 2012-12-07 17:39:13 UTC
  • Revision ID: package-import@ubuntu.com-20121207173913-5wqlq9suj93x4ap2
Tags: upstream-4.9.90
ImportĀ upstreamĀ versionĀ 4.9.90

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
 
 
13
KBlocksAnimFade::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
 
 
27
KBlocksAnimFade::~KBlocksAnimFade()
 
28
{
 
29
    delete mpTimeLine;
 
30
}
 
31
 
 
32
void KBlocksAnimFade::valueChanged(qreal value)
 
33
{
 
34
    foreach(KBlocksSvgItem * pItem, mItemList)
 
35
    {
 
36
        pItem->setOpacity(value);
 
37
    }
 
38
}
 
39
 
 
40
void KBlocksAnimFade::endAnimation()
 
41
{
 
42
    emit animationFinished();
 
43
}