16 */ |
16 */ |
17 |
17 |
18 #include <hbstyle.h> |
18 #include <hbstyle.h> |
19 #include <hbmainwindow.h> |
19 #include <hbmainwindow.h> |
20 #include <hbevent.h> |
20 #include <hbevent.h> |
|
21 #include <hbiconitem.h> |
|
22 #include <hbtextitem.h> |
|
23 #include <hbfontspec.h> |
|
24 #include <hbdeviceprofile.h> |
|
25 #include <hbstyleloader.h> |
|
26 #include <hbiconanimationmanager.h> |
|
27 #include <hbiconanimator.h> |
|
28 |
21 #include "bubbleheadingwidget.h" |
29 #include "bubbleheadingwidget.h" |
22 #include "bubbleprimitives.h" |
|
23 #include "bubblestyleoption.h" |
|
24 #include "bubblemanager2.h" |
30 #include "bubblemanager2.h" |
25 #include "bubbleutils.h" |
31 #include "bubbleutils.h" |
26 #include "bubbleheader.h" |
32 #include "bubbleheader.h" |
27 |
33 |
28 BubbleHeadingWidget::BubbleHeadingWidget( |
34 BubbleHeadingWidget::BubbleHeadingWidget(QGraphicsItem* item) |
29 const QString& stylePluginName, QGraphicsItem* item) |
35 : HbWidget(item), mStatusIcon(0), mNumberTypeIcon(0), |
30 : HbWidget(item), mStylePluginName(stylePluginName), mStatusIcon(0), |
36 mCipheringIcon(0), mText1(0), mText2(0), mText3(0) |
31 mNumberTypeIcon(0), mCipheringIcon(0), mText1(0), mText2(0), mText3(0) |
37 { |
32 { |
|
33 setPluginBaseId(style()->registerPlugin(mStylePluginName)); |
|
34 Q_ASSERT(pluginBaseId()!=-1); |
|
35 |
|
36 createPrimitives(); |
38 createPrimitives(); |
|
39 |
|
40 HbStyleLoader::registerFilePath(":/bubbleheadingwidget.css"); |
|
41 HbStyleLoader::registerFilePath(":/bubbleheadingwidget.widgetml"); |
|
42 |
|
43 // font is update in code, because cli position is changing |
|
44 mCliFont = new HbFontSpec(HbFontSpec::Primary); |
|
45 mTextFont = new HbFontSpec(HbFontSpec::Secondary); |
|
46 |
|
47 HbDeviceProfile profile; |
|
48 mCliFont->setTextHeight(4*HbDeviceProfile::current().unitValue()); |
|
49 mTextFont->setTextHeight(4*HbDeviceProfile::current().unitValue()); |
|
50 |
|
51 HbIconAnimationManager *mgr = HbIconAnimationManager::global(); |
|
52 mgr->addDefinitionFile(":/bubble_icon_anim.axml"); |
37 } |
53 } |
38 |
54 |
39 BubbleHeadingWidget::~BubbleHeadingWidget() |
55 BubbleHeadingWidget::~BubbleHeadingWidget() |
40 { |
56 { |
41 style()->unregisterPlugin(mStylePluginName); |
57 delete mCliFont; |
|
58 delete mTextFont; |
42 } |
59 } |
43 |
60 |
44 void BubbleHeadingWidget::reset() |
61 void BubbleHeadingWidget::reset() |
45 { |
62 { |
46 mHeader = 0; |
63 mHeader = 0; |
|
64 mText1->setText(QString()); |
|
65 mText2->setText(QString()); |
|
66 mText3->setText(QString()); |
|
67 mStatusIcon->hide(); |
|
68 mStatusIcon->animator().stopAnimation(); |
|
69 mNumberTypeIcon->hide(); |
|
70 mCipheringIcon->hide(); |
47 } |
71 } |
48 |
72 |
49 void BubbleHeadingWidget::readBubbleHeader(const BubbleHeader& header) |
73 void BubbleHeadingWidget::readBubbleHeader(const BubbleHeader& header) |
50 { |
74 { |
51 mHeader = &header; |
75 mHeader = &header; |
52 updatePrimitives(); |
76 updatePrimitives(); |
53 } |
77 } |
54 |
78 |
55 void BubbleHeadingWidget::createPrimitives() |
79 void BubbleHeadingWidget::createPrimitives() |
56 { |
80 { |
57 delete mText1; |
81 mText1 = new HbTextItem(this); |
58 mText1 = style()->createPrimitive( |
|
59 (HbStyle::Primitive)(pluginBaseId()+BP_Text1_text), this); |
|
60 style()->setItemName( mText1, "text_line_1" ); |
82 style()->setItemName( mText1, "text_line_1" ); |
61 |
83 |
62 delete mText2; |
84 mText2 = new HbTextItem(this); |
63 mText2 = style()->createPrimitive( |
|
64 (HbStyle::Primitive)(pluginBaseId()+BP_Text2_text), this); |
|
65 style()->setItemName( mText2, "text_line_2" ); |
85 style()->setItemName( mText2, "text_line_2" ); |
66 |
86 |
67 delete mText3; |
87 mText3 = new HbTextItem(this); |
68 mText3 = style()->createPrimitive( |
|
69 (HbStyle::Primitive)(pluginBaseId()+BP_Text3_text), this); |
|
70 style()->setItemName( mText3, "text_line_3" ); |
88 style()->setItemName( mText3, "text_line_3" ); |
71 |
89 |
72 delete mNumberTypeIcon; |
90 //mStatusIcon = new BubbleAnimIconItem(BUBBLE_ICON_ANIM_INTERVAL, this); |
73 mNumberTypeIcon = style()->createPrimitive( |
91 mStatusIcon = new HbIconItem(this); |
74 (HbStyle::Primitive)(pluginBaseId()+BP_NumberType_icon), this); |
92 style()->setItemName( mStatusIcon, "status_icon" ); |
|
93 |
|
94 mNumberTypeIcon = new HbIconItem(this); |
75 style()->setItemName( mNumberTypeIcon, "number_type_icon" ); |
95 style()->setItemName( mNumberTypeIcon, "number_type_icon" ); |
76 |
96 |
77 delete mCipheringIcon; |
97 mCipheringIcon = new HbIconItem(this); |
78 mCipheringIcon = style()->createPrimitive( |
|
79 (HbStyle::Primitive)(pluginBaseId()+BP_Ciphering_icon), this); |
|
80 style()->setItemName( mCipheringIcon, "ciphering_icon" ); |
98 style()->setItemName( mCipheringIcon, "ciphering_icon" ); |
81 |
|
82 delete mStatusIcon; |
|
83 mStatusIcon = style()->createPrimitive( |
|
84 (HbStyle::Primitive)(pluginBaseId()+BP_CallStatus_icon), this); |
|
85 style()->setItemName( mStatusIcon, "status_icon" ); |
|
86 } |
99 } |
87 |
100 |
88 void BubbleHeadingWidget::updatePrimitives() |
101 void BubbleHeadingWidget::updatePrimitives() |
89 { |
102 { |
90 BubbleStyleOption option; |
|
91 initStyleOption(option); |
|
92 |
|
93 if (mText1) { |
|
94 style()->updatePrimitive( |
|
95 mText1, |
|
96 (HbStyle::Primitive)(pluginBaseId()+BP_Text1_text), |
|
97 &option); |
|
98 } |
|
99 |
|
100 if (mText2) { |
|
101 style()->updatePrimitive( |
|
102 mText2, |
|
103 (HbStyle::Primitive)(pluginBaseId()+BP_Text2_text), |
|
104 &option); |
|
105 } |
|
106 |
|
107 if (mText3) { |
|
108 style()->updatePrimitive( |
|
109 mText3, |
|
110 (HbStyle::Primitive)(pluginBaseId()+BP_Text3_text), |
|
111 &option); |
|
112 } |
|
113 |
|
114 if (mStatusIcon) { |
|
115 style()->updatePrimitive( |
|
116 mStatusIcon, |
|
117 (HbStyle::Primitive)(pluginBaseId()+BP_CallStatus_icon), |
|
118 &option); |
|
119 } |
|
120 |
|
121 if (mNumberTypeIcon) { |
|
122 style()->updatePrimitive( |
|
123 mNumberTypeIcon, |
|
124 (HbStyle::Primitive)(pluginBaseId()+BP_NumberType_icon), |
|
125 &option); |
|
126 } |
|
127 |
|
128 if (mCipheringIcon) { |
|
129 style()->updatePrimitive( |
|
130 mCipheringIcon, |
|
131 (HbStyle::Primitive)(pluginBaseId()+BP_Ciphering_icon), |
|
132 &option); |
|
133 } |
|
134 |
|
135 repolish(); |
|
136 } |
|
137 |
|
138 void BubbleHeadingWidget::initStyleOption(BubbleStyleOption& option) |
|
139 { |
|
140 HbWidget::initStyleOption(&option); |
|
141 |
|
142 if (mHeader!=0) { |
103 if (mHeader!=0) { |
143 option.mCallState = mHeader->callState(); |
104 BubbleUtils::setCallStatusIcon( |
144 option.mCallFlags = mHeader->callFlags(); |
105 mHeader->callState(), mHeader->callFlags(), *mStatusIcon); |
|
106 |
|
107 BubbleUtils::setNumberTypeIcon( |
|
108 mHeader->callState(), mHeader->callFlags(), *mNumberTypeIcon); |
|
109 |
|
110 BubbleUtils::setCipheringIcon( |
|
111 mHeader->callState(), mHeader->callFlags(), *mCipheringIcon); |
|
112 |
|
113 // update text lines |
|
114 int cliLine = 0; |
145 |
115 |
146 if (lines==3) { |
116 if (lines==3) { |
147 BubbleUtils::setCallHeaderTexts3Lines( *mHeader, option ); |
117 BubbleUtils::setCallHeaderTexts3Lines( |
|
118 *mHeader, *mText1, *mText2, *mText3, cliLine, |
|
119 mCallTimerTextLine ); |
148 } else if (lines==2) { |
120 } else if (lines==2) { |
149 BubbleUtils::setCallHeaderTexts2Lines( *mHeader, option ); |
121 BubbleUtils::setCallHeaderTexts2Lines( |
|
122 *mHeader, *mText1, *mText2, cliLine, |
|
123 mCallTimerTextLine ); |
150 } else { |
124 } else { |
151 // todo: 1-line |
125 // todo: 1-line |
152 BubbleUtils::setCallHeaderTexts2Lines( *mHeader, option ); |
126 BubbleUtils::setCallHeaderTexts2Lines( |
|
127 *mHeader, *mText1, *mText2, cliLine, |
|
128 mCallTimerTextLine ); |
153 } |
129 } |
154 |
130 |
155 mCallTimerTextLine = option.mTimerLineNumber; |
131 // update font |
156 } |
132 if (cliLine==2) { |
|
133 mText1->setFontSpec(*mTextFont); |
|
134 mText2->setFontSpec(*mCliFont); |
|
135 mText3->setFontSpec(*mTextFont); |
|
136 } else { |
|
137 mText1->setFontSpec(*mCliFont); |
|
138 mText2->setFontSpec(*mTextFont); |
|
139 mText3->setFontSpec(*mTextFont); |
|
140 } |
|
141 } |
|
142 |
|
143 repolish(); |
157 } |
144 } |
158 |
145 |
159 void BubbleHeadingWidget::polishEvent() |
146 void BubbleHeadingWidget::polishEvent() |
160 { |
147 { |
161 if (mText1 && mText2 && mText3) { |
148 if (lines == 3) { |
162 if (lines == 3) { |
149 setLayout("three_lines"); |
163 setLayout("three_lines"); |
150 mText1->setVisible(true); |
164 mText1->setVisible(true); |
151 mText2->setVisible(true); |
165 mText2->setVisible(true); |
152 mText3->setVisible(true); |
166 mText3->setVisible(true); |
153 } else if (lines == 2) { |
167 } else if (lines == 2) { |
154 setLayout("two_lines"); |
168 setLayout("two_lines"); |
155 mText1->setVisible(true); |
169 mText1->setVisible(true); |
156 mText2->setVisible(true); |
170 mText2->setVisible(true); |
157 mText3->setVisible(false); |
171 mText3->setVisible(false); |
158 } else if (lines == 1) { |
172 } else if (lines == 1) { |
159 setLayout("one_line"); |
173 setLayout("one_line"); |
160 mText1->setVisible(true); |
174 mText1->setVisible(true); |
161 mText2->setVisible(true); |
175 mText2->setVisible(true); |
162 mText3->setVisible(false); |
176 mText3->setVisible(false); |
|
177 } |
|
178 } |
163 } |
179 |
164 |
180 HbWidget::polishEvent(); |
165 HbWidget::polishEvent(); |
181 } |
166 } |
182 |
167 |