equal
deleted
inserted
replaced
1 /* |
|
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 #include "HgImageFader.h" |
|
18 #include "hgimage.h" |
|
19 |
|
20 HgImageFader::HgImageFader() |
|
21 { |
|
22 QObject::connect(&mTimer, SIGNAL(timeout()), this, SLOT(doFading())); |
|
23 } |
|
24 |
|
25 HgImageFader::~HgImageFader() |
|
26 { |
|
27 if (mTimer.isActive()) |
|
28 mTimer.stop(); |
|
29 } |
|
30 |
|
31 void HgImageFader::addImage(HgImage* image) |
|
32 { |
|
33 mImages.push_back(image); |
|
34 } |
|
35 |
|
36 void HgImageFader::removeImage(HgImage* image) |
|
37 { |
|
38 mImages.removeOne(image); |
|
39 } |
|
40 |
|
41 void HgImageFader::fadeImages() |
|
42 { |
|
43 if (!mImages.empty() && !mTimer.isActive()) |
|
44 { |
|
45 mTimer.start(10); |
|
46 } |
|
47 } |
|
48 |
|
49 void HgImageFader::doFading() |
|
50 { |
|
51 QLinkedList<HgImage*>::iterator i = mImages.begin(); |
|
52 while (i != mImages.end()) |
|
53 { |
|
54 HgImage* image = (*i); |
|
55 image->setAlpha(image->alpha() + 0.1f); |
|
56 if (image->alpha() >= 1.0f) |
|
57 { |
|
58 image->setAlpha(1.0f); |
|
59 i = mImages.erase(i); |
|
60 } |
|
61 else |
|
62 { |
|
63 i++; |
|
64 } |
|
65 } |
|
66 |
|
67 //emit doUpdate(); |
|
68 |
|
69 if (mImages.empty()) |
|
70 { |
|
71 mTimer.stop(); |
|
72 } |
|
73 } |
|