50 |
50 |
51 #define H_MARGIN QString("hb-param-margin-gene-middle-horizontal") |
51 #define H_MARGIN QString("hb-param-margin-gene-middle-horizontal") |
52 #define V_MARGIN QString("hb-param-margin-gene-middle-vertical") |
52 #define V_MARGIN QString("hb-param-margin-gene-middle-vertical") |
53 |
53 |
54 // Container to encapsulate device dialog server status and sequential show |
54 // Container to encapsulate device dialog server status and sequential show |
|
55 /// \cond |
55 class SequentialShow : public HbWidgetSequentialShow |
56 class SequentialShow : public HbWidgetSequentialShow |
56 { |
57 { |
57 public: |
58 public: |
58 SequentialShow(); |
59 SequentialShow(); |
59 static bool allowNotification(void *serverStatus); |
60 static bool allowNotification(void *serverStatus); |
60 private: |
61 private: |
61 HbDeviceDialogServerStatus mServerStatus; |
62 HbDeviceDialogServerStatus mServerStatus; |
62 }; |
63 }; |
|
64 /// \endcond |
|
65 |
63 // Constructor |
66 // Constructor |
64 SequentialShow::SequentialShow() : |
67 SequentialShow::SequentialShow() : |
65 HbWidgetSequentialShow(SequentialShow::allowNotification, &mServerStatus), mServerStatus(false) |
68 HbWidgetSequentialShow(SequentialShow::allowNotification, &mServerStatus), mServerStatus(false) |
66 { |
69 { |
67 connect(&mServerStatus, SIGNAL(statusChanged()), SLOT(externalStatusChanged())); |
70 connect(&mServerStatus, SIGNAL(statusChanged()), SLOT(externalStatusChanged())); |
85 { |
88 { |
86 return notificationDialogSequentialShowInstance(); |
89 return notificationDialogSequentialShowInstance(); |
87 } |
90 } |
88 |
91 |
89 /*! |
92 /*! |
90 @beta |
93 @stable |
91 @hbwidgets |
94 @hbwidgets |
|
95 |
92 \class HbNotificationDialog |
96 \class HbNotificationDialog |
93 \brief HbNotificationDialog can be used to notify users of system |
97 \brief HbNotificationDialog is a non-modal dialog for displaying application notifications. |
94 generated or user activated events in the UI. |
98 |
95 |
99 HbNotificationDialog is displayed at top left corner of a display. It is intended for |
96 HbNotificationDialog is a non-modal dialog displayed on top of applications. |
100 applications to show notifications to user in non-intrusive way. The dialog does not |
97 These notifications do not require |
101 require user input and is usually closed by timeout. |
98 user input. |
102 |
99 |
103 For content, HbNotificationDialog supports two rows of text and an icon. Two text rows may |
100 Optionally, an action can be activated with a tap to the notification dialog. This is enabled |
104 consist either of a title spanning two lines or title and text. Setters are provided for |
101 by first enabling the touch activation with |
105 setting title, text and icon. Alternatively, a custom widget can be created and set as |
102 enableTouchActivation() and then starting the action with the signal |
106 content by an inherited method setContentWidget(). |
103 HbNotificationDialog::activated(). |
107 |
104 |
108 HbNotificationDialog closes when tapped. A tap triggers HbNotificationDialog::activated() signal |
105 HbNotificationDialog is a concrete class. For the content, you can use the default content |
109 if enabled by enableTouchActivation(). |
106 widgets which provides two rows of text (title spanning both lines, or title and text) and optionally an icon. |
110 |
107 You can use the default content widget by invoking the HbNotificationDialog with its |
111 Notification dialog is displayed by show() or open() methods. Static helper functions |
108 static launch-methods or by using the methods setText(), setTitle() and setIcon(). |
112 launchDialog() can be used to show dialogs. |
109 |
113 |
110 Alternatively, you can create a separate widget, and set it to the dialog with the inherited method |
114 By default, notification dialogs are synchronized with device dialogs. The display of |
111 HbNotificationDialog::setContentWidget(). |
115 notification dialogs is delayed until there are no device dialogs on display. |
112 |
116 Notifications dialogs are also synchronized with each other. If several of them |
113 To display a notification dialog, show() or open() must be called. By default, notifications |
117 are shown at the same time, they are shown sequentially instead of on top of each other. |
114 are synchronized with device dialogs. The display of notification dialogs is delayed until there |
118 The synchronization with device dialogs and sequential display of notification dialogs |
115 are no device dialogs on display. Notifications are also synchronized with each other. |
|
116 If several notifications are shown at the same time with the show() function, they are shown |
|
117 sequentially instead of on top of each other. The synchronization of dialogs and sequential display of dialogs |
|
118 can be disabled using the setSequentialShow() function. |
119 can be disabled using the setSequentialShow() function. |
|
120 |
|
121 Following sample code sets dialog title, text, icon and shows it. |
|
122 \code |
|
123 HbNotificationDialog *dialog = new HbNotificationDialog(); |
|
124 dialog->setAttribute(Qt::WA_DeleteOnClose, true); |
|
125 dialog->setTitle("My title"); |
|
126 dialog->setText("My text"); |
|
127 dialog->setIcon(HbIcon("qtg_large_info")); |
|
128 dialog->show(); |
|
129 \endcode |
|
130 |
|
131 Using a static helper to show a dialog. |
|
132 \code |
|
133 HbNotificationDialog::launchDialog(HbIcon("qtg_large_info"), "My title", "My text"); |
|
134 \endcode |
|
135 |
|
136 Connecting to activated signal. |
|
137 \code |
|
138 HbNotificationDialog *dialog = new HbNotificationDialog(); |
|
139 connect(dialog, SIGNAL(activated()), this, SLOT(dialogActivated())); |
|
140 dialog->enableTouchActivation(true); |
|
141 dialog->setAttribute(Qt::WA_DeleteOnClose, true); |
|
142 dialog->setTitle("My title"); |
|
143 dialog->setText("My text"); |
|
144 dialog->setIcon(HbIcon("qtg_large_info")); |
|
145 dialog->show(); |
|
146 \endcode |
119 */ |
147 */ |
120 |
148 |
121 /*! |
149 /*! |
122 \fn void HbNotificationDialog::activated(); |
150 \fn void HbNotificationDialog::activated(); |
123 |
151 |
124 This signal is emitted when the dialog is closed with a pointer tap. |
152 This signal is emitted when the dialog is tapped and touch activation is |
|
153 enabled. |
|
154 |
|
155 \sa enableTouchActivation() |
125 */ |
156 */ |
126 |
157 |
127 /*! |
158 /*! |
128 Constructor. |
159 Default constructor. |
129 */ |
160 */ |
130 HbNotificationDialog::HbNotificationDialog() : HbDialog(*new HbNotificationDialogPrivate, 0) |
161 HbNotificationDialog::HbNotificationDialog() : HbDialog(*new HbNotificationDialogPrivate, 0) |
131 { |
162 { |
132 Q_D(HbNotificationDialog); |
163 Q_D(HbNotificationDialog); |
133 d->q_ptr = this; |
164 d->q_ptr = this; |
196 Q_D(const HbNotificationDialog); |
226 Q_D(const HbNotificationDialog); |
197 return d->isTouchActivating; |
227 return d->isTouchActivating; |
198 } |
228 } |
199 |
229 |
200 /*! |
230 /*! |
201 Convenience method for using HbNotificationDialog. Shows a notification dialog with |
231 Convenience method to display HbNotificationDialog. Constructs a notification dialog and shows |
202 the given parameters. The dialog is owned by HbNotificationDialog. |
232 it. Constructed object is deleted on close. |
|
233 |
|
234 \param title Dialog title. |
|
235 \param text Dialog text. |
|
236 \param scene Scene to add the dialog into (optional). |
203 */ |
237 */ |
204 void HbNotificationDialog::launchDialog(const QString &title, const QString &text, QGraphicsScene* scene) |
238 void HbNotificationDialog::launchDialog(const QString &title, const QString &text, QGraphicsScene* scene) |
205 { |
239 { |
206 HbNotificationDialog *self = new HbNotificationDialog(); |
240 HbNotificationDialog *self = new HbNotificationDialog(); |
207 if (scene) { |
241 if (scene) { |
227 self->setTitle(title); |
264 self->setTitle(title); |
228 self->show(); |
265 self->show(); |
229 } |
266 } |
230 |
267 |
231 /*! |
268 /*! |
232 Convenience method for using HbNotificationDialog. Shows a notification dialog with |
269 Convenience method to display HbNotificationDialog. Constructs a notification dialog and shows |
233 the given parameters. The dialog is owned by HbNotificationDialog. |
270 it. Constructed object is deleted on close. |
|
271 |
|
272 \param icon Dialog icon. |
|
273 \param title Dialog title. |
|
274 \param text Dialog text. |
|
275 \param scene Scene to add the dialog into (optional). |
234 */ |
276 */ |
235 void HbNotificationDialog::launchDialog(const HbIcon &icon, const QString &title, |
277 void HbNotificationDialog::launchDialog(const HbIcon &icon, const QString &title, |
236 const QString &text, QGraphicsScene* scene) |
278 const QString &text, QGraphicsScene* scene) |
237 { |
279 { |
238 HbNotificationDialog *self = new HbNotificationDialog(); |
280 HbNotificationDialog *self = new HbNotificationDialog(); |
239 if (scene) { |
281 if (scene) { |
240 scene->addItem(self); |
282 scene->addItem(self); |
241 } |
283 } |
340 d->content->setIcon( icon ); |
377 d->content->setIcon( icon ); |
341 d->setNotificationDialogContent(); |
378 d->setNotificationDialogContent(); |
342 } |
379 } |
343 |
380 |
344 /*! |
381 /*! |
345 Returns the style of text wrapping for the title. |
382 Returns title text wrapping. |
346 |
383 |
347 The title can wrap only if there is no other text for the dialog. The title can wrap to a maximum of two lines. |
384 The title can wrap only if dialog text is empty. The title can wrap to a maximum of two lines. |
348 The default is Hb::TextWordWrap. |
385 The default is Hb::TextWordWrap. |
349 |
386 |
350 \sa setTitleTextWrapping(), HbNotificationDialog::title, HbNotificationDialog::text |
387 \sa setTitleTextWrapping(), title(), text() |
351 */ |
388 */ |
352 Hb::TextWrapping HbNotificationDialog::titleTextWrapping() const |
389 Hb::TextWrapping HbNotificationDialog::titleTextWrapping() const |
353 { |
390 { |
354 Q_D(const HbNotificationDialog); |
391 Q_D(const HbNotificationDialog); |
355 return d->titleTextWrapping; |
392 return d->titleTextWrapping; |
356 } |
393 } |
357 |
394 |
358 /*! |
395 /*! |
359 Sets whether the text for the title is wrapped. |
396 Sets title text wrapping. The title can wrap only if there is no text for the dialog. |
360 |
397 The title can wrap to a maximum of two lines. setText() also changes title text wrapping. |
361 The title can wrap only if there is no text for the dialog. The title can wrap to a maximum of two lines. |
398 |
362 \sa titleTextWrapping() |
399 \sa titleTextWrapping(), setText() |
363 */ |
400 */ |
364 void HbNotificationDialog::setTitleTextWrapping(Hb::TextWrapping wrapping) |
401 void HbNotificationDialog::setTitleTextWrapping(Hb::TextWrapping wrapping) |
365 { |
402 { |
366 Q_D(HbNotificationDialog); |
403 Q_D(HbNotificationDialog); |
367 if (d->titleTextWrapping != wrapping) { |
404 if (d->titleTextWrapping != wrapping) { |
372 d->doLayout(); |
409 d->doLayout(); |
373 } |
410 } |
374 } |
411 } |
375 |
412 |
376 /*! |
413 /*! |
377 Enables or disables sequential display of the Notification Dialog. |
414 Enables or disables sequential display of notification dialog. |
378 |
415 |
379 When enabled, notification dialogs are shown sequentially. If multiple calls to show() occur at the same time then the dialogs are displayed |
416 When enabled, the dialog is synchronized with other notification dialogs. If multiple calls |
380 in sequence instead of on top of each other. The display of the dialogs is also synchronized |
417 to show() occur at the same time then dialogs are displayed in sequence instead of on top |
381 with the device dialogs such that the notification dialogs do not appear until there are no device dialogs being displayed. |
418 of each other. The display of the dialog is also synchronized with device dialogs such |
382 |
419 that it does not appear until there are no device dialogs being displayed. |
383 With sequential show disabled, |
420 |
384 HbNotificationDialog behaves like other popups. While a dialog is waiting to be shown, |
421 With sequential show disabled, HbNotificationDialog behaves like other popups. |
385 setVisible(), hide() and show() have no effect. To remove a dialog from the wait queue, call setSequentialShow(false). |
422 |
|
423 While a dialog is waiting to be shown, setVisible(), hide() and show() have no effect. |
|
424 To remove a dialog from the wait queue, call setSequentialShow(false). |
386 |
425 |
387 This setting is enabled by default. |
426 This setting is enabled by default. |
388 |
427 |
389 \sa isSequentialShow() |
428 \sa isSequentialShow() |
390 */ |
429 */ |