LunaSysMgr
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
CardWindowManagerStates.h
Go to the documentation of this file.
1 /* @@@LICENSE
2 *
3 * Copyright (c) 2010-2013 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 CARDWINDOWMANAGERSTATES_H
23 #define CARDWINDOWMANAGERSTATES_H
24 
25 #include "Common.h"
26 
27 #include <QState>
28 #include <QGraphicsSceneMouseEvent>
29 #include <QRect>
30 #include <QSignalTransition>
31 #include <QGraphicsItem>
32 #include <stdint.h>
33 
34 class CardWindow;
35 class CardWindowManager;
36 
37 QT_BEGIN_NAMESPACE
38 class QGestureEvent;
39 class QTapGesture;
40 class QTapAndHoldGesture;
41 class QTouchEvent;
42 QT_END_NAMESPACE
43 
45 {
46  Q_OBJECT
47 
48 public:
50 
51 #if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0))
52  virtual void mousePressEvent(QGraphicsSceneMouseEvent* event);
53  virtual void mouseMoveEvent(QGraphicsSceneMouseEvent* event) {}
54  virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent* event) {}
55 #endif // QT_VERSION < 5.0.0
56  virtual void flickGestureEvent(QGestureEvent* event) {}
57  virtual void tapGestureEvent(QTapGesture* event) {}
58  virtual void tapAndHoldGestureEvent(QTapAndHoldGesture* event) {}
59 
60  virtual void windowAdded(CardWindow* win);
61  virtual void windowRemoved(CardWindow* win);
62  virtual void windowTimedOut(CardWindow* win) {}
63 
64  virtual void positiveSpaceAboutToChange(const QRect& r, bool fullScreen) {}
65  virtual void positiveSpaceChangeFinished(const QRect& r) {}
66  virtual void positiveSpaceChanged(const QRect& r) {}
67 
68  virtual void animationsFinished() {}
69  virtual void changeCardWindow(bool) {}
70 
71  virtual void focusMaximizedCardWindow(bool focus);
72 
73  virtual bool supportLauncherOverlay() const;
74 
75  virtual void relayout(const QRectF& r, bool animate=true) {}
76 
77  virtual void processTouchToShareTransfer(const std::string& appId) {}
78 
79  virtual bool handleKeyNavigation(QKeyEvent* keyEvent) { return true; }
80 
81 #if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
82  virtual void handleTouchBegin(QTouchEvent *e);
83  virtual void handleTouchEnd(QTouchEvent *e);
84  virtual void handleTouchUpdate(QTouchEvent *e);
85 #endif
86 
87 protected:
88  virtual void onEntry(QEvent* event);
89  bool lastWindowAddedType() const;
90  void resizeWindow(CardWindow* w, int width, int height);
91 
93 };
94 
95 // -----------------------------------------------------------------------------------
96 
98 {
99  Q_OBJECT
100 
101 public:
103  : CardWindowManagerState(wm) { setObjectName("Minimize"); }
104 
105 #if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0))
106  virtual void mousePressEvent(QGraphicsSceneMouseEvent* event);
107  virtual void mouseMoveEvent(QGraphicsSceneMouseEvent* event);
108  virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent* event);
109 #endif // QT_VERSION < 5.0.0
110 
111  virtual void flickGestureEvent(QGestureEvent* event);
112  virtual void tapGestureEvent(QTapGesture* event);
113  virtual void tapAndHoldGestureEvent(QTapAndHoldGesture* event);
114 
115  virtual void animationsFinished();
116  virtual void changeCardWindow(bool);
117 
118  virtual void relayout(const QRectF& r, bool animate);
119 
120  virtual bool handleKeyNavigation(QKeyEvent* keyEvent);
121 
122 #if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
123  virtual void handleTouchBegin(QTouchEvent *e);
124  virtual void handleTouchEnd(QTouchEvent *e);
125  virtual void handleTouchUpdate(QTouchEvent *e);
126 #endif
127 
128 protected:
129  virtual void onEntry(QEvent* event);
130 
131 Q_SIGNALS:
132  void signalFirstCardRun();
133 };
134 
135 // -----------------------------------------------------------------------------------
136 
138 {
139  Q_OBJECT
140 
141 public:
143 
144 #if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0))
145  virtual void mousePressEvent(QGraphicsSceneMouseEvent* event);
146 #endif // QT_VERSION < 5.0.0
147 
148  virtual void windowAdded(CardWindow* win);
149  virtual void windowRemoved(CardWindow* win);
150 
151  virtual void positiveSpaceAboutToChange(const QRect& r, bool fullScreen);
152  virtual void positiveSpaceChangeFinished(const QRect& r);
153  virtual void positiveSpaceChanged(const QRect& r);
154 
155  virtual void animationsFinished();
156  virtual void changeCardWindow(bool);
157 
158  virtual void relayout(const QRectF& r, bool animate=true);
159 
160  virtual void focusMaximizedCardWindow(bool focus);
161 
162  virtual void processTouchToShareTransfer(const std::string& appId);
163 
164  virtual bool handleKeyNavigation(QKeyEvent* keyEvent) { return false; }
165 
166 protected:
167  virtual void onExit(QEvent* event);
168  virtual void onEntry(QEvent* event);
169 
170 private Q_SLOTS:
171  void slotIncomingPhoneCall();
172 
173 private:
174  void finishMaximizingActiveWindow();
175 
176  bool m_exiting; // are we exiting this state?
177  int m_disableDirectRendering; // number of requests to disable direct rendering
178 };
179 
180 // -----------------------------------------------------------------------------------
181 
183 {
184 public:
186  : CardWindowManagerState(wm) { setObjectName("Focus"); }
187 
188  virtual void animationsFinished();
189 
190 protected:
191  virtual void onEntry(QEvent* event);
192 };
193 
194 // conditional transition from MaximizeState to FocusState
196 {
197 public:
199 
200 protected:
201  virtual bool eventTest(QEvent* event);
202 };
203 
204 // -----------------------------------------------------------------------------------
205 
207 {
208 public:
210  : CardWindowManagerState(wm) { setObjectName("Preparing"); }
211 
212 #if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0))
213  virtual void mousePressEvent(QGraphicsSceneMouseEvent* event);
214 #endif // QT_VERSION < 5.0.0
215 
216  virtual void windowAdded(CardWindow* win);
217  virtual void windowTimedOut(CardWindow* win);
218 
219  virtual bool supportLauncherOverlay() const;
220 
221 #if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
222  virtual void handleTouchBegin(QTouchEvent *e);
223 #endif
224 
225 protected:
226  virtual void onEntry(QEvent* event);
227 };
228 
229 // -----------------------------------------------------------------------------------
230 
232 {
233 public:
235  : CardWindowManagerState(wm) { setObjectName("Loading"); }
236 
237 #if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0))
238  virtual void mousePressEvent(QGraphicsSceneMouseEvent* event);
239 #endif // QT_VERSION < 5.0.0
240 
241  virtual void windowAdded(CardWindow* win);
242 
243  virtual void animationsFinished();
244 
245  virtual bool supportLauncherOverlay() const;
246 
247  virtual void relayout(const QRect& r, bool animate);
248 
249 #if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
250  virtual void handleTouchBegin(QTouchEvent *e);
251 #endif
252 
253 protected:
254  virtual void onExit(QEvent* event);
255 };
256 
257 // -----------------------------------------------------------------------------------
258 
260 {
261 public:
262  ReorderGrid(QGraphicsItem* parent, int slice);
263 
264  void paint(QPainter* painter, const QStyleOptionGraphicsItem*, QWidget*);
265 
266  virtual QRectF boundingRect() const { return m_boundingRect; }
267 
268 private:
269  QRectF m_boundingRect;
270  int m_slice;
271 };
272 
274 {
275 public:
277  : CardWindowManagerState(wm), m_grid(0) { setObjectName("Reorder"); }
278 
279 #if (QT_VERSION < QT_VERSION_CHECK(5,0,0))
280  virtual void mouseMoveEvent(QGraphicsSceneMouseEvent* event);
281  virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent* event);
282 #endif // QT_VERSION < 5.0.0
283 
284  virtual void animationsFinished();
285 
286 #if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
287  virtual void handleTouchEnd(QTouchEvent *e);
288  virtual void handleTouchUpdate(QTouchEvent *e);
289 #endif
290 
291 protected:
292  virtual void onExit(QEvent* event);
293  virtual void onEntry(QEvent* event);
294 
295 private:
296  ReorderGrid* m_grid;
297 };
298 
299 #endif /* CARDWINDOWMANAGERSTATES_H */