|
1 /**************************************************************************** |
|
2 ** |
|
3 ** Copyright (C) 2008-2010 Nokia Corporation and/or its subsidiary(-ies). |
|
4 ** All rights reserved. |
|
5 ** Contact: Nokia Corporation (developer.feedback@nokia.com) |
|
6 ** |
|
7 ** This file is part of the HbCore module of the UI Extensions for Mobile. |
|
8 ** |
|
9 ** GNU Lesser General Public License Usage |
|
10 ** This file may be used under the terms of the GNU Lesser General Public |
|
11 ** License version 2.1 as published by the Free Software Foundation and |
|
12 ** appearing in the file LICENSE.LGPL included in the packaging of this file. |
|
13 ** Please review the following information to ensure the GNU Lesser General |
|
14 ** Public License version 2.1 requirements will be met: |
|
15 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
|
16 ** |
|
17 ** In addition, as a special exception, Nokia gives you certain additional |
|
18 ** rights. These rights are described in the Nokia Qt LGPL Exception |
|
19 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. |
|
20 ** |
|
21 ** If you have questions regarding the use of this file, please contact |
|
22 ** Nokia at developer.feedback@nokia.com. |
|
23 ** |
|
24 ****************************************************************************/ |
|
25 |
|
26 #ifndef HBPOPUPMANAGER_P_P_H |
|
27 #define HBPOPUPMANAGER_P_P_H |
|
28 |
|
29 #include "hbdialog.h" |
|
30 #include "hbpopup.h" |
|
31 #include "hbdevicefadecontrol_p.h" |
|
32 #include <QGraphicsItem> |
|
33 #include <QHash> |
|
34 #include <QList> |
|
35 #include <QPointer> |
|
36 |
|
37 class HbDialog; |
|
38 class HbGraphicsScene; |
|
39 class HbPopupLayoutManager; |
|
40 |
|
41 QT_FORWARD_DECLARE_CLASS(QEvent) |
|
42 QT_FORWARD_DECLARE_CLASS(QGraphicsSceneMouseEvent) |
|
43 |
|
44 class HbPopupManagerPrivate : public QObject |
|
45 { |
|
46 Q_OBJECT |
|
47 public: |
|
48 explicit HbPopupManagerPrivate( HbGraphicsScene *scene, QObject * parent = 0 ); |
|
49 virtual ~HbPopupManagerPrivate(); |
|
50 |
|
51 public: |
|
52 void eventHook( QEvent *event); |
|
53 void showPopup( HbPopup *popup ); |
|
54 void hidePopup( HbPopup *popup ); |
|
55 void addPopup( HbPopup *popup ); |
|
56 void removePopup( HbPopup *popup ); |
|
57 |
|
58 private: |
|
59 |
|
60 void mouseReleaseEvent(QGraphicsSceneMouseEvent* mouseEvent); |
|
61 bool eventBlockItem(QGraphicsItem *item); |
|
62 static qreal popupZValueForPriority(int priority, int popupCountWaterMark); |
|
63 qreal nextPopupZValueForPriority(int priority); |
|
64 void updateHash(int priority, qreal zValueOfRemovedPopup); |
|
65 void updateFading(bool unfadeFirst = false); |
|
66 void setGeometryForPopup(HbPopup *popup); |
|
67 |
|
68 private slots: |
|
69 void deviceFadeChange( bool fadeOff ); |
|
70 |
|
71 private: |
|
72 |
|
73 class GraphicsItem: public QGraphicsItem |
|
74 { |
|
75 friend class HbPopupManagerPrivate; |
|
76 }; |
|
77 |
|
78 struct PopupCountRegister |
|
79 { |
|
80 PopupCountRegister():waterMark(0), count(0){} |
|
81 int waterMark; |
|
82 int count; |
|
83 }; |
|
84 |
|
85 QList<HbPopup *> popupList; |
|
86 HbPopup *topLevelFocusablePopup; |
|
87 QGraphicsItem *initialFocusedItem; |
|
88 QHash<int, PopupCountRegister> popupCountRegisters; |
|
89 HbDeviceFadeControl deviceFadeControl; |
|
90 HbGraphicsScene *scene; |
|
91 QMap<HbPopup *,HbPopupLayoutManager*> parentItems; |
|
92 }; |
|
93 |
|
94 class HbPopupLayoutSpacer: public HbWidgetBase |
|
95 { |
|
96 public: |
|
97 HbPopupLayoutSpacer( QGraphicsItem *parent = 0 ); |
|
98 virtual ~HbPopupLayoutSpacer() {} |
|
99 protected: |
|
100 QSizeF sizeHint(Qt::SizeHint which, const QSizeF &constraint = QSizeF()) const; |
|
101 void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget ); |
|
102 }; |
|
103 |
|
104 class HbPopupLayoutProxy : public HbWidgetBase |
|
105 { |
|
106 public: |
|
107 HbPopupLayoutProxy( HbPopup *popup, QGraphicsItem *parent ); |
|
108 virtual ~HbPopupLayoutProxy() {} |
|
109 QPointer<HbPopup> mPopup; |
|
110 QPointF mPreferredPos; |
|
111 bool mPreferredPosSet; |
|
112 HbPopup::Placement mPlacement; |
|
113 |
|
114 protected: |
|
115 QSizeF sizeHint(Qt::SizeHint which, const QSizeF &constraint = QSizeF()) const; |
|
116 void setGeometry(const QRectF &rect); |
|
117 bool event( QEvent *e ); |
|
118 bool eventFilter(QObject *obj, QEvent *event); |
|
119 void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget ); |
|
120 |
|
121 }; |
|
122 |
|
123 class HbPopupLayoutManager : public HbWidget |
|
124 { |
|
125 Q_OBJECT |
|
126 public: |
|
127 HbPopupLayoutManager( HbPopup *popup, QGraphicsScene *scene ); |
|
128 virtual ~HbPopupLayoutManager() {} |
|
129 public slots: |
|
130 void orientationChanged(const QRectF& rect); |
|
131 protected: |
|
132 QSizeF sizeHint(Qt::SizeHint which, const QSizeF &constraint) const; |
|
133 void changeEvent(QEvent *event); |
|
134 void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget ); |
|
135 }; |
|
136 |
|
137 #endif // HBPOPUPMANAGER_P_P_H |
|
138 |