LunaSysMgr
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
quicklaunchbar.h
Go to the documentation of this file.
1 /* @@@LICENSE
2 *
3 * Copyright (c) 2010-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 QUICKLAUNCHBAR_H_
23 #define QUICKLAUNCHBAR_H_
24 
25 #include "thingpaintable.h"
26 #include "pixmapobject.h"
27 #include "pixmap9tileobject.h"
28 #include "dimensionstypes.h"
29 #include "appmonitor.h"
30 
31 #include <QUuid>
32 #include <QPointer>
33 #include <QPointF>
34 #include <QSize>
35 #include <QList>
36 #include <QPair>
37 #include <QParallelAnimationGroup>
38 #include <QTimer>
39 
40 class QGraphicsSceneMouseEvent;
41 class QGesture;
42 class QGestureEvent;
43 class QTapAndHoldGesture;
44 class QTapGesture;
45 class FlickGesture;
46 
47 class Quicklauncher;
48 class IconBase;
49 class PixButton2State;
50 class QStateMachine;
51 class QState;
52 class QTouchEvent;
53 
54 
55 namespace DimensionsSystemInterface
56 {
57 class ExternalApp;
58 class WebOSApp;
59 class PageSaver;
60 class PageRestore;
61 }
62 
64 {
65  Q_OBJECT
66  Q_INTERFACES(QGraphicsItem)
67 
68 public:
69 
70  QuickLaunchBar(const QRectF& geom,Quicklauncher * p_quicklauncherWindow);
71  virtual ~QuickLaunchBar();
72 
73  virtual bool canAcceptIcons();
74  virtual bool offer(Thing * p_offer,Thing * p_offeringThing);
75  virtual bool take(Thing * p_takerThing);
76  virtual bool taking(Thing * p_victimThing, Thing * p_takerThing);
77  virtual void taken(Thing * p_takenThing,Thing * p_takerThing);
78 
79  virtual bool acceptIncomingIcon(IconBase * p_newIcon);
80  virtual bool releaseTransferredIcon(IconBase * p_transferredIcon);
81 
82  virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option=0,QWidget *widget=0);
83  virtual void paintOffscreen(QPainter *painter);
84  inline void paintBackground(QPainter * painter);
85 
86  virtual bool fullInit(quint32 screenWidth,quint32 screenHeight);
87 
88  //NOTE: pass in the ACTUAL size that the QL should be resized to, not the screen size or other "base" size
89  // that a QL size would be derived from
90  virtual bool resize(const QSize& s);
91 
92  static QSize QuickLaunchSizeFromScreenSize(int screenWidth,int screenHeight);
93 
94  virtual QList<QPointer<IconBase> > iconsInFlowOrder() const; //left to right , in order of appearance
95 
96  //will only work if there are no items currently
97  //TODO: remove this limitation
98  virtual bool restoreFromSave();
99 
100  void cancelLaunchFeedback();
101 
102 public Q_SLOTS:
103 
104  // **These mirror the versions with the same names in LauncherObject
105 
106  //prior to the appmonitor deleting all the app structures
108  //post appmonitor deleting all the app structures
110  void slotAppAuxiliaryIconRemove(const QUuid& appUid,
111  const QString& launchpointId,
113 
114 Q_SIGNALS:
115 
116  void signalIconAdded(QUuid iconUid);
117  void signalIconRemoved(QUuid iconUid);
118 
121 
122  void signalFlickAction(QPointF normVectorDirection = QPointF());
123 
124  void signalToggleLauncher();
125 
126 protected:
127 
128  virtual bool sceneEvent(QEvent * event);
129  virtual bool gestureEvent(QGestureEvent *gestureEvent) { return true; }
130  virtual bool flickGesture(FlickGesture *flickEvent,QGestureEvent * baseGestureEvent);
131  virtual bool tapAndHoldGesture(QTapAndHoldGesture *tapHoldEvent,QGestureEvent * baseGestureEvent);
132  virtual bool tapGesture(QTapGesture *tapEvent,QGestureEvent * baseGestureEvent);
133 
134  void setAppLaunchFeedback(IconBase* pIcon);
135 
136  //rearrange all the current items based on the current sizing
137  //PREREQUISITE: m_itemAreaXRange and m_itemsY are set correctly
138  virtual void rearrangeIcons(bool animate = false);
139 
140  //index >= items.size will append safely
141  virtual qint32 getCurrentIconListIndex(IconBase * p_icon);
142  virtual bool addIcon(quint32 index,IconBase * p_icon, bool animate = false);
143  virtual bool moveIcon(quint32 oldIndex, quint32 newIndex,IconBase * p_icon, bool animate = false);
144  virtual void removeIcon(IconBase * p_icon, bool animate = false);
145  virtual bool detectAndHandleSpecialMoveAreas(int id,const QPointF& pageCoordinate,const RedirectContext& redirContext);
146 
147  virtual void deleteIcon(IconBase * p_icon, bool animate); // removes icon from the list and also deletes the icon object
148 
149  virtual IconBase * getIconPtr(const QUuid& iconUid,bool paramIsMasterUid=true);
150 
151  virtual void iconActivatedTap(QUuid iconUid);
152 
153 protected Q_SLOTS:
154 
155  virtual void slotIconDeleted(QObject * p);
157 
159 
160 protected:
161 
166 
167  static const char * TouchFSMPropertyName_isTracking;
168  static const char * TouchFSMProperyName_trackedId;
169 
170  QMap<int,TouchRegister> m_touchRegisters;
171 
172  virtual bool anyTouchTracking(int * r_p_mainTouchId=0);
173 
174  virtual bool touchPointTriggerType(int id,TouchTriggerType::Enum& r_type);
176  //same as above, except will true condition also includes if the register is missing/invalid (it will create it)
178 
179  virtual RedirectingType::Enum isRedirecting(int id,Thing ** r_pp_redirectTargetThing,RedirectContext ** r_pp_redirContext);
180  virtual bool redirectTo(int id,Thing * p_redirectTargetThing,RedirectContext * p_redirContext = 0);
181  virtual bool changeRedirectTo(int id,Thing * p_currentlyRedirectedToThing,Thing * p_newRedirectedToThing,RedirectContext * p_redirContext = 0);
182 
183  virtual IconBase * iconAtCoordinate(const QPointF& coord);
184 
185  static void resetEventCounters();
186 
187  virtual void setupTouchFSM();
188  virtual void startTouchFSM();
189  virtual void stopTouchFSM();
190 
191  //these are the interface to QT...see sceneEvent()
192  virtual bool touchStartEvent(QTouchEvent *event);
193  virtual bool touchUpdateEvent(QTouchEvent *event);
194  virtual bool touchEndEvent(QTouchEvent *event);
195 
196  //passing in id, but really for now only 1 id can be tracked
197  virtual void touchTrackedPointMoved(int id,const QPointF& scenePosition,const QPointF& lastScenePosition,const QPointF& initialPosition);
198  virtual void touchTrackedPointReleased(int id,const QPointF& scenePosition,const QPointF& lastScenePosition,const QPointF& initialPosition);
199 
200  virtual void redirectedTouchTrackedPointMoved(Thing * p_sourceThing,int id,const QPointF& scenePosition,const QPointF& lastScenePosition,const QPointF& initialPosition,const RedirectContext& redirContext);
201  virtual void redirectedTouchTrackedPointReleased(Thing * p_sourceThing,int id,const QPointF& scenePosition,const QPointF& lastScenePosition,const QPointF& initialPosition,const RedirectContext& redirContext);
202 
203  virtual bool cancelRedirection(int id);
204 
205  virtual bool handleLauncherPageSpecialMoveArea(int id,const QPointF& pageCoordinate,const RedirectContext& redirContext);
206 
207  //DEFAULT POLICY: allow if no other gesture has claimed the touch point yet, else, reject.
208  // When the return == true, then the register is updated with the gesture as the trigger for that id
209  virtual bool okToUseFlick(int id);
210  virtual bool okToUseTap(int id);
211  virtual bool okToUseTapAndHold(int id);
212 
213  virtual qint32 iconSlotForInsertingAtXCoord(qint32 x);
214 
215 Q_SIGNALS:
216 
217 //Triggers: what causes FSM state changes
218  void signalTouchFSMTouchBegin_Trigger(QVariant touchId);
222 
223  //Actions: what the FSM outputs to signal state changes to this object
224  void signalTouchFSMBeginTrack_Action(); //on a new touch [kicks off the FSM]
225  void signalTouchFSMTouchLost_Action(); // when a new touch appears when a touch is already tracking;
226  // this is used when I only support single touch (like in this class)
227  void signalTouchFSMStationary_Action(); // when the motion stops for a period of time (TODO: implement)
228  void signalTouchFSMMoving_Action(); // when the touch point is moving again (only signalled after a stop, not after Begin)
229  void signalTouchEndTrack_Action(); // when the touch is released
230 
231  void signalIconActivatedTap(IconBase* pIcon); // user has tapped on a valid Icon
232 
233 
235 
236 protected:
237 
238  static qint32 sEventCounter0;
240  QPointer<Quicklauncher> m_qp_ownerWindow;
241  QPointer<PixmapObject> m_qp_backgroundTranslucent;
242  QPointer<PixmapObject> m_qp_backgroundSolid;
243 
244  QPointer<PixmapObject> m_qp_currentBg; //alias to one of the two; solid or translucent
245 
246  QPointer<PixButton2State> m_qp_launcherAccessButton;
247 
248  //items are constrained to within this x range in ICS
249  QPair<qint32,qint32> m_itemAreaXrange;
250  //...and this is the centerline
251  qint32 m_itemsY;
252 
253  QList<qint32> m_layoutAnchorsXcoords;
254  QList<QPointer<IconBase> > m_iconItems; //must be IN ORDER, as arranged on the QL. ==> when a reorder on the QL happens, this list needs to be shuffled to match
255  typedef QList<QPointer<IconBase> >::iterator IconListIter;
256 
257  QPointer<IconBase> m_qp_iconInMotion;
259 
260  QPointer<QParallelAnimationGroup> m_qp_reorderAnimationGroup;
261 
264 };
265 
266 #endif /* QUICKLAUNCHBAR_H_ */