20 ** |
20 ** |
21 ** If you have questions regarding the use of this file, please contact |
21 ** If you have questions regarding the use of this file, please contact |
22 ** Nokia at developer.feedback@nokia.com. |
22 ** Nokia at developer.feedback@nokia.com. |
23 ** |
23 ** |
24 ****************************************************************************/ |
24 ****************************************************************************/ |
25 |
25 #include "hbprogressbar_p.h" |
26 #include <hbprogressbar.h> |
26 #include <hbprogressbar.h> |
27 #include <hbstyleoptionprogressbar_p.h> |
27 #include <hbstyleoptionprogressbar_p.h> |
28 #include "hbprogressbar_p.h" |
|
29 #include "hbglobal_p.h" |
28 #include "hbglobal_p.h" |
30 |
29 |
31 #ifdef HB_EFFECTS |
30 #ifdef HB_EFFECTS |
32 #include <hbeffect.h> |
31 #include <hbeffect.h> |
33 #include "hbeffectinternal_p.h" |
32 #include "hbeffectinternal_p.h" |
38 @beta |
37 @beta |
39 @hbwidgets |
38 @hbwidgets |
40 \class HbProgressBar |
39 \class HbProgressBar |
41 |
40 |
42 \brief HbProgressBar widget provides a vertical and horizontal progress bar. |
41 \brief HbProgressBar widget provides a vertical and horizontal progress bar. |
43 An infinite progressbar is also available. |
|
44 |
|
45 A progress bar is used to give the user an indication of the progress of an operation and to |
|
46 reassure them that the application is still running. |
|
47 |
|
48 The progress bar uses the concept of steps. User can set it up by specifying the minimum and |
|
49 maximum possible step values, and it will display the percentage of steps that have been completed |
|
50 when you later give it the current step value. |
|
51 |
42 |
52 The percentage is calculated by dividing the progress (progressValue() - minimum()) divided by maximum() - minimum(). |
43 \image html progressbar.png "A Progress Bar with Min-Max text at bottom" |
53 |
44 \image html infiniteprogressbar.png "An infinite progres bar" |
54 User can specify the minimum and maximum number of steps with setMinimum() and setMaximum() APIs. |
45 |
55 The current number of steps is set with setProgressValue(). |
46 The HbProgressBar widget provides a horizontal or vertical progress bar. |
56 |
47 |
57 If minimum and maximum both are set to 0, the bar shows a busy indicator instead of a percentage of steps. |
48 A progress bar is used to give the user an indication of the progress of an operation and to reassure them that |
58 This is useful, for example, when using ftp or http to download items when they are unable to |
49 the application is still running. The progress bar uses the concept of steps. You set it up by specifying the |
59 determine the size of the item being downloaded. |
50 minimum and maximum possible step values, and it will display the percentage of steps that have been completed |
60 |
51 when you later give it the current step value. The percentage is calculated by dividing the |
61 ProgressBar also supports adding text . min max text pair is also supported which is commonly |
52 progress (value() - minimum()) divided by maximum() - minimum(). |
62 used for progress indication for music. |
|
63 |
53 |
64 \image html hbprogressbartext.png Left Aligned Text, Min Max Text. |
54 By default the min value is 0 and max value is 100.If minimum and maximum both are set to 0, the bar shows a busy indicator |
65 |
55 instead of a percentage of steps.The ProgressBar is always non interactive. |
|
56 |
|
57 ProgressBar also supports adding text . Min-Max text pair is also supported which is commonly |
|
58 used for progress indication for music. |
|
59 |
66 Progress bar provides below signal. |
60 Progress bar provides below signal. |
67 |
61 |
68 \li valueChanged(int value) Emitted when the value of the progressbar is changed. |
62 \li valueChanged(int value) Emitted when the value of the progressbar is changed. |
69 */ |
63 |
70 |
64 |
71 /*! |
65 Example code for creating normal ProgressBar: |
72 @beta |
66 \code |
73 \fn void HbProgressBar::valueChanged(int value) |
67 HbProgressBar *pb = new HbProgressBar(); |
74 |
68 pb->setMinimum(0); |
75 Emitted when the value of the progressbar is changed. |
69 pb->setMaximum(500); |
76 */ |
70 pb->setProgressValue(175); |
77 |
71 \endcode |
78 |
72 |
79 /*! |
73 Example code for creating infinite ProgressBar: |
80 @beta |
74 \code |
81 \reimp |
75 HbProgressBar *pb = new HbProgressBar(); |
82 \fn int HbProgressBar::type() const |
76 pb->setMinimum(0); |
83 */ |
77 pb->setMaximum(0); |
84 |
78 \endcode |
85 /*! |
79 |
86 @beta |
80 Example code for creating normal ProgressBar with Min-Max text at Top: |
87 \enum HbProgressBar::ProgressBarType |
81 \code |
88 |
82 HbProgressBar *pb = new HbProgressBar(); |
89 This enum defines available progress bar types. |
83 pb->setMinimum(0); |
|
84 pb->setMaximum(500); |
|
85 pb->setProgressValue(175); |
|
86 pb->setMinMaxTextVisible(true); |
|
87 pb->setMinMaxTextAlignment(Qt::AlignTop);// The possible options are Qt::AlignTop ,Qt::AlignBottom ,Qt::AlignCenter |
|
88 pb->setminText("0"); |
|
89 pb->setmaxText("500"); |
|
90 |
|
91 \endcode |
|
92 |
|
93 Example code for creating vertical normal ProgressBar: |
|
94 \code |
|
95 HbProgressBar *pb = new HbProgressBar(); |
|
96 pb->setOrientation(Qt::Vertical); |
|
97 pb->setMinimum(0); |
|
98 pb->setMaximum(500); |
|
99 pb->setProgressValue(175); |
|
100 \endcode |
90 */ |
101 */ |
91 |
102 |
92 |
103 |
93 /* |
104 /* |
94 HbProgressBarPrivate |
105 HbProgressBarPrivate |
221 |
232 |
222 if(mProgressValue > mMaximum){ |
233 if(mProgressValue > mMaximum){ |
223 mProgressValue = mMaximum; |
234 mProgressValue = mMaximum; |
224 } |
235 } |
225 |
236 |
|
237 // update primitve optimization, update only track primitive |
|
238 // incase of normal as well as in infinite progressbar |
|
239 HbStyleOptionProgressBar progressBarOption; |
|
240 q->initStyleOption(&progressBarOption); |
|
241 |
226 if( (mMinimum == 0) && (mMaximum == 0) ) { |
242 if( (mMinimum == 0) && (mMaximum == 0) ) { |
227 mWaitTrack->setVisible(true); |
243 mWaitTrack->setVisible(true); |
228 mTrack->setVisible(false); |
244 mTrack->setVisible(false); |
|
245 |
|
246 q->style()->updatePrimitive(mWaitTrack, HbStyle::P_ProgressBar_waittrack, &progressBarOption); |
229 } else { |
247 } else { |
230 mWaitTrack->setVisible(false); |
248 mWaitTrack->setVisible(false); |
231 mTrack->setVisible(true); |
249 mTrack->setVisible(true); |
232 } |
250 |
233 q->updatePrimitives(); |
251 q->style()->updatePrimitive(mTrack, HbStyle::P_ProgressBar_track, &progressBarOption); |
|
252 } |
|
253 //q->updatePrimitives(); |
234 } |
254 } |
235 |
255 |
236 /*! |
256 /*! |
237 \internal |
257 \internal |
238 Sets the progressbar orientation. |
258 Sets the progressbar orientation. |
302 { |
323 { |
303 } |
324 } |
304 |
325 |
305 /*! |
326 /*! |
306 @beta |
327 @beta |
307 Return the inverted appearence property. |
328 Return the inverted appearance property. |
308 |
|
309 \sa setInvertedAppearance() |
329 \sa setInvertedAppearance() |
310 */ |
330 */ |
311 bool HbProgressBar::invertedAppearance() const |
331 bool HbProgressBar::invertedAppearance() const |
312 { |
332 { |
313 Q_D( const HbProgressBar ); |
333 Q_D( const HbProgressBar ); |
314 return d->mInvertedAppearance; |
334 return d->mInvertedAppearance; |
315 } |
335 } |
316 |
336 |
317 /*! |
337 /*! |
318 @beta |
338 @beta |
319 Sets the inverted appearence. If this is true progress grows from right to |
339 Sets the inverted Appearance. If this is true progress grows from right to |
320 left otherwise left to right. |
340 left otherwise left to right. |
321 |
341 |
322 \param inverted true or false. |
342 \param inverted true or false. |
323 |
343 |
324 \sa invertedAppearance() |
344 \sa invertedAppearance() |
408 } |
428 } |
409 |
429 |
410 /*! |
430 /*! |
411 @beta |
431 @beta |
412 This function is provided for convenience. |
432 This function is provided for convenience. |
413 |
|
414 Sets the progress bar's minimum and its maximum. |
433 Sets the progress bar's minimum and its maximum. |
415 |
434 |
416 If maximum is smaller than minimum, minimum becomes the only valid legal |
435 If maximum is smaller than minimum, minimum becomes the only valid legal |
417 value. |
436 value. |
418 |
437 |
419 \param minimum the minimum value |
438 \param minimum the minimum value |
420 \param maximum the maximum value |
439 \param maximum the maximum value |
421 */ |
440 */ |
422 void HbProgressBar::setRange(int minimum, int maximum) |
441 void HbProgressBar::setRange(int minimum, int maximum) |
423 { |
442 { |
424 Q_D( HbProgressBar ); |
443 Q_D( HbProgressBar ); |
425 d->setRange(minimum , maximum); |
444 d->setRange(minimum , maximum); |
426 } |
445 } |
427 |
446 |
428 /*! |
447 /*! |
429 @beta |
448 @beta |
430 Sets the min text string. |
449 A text can be shown at top,bottom or left-right of the progressbar near minimum and maximum. |
|
450 This will set the text near the minimum point. |
431 |
451 |
432 \param text mintext string |
452 \param text mintext string |
433 |
453 |
434 \sa minText() |
454 \sa minText() |
435 */ |
455 */ |
500 |
521 |
501 if(d->mMinMaxTextVisible) { |
522 if(d->mMinMaxTextVisible) { |
502 if(!d->mMinTextItem && !d->mMaxTextItem){ |
523 if(!d->mMinTextItem && !d->mMaxTextItem){ |
503 d->createTextPrimitives(); |
524 d->createTextPrimitives(); |
504 } |
525 } |
|
526 |
|
527 // update primitve optimization, update only text primitives |
|
528 // incase of with and without min-max text |
|
529 HbStyleOptionProgressBar progressBarOption; |
|
530 initStyleOption(&progressBarOption); |
|
531 |
|
532 style()->updatePrimitive(d->mMinTextItem,HbStyle::P_ProgressBar_mintext,&progressBarOption); |
|
533 style()->updatePrimitive(d->mMaxTextItem,HbStyle::P_ProgressBar_maxtext,&progressBarOption); |
|
534 |
505 d->mMinTextItem->show(); |
535 d->mMinTextItem->show(); |
506 d->mMaxTextItem->show(); |
536 d->mMaxTextItem->show(); |
507 } else { |
537 } else { |
508 if(d->mMinTextItem && d->mMaxTextItem){ |
538 if(d->mMinTextItem && d->mMaxTextItem){ |
509 d->mMinTextItem->hide(); |
539 d->mMinTextItem->hide(); |
510 d->mMaxTextItem->hide(); |
540 d->mMaxTextItem->hide(); |
511 } |
541 } |
512 } |
542 } |
513 repolish(); |
543 repolish(); |
514 updatePrimitives(); |
544 //updatePrimitives(); |
515 } |
545 } |
516 } |
546 } |
517 |
547 |
518 /*! |
548 /*! |
519 @beta |
549 @beta |
671 option->maxText = d->mMaxText; |
700 option->maxText = d->mMaxText; |
672 option->orientation = d->mOrientation; |
701 option->orientation = d->mOrientation; |
673 option->inverted = d->mInvertedAppearance; |
702 option->inverted = d->mInvertedAppearance; |
674 option->stopWaitAnimation = false; |
703 option->stopWaitAnimation = false; |
675 option->minMaxTextAlignment = d->mMinMaxTextAlignment; |
704 option->minMaxTextAlignment = d->mMinMaxTextAlignment; |
676 QRect rect((int)d->mFrame->boundingRect().x(),(int)d->mFrame->boundingRect().y(),(int)d->mFrame->boundingRect().width(), |
705 |
677 (int)d->mFrame->boundingRect().height()); |
|
678 option->rect = rect; |
|
679 } |
706 } |
680 |
707 |
681 /*! |
708 /*! |
682 \reimp |
709 \reimp |
683 */ |
710 */ |