LunaSysMgr
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
LockWindow.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 LOCKWINDOW_H
23 #define LOCKWINDOW_H
24 
25 #include "Common.h"
26 
27 #include "Timer.h"
28 #include "sptr.h"
29 #include "Event.h"
30 #include "StatusBar.h"
31 
32 #include <QObject>
33 #include <QPointer>
34 #include <QGraphicsObject>
35 #include <QPropertyAnimation>
36 #include <QDeclarativeComponent>
37 
38 
39 class Window;
40 class CardWindow;
41 class HelpWindow;
42 class LockButton;
43 class ClockWindow;
44 class LockBackground;
45 class DashboardAlerts;
46 class BannerAlerts;
47 class PopUpAlert;
48 class TransparentNode;
49 class EASPolicy;
50 class QMouseEvent;
53 class InputItem;
54 class QTouchEvent;
55 
57 {
58  Q_OBJECT
59 
60 public:
61 
62  LockWindow(uint32_t maxWidth, uint32_t maxHeight);
63  virtual ~LockWindow();
64 
65  virtual void init();
66 
67  void addPhoneAppWindow(Window* win);
68 
69  bool isLocked() const { return m_state != StateUnlocked; }
70  bool isDockMode() const { return m_state == StateDockMode; }
71 
72  void fadeWindow (bool in);
73 
74  bool handleFilteredSceneEvent(QEvent* event);
75 
76  bool okToResize();
77  void resize(int width, int height);
78  void delayDockModeLocking();
79  void performDelayedLock();
80 
81  enum ScreenState {
85  };
86 
87 
88 Q_SIGNALS:
89 
90  void signalScreenLocked(int screenState);
91 
92 private Q_SLOTS:
93 
94  void slotDisplayStateChanged(int event);
95  void slotLockStateChanged(int event, int displayEvent);
96 
97  void slotAlertActivated();
98  void slotAlertDeactivated();
99  void slotTransientAlertActivated();
100  void slotTransientAlertDeactivated();
101  void slotBannerActivated();
102  void slotBannerDeactivated();
103  void slotDeviceUnlocked();
104  void slotCancelPasswordEntry();
105  void slotPasswordSubmitted(QString password, bool isPIN);
106  void slotPinPanelFocusRequest(bool focusRequest);
107  void slotBannerAboutToUpdate(QRect& target);
108  void slotBootFinished();
109  void slotWindowUpdated(Window* win);
110  void slotPolicyChanged(const EASPolicy * const policy);
111  void slotSetLockTimeout(uint32_t timeout);
112  void slotDialogButton1Pressed();
113  void slotDialogButton2Pressed();
114  void slotDialogButton3Pressed();
115 
116  void slotWindowFadeAnimationFinished();
117  void slotVisibilityChanged();
118 
119 // void slotPhoneWindowAnimationFinished();
120 
121  void slotPositiveSpaceAboutToChange(const QRect& r, bool fullscreen, bool resizing);
122  void slotPositiveSpaceChanged(const QRect& r);
123  void slotPositiveSpaceChangeFinished(const QRect& r);
124 
125  void slotUiRotationCompleted();
126 
127 private:
128 
129  enum State {
130  StateUnlocked = 0,
131  StateNormal,
132  StateDockMode,
133  StatePinEntry,
134  StateLastTryDialog,
135  StateNewPinDialog
136 // , StateInPhoneCall // disabled for now in Dartfish
137  };
138 
139  // QGraphicsItem::boundingRect
140  QRectF boundingRect() const;
141 
142  // QGraphicsItem::paint
143  void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget);
144 
145  void handlePowerOn();
146  void handlePowerOff();
147 
148  void activatePopUpAlert();
149  void activateBannerAlert();
150  void registerBannerView();
151  void unregisterBannerView();
152 
153  void changeState(State newState);
154 
155  bool handleMouseEvent(QMouseEvent *event);
156 #if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
157  bool handleTouchEvent(QTouchEvent *event);
158 #endif
159  void handlePenDownEvent(Event* event);
160  void handlePenMoveEvent(Event* event);
161  void handlePenUpEvent(Event* event);
162  void handlePenFlickEvent(Event* event);
163  void handlePenCancelEvent(Event* event);
164 
165  bool handleKeyDownEvent(Event* event);
166  bool handleKeyUpEvent(Event* event);
167 
168  void handlePenDownStateNormal(Event* event);
169  void handlePenMoveStateNormal(Event* event);
170  void handlePenUpStateNormal(Event* event);
171  void handlePenCancelStateNormal(Event* event);
172 
173  void mapCoordToWindow(Window* win, int& x, int& y) const;
174 
175  void tryUnlock();
176  void unlock();
177  bool requiresPasscode() const;
178 
179  // handles updating the screen (alerts/dashboard/clock)
180  Timer<LockWindow> m_paintTimer;
181  bool paint();
182 
183  Timer<LockWindow> m_hideHelpTimer;
184  void startHideHelpTimer();
185  bool hideHelpTimeout();
186  void showHelp();
187  void hideHelp(bool animate = true);
188 
189  void showPinPanel();
190  void hidePinPanel(bool animate = true);
191 
192  void showDialog();
193  void hideDialog(bool animate = true);
194 
195 // void showPhoneApp();
196 // void hidePhoneApp(bool animate = true);
197 
198 // void toggleElemetsVisibleUnderPhoneApp(bool visible);
199 
200  void showAlert(TransparentNode* alertNode);
201  void hideAlert(TransparentNode* alertNode);
202 
203  QRectF m_bounds;
204 
205  uint32_t m_lastLocked;
206  uint32_t m_lockTimeout;
207  bool setLockTimeout(uint32_t timeout);
208 
209  bool m_popupActive;
210  bool m_bannerActive;
211  bool m_activeCall;
212  State m_state;
213 
214  bool m_elementsShown;
215 
216  bool m_delayDockModeLocking;
217 
218  int m_lockButtonX, m_lockButtonY;
219 
220  QPropertyAnimation m_windowFadeAnimation;
221 // QPropertyAnimation m_phoneWinAnimation;
222 
223  // lock screen widgets
224  LockBackground* m_bgNode;
225  StatusBar* m_statusBar;
226 
227  HelpWindow* m_helpWin;
228  LockButton* m_lockButton;
229  ClockWindow* m_clockWin;
230 
231 // int m_phoneAppShownY, m_phoneAppHiddenY;
232 
233  DashboardAlerts* m_dashboardAlerts;
234  BannerAlerts* m_bannerAlerts;
235  PopUpAlert* m_popUpAlert;
236 
237  GraphicsItemContainer* m_cornerContainer;
238  QGraphicsPixmapItem* m_corners[4];
239  void positionCornerWindows(const QRect& r);
240 
241  bool bannerViewRegistered;
242 
243 // CardWindow* m_phoneAppWin;
244  QDeclarativeComponent* m_qmlUnlockPanel;
245  QDeclarativeComponent* m_qmlUnlockDialog;
246  InputItem* m_unlockPanel;
247  QGraphicsObject* m_unlockDialog;
248 
249 
250  QString m_newPasscode;
251  bool m_setupNewPin;
252  bool m_setupNewPassword;
253 
254  QRect m_targetPositiveSpace;
255 };
256 
257 #endif
258