|
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 HbWidgets 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 #include <hbdevicedialog.h> |
|
27 #include <hbdevicedialogtrace_p.h> |
|
28 #include "hbdeviceprogressdialog.h" |
|
29 #include "hbdeviceprogressdialog_p.h" |
|
30 |
|
31 #include <QTimer> |
|
32 #include <QAction> |
|
33 |
|
34 HbDeviceProgressDialogPrivate::HbDeviceProgressDialogPrivate() : QObject(), |
|
35 mVisible(false), |
|
36 mUpdateTimerId(0) |
|
37 { |
|
38 TRACE_ENTRY |
|
39 for(int i = 0; i < NumActions; i++) { |
|
40 mDefaultActions[i] = 0; |
|
41 } |
|
42 TRACE_EXIT |
|
43 } |
|
44 |
|
45 HbDeviceProgressDialogPrivate::~HbDeviceProgressDialogPrivate() |
|
46 { |
|
47 TRACE_ENTRY |
|
48 cancel(); |
|
49 killTimer(mUpdateTimerId); |
|
50 for(int i = 0; i < NumActions; i++) { |
|
51 delete mDefaultActions[i]; |
|
52 } |
|
53 TRACE_EXIT |
|
54 } |
|
55 |
|
56 void HbDeviceProgressDialogPrivate::initProperties(HbProgressDialog::ProgressDialogType type) |
|
57 { |
|
58 for(int i = 0; i < NumProperties; i++) { |
|
59 mProperties[i].mFlags = NoFlags; |
|
60 } |
|
61 clearActions(); |
|
62 if (!mDefaultActions[CancelButton]) { |
|
63 mDefaultActions[CancelButton] = new QAction(0); |
|
64 } |
|
65 mActions[CancelButton].mAction = mDefaultActions[CancelButton]; |
|
66 |
|
67 QString text; |
|
68 mProperties[ProgressType].mValue.setValue(static_cast<int>(type)); |
|
69 mProperties[ProgressType].mFlags = Modified; |
|
70 if (type == HbProgressDialog::WaitDialog){ |
|
71 q->setRange(0,0); |
|
72 q->setAutoClose(false); |
|
73 } else { |
|
74 q->setRange(0,100); |
|
75 q->setAutoClose(true); |
|
76 } |
|
77 q->setProgressValue(0); |
|
78 q->setText(text); |
|
79 q->setTextAlignment(Qt::AlignLeft|Qt::AlignVCenter); |
|
80 q->setIconName(text); |
|
81 q->setIconAlignment(Qt::AlignCenter); |
|
82 q->setAnimationDefinition(text); |
|
83 } |
|
84 |
|
85 // Send properties to server |
|
86 void HbDeviceProgressDialogPrivate::sendToServer(bool show) |
|
87 { |
|
88 killTimer(mUpdateTimerId); |
|
89 mUpdateTimerId = 0; |
|
90 |
|
91 // If this is update but show has not been called, return. |
|
92 if (!show && !mVisible) { |
|
93 return; |
|
94 } |
|
95 |
|
96 // If this is update but no properties have been mofified, return |
|
97 if (!show && !propertiesModified()) { |
|
98 return; |
|
99 } |
|
100 |
|
101 static const char * const propertyNames[] = { |
|
102 "progressDialogType", |
|
103 "maximum", |
|
104 "minimum", |
|
105 "value", |
|
106 "autoClose", |
|
107 "text", |
|
108 "textAlignment", |
|
109 "iconName", |
|
110 "iconAlignment", |
|
111 "animationDefinition" |
|
112 }; |
|
113 |
|
114 QVariantMap parameters; |
|
115 for(int i = 0; i < NumProperties; i++) { |
|
116 if (mProperties[i].mFlags & Modified) { |
|
117 if (show || !(mProperties[i].mFlags & SentToServer)) { |
|
118 parameters.insert(propertyNames[i], mProperties[i].mValue); |
|
119 mProperties[i].mFlags |= SentToServer; |
|
120 } |
|
121 } |
|
122 } |
|
123 |
|
124 static const char * const actionNames[] = { |
|
125 "primaryActionText" |
|
126 }; |
|
127 static const char * const nullActionNames[] = { |
|
128 "primaryActionNull" |
|
129 }; |
|
130 |
|
131 for(int i = 0; i < NumActions; i++) { |
|
132 if (mActions[i].mFlags & Modified) { |
|
133 if (show || !(mActions[i].mFlags & SentToServer)) { |
|
134 if (mActions[i].mAction) { |
|
135 parameters.insert(actionNames[i], mActions[i].mAction->text()); |
|
136 } else { |
|
137 parameters.insert(nullActionNames[i], true); |
|
138 } |
|
139 mActions[i].mFlags |= SentToServer; |
|
140 } |
|
141 } |
|
142 } |
|
143 |
|
144 if (show) { |
|
145 for(int i = 0; i < NumActions; i++) { |
|
146 mActions[i].mTriggered = false; |
|
147 } |
|
148 if (mDeviceDialog.show("com.nokia.hb.deviceprogressdialog/1.0", parameters)) { |
|
149 mVisible = true; |
|
150 } else { |
|
151 // Failed to show the device dialog. Start a one shot to emit aboutToClose() signal. |
|
152 QTimer::singleShot(0, this, SLOT(aboutToClose())); |
|
153 } |
|
154 } else { |
|
155 mDeviceDialog.update(parameters); |
|
156 } |
|
157 } |
|
158 |
|
159 // Check if any properties have been modified |
|
160 bool HbDeviceProgressDialogPrivate::propertiesModified() const |
|
161 { |
|
162 for(int i = 0; i < NumProperties; i++) { |
|
163 if ((mProperties[i].mFlags & Modified) && !(mProperties[i].mFlags & SentToServer)) { |
|
164 return true; |
|
165 } |
|
166 } |
|
167 for(int i = 0; i < NumActions; i++) { |
|
168 if ((mActions[i].mFlags & Modified) && !(mActions[i].mFlags & SentToServer)) { |
|
169 return true; |
|
170 } |
|
171 } |
|
172 return false; |
|
173 } |
|
174 |
|
175 // Clear actions |
|
176 void HbDeviceProgressDialogPrivate::clearActions() |
|
177 { |
|
178 for(int i = 0; i < NumActions; i++) { |
|
179 mActions[i].mAction = 0; |
|
180 mActions[i].mFlags = NoFlags; |
|
181 mActions[i].mTriggered = false; |
|
182 } |
|
183 } |
|
184 |
|
185 // Set int property |
|
186 void HbDeviceProgressDialogPrivate::setProperty(PropertySelector propertySelector, int value) |
|
187 { |
|
188 Property &property = mProperties[propertySelector]; |
|
189 property.mValue.setValue(value); |
|
190 property.mFlags = Modified; |
|
191 scheduleUpdateEvent(); |
|
192 } |
|
193 |
|
194 // Set string property |
|
195 void HbDeviceProgressDialogPrivate::setProperty(PropertySelector propertySelector, |
|
196 const QString &value) |
|
197 { |
|
198 Property &property = mProperties[propertySelector]; |
|
199 property.mValue.setValue(value); |
|
200 property.mFlags = Modified; |
|
201 scheduleUpdateEvent(); |
|
202 } |
|
203 |
|
204 void HbDeviceProgressDialogPrivate::init(HbProgressDialog::ProgressDialogType type) |
|
205 { |
|
206 TRACE_ENTRY |
|
207 |
|
208 initProperties(type); |
|
209 connect(&mDeviceDialog, SIGNAL(deviceDialogClosed()), this, SLOT(aboutToClose())); |
|
210 connect(&mDeviceDialog, SIGNAL(dataReceived(QVariantMap)), this, SLOT(dataReceived(QVariantMap))); |
|
211 |
|
212 TRACE_EXIT |
|
213 } |
|
214 |
|
215 void HbDeviceProgressDialogPrivate::cancel() |
|
216 { |
|
217 TRACE_ENTRY |
|
218 mDeviceDialog.cancel(); |
|
219 TRACE_EXIT |
|
220 return; |
|
221 } |
|
222 |
|
223 // Schedule event to update changed properties to device dialog server. update() is not |
|
224 // called after each time a property is set. Instead an event is scheduled in order to |
|
225 // update all changed properties in one shot. |
|
226 void HbDeviceProgressDialogPrivate::scheduleUpdateEvent() |
|
227 { |
|
228 if (mVisible && mUpdateTimerId == 0) { |
|
229 mUpdateTimerId = startTimer(0); |
|
230 } |
|
231 } |
|
232 |
|
233 void HbDeviceProgressDialogPrivate::timerEvent(QTimerEvent *event) |
|
234 { |
|
235 if (event->timerId() == mUpdateTimerId) { |
|
236 sendToServer(false); |
|
237 } |
|
238 } |
|
239 |
|
240 HbDeviceProgressDialogPrivate::ActionSelector HbDeviceProgressDialogPrivate::actionSelector( |
|
241 HbDeviceProgressDialog::ActionRole role) |
|
242 { |
|
243 static const ActionSelector selectors[] = { |
|
244 CancelButton |
|
245 }; |
|
246 const unsigned numSelectors = sizeof(selectors) / sizeof(selectors[0]); |
|
247 unsigned index = role; |
|
248 if (index >= numSelectors) { |
|
249 Q_ASSERT(false); |
|
250 return InvalidSelector; |
|
251 } |
|
252 else { |
|
253 return selectors[index]; |
|
254 } |
|
255 } |
|
256 |
|
257 void HbDeviceProgressDialogPrivate::aboutToClose() |
|
258 { |
|
259 TRACE_ENTRY |
|
260 |
|
261 mVisible = false; |
|
262 emit q->aboutToClose(); |
|
263 |
|
264 TRACE_EXIT |
|
265 return; |
|
266 } |
|
267 |
|
268 void HbDeviceProgressDialogPrivate::dataReceived(QVariantMap data) |
|
269 { |
|
270 const char *key = "act"; |
|
271 QVariantMap::const_iterator i = data.find(key); |
|
272 if (i != data.constEnd()) { |
|
273 if (i.value().toString() == "p") { |
|
274 // Client has pressed button. Signal action if one is set. Otherwise emit |
|
275 // cancelled() signal. |
|
276 mActions[CancelButton].mTriggered = true; |
|
277 QAction *action = mActions[CancelButton].mAction; |
|
278 if (action) { |
|
279 action->trigger(); |
|
280 emit q->cancelled(); |
|
281 } |
|
282 } |
|
283 } |
|
284 } |
|
285 |
|
286 /*! |
|
287 \class HbDeviceProgressDialog |
|
288 \brief HbDeviceProgressDialog is a device dialog version of HbProgressDialog. |
|
289 |
|
290 It displays a dialog with a wait animation or progress bar, text, icon or animation and a |
|
291 cancel button. |
|
292 |
|
293 Device dialogs are shown on top of any running applications and are always modal by nature. |
|
294 |
|
295 Two different dialogs are supported: wait and progress. The wait dialog displays an animated |
|
296 bar and progress dialog a progress bar indicating progress of the operation. |
|
297 |
|
298 Wait dialog is used when length of an operation cannot be determined beforehand. It displays |
|
299 an animated bar to indicate an action. The dialog is closed by the user pressing the cancel |
|
300 button, the application closing the dialog after the operation is finished. |
|
301 |
|
302 Progress dialog is used when the length of operation can be determined. For example |
|
303 when deleting a number of files, the progress of the operation could be shown as a |
|
304 percentage of the files deleted. Application updates the progress bar during the |
|
305 operation. The dialog closes by user pressing the cancel button, the application closing the |
|
306 dialog after the operation is finished or automatically when progress value reaches a |
|
307 maximum. |
|
308 |
|
309 HbDeviceProgressDialog provides a similar kind of interface as HbProgressDialog, excluding |
|
310 functions which handle concrete UI-component related information. Progress dialogs are |
|
311 always asynchronous by as the client needs to perform the operation and update the dialog |
|
312 while the dialog is showing. |
|
313 |
|
314 Device progress dialog is launched when show() is called. Launched dialog can be updated by setters. |
|
315 Because updating a dialog requires interprocess communication, it's advisable to fully construct the |
|
316 progress dialog before calling show(). |
|
317 |
|
318 Supported icon animation formats are following: |
|
319 - GIF (.gif) |
|
320 - MNG (.mng) |
|
321 - Frame animations |
|
322 |
|
323 Sample code: |
|
324 |
|
325 An example showing the wait dialog: |
|
326 |
|
327 \code |
|
328 mDialog = new HbDeviceProgressDialog(HbProgressDialog::WaitDialog); |
|
329 mDialog->setText("Connecting..."); |
|
330 mDialog->show(); |
|
331 \endcode |
|
332 |
|
333 An example showing the progress dialog: |
|
334 |
|
335 \include deviceprogressdialog/main.cpp |
|
336 |
|
337 Creating a frame animation. |
|
338 |
|
339 Create an animation definition file: |
|
340 \code |
|
341 <animations> |
|
342 <icon name="frame_anim_looping" playmode="loop"> |
|
343 <frame duration="100">c:\icon1.svg</frame> |
|
344 <frame duration="200">c:\icon2.svg</frame> |
|
345 <frame duration="300">c:\icon3.svg</frame> |
|
346 </icon> |
|
347 </animations> |
|
348 \endcode |
|
349 |
|
350 Create HbDeviceMessageBox in a way described before and |
|
351 set definition file and animation's logical name. |
|
352 |
|
353 \code |
|
354 QString animationDefinitionXML("c:\animation.axml"); |
|
355 QString logicalIconName("frame_anim_looping"); |
|
356 |
|
357 msg->setAnimationDefinition(animationDefinitionXML); |
|
358 msg->setIconName(logicalIconName); |
|
359 msg->show(); |
|
360 \endcode |
|
361 |
|
362 \sa HbProgressDialog, HbDialog, HbDeviceDialog |
|
363 \alpha |
|
364 \hbwidgets |
|
365 */ |
|
366 |
|
367 /*! |
|
368 \fn void HbDeviceProgressDialog::aboutToClose(); |
|
369 |
|
370 This signal is emitted when a device progress dialog has closed. The closing may |
|
371 be a result of close() being called, a dialog with autoClose property has reached |
|
372 its maximum value or user pressing cancel button. It is not emitted if close() is |
|
373 called before show(). |
|
374 */ |
|
375 |
|
376 /*! |
|
377 \fn void HbDeviceProgressDialog::cancelled(); |
|
378 |
|
379 This signal is emitted when the device progress dialog is closed by user pressing the |
|
380 "cancel" button. It is not emitted if dialog is closed for any other reason. |
|
381 */ |
|
382 |
|
383 /*! |
|
384 \enum HbDeviceProgressDialog::ActionRole |
|
385 Defines roles for actions set into a progress dialog. |
|
386 */ |
|
387 /*! |
|
388 \var HbDeviceProgressDialog::ActionRole HbDeviceProgressDialog::InvalidRole |
|
389 No action. |
|
390 */ |
|
391 /*! |
|
392 \var HbDeviceProgressDialog::ActionRole HbDeviceProgressDialog::CancelButtonRole |
|
393 Cancel button action. |
|
394 */ |
|
395 |
|
396 /*! |
|
397 Constructor. |
|
398 \param type Must be one of the defined HbProgressDialog::ProgressDialogType enumerations. |
|
399 \param parent An optional parameter. |
|
400 */ |
|
401 HbDeviceProgressDialog::HbDeviceProgressDialog(HbProgressDialog::ProgressDialogType type, QObject *parent) : |
|
402 QObject(parent), d(new HbDeviceProgressDialogPrivate) |
|
403 { |
|
404 TRACE_ENTRY |
|
405 d->q = this; |
|
406 d->init(type); |
|
407 TRACE_EXIT |
|
408 } |
|
409 |
|
410 /*! |
|
411 Constructor. |
|
412 \param parent An optional parameter. |
|
413 */ |
|
414 HbDeviceProgressDialog::HbDeviceProgressDialog(QObject *parent) : |
|
415 QObject(parent), d(new HbDeviceProgressDialogPrivate) |
|
416 { |
|
417 TRACE_ENTRY |
|
418 d->q = this; |
|
419 d->init(HbProgressDialog::ProgressDialog); |
|
420 TRACE_EXIT |
|
421 } |
|
422 |
|
423 /*! |
|
424 Destructs the class. |
|
425 */ |
|
426 HbDeviceProgressDialog::~HbDeviceProgressDialog() |
|
427 { |
|
428 TRACE_ENTRY |
|
429 delete d; |
|
430 TRACE_EXIT |
|
431 } |
|
432 |
|
433 /*! |
|
434 Executes the dialog asynchronously. |
|
435 */ |
|
436 void HbDeviceProgressDialog::show() |
|
437 { |
|
438 TRACE_ENTRY |
|
439 d->sendToServer(true); |
|
440 TRACE_EXIT |
|
441 } |
|
442 |
|
443 /*! |
|
444 Updates changed properties of a launched progress dialog to device dialog service using |
|
445 interprocess communication. Has no effect if show() has not been called or dialog has |
|
446 closed already. Calling show() is optional as updating any property schedules an event |
|
447 and the dialog is updated next time Qt event loop executes. |
|
448 |
|
449 \sa show() |
|
450 */ |
|
451 void HbDeviceProgressDialog::update() |
|
452 { |
|
453 TRACE_ENTRY |
|
454 d->sendToServer(false); |
|
455 TRACE_EXIT |
|
456 } |
|
457 |
|
458 /*! |
|
459 Closes the dialog. |
|
460 |
|
461 \deprecated HbDeviceProgressDialog::cancel() |
|
462 is deprecated. Replaced by HbDeviceProgressDialog::close(). |
|
463 |
|
464 */ |
|
465 void HbDeviceProgressDialog::cancel() |
|
466 { |
|
467 TRACE_ENTRY |
|
468 return d->cancel(); |
|
469 TRACE_EXIT |
|
470 } |
|
471 |
|
472 /*! |
|
473 Closes the dialog. |
|
474 */ |
|
475 void HbDeviceProgressDialog::close() |
|
476 { |
|
477 TRACE_ENTRY |
|
478 return d->cancel(); |
|
479 TRACE_EXIT |
|
480 } |
|
481 |
|
482 /*! |
|
483 Returns an action user triggered causing the dialog to close. Returns 0 if none of the actions were |
|
484 triggered and dialog was closed for other reason. |
|
485 |
|
486 \sa show(), action() |
|
487 */ |
|
488 const QAction *HbDeviceProgressDialog::triggeredAction() const |
|
489 { |
|
490 for(int i = 0; i < HbDeviceProgressDialogPrivate::NumActions; i++) { |
|
491 if (d->mActions[i].mTriggered) { |
|
492 return d->mActions[i].mAction; |
|
493 } |
|
494 } |
|
495 return 0; |
|
496 } |
|
497 |
|
498 /*! |
|
499 Sets the maximum value of the progress bar within the dialog. |
|
500 |
|
501 \sa maximum() |
|
502 */ |
|
503 void HbDeviceProgressDialog::setMaximum(int max) |
|
504 { |
|
505 TRACE_ENTRY |
|
506 // Don't allow wait dialog to set max/min other than zero as wait |
|
507 // animation bar doesn't work in that case. |
|
508 if (progressType() == HbProgressDialog::WaitDialog) { |
|
509 max = 0; |
|
510 } |
|
511 d->setProperty(HbDeviceProgressDialogPrivate::Maximum, max); |
|
512 TRACE_EXIT |
|
513 } |
|
514 |
|
515 /*! |
|
516 Returns the maximum value of the progress bar within the dialog. Default value is 100. |
|
517 |
|
518 \sa setMaximum() |
|
519 */ |
|
520 int HbDeviceProgressDialog::maximum() const |
|
521 { |
|
522 return d->mProperties[HbDeviceProgressDialogPrivate::Maximum].mValue.toInt(); |
|
523 } |
|
524 |
|
525 /*! |
|
526 Sets the minimum value of the progress bar within the dialog. |
|
527 |
|
528 \sa minimum() |
|
529 */ |
|
530 void HbDeviceProgressDialog::setMinimum(int min) |
|
531 { |
|
532 TRACE_ENTRY |
|
533 // Don't allow wait dialog to set max/min other than zero as wait |
|
534 // animation bar doesn't work in that case. |
|
535 if (progressType() == HbProgressDialog::WaitDialog) { |
|
536 min = 0; |
|
537 } |
|
538 d->setProperty(HbDeviceProgressDialogPrivate::Minimum, min); |
|
539 TRACE_EXIT |
|
540 } |
|
541 |
|
542 /*! |
|
543 Returns the minimum value of the progress bar within the dialog. Default value is 0. |
|
544 |
|
545 \sa setMinimum() |
|
546 */ |
|
547 int HbDeviceProgressDialog::minimum() const |
|
548 { |
|
549 return d->mProperties[HbDeviceProgressDialogPrivate::Minimum].mValue.toInt(); |
|
550 } |
|
551 |
|
552 /*! |
|
553 Sets the minimum and maximum value of the progress bar within the dialog. |
|
554 |
|
555 \sa minimum(), maximum() |
|
556 */ |
|
557 void HbDeviceProgressDialog::setRange(int min, int max) |
|
558 { |
|
559 setMinimum(min); |
|
560 setMaximum(max); |
|
561 } |
|
562 |
|
563 /*! |
|
564 Sets the value of the progress bar within the dialog. |
|
565 |
|
566 \sa progressValue() |
|
567 */ |
|
568 void HbDeviceProgressDialog::setProgressValue(int progressValue) |
|
569 { |
|
570 TRACE_ENTRY |
|
571 d->setProperty(HbDeviceProgressDialogPrivate::Value, progressValue); |
|
572 TRACE_EXIT |
|
573 } |
|
574 |
|
575 /*! |
|
576 Returns the value of the progress bar within the dialog. |
|
577 |
|
578 \sa setProgressValue() |
|
579 */ |
|
580 int HbDeviceProgressDialog::progressValue() const |
|
581 { |
|
582 return d->mProperties[HbDeviceProgressDialogPrivate::Value].mValue.toInt(); |
|
583 } |
|
584 |
|
585 /*! |
|
586 Sets the autoClose property value of the dialog. |
|
587 |
|
588 \param autoClose When set, the dialog is closed when value of the progress bar reaches |
|
589 the maximum value of the progress bar. |
|
590 |
|
591 \sa autoClose() |
|
592 */ |
|
593 void HbDeviceProgressDialog::setAutoClose(bool autoClose) |
|
594 { |
|
595 TRACE_ENTRY |
|
596 d->setProperty(HbDeviceProgressDialogPrivate::AutoClose, autoClose); |
|
597 TRACE_EXIT |
|
598 } |
|
599 |
|
600 /*! |
|
601 Returns the value of the autoClose property of the dialog. |
|
602 |
|
603 The default value is true for HbProgressDialog::ProgressDialog and false |
|
604 for HbProgressDialog::WaitDialog. |
|
605 |
|
606 \sa setAutoClose() |
|
607 */ |
|
608 bool HbDeviceProgressDialog::autoClose() const |
|
609 { |
|
610 return d->mProperties[HbDeviceProgressDialogPrivate::AutoClose].mValue.toInt(); |
|
611 } |
|
612 |
|
613 /*! |
|
614 Sets dialog's progress type. After setProgressType(), a new dialog is launched by a show(). |
|
615 |
|
616 \sa progressType() |
|
617 */ |
|
618 void HbDeviceProgressDialog::setProgressType(HbProgressDialog::ProgressDialogType type) |
|
619 { |
|
620 TRACE_ENTRY |
|
621 // After setProgressType(), a new dialog is launched by a show() |
|
622 d->mVisible = false; |
|
623 // All properties initialized to default |
|
624 d->initProperties(type); |
|
625 TRACE_EXIT |
|
626 } |
|
627 |
|
628 /*! |
|
629 Returns dialog's progress type. |
|
630 |
|
631 \sa setProgressType() |
|
632 */ |
|
633 HbProgressDialog::ProgressDialogType HbDeviceProgressDialog::progressType() const |
|
634 { |
|
635 return static_cast<HbProgressDialog::ProgressDialogType> |
|
636 (d->mProperties[HbDeviceProgressDialogPrivate::ProgressType].mValue.toInt()); |
|
637 } |
|
638 |
|
639 /*! |
|
640 Sets text of the dialog. |
|
641 |
|
642 \sa text() |
|
643 */ |
|
644 void HbDeviceProgressDialog::setText(const QString &text) |
|
645 { |
|
646 TRACE_ENTRY |
|
647 d->setProperty(HbDeviceProgressDialogPrivate::Text, text); |
|
648 TRACE_EXIT |
|
649 } |
|
650 |
|
651 /*! |
|
652 Returns text of the dialog. |
|
653 \sa setText() |
|
654 */ |
|
655 QString HbDeviceProgressDialog::text() const |
|
656 { |
|
657 return d->mProperties[HbDeviceProgressDialogPrivate::Text].mValue.toString(); |
|
658 } |
|
659 |
|
660 /*! |
|
661 Sets the text alignment. |
|
662 |
|
663 \param align Qt defined alignment options can used. |
|
664 |
|
665 \sa textAlignment() |
|
666 */ |
|
667 void HbDeviceProgressDialog::setTextAlignment(Qt::Alignment align) |
|
668 { |
|
669 TRACE_ENTRY |
|
670 d->setProperty(HbDeviceProgressDialogPrivate::TextAlignment, align); |
|
671 TRACE_EXIT |
|
672 } |
|
673 |
|
674 /*! |
|
675 Returns the text alignment. |
|
676 |
|
677 The default value is Qt::AlignLeft|Qt::AlignVCenter |
|
678 |
|
679 \sa setTextAlignment() |
|
680 */ |
|
681 Qt::Alignment HbDeviceProgressDialog::textAlignment() const |
|
682 { |
|
683 return static_cast<Qt::Alignment> |
|
684 (d->mProperties[HbDeviceProgressDialogPrivate::TextAlignment].mValue.toInt()); |
|
685 } |
|
686 |
|
687 /*! |
|
688 Sets the text wrapping. |
|
689 |
|
690 \param wrap When set, the text is drawn with Qt::TextWordWrap enabled meaning that |
|
691 lines breaks are at appropriate point, e.g. at word boundaries. |
|
692 |
|
693 \sa textWrapping() |
|
694 |
|
695 \deprecated HbDeviceProgressDialog::setTextWrapping() |
|
696 is deprecated. Will be removed. |
|
697 */ |
|
698 void HbDeviceProgressDialog::setTextWrapping(bool wrap) |
|
699 { |
|
700 TRACE_ENTRY |
|
701 Q_UNUSED(wrap) |
|
702 TRACE_EXIT |
|
703 } |
|
704 |
|
705 /*! |
|
706 Returns the text wrapping setting. Default value is true. |
|
707 |
|
708 \sa setTextWrapping() |
|
709 |
|
710 \deprecated HbDeviceProgressDialog::textWrapping() |
|
711 is deprecated. Will be removed. |
|
712 */ |
|
713 bool HbDeviceProgressDialog::textWrapping() const |
|
714 { |
|
715 return true; |
|
716 } |
|
717 |
|
718 /*! |
|
719 Sets message box icon name or animation logical name. |
|
720 |
|
721 \param aIconName Icon name. Icon can be from Hb resources or themes. Or can be a file in |
|
722 a file system. |
|
723 |
|
724 \sa IconName() |
|
725 */ |
|
726 void HbDeviceProgressDialog::setIconName(const QString &iconName) |
|
727 { |
|
728 TRACE_ENTRY |
|
729 d->setProperty(HbDeviceProgressDialogPrivate::IconName, iconName); |
|
730 TRACE_EXIT |
|
731 } |
|
732 |
|
733 /*! |
|
734 Returns name and path of the icon or animation's logical name. |
|
735 |
|
736 \sa setIconName() |
|
737 */ |
|
738 QString HbDeviceProgressDialog::iconName() const |
|
739 { |
|
740 return d->mProperties[HbDeviceProgressDialogPrivate::IconName].mValue.toString(); |
|
741 } |
|
742 |
|
743 /*! |
|
744 Sets the icon alignment. |
|
745 |
|
746 \param align Qt defined alignment options can used. |
|
747 |
|
748 \sa iconAlignment() |
|
749 */ |
|
750 void HbDeviceProgressDialog::setIconAlignment(Qt::Alignment align) |
|
751 { |
|
752 TRACE_ENTRY |
|
753 d->setProperty(HbDeviceProgressDialogPrivate::IconAlignment, align); |
|
754 TRACE_EXIT |
|
755 } |
|
756 |
|
757 /*! |
|
758 Returns the icon alignment. Default value is Qt::AlignCenter. |
|
759 |
|
760 \sa setIconAlignment() |
|
761 */ |
|
762 Qt::Alignment HbDeviceProgressDialog::iconAlignment() const |
|
763 { |
|
764 return static_cast<Qt::Alignment> |
|
765 (d->mProperties[HbDeviceProgressDialogPrivate::IconAlignment].mValue.toInt()); |
|
766 } |
|
767 |
|
768 /*! |
|
769 Sets animation definition to a dialog. Animation's logical name has to be set |
|
770 using setIcon(). Animation definition files must be stored to a place where they |
|
771 can be accessed by device dialog service. |
|
772 |
|
773 Supported animation formats are following: |
|
774 - GIF (.gif) |
|
775 - MNG (.mng) |
|
776 - Frame animations |
|
777 |
|
778 \param animationDefinition Path and name of the animation definition file. |
|
779 |
|
780 \sa setIcon(), animationDefinition(), HbIconAnimationManager::addDefinitionFile() |
|
781 |
|
782 */ |
|
783 void HbDeviceProgressDialog::setAnimationDefinition(QString &animationDefinition) |
|
784 { |
|
785 TRACE_ENTRY |
|
786 d->setProperty(HbDeviceProgressDialogPrivate::AnimationDefinition, animationDefinition); |
|
787 TRACE_EXIT |
|
788 } |
|
789 |
|
790 /*! |
|
791 Returns animation definition file name. |
|
792 |
|
793 \sa setAnimationDefinition() |
|
794 */ |
|
795 QString HbDeviceProgressDialog::animationDefinition() const |
|
796 { |
|
797 return d->mProperties[HbDeviceProgressDialogPrivate::AnimationDefinition].mValue.toString(); |
|
798 } |
|
799 |
|
800 /*! |
|
801 Sets a new action into progress dialog. When users presses a button on dialog, triggered() |
|
802 signal of the action is emitted. HbDeviceProgressDialog constructor sets a default action |
|
803 into a dialog. |
|
804 |
|
805 \param action Action or Null. Ownership is not transferred. |
|
806 \param role Selects an action to set. |
|
807 |
|
808 \sa action() |
|
809 */ |
|
810 void HbDeviceProgressDialog::setAction(QAction *action, ActionRole role) |
|
811 { |
|
812 TRACE_ENTRY |
|
813 HbDeviceProgressDialogPrivate::ActionSelector actionSelector = |
|
814 HbDeviceProgressDialogPrivate::actionSelector(role); |
|
815 if (actionSelector != HbDeviceProgressDialogPrivate::InvalidSelector) { |
|
816 HbDeviceProgressDialogPrivate::Action &dialogAction = d->mActions[actionSelector]; |
|
817 dialogAction.mAction = action; |
|
818 dialogAction.mFlags = HbDeviceProgressDialogPrivate::Modified; |
|
819 d->scheduleUpdateEvent(); |
|
820 } |
|
821 TRACE_EXIT |
|
822 } |
|
823 |
|
824 /*! |
|
825 Returns progress dialog action. The action may be a default action owned by the dialog |
|
826 or the one set by setAction(). |
|
827 |
|
828 \param role Selects an action to get. |
|
829 |
|
830 \sa setAction() |
|
831 */ |
|
832 QAction *HbDeviceProgressDialog::action(ActionRole role) const |
|
833 { |
|
834 HbDeviceProgressDialogPrivate::ActionSelector actionSelector = |
|
835 HbDeviceProgressDialogPrivate::actionSelector(role); |
|
836 return actionSelector != HbDeviceProgressDialogPrivate::InvalidSelector ? |
|
837 d->mActions[actionSelector].mAction : 0; |
|
838 } |