|
1 /* |
|
2 * Copyright (c) 2010 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 |
|
18 |
|
19 #include "visibilityanimator.h" |
|
20 #include <QTimeLine> |
|
21 // NB: These includes go away when plugins are implemented |
|
22 #include "animations/flyoutanimator.h" |
|
23 #include "animations/fadeanimator.h" |
|
24 #include "animations/malstromanimator.h" |
|
25 #include "animations/slideanimator.h" |
|
26 |
|
27 VisibilityAnimator::~VisibilityAnimator(){ |
|
28 delete m_timeLine; |
|
29 } |
|
30 |
|
31 // NB: Replace factory implementation with hash table populated by plugin discovery |
|
32 |
|
33 VisibilityAnimator * VisibilityAnimator:: create(const QString & name, ChromeSnippet* snippet){ |
|
34 if(name.compare("G_VISIBILITY_SLIDE_ANIMATOR") == 0){ |
|
35 return new SlideAnimator(snippet); |
|
36 } |
|
37 if(name.compare("G_VISIBILITY_FLYOUT_ANIMATOR") == 0){ |
|
38 return new FlyoutAnimator(snippet); |
|
39 } |
|
40 if(name.compare("G_VISIBILITY_FADE_ANIMATOR") == 0){ |
|
41 return new FadeAnimator(snippet); |
|
42 } |
|
43 if(name.compare("G_VISIBILITY_MALSTROM_ANIMATOR") == 0){ |
|
44 return new MalstromAnimator(snippet); |
|
45 } |
|
46 return 0; |
|
47 } |
|
48 |
|
49 void VisibilityAnimator::toggleVisibility(){ |
|
50 if(!m_timeLine) { |
|
51 m_timeLine = new QTimeLine(1000); //Default to 1 sec |
|
52 connect(m_timeLine, SIGNAL(valueChanged(qreal)), |
|
53 this, SLOT(updateVisibility(qreal))); |
|
54 } |
|
55 else { |
|
56 m_timeLine->stop(); |
|
57 } |
|
58 |
|
59 if(m_visible) { |
|
60 m_visible = false; |
|
61 m_timeLine->setDirection(QTimeLine::Forward); |
|
62 } |
|
63 else { |
|
64 m_visible = true; |
|
65 m_timeLine->setDirection(QTimeLine::Backward); |
|
66 m_timeLine->setStartFrame(m_timeLine->endFrame()); |
|
67 } |
|
68 m_timeLine->start(); |
|
69 } |