LunaSysMgr
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
CardLoading.h
Go to the documentation of this file.
1 /* @@@LICENSE
2 *
3 * Copyright (c) 2009-2012 Hewlett-Packard Development Company, L.P.
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 *
17 * LICENSE@@@ */
18 
19 
20 
21 
22 #ifndef CARDLOADING_H
23 #define CARDLOADING_H
24 
25 #include "Common.h"
26 
27 #include "AnimationEquations.h"
28 
29 #include <QPainter>
30 #include <QSequentialAnimationGroup>
31 #include <QPropertyAnimation>
32 #include <QTimer>
33 
34 class Window;
35 class CardRoundedCornerShaderStage;
36 
37 class CardLoading : public QObject
38 {
39  Q_OBJECT
40  Q_PROPERTY(qreal pulseOpacity READ pulseOpacity WRITE setPulseOpacity)
41  Q_PROPERTY(qreal fadeOpacity READ fadeOpacity WRITE setFadeOpacity)
42 
43 public:
44 
45  CardLoading(Window* win);
46  ~CardLoading();
47 
48  // tell the loading animation to start transitioning to a finished state
49  void finish();
50 
51  // are we trying to finish?
52  bool finishing() const;
53 
54  void paint(QPainter* painter, bool maximized);
55 
56  void setScale(float scale);
57 
58 Q_SIGNALS:
59 
60  void signalLoadingFinished();
61 
62 private Q_SLOTS:
63 
64  void slotCrossFadeFinished();
65  void slotPulseTimeout();
66 
67 private:
68 
69  qreal pulseOpacity() const { return m_pulseOpacity; }
70  void setPulseOpacity(qreal opacity);
71 
72  qreal fadeOpacity() const { return m_fadeOpacity; }
73  void setFadeOpacity(qreal opacity);
74 
75  void initializeRoundedCornerStage();
76 
77  Window* m_win;
78 
79  qreal m_fadeOpacity;
80  qreal m_pulseOpacity;
81  qreal m_pulseOpacityAnimInc;
82  bool m_pulseIn;
83 
84  QTimer m_pulseTimer;
85  QTimer m_pulsePauseTimer;
86  QPropertyAnimation m_fadeAnimation;
87 
88  QPixmap m_background;
89  QPixmap m_icon;
90  static unsigned int s_glowRefCount;
91  static QPixmap* s_glow;
92  bool m_showAnimation;
93 
94  static unsigned int s_backgroundRefCount;
95  static QPixmap* s_background;
96  CardRoundedCornerShaderStage* m_shader;
97 };
98 
99 #endif /* CARDLOADING_H */