LunaSysMgr
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
DockModeWindowManager.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 DOCKMODEWINDOWMANAGER_H
23 #define DOCKMODEWINDOWMANAGER_H
24 
25 #include "Common.h"
26 
27 #include <set>
28 #include "WindowManagerBase.h"
29 #include "PtrArray.h"
30 #include "VariantAnimation.h"
31 #include "CustomEvents.h"
32 #include "SystemMenu.h"
33 #include <QPropertyAnimation>
34 #include <QParallelAnimationGroup>
35 #include <QGraphicsSceneMouseEvent>
36 
37 #include <QDeclarativeComponent>
38 
39 #include <QGestureEvent>
40 #include <QTextLayout>
41 #include <QPointer>
42 #include <QBitArray>
43 
44 #define MINIMIZED_SCALE_FACTOR 4.0
45 
46 
47 class Window;
48 class StatusBar;
49 class DockModeWindow;
50 class LaunchPoint;
51 class DockModeIcons;
52 class QTapGesture;
53 class FlickGesture;
55 class PixmapButton;
56 class DockModeClock;
59 
61 {
62  Q_OBJECT
63 
64 public:
65 
66  DockModeWindowManager(uint32_t maxWidth, uint32_t maxHeight);
67  virtual ~DockModeWindowManager();
68 
69  virtual void init();
70 
71 
72  virtual void addWindow(Window* win);
73  virtual void prepareAddWindow(Window* win);
74  virtual void removeWindow(Window* win);
75 
77 
78  void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget);
79 
80  void setDockModeState(bool enabled);
81  void setInModeAnimation(bool animating);
82 
83  void resize(int width, int height);
84 
85  virtual void mousePressEvent(QGraphicsSceneMouseEvent* event);
86  virtual void mouseMoveEvent(QGraphicsSceneMouseEvent* event);
87  virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent* event);
88 
89  void setDashboardOpened(bool val, bool softDismissable);
90  bool isDashboardOpened();
92  void closeDashboard(bool force);
93 
94  bool enableDockModeLaunchPoint(const LaunchPoint* lp);
95  bool disableDockModeLaunchPoint(const LaunchPoint* lp);
96 
97  Window* getActiveDockModeWindow() const { return m_inDockMode ? m_activeWin : 0; }
98 
100 
101  void addPuckIdAndDefaultApp (const std::string& puckId, const std::string& appId);
102 
103  virtual bool handleNavigationEvent(QKeyEvent* keyEvent, bool& propogate);
104 
105 Q_SIGNALS:
106 
107  void signalDockModeStatusChanged(bool enabled);
108  void signalCloseDashboard(bool forceClose);
110 
111 private Q_SLOTS:
112 
113  void slotBootFinished();
114  void slotWindowChangeAnimationFinished();
115  void slotVisibilityChanged();
116  void slotLowMemoryActionsRequested(bool allowExpensive);
117  void slotDockModeAppSelected (DockModeLaunchPoint* dlp);
118  void slotDockModeLaunchPointEnabled (const LaunchPoint* lp);
119  void slotDockModeLaunchPointDisabled (const LaunchPoint* lp);
120  void slotDockModeAnimationStarted();
121  void slotDockModeAnimationComplete();
122  void slotPuckConnected(bool connected);
123  void slotPositiveSpaceChanged (const QRect& rect);
124  void slotLaunchPointRemoved(const LaunchPoint* lp, QBitArray reasons);
125 
126 private:
127 
128  bool tapAndHoldEvent(QGestureEvent* tapAndHoldEvent);
129 
130  int appIndexForId(const std::string appId);
131  DockModeLaunchPoint* launchPointForId(const std::string appId);
132 
133  bool launchApp(DockModeLaunchPoint* dockApp, bool maximized=false);
134  void closeApp(const std::string appId);
135  void closeWindow(Window* win);
136 
137  bool enableDockModeLaunchPointInternal(const LaunchPoint* lp, bool isPermanent);
138  void updateDockModeLaunchPoint(const LaunchPoint* lp); // $$$ Implement this
139 
140  void queueFocusAction(Window* win, bool focused);
141  void performPendingFocusActions();
142  void removePendingFocusActionWindow(Window* win);
143 
144  void positionLauncherIcons(bool immediate = true);
145  void configureAllIconsAndWindows();
146 
147  int findDefaultDlpIndex (const std::string&);
148  void animateWindowChange(Window* win);
149 
150  QRect m_screenBounds;
151 
152  bool m_dashboardOpened;
153  bool m_dashboardSoftDismissable;
154 
155  QPainter::CompositionMode m_compMode, m_previous;
156  QPixmap *m_background;
157 
158  bool m_inDockMode;
159  bool m_inTransitionAnimation;
160  int m_defaultIndex;
161  OrientationEvent::Orientation m_orientation, m_newOrientation;
162 
163  StatusBar* m_statusBar;
164  DockModeClock* m_dockModeClock;
165  DockModePositionManager* m_dockModePosMgr;
166  DockModeAppMenuContainer* m_appMenuContainer;
167  QRect m_positiveSpace;
168 
169  PtrArray<DockModeLaunchPoint> m_dockLpArray;
170 
171  // Pointers (no instances) to Launch points
172  DockModeLaunchPoint* m_sysUiLpInUse;
173  DockModeLaunchPoint* m_newlyAddedLp;
174 
175  Window* m_activeWin;
176  Window* m_lastMaximizedWin;
177 
178  bool m_inReorderMode;
179  DockModeLaunchPoint* m_dragLp;
180 
181  std::set<Window*> m_pendingActionWinSet;
182 
183  // animations for fading LockMode in/out
184  QPointer<QPropertyAnimation> m_fadeAnimation;
185 
186  Window* m_windowInAnimation;
187 
188  // animations for switching maximized apps
189  QPropertyAnimation m_windowAnimationCurrent;
190  QPropertyAnimation m_windowAnimationNext;
191  QParallelAnimationGroup m_windowChangeAnimationGroup;
192  Window* m_nextActiveWin;
193 
194  // animations for the Preferences App
195  QPointer<QParallelAnimationGroup> m_systemAppAnimation;
196 
197  std::map<std::string, int> m_puckIdToDlpIndex;
198  std::string m_currentPuckId;
199  bool m_bootFinished;
200 };
201 
202 
203 #endif /* DOCKMODEWINDOWMANAGER_H */