54 #endif |
55 #endif |
55 /*! |
56 /*! |
56 @beta |
57 @beta |
57 @hbcore |
58 @hbcore |
58 \class HbPopup |
59 \class HbPopup |
59 \brief HbPopup is a base class for different popups in Hb library. |
60 \brief The HbPopup class defines a set of properties that control the behavior of |
60 |
61 the many dialog and popup classes that derive from it. |
61 Popup is a widget that is displayed above other widgets in the view. |
62 |
62 |
63 Objects of classes derived from %HbPopup are called \b popups. Typically they |
63 Lastly shown popup is always positioned in Z order on the the top |
64 are displayed above other objects within the view, at the highest z-order. The %HbPopup |
64 of already visible popups. |
65 class simply defines a frame with a number of properties. If you want to create an |
65 |
66 application dialog with a heading, content and a toolbar, use the HbDialog class (which |
66 A popup can be permanent or automatically dismissed after a |
67 is derived from %HbPopup) or one of its convenience subclasses. |
67 time-out. Modal popups interrupt any other user interaction |
68 |
68 outside of the popup while they are visible, whereas non-modal |
69 %HbPopup provides properties that you can use to customize the following aspects of a popup: |
69 popups do not. |
70 |
70 |
71 - \b Modality. You can define whether the popup is modal or non-modal. A modal popup stops |
71 \sa HbDialog |
72 the user interacting with anything outside of the popup until it closes. A non-modal |
72 */ |
73 popup does not block the user's interaction with things outside of the popup. You |
73 |
74 set and get the modality by calling setModal() and isModal(), respectively. |
74 /*! |
75 |
75 \reimp |
76 - <b>Dismiss policy</b>. You can define which user actions, if any, cause the popup to |
|
77 close. Possible values are defined by HbPopup::DismissPolicy. You set and get the dismiss |
|
78 policy by calling setDismissPolicy() and dismissPolicy(), respectively. |
|
79 |
|
80 - <b>Background fade policy</b>. You can set a policy to fade everything behind the |
|
81 popup. This is useful for modal dialogs, because the user cannot interact with |
|
82 anything behind the popup. You control this policy by calling setBackgroundFaded() and |
|
83 get the current policy by calling isBackgroundFaded(). |
|
84 |
|
85 - \b Timeout. You can define a timeout that causes the popup to be dismissed automatically |
|
86 after a set a period. You set and get this property by calling setTimeout() and |
|
87 timeout(), respectively. Call the setTimeout(HbPopup::DefaultTimeout) overload to use the |
|
88 default value for the popup type, which provides a common look and feel. |
|
89 |
|
90 - <b>Frame background type</b>. You can define the popup's background style. However, |
|
91 the actual appearance of the popup depends on the theme. You set and get this property by |
|
92 calling setFrameType() and frameType(), respectively. |
|
93 |
|
94 By default, popups are displayed in the center of the screen. Typically you should not override |
|
95 the default position of modal dialogs. However, some popups, such as context menus, need to be |
|
96 in a specific position. For these, you can use the setPreferredPos() method to set the |
|
97 preferred position. |
|
98 |
|
99 Popups that contain an editor may be repositioned by the virtual keyboard when it opens. |
|
100 When the virtual keyboard closes, it attempts to reposition the popup back to its |
|
101 previous position. However, this is not always possible, particularly when there has also |
|
102 been an orientation switch. |
|
103 |
|
104 \section _usecases_hbpopup Using the HbPopup class |
|
105 |
|
106 Although it is possible to create an instance of the HbPopup class, it is designed as a |
|
107 base class to provide common features to the many popup and dialog classes that are |
|
108 derived from it (such as HbMenu, HbDialog, HbToolBarExtension, HbZoomSliderPopup). |
|
109 |
|
110 How you open a popup depends on whether it is modal. It is important to use the |
|
111 appropriate method, because this ensures the correct touch event handling. |
|
112 |
|
113 <table border="1" style="border-collapse: collapse; border: solid;"> |
|
114 <tr><th>To open</TH><TH>Call</th></tr> |
|
115 <tr><td>Modal popups</td><td>open()</td></tr> |
|
116 <tr><td>Non-modal popups</td><td>\link QGraphicsItem::show() show()\endlink</td></tr> |
|
117 </table> |
|
118 |
|
119 \sa HbDialog, HbMenu |
|
120 */ |
|
121 |
|
122 /*! |
76 \fn int HbPopup::type() const |
123 \fn int HbPopup::type() const |
77 */ |
124 */ |
78 |
125 |
79 /*! |
126 /*! |
80 \enum HbPopup::DefaultTimeout |
127 \enum HbPopup::DefaultTimeout |
81 |
128 |
82 This enum defines available default timeout values to be used in method |
129 Identifies default timeout values for various popup types. The timeout defines a time |
83 setTimeout(HbPopup::DefaultTimeout). |
130 period after which the popup is automatically closed. Using these default values |
|
131 provides a consistent look and feel. |
|
132 \sa setTimeout(HbPopup::DefaultTimeout) |
84 */ |
133 */ |
85 |
134 |
86 /*! |
135 /*! |
87 \var HbPopup::NoTimeout |
136 \var HbPopup::NoTimeout |
88 |
137 Defines a permanent popup, for which no timeout is defined. |
89 No timeout is defined for automatically closing the popup. i.e. the popup is permanent. |
|
90 */ |
138 */ |
91 |
139 |
92 /*! |
140 /*! |
93 \var HbPopup::ConfirmationNoteTimeout |
141 \var HbPopup::ConfirmationNoteTimeout |
94 |
142 The default timeout value for confirmation notes. |
95 Timeout value intended to be used by confirmation notes. |
|
96 */ |
143 */ |
97 |
144 |
98 /*! |
145 /*! |
99 \var HbPopup::StandardTimeout |
146 \var HbPopup::StandardTimeout |
100 |
147 The default timeout value for standard non-permanent popups, such as notes. |
101 The default timeout value intended to be used by most non-permanent popups e.g. by notes. |
|
102 */ |
148 */ |
103 |
149 |
104 /*! |
150 /*! |
105 \var HbPopup::ContextMenuTimeout |
151 \var HbPopup::ContextMenuTimeout |
106 |
152 The default timeout value for context menus. |
107 The default timeout value intended to be used by context menus. |
|
108 */ |
153 */ |
109 |
154 |
110 /*! |
155 /*! |
111 \enum HbPopup::DismissPolicy |
156 \enum HbPopup::DismissPolicy |
112 |
157 |
113 This enum defines available dismiss policy values. |
158 Defines the available dismiss policy values. The dismiss policy defines which |
114 |
159 user actions cause the popup to close. |
115 The dismiss policy defines what user actions will cause the popup to be dismissed i.e. closed. |
160 |
|
161 \sa setDismissPolicy(), dismissPolicy() |
116 */ |
162 */ |
117 |
163 |
118 /*! |
164 /*! |
119 \var HbPopup::NoDismiss |
165 \var HbPopup::NoDismiss |
120 |
166 The popup cannot be closed by the user. |
121 The popup cannot be dismissed automatically by user interaction. |
|
122 */ |
167 */ |
123 |
168 |
124 /*! |
169 /*! |
125 \var HbPopup::TapInside |
170 \var HbPopup::TapInside |
126 |
171 Closes the popup when the user taps within the popup's bounding rectangle. |
127 The popup is dismissed when user taps within the bounding rectangle of the popup. |
|
128 */ |
172 */ |
129 |
173 |
130 /*! |
174 /*! |
131 \var HbPopup::TapOutside |
175 \var HbPopup::TapOutside |
132 |
176 |
133 The popup is dismissed when user taps outside of the bounding rectangle of the popup. |
177 Closes the popup when the user taps outside of the popup's bounding rectangle. |
134 */ |
178 */ |
135 |
179 |
136 /*! |
180 /*! |
137 \var HbPopup::TapAnywhere |
181 \var HbPopup::TapAnywhere |
138 |
182 Closes the popup when the user taps either inside or outside the popup's bounding |
139 The popup is dismissed when user taps either within or outside |
183 rectangle. |
140 of the bounding rectangle of the popup. |
|
141 */ |
184 */ |
142 |
185 |
143 /*! |
186 /*! |
144 \enum HbPopup::FrameType |
187 \enum HbPopup::FrameType |
145 |
188 |
146 This enum defines available frame type values. |
189 Identifies the background graphical styles of the popup's frame. |
147 |
190 |
148 The frame types defines what frame item backgrounds will be used |
191 \sa setFrameType(), frameType() |
149 by the popup. Actual appearance is dependent on theme. |
|
150 */ |
192 */ |
151 |
193 |
152 /*! |
194 /*! |
153 \var HbPopup::Strong |
195 \var HbPopup::Strong |
154 |
196 Use the "strong" frame background style. |
155 The popup is using strong frame. |
|
156 */ |
197 */ |
157 |
198 |
158 /*! |
199 /*! |
159 \var HbPopup::Weak |
200 \var HbPopup::Weak |
160 |
201 Use the "weak" frame background style. |
161 The popup is using weak frame. |
|
162 */ |
202 */ |
163 |
203 |
164 /*! |
204 /*! |
165 \fn void HbPopup::aboutToShow(); |
205 \fn void HbPopup::aboutToShow(); |
166 |
206 |
167 This signal is emitted when the popup is about to be shown i.e. when method show() is called. |
207 This signal is emitted when the popup is about to be shown; that is, when |
|
208 \link QGraphicsItem::show() show()\endlink is called. |
168 */ |
209 */ |
169 |
210 |
170 /*! |
211 /*! |
171 \fn void HbPopup::aboutToHide(); |
212 \fn void HbPopup::aboutToHide(); |
172 |
213 |
173 This signal is emitted when the popup is about to be hidden i.e. when method hide() is called. |
214 This signal is emitted when the popup is about to be hidden; that is, when |
|
215 \link QGraphicsItem::hide() hide()\endlink is called. |
174 */ |
216 */ |
175 |
217 |
176 |
218 |
177 /*! |
219 /*! |
178 \fn void HbPopup::aboutToClose(); |
220 \fn void HbPopup::aboutToClose(); |
179 |
221 |
180 This signal is emitted when the popup is about to be closed i.e. when method close() is called |
222 This signal is emitted when the popup is about to close; that is, when |
181 or the popup is |
223 \link QGraphicsWidget::close() close()\endlink is called or the popup is dismissed |
182 dismissed by the user or timeout. |
224 by the user or timeout. |
183 */ |
225 */ |
184 |
226 |
185 /*! |
227 /*! |
186 \enum HbPopup::Placement |
228 \enum HbPopup::Placement |
187 |
229 Identifies the corners and edges of the popup for use when setting its position |
188 Placement is the corner or edge to which position of the popup refers to. |
230 using setPreferredPos(). |
189 */ |
231 */ |
190 |
232 |
191 /*! |
233 /*! |
192 \primitives |
234 \var HbPopup::TopLeftCorner |
193 \primitive{background} HbFrameItem representing the popup background. The background can be weak or strong (different graphical styles) depending on popup type. |
235 The popup's top left corner. |
194 \primitive{P_Popup_heading_frame} HbFrameItem representing the popup heading text background |
236 */ |
195 */ |
237 |
|
238 /*! |
|
239 \var HbPopup::TopRightCorner |
|
240 The popup's top right corner. |
|
241 */ |
|
242 |
|
243 /*! |
|
244 \var HbPopup::BottomLeftCorner |
|
245 The popup's bottom left corner. |
|
246 */ |
|
247 |
|
248 /*! |
|
249 \var HbPopup::BottomRightCorner |
|
250 The popup's bottom right corner. |
|
251 */ |
|
252 |
|
253 /*! |
|
254 \var HbPopup::TopEdgeCenter |
|
255 The center of the popup's top edge. |
|
256 */ |
|
257 |
|
258 /*! |
|
259 \var HbPopup::RightEdgeCenter |
|
260 The center of the popup's rightmost edge. |
|
261 */ |
|
262 |
|
263 /*! |
|
264 \var HbPopup::BottomEdgeCenter |
|
265 The center of the popup's bottom edge. |
|
266 */ |
|
267 |
|
268 /*! |
|
269 \var HbPopup::LeftEdgeCenter |
|
270 The center of the popup's leftmost edge. |
|
271 */ |
|
272 |
|
273 /*! |
|
274 \var HbPopup::Center |
|
275 The center of the popup. |
|
276 */ |
196 |
277 |
197 static const struct { HbPopup::DefaultTimeout timeout; int value; } timeoutValues[] = |
278 static const struct { HbPopup::DefaultTimeout timeout; int value; } timeoutValues[] = |
198 { |
279 { |
199 {HbPopup::NoTimeout,0}, |
280 {HbPopup::NoTimeout,0}, |
200 {HbPopup::ConfirmationNoteTimeout,1500}, |
281 {HbPopup::ConfirmationNoteTimeout,1500}, |
201 {HbPopup::StandardTimeout,3000}, |
282 {HbPopup::StandardTimeout,3000}, |
202 {HbPopup::ContextMenuTimeout,6000}, |
283 {HbPopup::ContextMenuTimeout,6000}, |
203 }; |
284 }; |
204 |
285 |
|
286 /* |
|
287 \primitives |
|
288 \primitive{background} HbFrameItem representing the popup background. The background can be |
|
289 weak or strong (different graphical styles) depending on popup type. |
|
290 \primitive{P_Popup_heading_frame} HbFrameItem representing the popup heading text background |
|
291 */ |
205 HbPopupBackGround::HbPopupBackGround(HbPopup * popup, QGraphicsItem *parent) : |
292 HbPopupBackGround::HbPopupBackGround(HbPopup * popup, QGraphicsItem *parent) : |
206 QGraphicsItem(parent), |
293 QGraphicsItem(parent), |
207 popup(popup) |
294 popup(popup) |
208 { |
295 { |
209 // This is needed to be able to block moving the focus to items behind background item by |
296 // This is needed to be able to block moving the focus to items behind background item by |
595 mVgMaskEffect->setForceSwMode(true); |
696 mVgMaskEffect->setForceSwMode(true); |
596 // There may be children (like the scroll area in menus) that |
697 // There may be children (like the scroll area in menus) that |
597 // would mess up the masking so exclude those. |
698 // would mess up the masking so exclude those. |
598 mVgMaskEffect->setIncludeSourceItemOnly(true); |
699 mVgMaskEffect->setIncludeSourceItemOnly(true); |
599 if (!q->graphicsEffect()) { |
700 if (!q->graphicsEffect()) { |
600 // Attach the effect. Ownership is transferred to q. |
701 // Attach the effect. Ownership is transferred to the chain. The |
601 mVgMaskEffect->install(q); |
702 // ownership of the chain is transferred to q. The chain is needed |
|
703 // because we must co-exist with FXML-based filter effects. |
|
704 HbVgChainedEffect *c = new HbVgChainedEffect; |
|
705 c->add(mVgMaskEffect); |
|
706 c->install(q); |
602 } else { |
707 } else { |
603 // Avoid replacing already set effects. Do not mask if |
708 // Avoid replacing already set effects. Do not mask if this is not |
604 // this is not possible, otherwise we would unexpectedly |
709 // possible, otherwise we would unexpectedly delete the previously |
605 // delete the previously set graphics effect. |
710 // set graphics effect. However by being able to add the effect to a |
|
711 // chain makes it possible to co-exist with FXML-based filter |
|
712 // effects. Similar solution is also present in HbEffectGroup. |
606 HbVgChainedEffect *c = qobject_cast<HbVgChainedEffect *>(q->graphicsEffect()); |
713 HbVgChainedEffect *c = qobject_cast<HbVgChainedEffect *>(q->graphicsEffect()); |
607 if (c) { |
714 if (c) { |
608 c->add(mVgMaskEffect); |
715 c->add(mVgMaskEffect); |
609 } else { |
716 } else { |
610 delete mVgMaskEffect; |
717 delete mVgMaskEffect; |
|
718 mVgMaskEffect = 0; |
611 } |
719 } |
612 } |
720 } |
613 } |
721 } |
614 QPixmap image(QSize(static_cast<int>(q->backgroundItem()->boundingRect().width()), |
722 QPixmap image(q->backgroundItem()->boundingRect().size().toSize()); |
615 static_cast<int>(q->backgroundItem()->boundingRect().height()))); |
|
616 image.fill(Qt::transparent); |
723 image.fill(Qt::transparent); |
617 QPainter imagePainter(&image); |
724 QPainter imagePainter(&image); |
618 q->backgroundItem()->paint(&imagePainter, 0, 0); |
725 q->backgroundItem()->paint(&imagePainter, 0, 0); |
619 imagePainter.end(); |
726 imagePainter.end(); |
620 mVgMaskEffect->setMask(image); |
727 mVgMaskEffect->setMask(image); |
621 #endif |
728 } |
622 } |
729 |
623 |
730 void HbPopupPrivate::resizePopup() |
624 /*! |
731 { |
625 Constructs a popup with given \a parent graphics item.\n |
732 |
626 Note: popups with \a parent set as 0 are behaving as real popups. |
733 } |
627 This is actually the intended use. |
734 |
628 |
735 /*! |
629 However in some situation could be useful to embedd a popup into a QGraphicsItem. |
736 Constructs a popup with the given \a parent graphics item. For true popup |
630 In this case a non zero \a parent value must be passed. |
737 behavior (which means that it opens above other objects, at the highest z-order) |
631 Popups with parent items behaving just like any other QGraphicsWidget. |
738 set \a parent to 0. This is the primary intended use of this class. |
632 The following features are not supported (i.e. ignored) for popup with parents: |
739 |
633 |
740 However, it may sometimes be useful to embed a popup into a QGraphicsItem. To do |
634 - modality |
741 this, pass a non-zero \a parent value. HbPopup objects that have a parent are |
635 - timeout |
742 not real popups: they behave like any other QGraphicsWidget object and following |
636 - unfadedItems |
743 properties are ignored. In addition the aboutToClose() signal is not emitted. |
637 - dismissPolicy |
744 |
638 - signal aboutToClose |
745 - \link isModal() modal\endlink property |
|
746 - \link timeout() timeout\endlink property |
|
747 - \link isBackgroundFaded() Backgroundfaded\endlink property |
|
748 - \link dismissPolicy() dismissPolicy\endlink property |
639 */ |
749 */ |
640 HbPopup::HbPopup(QGraphicsItem *parent) : |
750 HbPopup::HbPopup(QGraphicsItem *parent) : |
641 HbWidget(*new HbPopupPrivate,parent) |
751 HbWidget(*new HbPopupPrivate,parent) |
642 { |
752 { |
643 Q_D(HbPopup); |
753 Q_D(HbPopup); |
686 delete d->backgroundItem; |
796 delete d->backgroundItem; |
687 } |
797 } |
688 } |
798 } |
689 } |
799 } |
690 |
800 |
691 |
801 /*! |
692 /*! |
802 Returns the popup's timeout property in milliseconds. The timeout causes the popup to |
693 Returns the popup timeout property in milliseconds. |
803 be dismissed automatically after the specified time period has elapsed. A value of |
694 If this property is not set the deafult is HbPopup::StandardTimeout. |
804 zero or less than zero, means that the popup is permanent and the user must take |
695 \sa setTimeout() |
805 some explicit action in order to close the popup. |
|
806 |
|
807 The default value for this property is HbPopup::StandardTimeout. |
|
808 |
|
809 \sa setTimeout(), setTimeout(HbPopup::DefaultTimeout) |
696 */ |
810 */ |
697 int HbPopup::timeout() const |
811 int HbPopup::timeout() const |
698 { |
812 { |
699 Q_D(const HbPopup); |
813 Q_D(const HbPopup); |
700 return d->timeout; |
814 return d->timeout; |
701 } |
815 } |
702 |
816 |
703 /*! |
817 /*! |
704 Sets the popup timeout property in milliseconds. |
818 Sets the popup's timeout property in milliseconds. A value of zero or less than zero |
705 If timeout <= 0 then the popup is permanent and not closed automatically. |
819 means that the popup is permanent and is not closed automatically. |
706 \sa timeout() setTimeout(HbPopup::DefaultTimeout) QGraphicsWidget::close() |
820 |
|
821 \overload |
|
822 \sa timeout() setTimeout(HbPopup::DefaultTimeout), QGraphicsWidget::close() |
707 */ |
823 */ |
708 void HbPopup::setTimeout(int timeout) |
824 void HbPopup::setTimeout(int timeout) |
709 { |
825 { |
710 Q_D(HbPopup); |
826 Q_D(HbPopup); |
711 d->setTimeout(timeout); |
827 d->setTimeout(timeout); |
712 //d->timeout = timeout; |
828 //d->timeout = timeout; |
713 } |
829 } |
714 |
830 |
715 /*! |
831 /*! |
716 It is a convenience overload of \a timeout() for setting HbPopup::DefaultTimeout values |
832 Sets the popup's timeout property to the default value for a standard popup type. |
717 to achieve common look & feel. |
833 This has the advantage of creating a common look and feel. |
718 \sa enum DefaultTimeout |
834 |
719 \sa timeout() setTimeout(int) QGraphicsWidget::close() |
835 \overload |
|
836 \sa timeout(), setTimeout(int), QGraphicsWidget::close() |
720 */ |
837 */ |
721 void HbPopup::setTimeout(HbPopup::DefaultTimeout timeout) |
838 void HbPopup::setTimeout(HbPopup::DefaultTimeout timeout) |
722 { |
839 { |
723 setTimeout(HbPopupPrivate::timeoutValue(timeout)); |
840 setTimeout(HbPopupPrivate::timeoutValue(timeout)); |
724 } |
841 } |
725 |
842 |
726 /*! |
843 /*! |
727 Returns the popup modality property. |
844 Returns the popup's modality property. A modal popup blocks any user-initiated |
728 A modal popup blocks any user initiated events outside of the popup |
845 events outside of the popup until it is closed. |
729 until it is closed. |
846 \sa setModal() |
730 \sa setModal() |
|
731 */ |
847 */ |
732 bool HbPopup::isModal() const |
848 bool HbPopup::isModal() const |
733 { |
849 { |
734 Q_D(const HbPopup); |
850 Q_D(const HbPopup); |
735 return d->modal; |
851 return d->modal; |
736 } |
852 } |
737 |
853 |
738 /*! |
854 /*! |
739 Sets the popup modality property. |
855 Sets the popup's modality property. |
740 \sa isModal() |
856 |
|
857 To open a modal popup, call open(). To open a non-modal popup, call |
|
858 \link QGraphicsItem::show() show()\endlink. |
|
859 \sa isModal() |
741 */ |
860 */ |
742 void HbPopup::setModal(bool enabled) |
861 void HbPopup::setModal(bool enabled) |
743 { |
862 { |
744 Q_D(HbPopup); |
863 Q_D(HbPopup); |
745 d->modal = enabled; |
864 d->modal = enabled; |
746 d->doSetModal( d->modal ); |
865 d->doSetModal( d->modal ); |
747 } |
866 } |
748 |
867 |
749 /*! |
868 /*! |
750 Sets the background of popup faded if \a fadeBackground is true otherwise |
869 Sets the popup's background fade policy property. When this is set to true, it causes |
751 the background will not be faded. |
870 everything behind the popup to be faded. |
752 \sa isBackgroundFaded() |
871 \sa isBackgroundFaded() |
753 */ |
872 */ |
754 void HbPopup::setBackgroundFaded(bool fadeBackground) |
873 void HbPopup::setBackgroundFaded(bool fadeBackground) |
755 { |
874 { |
756 Q_D(HbPopup); |
875 Q_D(HbPopup); |
757 d->fadeBackground = fadeBackground; |
876 d->fadeBackground = fadeBackground; |
758 } |
877 } |
759 |
878 |
760 /*! |
879 /*! |
761 Returns if the background of the popup is faded or not. |
880 Returns the popup's background fade policy property. This controls whether |
762 Default: true |
881 everything behind the popup is faded while the popup is on the screen. Typically |
763 \sa isBackgroundFaded() |
882 this property is set to true for modal dialogs only. The default is true. |
|
883 \sa setBackgroundFaded() |
764 */ |
884 */ |
765 bool HbPopup::isBackgroundFaded() const |
885 bool HbPopup::isBackgroundFaded() const |
766 { |
886 { |
767 Q_D(const HbPopup); |
887 Q_D(const HbPopup); |
768 return d->backgroundItem && d->fadeBackground; |
888 return d->backgroundItem && d->fadeBackground; |
769 } |
889 } |
770 |
890 |
771 /*! |
891 /*! |
772 Returns the dismiss policy of the popup. |
892 Returns the popup's dismiss policy. This defines which user actions (if any) cause |
773 Default is HbPopup::TapOutside. |
893 the popup to close. The default is HbPopup::TapOutside. |
774 \sa setDismissPolicy() |
894 \sa setDismissPolicy() |
775 */ |
895 */ |
776 HbPopup::DismissPolicy HbPopup::dismissPolicy() const |
896 HbPopup::DismissPolicy HbPopup::dismissPolicy() const |
777 { |
897 { |
778 Q_D(const HbPopup); |
898 Q_D(const HbPopup); |
779 return d->dismissPolicy; |
899 return d->dismissPolicy; |
780 } |
900 } |
781 |
901 |
782 /*! |
902 /*! |
783 Sets the dismiss policy property for the the popup. |
903 Sets the popup's dismiss policy property. |
784 |
904 |
785 \sa dismissPolicy() |
905 \sa dismissPolicy() |
786 */ |
906 */ |
787 void HbPopup::setDismissPolicy(HbPopup::DismissPolicy dismissPolicy) |
907 void HbPopup::setDismissPolicy(HbPopup::DismissPolicy dismissPolicy) |
788 { |
908 { |
789 Q_D(HbPopup); |
909 Q_D(HbPopup); |
790 d->dismissPolicy = dismissPolicy; |
910 d->dismissPolicy = dismissPolicy; |
791 } |
911 } |
792 |
912 |
793 /*! |
913 /*! |
794 Returns the frame type of the popup. |
914 Returns the popup's frame type. This controls the popup's background style. However, |
795 Default is HbPopup::Strong |
915 the actual appearance depends on the theme. The default value is HbPopup::Strong. |
796 \sa setFrameType() |
916 |
|
917 \sa setFrameType() |
797 */ |
918 */ |
798 HbPopup::FrameType HbPopup::frameType() const |
919 HbPopup::FrameType HbPopup::frameType() const |
799 { |
920 { |
800 Q_D(const HbPopup); |
921 Q_D(const HbPopup); |
801 return d->frameType; |
922 return d->frameType; |
802 } |
923 } |
803 |
924 |
804 /*! |
925 /*! |
805 Sets the frame typeproperty for the the popup. |
926 Sets the popup's frame type, which controls the popup's background style. |
806 |
927 |
807 \sa frameType() |
928 \sa frameType() |
808 */ |
929 */ |
809 void HbPopup::setFrameType(HbPopup::FrameType frameType) |
930 void HbPopup::setFrameType(HbPopup::FrameType frameType) |
810 { |
931 { |
811 Q_D(HbPopup); |
932 Q_D(HbPopup); |
812 if ( d->frameType != frameType ) { |
933 if ( d->frameType != frameType ) { |
813 switch( frameType ) { |
934 switch( frameType ) { |
814 case HbPopup::Weak: |
935 case HbPopup::Weak: |
815 d->setBackgroundItem(HbStyle::P_Popup_background_weak); |
936 d->setBackgroundItem(HbStylePrivate::P_Popup_background_weak); |
816 break; |
937 break; |
817 case HbPopup::Strong: |
938 case HbPopup::Strong: |
818 default: |
939 default: |
819 d->setBackgroundItem(HbStyle::P_Popup_background); |
940 d->setBackgroundItem(HbStylePrivate::P_Popup_background); |
820 break; |
941 break; |
821 } |
942 } |
822 d->frameType = frameType; |
943 d->frameType = frameType; |
823 updatePrimitives(); |
944 updatePrimitives(); |
824 } |
945 } |
825 } |
946 } |
826 |
947 |
827 |
948 |
828 /*! |
949 /*! |
829 Shows the popup as modal popup returning immediately. |
950 Displays the popup on the screen and returns immediately. This function also |
830 |
951 connects the popup's aboutToClose() signal to a specified slot. The signal |
831 Connects aboutToClose() signal to the slot specified by \a receiver and |
952 is disconnected from the slot when the popup closes. |
832 \a member. The signal will be disconnected from the slot when the |
953 |
833 popup is closed. |
954 Use this function to open modal popups. To open non-modal popups, call |
834 |
955 \link QGraphicsItem::show() show()\endlink. |
835 For non modal popups, use show(). |
956 |
|
957 \param receiver The object that is to receive the signal. |
|
958 \param member The slot on the receiver to which the signal is to connect. |
|
959 |
|
960 \sa isModal() |
836 */ |
961 */ |
837 void HbPopup::open( QObject *receiver, const char *member ) |
962 void HbPopup::open( QObject *receiver, const char *member ) |
838 { |
963 { |
839 Q_D(HbPopup); |
964 Q_D(HbPopup); |
840 if (receiver) { |
965 if (receiver) { |
1152 } |
1269 } |
1153 } |
1270 } |
1154 } else if (event->type() == QEvent::LayoutRequest) { |
1271 } else if (event->type() == QEvent::LayoutRequest) { |
1155 //Workaround when showing first time |
1272 //Workaround when showing first time |
1156 #ifdef HB_EFFECTS |
1273 #ifdef HB_EFFECTS |
1157 if(d->mStartEffect && boundingRect().isValid()) { |
1274 if (d->mStartEffect && boundingRect().isValid()) { |
1158 d->mStartEffect = false; |
1275 d->mStartEffect = false; |
1159 QCoreApplication::sendPostedEvents(this, QEvent::LayoutRequest); |
1276 QCoreApplication::sendPostedEvents(this, QEvent::LayoutRequest); |
1160 QRectF extRect(0.0, |
1277 QRectF extRect(0.0, |
1161 -boundingRect().height(), |
1278 -boundingRect().height(), |
1162 boundingRect().width(), |
1279 boundingRect().width(), |
1163 0); |
1280 0); |
1164 d->mStartEffect = true; |
|
1165 HbEffect::cancel(this); |
1281 HbEffect::cancel(this); |
1166 d->mStartEffect = false; |
1282 HbEffectInternal::start(this, this, HbEffectInternal::UpdateAtEachStep, |
1167 HbEffect::start(this, d->effectType, "appear", this, "_q_appearEffectEnded", QVariant(), extRect); |
1283 d->effectType, "appear", this, "_q_appearEffectEnded", |
1168 } |
1284 QVariant(), extRect); |
1169 #endif//HB_EFFECTS |
1285 } else if (d->mStartEffect) { |
|
1286 // Workaround for submenus that do not have any effect when shown |
|
1287 // first. The appear/disappear effect would call update() a number |
|
1288 // of times but in this case we have to do it manually. |
|
1289 new HbPopupUpdater(this, this); |
|
1290 } |
|
1291 #endif //HB_EFFECTS |
1170 //workaround ends |
1292 //workaround ends |
1171 } |
1293 } else if (d->mGestureOverride && event->type() == QEvent::GestureOverride) { |
|
1294 event->accept(); |
|
1295 return true; |
|
1296 } |
|
1297 |
1172 return HbWidget::event(event); |
1298 return HbWidget::event(event); |
1173 } |
1299 } |
1174 |
1300 |
1175 /*! |
1301 /*! |
1176 Sets preferred position\a position for popup with \a placement |
1302 Sets the preferred position of the popup. By default, the popup is placed in the middle |
1177 as origin. |
1303 of the screen. If you use this function to set the preferred position, it is your |
1178 |
1304 responsibility to ensure that this position works correctly on devices with different |
1179 By default popup is placed in the middle of the screen. If other positions are needed please |
1305 screen sizes. |
1180 ensure that the preferred position is working properly with different screen sizes. |
1306 |
1181 |
1307 Typically you should set the preferred position only for context aware popups, such as |
1182 \param position is the position at which the popup is shown. |
1308 context menus and slider popups. The position is not relevant for most dialogs and |
1183 \param placement is the corner or edge which \a position refers to |
1309 popups and you should use the default position for these. |
1184 |
1310 |
1185 Example usage: |
1311 \param preferredPos Defines the coordinates of preferred position on the screen where |
1186 \code |
1312 the popup is to open. |
1187 HbPopup *popup = new HbPopup(); |
1313 \param placement The corner or edge of the dialog that is to be placed at \a preferredPos. |
1188 ... |
1314 |
1189 popup->setPreferredPosition( QPointF(x,y), HbPopupBase::BottomEdgeCenter ); |
1315 \b Example: |
1190 popup->show(); |
1316 \code |
1191 \endcode |
1317 HbPopup *popup = new HbPopup(); |
|
1318 |
|
1319 popup->setPreferredPos( QPointF(x,y), HbPopup::BottomEdgeCenter ); |
|
1320 popup->show(); |
|
1321 \endcode |
1192 */ |
1322 */ |
1193 void HbPopup::setPreferredPos( const QPointF& preferredPos, |
1323 void HbPopup::setPreferredPos( const QPointF& preferredPos, |
1194 HbPopup::Placement placement ) |
1324 HbPopup::Placement placement ) |
1195 { |
1325 { |
1196 Q_D(HbPopup); |
1326 Q_D(HbPopup); |