LunaSysMgr
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
SystemUiController.h
Go to the documentation of this file.
1 /* @@@LICENSE
2 *
3 * Copyright (c) 2008-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 SYSTEMUICONTROLLER_H
23 #define SYSTEMUICONTROLLER_H
24 
25 #include "Common.h"
26 
27 #include <string>
28 #include <QEvent>
29 #include <QKeyEvent>
30 #include <QMouseEvent>
31 #include <QObject>
32 #include <QRect>
33 #include <QSharedPointer>
34 #include <QWeakPointer>
35 
36 #include "ApplicationDescription.h"
37 #include "Event.h"
38 #include "SuspendBlocker.h"
39 #include "VariantAnimation.h"
40 #include "Window.h"
41 #include "CustomEvents.h"
42 #include "StatusBar.h"
43 
44 class CardWindow;
45 class SysMgrKeyEvent;
46 
47 QT_BEGIN_NAMESPACE
48 class QPixmap;
49 QT_END_NAMESPACE
50 
51 class QGesture;
52 
53 #if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
54 class QGestureEvent;
55 #endif
56 
58 {
59  Q_OBJECT
60 
61 public:
62 
63  static SystemUiController* instance();
65 
66  void init();
67 
68  bool handleEvent(QEvent *event);
69  bool handleKeyEvent(QKeyEvent *event);
70  bool handleMouseEvent(QMouseEvent *event);
71  bool handleGestureEvent(QGestureEvent *event);
72  bool handleCustomEvent(QEvent *event);
73 
75 
76  void setCardWindowMaximized(bool val);
77 
78  void updateStatusBarTitle();
79 
80  void setLauncherShown(bool val);
81 
82  void setUniversalSearchShown(bool val);
83 
84  void setDockShown(bool val);
85 
86  void showOrHideUniversalSearch(bool show, bool showLauncher, bool speedDial);
87 
88  void showOrHideLauncher(bool show);
89 
90  void showOrHideDock(bool show);
91 
92  void setDashboardOpened(bool val, bool isSoftDismissable);
93 
94  void setDashboardHasContent(bool val);
95 
96  void setAlertVisible(bool val);
97 
98  void setEmergencyMode(bool enable);
99 
100  void setActiveCardWindow(Window* window);
101 
102  void setMaximizedCardWindow(Window* window);
103 
104  void setRequestedSystemOrientation(Event::Orientation orient, bool reasonCardMaximizing = false, bool skipAnimation = false);
105 
106  void setLauncherWindow(Window* window) { m_launcherWindow = window; }
107 
108  void setUniversalSearchWindow(Window* window) { m_universalSearchWindow = window; }
109 
110  void focusMaximizedCardWindow(bool enable);
111 
112  void enterOrExitCardReorder(bool entered);
113 
114  bool doesDashboardHaveContent() const {return m_dashboardHasContent;}
115 
116  void enterOrExitDockModeUi(bool enter);
117 
118  // The order of the layers below defines their priorities in terms of direct rendering
120  {
121  DISABLE_ALL_DIRECT_RENDERING = 0, // virtual layer used to temporarily completely disable direct rendering
124  EMERGENCY_MODE_WINDOW_MANAGER, // Temporarily demoted Emergency Mode WM in Dartfish (it is being used for Flash full screen)
128  };
129 
130  void setDirectRenderingForWindow(DirectRenderingEnabledLayers layer, CardWindow* win, bool enable, bool force=false);
131  void enableDirectRendering(bool enable);
132 
133  void setLauncherVisible(bool visible, bool fullyVisible);
134  void setDockVisible(bool val);
135  void setMenuVisible(bool val);
136  void setDeviceLocked(bool val);
137  void setDockMode(bool inDockMode);
138  void setInLauncherReorder(bool reorder);
139 
140  void toggleCurrentAppMenu();
141 
142  void openDashboard();
143  void closeDashboard(bool force);
144 
145  bool isCardWindowMaximized( ) const { return m_cardWindowMaximized; }
146  bool isLauncherShown( ) const;
147  bool isUniversalSearchShown() { return m_universalSearchShown; }
148  bool isDockShown( ) const;
149  bool isDashboardOpened( ) const { return m_dashboardOpened; }
150  bool isInDockMode( ) const { return m_inDockMode; }
151  bool isScreenLocked() const { return (m_deviceLocked); }
152  bool isInEmergencyMode() const {return m_emergencyMode; }
153  bool isInFullScreenMode();
154  bool isModalWindowActive() {return m_modalCardWindowActive;}
155 
156  const Window* launcherWindow() const { return m_launcherWindow; }
157  const Window* universalSearchWindow() const { return m_universalSearchWindow; }
158 
159  Window* activeCardWindow() const { return m_activeCardWindow; }
160 
161  Window* activeWindow() const;
162 
163  std::string activeApplicationName();
164 
165  Window* maximizedCardWindow() const { return m_maximizedCardWindow; }
166 
167  std::string maximizedApplicationName() const;
168  std::string maximizedApplicationMenuName() const;
169  std::string maximizedApplicationId() const;
170 
171  // this call lays out the positive and negative spaces
172  void layout();
173 
174  bool okToResizeUi();
175  void resizeAndRotateUi(int width, int height, int rotationAngle);
176  void rotationStarting();
177  void rotationComplete();
178  bool isUiRotating() { return m_uiRotating; }
179  int getRotationAngle() { return m_uiRotating ? m_rotationAngle : 0; }
180 
181  bool dashboardOwnsNegativeSpace() const { return m_dashboardOwnsNegativeSpace; }
182 
183  void setUiRootItemPtr(QGraphicsItem* ptr) { m_uiRootItemPtr = ptr; }
184 
185  int currentUiWidth() { return m_uiWidth; }
186  int currentUiHeight() { return m_uiHeight; }
187  bool isUiInPortraitMode() { return (m_uiWidth < m_uiHeight); }
188 
189  void setMinimumPositiveSpaceHeight(int val);
190  void setMaximumPositiveSpaceHeight(int val);
191  int minimumPositiveSpaceHeight() const;
192  int maximumPositiveSpaceHeight() const;
193  int minimumPositiveSpaceBottom() const;
194  int maximumPositiveSpaceBottom() const;
195  bool changeNegativeSpace(int newTop, bool openingDashboard, bool immediate=false);
196 
197  const QRect& positiveSpaceBounds() { return m_positiveSpace; }
198  const QRect& negativeSpaceBounds() { return m_negativeSpace; }
199 
202  bool statusBarAndNotificationAreaShown() const { return m_statusBarAndNotificationShown; }
203 
204  void setBootFinished();
205  bool bootFinished() const;
206 
207  void updateProperties (Window* win, const WindowProperties& props);
208 
215  void notifyBannerAboutToUpdate(QRect& scrBounds) { Q_EMIT signalBannerAboutToUpdate(scrBounds); }
216  void notifyModalWindowActivated(Window* modalParent);
218  Window* getModalParent() const {return m_parentOfModalWindow; }
219  void notifyEditorFocusChanged(bool focus) { Q_EMIT signalEditorFocusChanged(focus); }
220 
221  QSharedPointer<QPixmap> loadingStrip();
222  QSharedPointer<QPixmap> warningIcon();
223 
224  void aboutToSendSyncMessage();
225 
226  void setStatusBar(StatusBar* statusBar) { m_statusBarPtr = statusBar; }
227  const StatusBar* statusBar() const { return m_statusBarPtr; }
228 
231  NoErr = 0,
238  //AppToLaunchIsNotHeadless,
244  };
245 
253  };
254 
255  void setModalWindowDismissErrReason(ModalWinDismissErrorReason reason) { if(m_modalWindowDismissErr != reason) m_modalWindowDismissErr = reason; }
256  void setModalWindowLaunchErrReason(ModalWinLaunchErrorReason reason) { if(m_modalWindowLaunchErr != reason) m_modalWindowLaunchErr = reason; }
257 
258  bool wasModalAddedSuccessfully() { return(m_modalWindowLaunchErr == NoErr)? true : false; }
259 
260  std::string getModalWindowLaunchErrReason();
261  std::string getModalWindowDismissErrReason();
262  int getModalWindowLaunchErrReasonCode() {return m_modalWindowLaunchErr; }
263  int getModalWindowDismissErrReasonCode() {return m_modalWindowDismissErr; }
264 
265 public:
266  void cardWindowAdded();
267  void cardWindowTimeout();
268 
269 public:
270 
272  {
277  LAUNCHEROP_UNKNOWN //keep this as the last one
278  };
279 
281  {
287  };
288 
291  void launcherChangeCardTitle(int launcherCardId,const std::string& launcherCardLabel);
292 
293  void launcherDbgActionScreenGrid(LauncherActions act,int xspan=0,int yspan=0);
294 
295  uint32_t getOverlayNotificationPosition() { return m_overlayNotificationPosition; }
296 
297  // Signals
298 
299 Q_SIGNALS:
300  void signalCardWindowAdded();
302 
303  void signalPositiveSpaceChanged(const QRect& r);
304  void signalPositiveSpaceAboutToChange(const QRect& r, bool fullScreen, bool screenResizing);
305  void signalPositiveSpaceChangeFinished(const QRect& r);
306  void signalNegativeSpaceChanged(const QRect& r);
307  void signalNegativeSpaceAboutToChange(const QRect& r, bool fullScreen, bool screenResizing);
308  void signalNegativeSpaceChangeFinished(const QRect& r);
309  void signalEmergencyMode(bool enable);
311 
312  void signalFocusMaximizedCardWindow(bool enable);
318  void signalChangeCardWindow(bool next);
319 
320  void signalHideMenu();
321 
322  void signalLauncherVisible(bool visible, bool fullyVisible);
323  void signalLauncherShown(bool shown);
325  void signalHideUniversalSearch(bool showLauncher, bool speedDial);
326  void signalUniversalSearchFocusChange(bool enabled);
327 
328  void signalShowLauncher();
329  void signalHideLauncher();
330  void signalToggleLauncher();
331  void signalLauncherAddCard();
333  void signalLauncherRenameCard(int,QString);
336 
340  void signalLauncherActionDbgScreenGrid(bool on,int xspan,int yspan);
341 
344 
345  void signalShowDock();
346  void signalHideDock();
347  void signalFadeDock(bool fadeOut);
348 
349  void signalOpenDashboard();
350  void signalCloseDashboard(bool forceClose);
351  void signalCloseAlert();
352 
353  void signalDockModeEnable(bool enabled);
354  void signalChangeDockModeApp(bool next);
356 
357  void signalBootFinished();
358 
359  void signalStatusBarAndNotificationShown(bool shown);
360 
361  void signalOverlayNotificationPositionChanged(uint32_t newPosition);
363 
364  void signalAlertActivated();
365  void signalAlertDeactivated();
368  void signalBannerActivated();
370  void signalBannerAboutToUpdate(QRect& scrBounds);
371 
372  void signalEditorFocusChanged(bool focus);
373 
375 
377 
378  void signalModalWindowAdded();
379 
381 
384 
385  void signalEmergencyModeWindowFocusChange(bool focus);
386 
387 private Q_SLOTS:
388 
389  void slotEnterBrickMode(bool val);
390  void slotExitBrickMode();
391 
392  void slotCopy();
393  void slotCut();
394  void slotPaste();
395  void slotSelectAll();
396 
397  void slotAnimFinished();
398 
399  void slotKeyEventRejected(const SysMgrKeyEvent& event);
400 private:
401 
403  void startPositiveSpaceAnimation(const QRect& start, const QRect& end);
404  void stopPositiveSpaceAnimation();
405  void animValueChanged(const QVariant& value);
406  bool allowSuspend();
407  void setSuspended(bool);
408  void handleScreenEdgeFlickGesture(QGesture* gesture);
409 
410  Window* m_parentOfModalWindow;
411  Window* m_activeCardWindow;
412  Window* m_maximizedCardWindow;
413  Window* m_launcherWindow;
414  Window* m_universalSearchWindow;
415 
416  bool m_cardWindowAboutToMaximize;
417  bool m_cardWindowMaximized;
418  bool m_dashboardOpened;
419  bool m_dashboardSoftDismissable;
420  bool m_dashboardHasContent;
421  bool m_alertVisible;
422  const bool m_dashboardOwnsNegativeSpace;
423  bool m_launcherShown;
424  bool m_dockShown;
425  bool m_inDockMode;
426  bool m_universalSearchShown;
427 
428  bool m_emergencyMode;
429 
430  QGraphicsItem* m_uiRootItemPtr;
431 
432  QRect m_positiveSpace;
433  QRect m_negativeSpace;
434  int m_minimumPositiveSpaceHeight;
435  int m_maximumPositiveSpaceHeight;
436 
437  bool m_launcherVisible;
438  bool m_dockVisible;
439  bool m_menuVisible;
440  bool m_deviceLocked;
441 
442  bool m_started;
443  int m_startCount;
444 
445  int m_dockBrightness;
446  bool m_statusBarAndNotificationShown;
447 
448  int m_requestedNegativeSpaceTop;
449 
450  int m_uiWidth, m_uiHeight;
451 
453 
454  bool m_bootFinished;
455 
456  bool m_uiRotating;
457  int m_rotationAngle;
458 
459  SuspendBlocker<SystemUiController> m_suspendBlocker;
460 
461  void applyWindowProperties (Window* win);
462  void removeWindowProperties ();
463  bool m_isBlockScreenTimeout;
464  bool m_isSubtleLightbar;
465  bool m_activeTouchpanel;
466  bool m_alsDisabled;
467  uint32_t m_overlayNotificationPosition;
468  bool m_suppressBannerMessages;
469  bool m_suppressGestures;
470  bool m_modalCardWindowActive;
471 
472  // members used for Focus/DirectRendering control
473  struct DirectRenderLayer {
474  bool requestedDirectRendring;
476  };
477 
478  DirectRenderLayer m_directRenderLayers[NUMBER_OF_LAYERS];
479  int m_currentlyDirectRenderingLayer;
480  CardWindow* m_currentlyDirectRenderingWindow;
481 
482  ModalWinLaunchErrorReason m_modalWindowLaunchErr;
483  ModalWinDismissErrorReason m_modalWindowDismissErr;
484 
485 private:
486 
488  SystemUiController& operator=(const SystemUiController&);
489 
490  std::string getMenuTitleForMaximizedWindow(Window* win);
491 
492  QWeakPointer<QPixmap> m_iconProgressSurf;
493  QWeakPointer<QPixmap> m_iconWarningSurf;
494 
495  StatusBar* m_statusBarPtr;
496 };
497 
498 
499 #endif /* SYSTEMUICONTROLLER_H */