LunaSysMgr
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
DashboardWindowManager.h
Go to the documentation of this file.
1 /* @@@LICENSE
2 *
3 * Copyright (c) 2008-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 DASHBOARDWINDOWMANAGER_H
23 #define DASHBOARDWINDOWMANAGER_H
24 
25 #include "Common.h"
26 #include "Timer.h"
27 #include "Window.h"
28 #include "WindowManagerBase.h"
29 #include "CustomEvents.h"
30 #include "GraphicsItemContainer.h"
31 #include "Settings.h"
32 
33 #include <list>
34 #include <map>
35 #include <QVector>
36 #include <QParallelAnimationGroup>
37 #include <QPropertyAnimation>
38 
39 class QGraphicsSceneMouseEvent;
40 class QStateMachine;
41 class QState;
42 class QEvent;
43 
44 class DWMStateBase;
45 class DWMStateOpen;
46 class DWMStateAlertOpen;
47 class DWMStateClosed;
48 
49 class AlertWindow;
50 class BannerWindow;
51 class DashboardWindow;
54 class NotificationPolicy;
55 class QDeclarativeComponent;
56 
58 {
59  Q_OBJECT
60 
61 public:
62 
63  DashboardWindowManager(int maxWidth, int maxHeight);
65 
66  void init();
72  void setBannerHasContent(bool val);
73  void raiseAlertWindow(AlertWindow* window);
75  void raiseBackgroundWindow();
76  void openDashboard();
77  void sendClicktoDashboardWindow(int num, int x, int y, bool whileLocked);
78  void focusWindow(Window* win);
79  void unfocusWindow(Window* win);
80  void hideDashboardWindow();
81  void animateAlertWindow();
82  void animateTransientAlertWindow(bool in);
83  int bannerWindowHeight();
85  void setInDockMode(bool dockMode);
86 
87  inline bool alertOpen() const {
88  return m_stateCurrent == (DWMStateBase*)m_stateAlertOpen;
89  }
90 
91  inline bool alertVisible() const {
92  return m_alertWinContainer->isVisible();
93  } // Remove this
94 
95  inline const Window* getActiveAlertWin() const {
96  return m_alertWinArray.empty() ? 0 : (const Window*) m_alertWinArray[0];
97  }
98 
99  inline const Window* getActiveTransientAlertWin() const {
100  return (const Window*) m_activeTransientAlert;
101  }
102 
104  return m_notificationPolicy;
105  }
106 
107  inline AlertWindow* topAlertWindow() const {
108  if (m_alertWinArray.empty())
109  return 0;
110 
111  return m_alertWinArray[0];
112  }
113 
115  return m_dashboardWinContainer;
116  }
117 
118  inline QGraphicsObject* dashboardMenu() const {
119  return m_menuObject;
120  }
121 
122  inline void currentStateChanged(DWMStateBase* state) {
123  m_stateCurrent = state;
124  }
125  bool isInDockModeAnimation() const { return m_inDockModeAnimation; }
126 
127 
128  bool hasDashboardContent() const;
129  bool canCloseDashboard() const;
130  bool dashboardOpen() const;
131  bool isOverlay() const { return m_isOverlay; }
132 
133  static int sTabletUiWidth();
134 
136  Invalid = 0,
140  };
141 
143  return m_AlertWindowFadeOption;
144  }
145 
146 // private functions.
147 private:
148 
149  int activeAlertWindowHeight();
150  void setupStateMachine();
151  void resize(int width, int height);
152  void resizeAlertWindows(int width);
153  void negativeSpaceChanged(const QRect& r);
154  void addWindow(Window* win);
155  void removeWindow(Window* win);
156  void addAlertWindow(AlertWindow* win);
157  void addTransientAlertWindow(AlertWindow* win);
158  void removeAlertWindow(AlertWindow* win);
159  void removeTransientAlertWindow(AlertWindow* win);
160  void addAlertWindowBasedOnPriority(AlertWindow* win);
161  bool doesMousePressFallInBannerWindow(QGraphicsSceneMouseEvent* event);
162 
163  void mousePressEvent(QGraphicsSceneMouseEvent* event);
164  void mouseMoveEvent(QGraphicsSceneMouseEvent* event);
165  void mouseReleaseEvent(QGraphicsSceneMouseEvent* event);
166  bool sceneEvent(QEvent* event);
167 
168  // Override the signals in DashboardWindowManagerBase
169 Q_SIGNALS:
171  void signalOpen();
172  void signalClose(bool forceClose);
175 
176 private Q_SLOTS:
177  void slotPositiveSpaceChanged(const QRect& r);
178  void slotPositiveSpaceChangeFinished(const QRect& r);
179  void slotNegativeSpaceChanged(const QRect& r);
180  void slotNegativeSpaceChangeFinished(const QRect& r);
181  void slotOpenDashboard();
182  void slotCloseDashboard(bool forceClose);
183  void slotCloseAlert();
184  void slotDashboardWindowAdded(DashboardWindow* w);
185  void slotDashboardWindowsRemoved(DashboardWindow* w);
186  void slotDashboardViewportHeightChanged();
187  void slotDeleteAnimationFinished();
188  void slotTransientAnimationFinished();
189  void slotDashboardAreaRightEdgeOffset(int offset);
190 
191  void slotDockModeAnimationStarted();
192  void slotDockModeAnimationComplete();
193 
194 // private data
195 private:
196 
199  const DashboardWindowManager& operator=(const DashboardWindowManager&);
200  void positionDashboardContainer(const QRect& posSpace = QRect());
201  void positionAlertWindowContainer(const QRect& posSpace = QRect());
202  void positionTransientWindowContainer(const QRect& posSpace = QRect());
203 
204  QParallelAnimationGroup m_fadeInOutAnimation;
205  QPropertyAnimation m_transAlertAnimation;
206  AlertWindowFadeOption m_AlertWindowFadeOption;
207  QStateMachine* m_stateMachine;
208  DWMStateOpen* m_stateDashboardOpen;
209  DWMStateAlertOpen* m_stateAlertOpen;
210  DWMStateClosed* m_stateClosed;
211  DWMStateBase* m_stateCurrent;
212  BannerWindow* m_bannerWin;
213  GraphicsItemContainer* m_bgItem;
214  GraphicsItemContainer* m_alertWinContainer;
215  GraphicsItemContainer* m_transientContainer;
216  DashboardWindowContainer* m_dashboardWinContainer;
217  NotificationPolicy* m_notificationPolicy;
218  QVector<AlertWindow*> m_alertWinArray;
219  AlertWindow* m_activeTransientAlert;
220  AlertWindow* m_deleteWinAfterAnimation;
221  bool m_deleteTransientWinAfterAnimation;
222  AlertWindow* m_previousActiveAlertWindow;
223 
224  bool m_isOverlay;
225  bool m_bannerHasContent;
226  int m_dashboardRightOffset;
227  friend class BannerWindow;
228 
229  QDeclarativeComponent* m_qmlNotifMenu;
230  // Top Level Menu Object
231  QGraphicsObject* m_menuObject;
232  int m_notifMenuRightEdgeOffset;
233  //bool m_goingUp;
234  bool m_inDockModeAnimation;
235 };
236 
237 #endif /* DASHBOARDWINDOWMANAGER_H */