24 ****************************************************************************/ |
24 ****************************************************************************/ |
25 |
25 |
26 #include <hbprogressdialog.h> |
26 #include <hbprogressdialog.h> |
27 #include <hbprogressdialog_p.h> |
27 #include <hbprogressdialog_p.h> |
28 #include <hbstyleoptionprogressdialog_p.h> |
28 #include <hbstyleoptionprogressdialog_p.h> |
29 |
|
30 #include <hbnamespace_p.h> |
29 #include <hbnamespace_p.h> |
31 #include <hbaction.h> |
30 #include <hbaction.h> |
32 #include <hbpopup.h> |
31 #include <hbpopup.h> |
33 #include <hbtextitem.h> |
32 #include <hbtextitem.h> |
34 #include <QGraphicsItem> |
33 #include <QGraphicsItem> |
35 |
34 #include <hbstyleprimitivedata.h> |
|
35 #include <hbstyleiconprimitivedata.h> |
|
36 #include <hbstyletextprimitivedata.h> |
36 /* |
37 /* |
37 \internal |
38 \internal |
38 HbProgressDialogContentWidget class |
39 HbProgressDialogContentWidget class |
39 |
40 |
40 HbProgressDialogContentWidget is internal to HbProgressDialog and is the content widget to progressDialog |
41 HbProgressDialogContentWidget is internal to HbProgressDialog and is the content widget to progressDialog |
46 { |
47 { |
47 Q_OBJECT |
48 Q_OBJECT |
48 |
49 |
49 public: |
50 public: |
50 |
51 |
51 QGraphicsItem *mIconItem; |
52 QGraphicsObject *mIconItem; |
52 HbProgressBar *mProgressBar; |
53 HbProgressBar *mProgressBar; |
53 QGraphicsItem *mTextItem; |
54 QGraphicsObject *mTextItem; |
54 HbProgressDialogPrivate *d; |
55 HbProgressDialogPrivate *d; |
55 |
56 |
56 enum { Type = HbPrivate::ItemType_ProgressDialogContentWidget }; |
57 enum { Type = HbPrivate::ItemType_ProgressDialogContentWidget }; |
57 int type() const { return Type; } |
58 int type() const { return Type; } |
58 |
59 |
109 } |
110 } |
110 else{ |
111 else{ |
111 mContentWidget->mProgressBar->setRange(0,100); |
112 mContentWidget->mProgressBar->setRange(0,100); |
112 } |
113 } |
113 |
114 |
114 HbAction *action = new HbAction(hbTrId("txt_common_button_cancel"), q); |
115 mAction = new HbAction(hbTrId("txt_common_button_cancel"), q); |
115 QObject::connect(action, SIGNAL(triggered()), q, SLOT(_q_userCancel())); |
116 QObject::connect(mAction, SIGNAL(triggered()), q, SLOT(_q_userCancel())); |
116 q->addAction(action); |
117 q->addAction(mAction); |
117 |
118 |
118 mMinDuration = 1500; |
119 mMinDuration = 1500; |
119 mDelayTime = 1000; |
120 mDelayTime = 1000; |
120 |
121 |
121 mTimer = new QTimeLine(mDelayTime, q); |
122 mTimer = new QTimeLine(mDelayTime, q); |
132 |
133 |
133 createPrimitives. |
134 createPrimitives. |
134 */ |
135 */ |
135 void HbProgressDialogPrivate::createPrimitives() |
136 void HbProgressDialogPrivate::createPrimitives() |
136 { |
137 { |
|
138 Q_Q(HbProgressDialog); |
137 if( !mContentWidget->mProgressBar ){ |
139 if( !mContentWidget->mProgressBar ){ |
138 mContentWidget->mProgressBar = new HbProgressBar(mContentWidget); |
140 mContentWidget->mProgressBar = new HbProgressBar(mContentWidget); |
139 HbStyle::setItemName(mContentWidget->mProgressBar, "pbar"); |
141 HbStyle::setItemName(mContentWidget->mProgressBar, "pbar"); |
140 } |
142 } |
141 |
143 |
142 if ( !mContentWidget->mTextItem ) { |
144 if ( !mContentWidget->mTextItem ) { |
143 mContentWidget->mTextItem = HbStylePrivate::createPrimitive(HbStylePrivate::P_ProgressDialog_text,mContentWidget); |
145 mContentWidget->mTextItem = q->style()->createPrimitive(HbStyle::PT_TextItem, "text", mContentWidget); |
144 HbStyle::setItemName(mContentWidget->mTextItem, "text"); |
|
145 } |
146 } |
146 |
147 |
147 if ( !mIcon.isNull() ) { |
148 if ( !mIcon.isNull() ) { |
148 if ( !mContentWidget->mIconItem ) { |
149 if ( !mContentWidget->mIconItem ) { |
149 mContentWidget->mIconItem = HbStylePrivate::createPrimitive(HbStylePrivate::P_ProgressDialog_icon, mContentWidget); |
150 mContentWidget->mIconItem = q->style()->createPrimitive(HbStyle::PT_IconItem, "icon", mContentWidget); |
150 HbStyle::setItemName(mContentWidget->mIconItem, "icon"); |
|
151 } |
151 } |
152 } else { |
152 } else { |
153 if( mContentWidget->mIconItem ){ |
153 if( mContentWidget->mIconItem ){ |
154 delete mContentWidget->mIconItem; |
154 delete mContentWidget->mIconItem; |
155 } |
155 } |
192 flags |= HbProgressDialogPrivate::Closetimer; |
192 flags |= HbProgressDialogPrivate::Closetimer; |
193 } |
193 } |
194 else if(flags.testFlag(HbProgressDialogPrivate::Closetimer)){ |
194 else if(flags.testFlag(HbProgressDialogPrivate::Closetimer)){ |
195 flags &= ~HbProgressDialogPrivate::Closetimer; |
195 flags &= ~HbProgressDialogPrivate::Closetimer; |
196 if(flags.testFlag(HbProgressDialogPrivate::Closepending)){ |
196 if(flags.testFlag(HbProgressDialogPrivate::Closepending)){ |
197 q->close(); |
197 flags &= ~HbProgressDialogPrivate::Closepending; |
|
198 q->close(); |
198 } |
199 } |
199 } |
200 } |
200 } |
201 } |
201 |
202 |
202 /*! |
203 /*! |
205 Private slot, for when progress value changes. When maximum value, stop the timer and close the dialog. |
206 Private slot, for when progress value changes. When maximum value, stop the timer and close the dialog. |
206 */ |
207 */ |
207 void HbProgressDialogPrivate::_q_progressValueChanged(int value) |
208 void HbProgressDialogPrivate::_q_progressValueChanged(int value) |
208 { |
209 { |
209 Q_Q(HbProgressDialog); |
210 Q_Q(HbProgressDialog); |
210 |
211 if(value >= mContentWidget->mProgressBar->maximum() && !(q->autoClose())){ |
|
212 mAction->setText(hbTrId("txt_common_button_close")); |
|
213 } |
211 if(value >= mContentWidget->mProgressBar->maximum() && q->autoClose()){ |
214 if(value >= mContentWidget->mProgressBar->maximum() && q->autoClose()){ |
|
215 |
212 if(flags.testFlag(HbProgressDialogPrivate::Closetimer)){ |
216 if(flags.testFlag(HbProgressDialogPrivate::Closetimer)){ |
213 flags |= HbProgressDialogPrivate::Closepending; |
217 flags |= HbProgressDialogPrivate::Closepending; |
214 flags &= ~HbProgressDialogPrivate::Showtimer; |
218 flags &= ~HbProgressDialogPrivate::Showtimer; |
215 } |
219 } |
216 else if(!flags.testFlag(HbProgressDialogPrivate::Showtimer)){ |
220 else if(!flags.testFlag(HbProgressDialogPrivate::Showtimer)){ |
609 option->iconAlignment = d->mIconAlignment; |
613 option->iconAlignment = d->mIconAlignment; |
610 option->text = d->mTextString; |
614 option->text = d->mTextString; |
611 option->textAlignment = d->mAlign; |
615 option->textAlignment = d->mAlign; |
612 } |
616 } |
613 |
617 |
|
618 void HbProgressDialog::initPrimitiveData(HbStylePrimitiveData *primitiveData, const QGraphicsObject *primitive) |
|
619 { |
|
620 HbWidgetBase::initPrimitiveData(primitiveData, primitive); |
|
621 QString itemName = HbStyle::itemName(primitive); |
|
622 if (itemName == QLatin1String("text")) { |
|
623 HbStyleTextPrimitiveData *data = hbstyleprimitivedata_cast<HbStyleTextPrimitiveData*>(primitiveData); |
|
624 data->text = text(); |
|
625 data->textWrapping = Hb::TextWordWrap; |
|
626 } |
|
627 |
|
628 if (itemName == QLatin1String("icon")) { |
|
629 HbStyleIconPrimitiveData *data = hbstyleprimitivedata_cast<HbStyleIconPrimitiveData*>(primitiveData); |
|
630 data->icon = icon(); |
|
631 } |
|
632 } |
|
633 |
614 /*! |
634 /*! |
615 \reimp |
635 \reimp |
616 */ |
636 */ |
617 void HbProgressDialog::showEvent(QShowEvent *event) |
637 void HbProgressDialog::showEvent(QShowEvent *event) |
618 { |
638 { |
619 Q_D(HbProgressDialog); |
639 Q_D(HbProgressDialog); |
620 |
|
621 d->mContentWidget->mProgressBar->show(); |
640 d->mContentWidget->mProgressBar->show(); |
|
641 d->mAction->setText(hbTrId("txt_common_button_cancel")); |
622 HbDialog::showEvent(event); |
642 HbDialog::showEvent(event); |
623 } |
643 } |
624 |
644 |
625 /*! |
645 /*! |
626 \reimp |
646 \reimp |
658 d->mTextString = text; |
678 d->mTextString = text; |
659 d->createPrimitives(); |
679 d->createPrimitives(); |
660 |
680 |
661 if(d->mContentWidget->mTextItem) |
681 if(d->mContentWidget->mTextItem) |
662 { |
682 { |
663 HbStyleOptionProgressDialog progressDialogOption; |
683 HbStyleTextPrimitiveData data; |
664 initStyleOption(&progressDialogOption); |
684 initPrimitiveData(&data, d->mContentWidget->mTextItem); |
665 HbStylePrivate::updatePrimitive(d->mContentWidget->mTextItem, HbStylePrivate::P_ProgressDialog_text, &progressDialogOption); |
685 style()->updatePrimitive(d->mContentWidget->mTextItem, &data, this); |
666 } |
686 } |
667 } |
687 } |
668 } |
688 } |
669 |
689 |
670 /*! |
690 /*! |
696 d->mIcon = icon; |
716 d->mIcon = icon; |
697 d->createPrimitives(); |
717 d->createPrimitives(); |
698 |
718 |
699 if (d->mContentWidget->mIconItem) { |
719 if (d->mContentWidget->mIconItem) { |
700 d->mContentWidget->setProperty("icon",true); |
720 d->mContentWidget->setProperty("icon",true); |
701 |
721 HbStyleIconPrimitiveData data; |
702 HbStyleOptionProgressDialog progressDialogOption; |
722 initPrimitiveData(&data, d->mContentWidget->mIconItem); |
703 initStyleOption(&progressDialogOption); |
723 style()->updatePrimitive(d->mContentWidget->mIconItem, &data, this); |
704 HbStylePrivate::updatePrimitive(d->mContentWidget->mIconItem, HbStylePrivate::P_ProgressDialog_icon, &progressDialogOption); |
724 |
705 } |
725 } |
706 else |
726 else |
707 { |
727 { |
708 d->mContentWidget->setProperty("icon",false); |
728 d->mContentWidget->setProperty("icon",false); |
709 } |
729 } |
722 { |
742 { |
723 Q_D(const HbProgressDialog); |
743 Q_D(const HbProgressDialog); |
724 |
744 |
725 return d->mIcon; |
745 return d->mIcon; |
726 } |
746 } |
727 |
747 /*! |
|
748 updation of pri |
|
749 */ |
|
750 void HbProgressDialog::updatePrimitives() |
|
751 { |
|
752 Q_D(HbProgressDialog); |
|
753 HbDialog::updatePrimitives(); |
|
754 if (d->mContentWidget->mIconItem) { |
|
755 HbStyleIconPrimitiveData data; |
|
756 initPrimitiveData(&data, d->mContentWidget->mIconItem); |
|
757 style()->updatePrimitive(d->mContentWidget->mIconItem, &data, this); |
|
758 } |
|
759 |
|
760 if (d->mContentWidget->mTextItem) { |
|
761 HbStyleTextPrimitiveData data; |
|
762 initPrimitiveData(&data, d->mContentWidget->mTextItem); |
|
763 style()->updatePrimitive(d->mContentWidget->mTextItem, &data, this); |
|
764 } |
|
765 } |
|
766 /*! |
|
767 Recreaction of all the primitives. |
|
768 */ |
|
769 void HbProgressDialog::recreatePrimitives() |
|
770 { |
|
771 Q_D(HbProgressDialog); |
|
772 if (d->mContentWidget->mIconItem) { |
|
773 delete d->mContentWidget->mIconItem; |
|
774 d->mContentWidget->mIconItem = 0; |
|
775 d->mContentWidget->mIconItem = style()->createPrimitive(HbStyle::PT_IconItem, "icon",d->mContentWidget); |
|
776 } |
|
777 if (d->mContentWidget->mTextItem) { |
|
778 delete d->mContentWidget->mTextItem; |
|
779 d->mContentWidget->mTextItem = 0; |
|
780 d->mContentWidget->mTextItem = style()->createPrimitive(HbStyle::PT_TextItem, "text",d->mContentWidget); |
|
781 } |
|
782 } |
728 |
783 |
729 #include "moc_hbprogressdialog.cpp" |
784 #include "moc_hbprogressdialog.cpp" |
730 #include "hbprogressdialog.moc" |
785 #include "hbprogressdialog.moc" |