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 { |
89 { |
86 return notificationDialogSequentialShowInstance(); |
90 return notificationDialogSequentialShowInstance(); |
87 } |
91 } |
88 |
92 |
89 /*! |
93 /*! |
90 @beta |
94 @stable |
91 @hbwidgets |
95 @hbwidgets |
|
96 |
92 \class HbNotificationDialog |
97 \class HbNotificationDialog |
93 \brief HbNotificationDialog can be used to notify users of system |
98 \brief HbNotificationDialog is a non-modal dialog for displaying application notifications. |
94 generated or user activated events in the UI. |
99 |
95 |
100 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. |
101 applications to show notifications to user in non-intrusive way. The dialog does not |
97 These notifications do not require |
102 require user input and is usually closed by timeout. |
98 user input. |
103 |
99 |
104 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 |
105 consist either of a title spanning two lines or title and text. Setters are provided for |
101 by first enabling the touch activation with |
106 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 |
107 content by an inherited method setContentWidget(). |
103 HbNotificationDialog::activated(). |
108 |
104 |
109 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 |
110 if enabled by enableTouchActivation(). |
106 widgets which provides two rows of text (title spanning both lines, or title and text) and optionally an icon. |
111 |
107 You can use the default content widget by invoking the HbNotificationDialog with its |
112 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(). |
113 launchDialog() can be used to show dialogs. |
109 |
114 |
110 Alternatively, you can create a separate widget, and set it to the dialog with the inherited method |
115 By default, notification dialogs are synchronized with device dialogs. The display of |
111 HbNotificationDialog::setContentWidget(). |
116 notification dialogs is delayed until there are no device dialogs on display. |
112 |
117 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 |
118 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 |
119 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. |
120 can be disabled using the setSequentialShow() function. |
|
121 |
|
122 Following sample code sets dialog title, text, icon and shows it. |
|
123 \code |
|
124 HbNotificationDialog *dialog = new HbNotificationDialog(); |
|
125 dialog->setAttribute(Qt::WA_DeleteOnClose, true); |
|
126 dialog->setTitle("My title"); |
|
127 dialog->setText("My text"); |
|
128 dialog->setIcon(HbIcon("qtg_large_info")); |
|
129 dialog->show(); |
|
130 \endcode |
|
131 |
|
132 Using a static helper to show a dialog. |
|
133 \code |
|
134 HbNotificationDialog::launchDialog(HbIcon("qtg_large_info"), "My title", "My text"); |
|
135 \endcode |
|
136 |
|
137 Connecting to activated signal. |
|
138 \code |
|
139 HbNotificationDialog *dialog = new HbNotificationDialog(); |
|
140 connect(dialog, SIGNAL(activated()), this, SLOT(dialogActivated())); |
|
141 dialog->enableTouchActivation(true); |
|
142 dialog->setAttribute(Qt::WA_DeleteOnClose, true); |
|
143 dialog->setTitle("My title"); |
|
144 dialog->setText("My text"); |
|
145 dialog->setIcon(HbIcon("qtg_large_info")); |
|
146 dialog->show(); |
|
147 \endcode |
119 */ |
148 */ |
120 |
149 |
121 /*! |
150 /*! |
122 \fn void HbNotificationDialog::activated(); |
151 \fn void HbNotificationDialog::activated(); |
123 |
152 |
124 This signal is emitted when the dialog is closed with a pointer tap. |
153 This signal is emitted when the dialog is tapped and touch activation is |
|
154 enabled. |
|
155 |
|
156 \sa enableTouchActivation() |
125 */ |
157 */ |
126 |
158 |
127 /*! |
159 /*! |
128 Constructor. |
160 Constructs HbNotificationDialog. |
129 */ |
161 */ |
130 HbNotificationDialog::HbNotificationDialog() : HbDialog(*new HbNotificationDialogPrivate, 0) |
162 HbNotificationDialog::HbNotificationDialog() : HbDialog(*new HbNotificationDialogPrivate, 0) |
131 { |
163 { |
132 Q_D(HbNotificationDialog); |
164 Q_D(HbNotificationDialog); |
133 d->q_ptr = this; |
165 d->q_ptr = this; |
134 setFocusPolicy(Qt::NoFocus); |
166 setFocusPolicy(Qt::NoFocus); |
135 d->timeout = HbDialog::StandardTimeout; |
|
136 |
167 |
137 // Preferred position from style |
168 // Preferred position from style |
138 qreal hMargin = 0; |
169 qreal hMargin = 0; |
139 qreal vMargin = 0; |
170 qreal vMargin = 0; |
140 if ((style()->parameter(H_MARGIN, hMargin)) && |
171 if ((style()->parameter(H_MARGIN, hMargin)) && |
141 (style()->parameter(V_MARGIN, vMargin))) { |
172 (style()->parameter(V_MARGIN, vMargin))) { |
142 setPreferredPos(QPointF(hMargin, vMargin)); |
173 setPreferredPos(QPointF(hMargin, vMargin)); |
143 } |
174 } |
144 |
175 |
145 //d->setPriority(1); |
|
146 |
|
147 setModal(false); |
176 setModal(false); |
148 |
177 |
149 setBackgroundFaded(false); |
178 setBackgroundFaded(false); |
150 setDismissPolicy(HbPopup::NoDismiss); |
179 setDismissPolicy(HbPopup::NoDismiss); |
151 setTimeout(HbPopup::StandardTimeout); |
180 setTimeout(HbPopup::StandardTimeout); |
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 */ |