14 * Description: Utility methods. |
14 * Description: Utility methods. |
15 * |
15 * |
16 */ |
16 */ |
17 |
17 |
18 #include <hbiconitem.h> |
18 #include <hbiconitem.h> |
|
19 #include <hbaction.h> |
|
20 #include <hbtextitem.h> |
|
21 #include <hbstringutil.h> |
|
22 #include <hbiconanimator.h> |
|
23 #include <hbcolorscheme.h> |
|
24 |
19 #include "bubblemanager2.h" |
25 #include "bubblemanager2.h" |
20 #include "bubbleutils.h" |
26 #include "bubbleutils.h" |
21 #include "bubbleheader.h" |
27 #include "bubbleheader.h" |
22 #include "bubblestyleoption.h" |
28 #include "bubblebutton.h" |
23 #include "bubblebuttonstyle.h" |
|
24 #include "hbpushbutton.h" |
|
25 #include "hbaction.h" |
|
26 |
29 |
27 void BubbleUtils::setCallHeaderTexts3Lines( |
30 void BubbleUtils::setCallHeaderTexts3Lines( |
28 const BubbleHeader& header, |
31 const BubbleHeader& header, |
29 BubbleStyleOption& option ) |
32 HbTextItem& textLine1, |
|
33 HbTextItem& textLine2, |
|
34 HbTextItem& textLine3, |
|
35 int& cliLineNumber, |
|
36 int& timerLineNumber) |
30 { |
37 { |
31 switch( header.callState() ) { |
38 switch( header.callState() ) { |
32 case BubbleManager::Incoming: |
39 case BubbleManager::Incoming: |
33 case BubbleManager::Waiting: |
40 case BubbleManager::Waiting: |
34 case BubbleManager::AlertToDisconnected: |
41 case BubbleManager::AlertToDisconnected: |
35 { |
42 { |
36 if ( header.secondaryCli().length() ) { |
43 if ( header.secondaryCli().length() ) { |
37 option.mText1.append( header.cli() ); |
44 setText(textLine1, header.cli(), header.cliClipDirection()); |
38 option.mText1Clip = header.cliClipDirection(); |
45 setText(textLine2, header.secondaryCli(), |
39 option.mText2.append( header.secondaryCli() ); |
46 header.secondaryCliClipDirection()); |
40 option.mText2Clip = header.secondaryCliClipDirection(); |
47 setText(textLine3, header.text(), header.textClipDirection()); |
41 option.mText3.append( header.text() ); |
48 cliLineNumber = 1; |
42 option.mText3Clip = header.textClipDirection(); |
49 } else { |
43 option.mCliLineNumber = 1; |
50 setText(textLine1,header.cli(), header.cliClipDirection()); |
44 } else { |
51 setText(textLine2,header.text(), header.textClipDirection()); |
45 option.mText1.append( header.cli() ); |
52 cliLineNumber = 1; |
46 option.mText1Clip = header.cliClipDirection(); |
53 } |
47 option.mText2.append( header.text() ); |
54 break; |
48 option.mText2Clip = header.textClipDirection(); |
55 } |
49 option.mCliLineNumber = 1; |
56 |
50 } |
|
51 break; |
|
52 } |
|
53 |
|
54 case BubbleManager::Outgoing: |
57 case BubbleManager::Outgoing: |
55 { |
58 { |
56 if ( header.secondaryCli().length() ) { |
59 if ( header.secondaryCli().length() ) { |
57 option.mText1.append( header.text() ); |
60 setText(textLine1, header.text(), header.textClipDirection()); |
58 option.mText1Clip = header.textClipDirection(); |
61 setText(textLine2, header.cli(), header.cliClipDirection()); |
59 option.mText2.append( header.cli() ); |
62 setText(textLine3, header.secondaryCli(), |
60 option.mText2Clip = header.cliClipDirection(); |
63 header.secondaryCliClipDirection()); |
61 option.mText3.append( header.secondaryCli() ); |
64 cliLineNumber = 2; |
62 option.mText3Clip = header.secondaryCliClipDirection(); |
65 } else { |
63 option.mCliLineNumber = 2; |
66 setText(textLine1, header.text(), header.textClipDirection()); |
64 } else { |
67 setText(textLine2, header.cli(), header.cliClipDirection()); |
65 option.mText1.append( header.text() ); |
68 cliLineNumber = 2; |
66 option.mText1Clip = header.textClipDirection(); |
|
67 option.mText2.append( header.cli() ); |
|
68 option.mText2Clip = header.cliClipDirection(); |
|
69 option.mCliLineNumber = 2; |
|
70 } |
69 } |
71 break; |
70 break; |
72 } |
71 } |
73 |
72 |
74 case BubbleManager::Active: |
73 case BubbleManager::Active: |
75 case BubbleManager::Alerting: |
74 case BubbleManager::Alerting: |
76 { |
75 { |
77 if ( header.secondaryCli().length() ) { |
76 if ( header.secondaryCli().length() ) { |
78 option.mText1.append( header.cli() ); |
77 setText(textLine1, header.cli(), header.cliClipDirection()); |
79 option.mText1Clip = header.cliClipDirection(); |
78 setText(textLine2, header.secondaryCli(), |
80 option.mText2.append( header.secondaryCli() ); |
79 header.secondaryCliClipDirection()); |
81 option.mText2Clip = header.secondaryCliClipDirection(); |
80 setText(textLine3, header.timerCost(), Qt::ElideRight); |
82 option.mText3.append( header.timerCost() ); |
81 cliLineNumber = 1; |
83 option.mText3Clip = Qt::ElideRight; |
82 timerLineNumber = 3; |
84 option.mCliLineNumber = 1; |
83 } else { |
85 option.mTimerLineNumber = 3; |
84 setText(textLine1, header.cli(), header.cliClipDirection()); |
86 } else { |
85 setText(textLine2, header.timerCost(), Qt::ElideRight); |
87 option.mText1.append( header.cli() ); |
86 cliLineNumber = 1; |
88 option.mText1Clip = header.cliClipDirection(); |
87 timerLineNumber = 2; |
89 option.mText2.append( header.timerCost() ); |
88 } |
90 option.mText2Clip = Qt::ElideRight; |
89 break; |
91 option.mCliLineNumber = 1; |
90 } |
92 option.mTimerLineNumber = 2; |
91 |
93 } |
|
94 break; |
|
95 } |
|
96 |
|
97 case BubbleManager::OnHold: |
92 case BubbleManager::OnHold: |
98 case BubbleManager::Disconnected: |
93 case BubbleManager::Disconnected: |
99 { |
94 { |
100 if ( header.secondaryCli().length() ) { |
95 if ( header.secondaryCli().length() ) { |
101 option.mText1.append( header.cli() ); |
96 setText(textLine1, header.cli(), header.cliClipDirection()); |
102 option.mText1Clip = header.cliClipDirection(); |
97 setText(textLine2, header.secondaryCli(), |
103 option.mText2.append( header.secondaryCli() ); |
98 header.secondaryCliClipDirection()); |
104 option.mText2Clip = header.secondaryCliClipDirection(); |
99 setText(textLine3, header.text(), header.textClipDirection()); |
105 option.mText3.append( header.text() ); |
100 cliLineNumber = 1; |
106 option.mText3Clip = header.textClipDirection(); |
101 } else { |
107 option.mCliLineNumber = 1; |
102 setText(textLine1, header.cli(), header.cliClipDirection()); |
108 } else { |
103 setText(textLine2, header.text(), header.textClipDirection()); |
109 option.mText1.append( header.cli() ); |
104 cliLineNumber = 1; |
110 option.mText1Clip = header.cliClipDirection(); |
|
111 option.mText2.append( header.text() ); |
|
112 option.mText2Clip = header.textClipDirection(); |
|
113 option.mCliLineNumber = 1; |
|
114 } |
105 } |
115 break; |
106 break; |
116 } |
107 } |
117 |
108 |
118 default: |
109 default: |
121 } // switch |
112 } // switch |
122 } |
113 } |
123 |
114 |
124 void BubbleUtils::setCallHeaderTexts2Lines( |
115 void BubbleUtils::setCallHeaderTexts2Lines( |
125 const BubbleHeader& header, |
116 const BubbleHeader& header, |
126 BubbleStyleOption& option ) |
117 HbTextItem& textLine1, |
|
118 HbTextItem& textLine2, |
|
119 int& cliLineNumber, |
|
120 int& timerLineNumber) |
127 { |
121 { |
128 switch( header.callState() ) { |
122 switch( header.callState() ) { |
129 case BubbleManager::Active: |
123 case BubbleManager::Active: |
130 option.mText1.append( header.cli() ); |
124 setText(textLine1, header.cli(), header.cliClipDirection()); |
131 option.mText1Clip = header.cliClipDirection(); |
125 setText(textLine2, header.timerCost(), Qt::ElideRight); |
132 option.mText2.append( header.timerCost() ); |
126 cliLineNumber = 1; |
133 option.mText2Clip = Qt::ElideRight; |
127 timerLineNumber = 2; |
134 option.mCliLineNumber = 1; |
|
135 option.mTimerLineNumber = 2; |
|
136 break; |
128 break; |
137 |
129 |
138 |
130 |
139 case BubbleManager::OnHold: |
131 case BubbleManager::OnHold: |
140 case BubbleManager::Disconnected: |
132 case BubbleManager::Disconnected: |
141 option.mText1.append( header.cli() ); |
133 setText(textLine1, header.cli(), header.cliClipDirection()); |
142 option.mText1Clip = header.cliClipDirection(); |
134 setText(textLine2, header.text(), header.textClipDirection()); |
143 option.mText2.append( header.text() ); |
135 cliLineNumber = 1; |
144 option.mText2Clip = header.textClipDirection(); |
|
145 option.mCliLineNumber = 1; |
|
146 break; |
136 break; |
147 |
137 |
148 case BubbleManager::Waiting: |
138 case BubbleManager::Waiting: |
149 case BubbleManager::AlertToDisconnected: |
139 case BubbleManager::AlertToDisconnected: |
150 option.mText1.append( header.cli() ); |
140 setText(textLine1, header.cli(), header.cliClipDirection()); |
151 option.mText1Clip = header.cliClipDirection(); |
141 setText(textLine2, header.text(), header.textClipDirection()); |
152 option.mText2.append( header.text() ); |
142 cliLineNumber = 1; |
153 option.mText2Clip = header.textClipDirection(); |
|
154 option.mCliLineNumber = 1; |
|
155 break; |
143 break; |
156 |
144 |
157 case BubbleManager::Outgoing: |
145 case BubbleManager::Outgoing: |
158 option.mText1.append(header.text()); |
146 setText(textLine1, header.text(), header.textClipDirection()); |
159 option.mText1Clip = header.textClipDirection(); |
147 setText(textLine2, header.cli(), header.cliClipDirection()); |
160 option.mText2.append(header.cli()); |
148 cliLineNumber = 2; |
161 option.mText2Clip = header.cliClipDirection(); |
|
162 option.mCliLineNumber = 2; |
|
163 break; |
149 break; |
164 |
150 |
165 default: |
151 default: |
166 // do nothing |
152 // do nothing |
167 break; |
153 break; |
168 } // switch |
154 } // switch |
|
155 } |
|
156 |
|
157 void BubbleUtils::setText( |
|
158 HbTextItem& item, |
|
159 const QString& text, |
|
160 Qt::TextElideMode clip) |
|
161 { |
|
162 if (clip == Qt::ElideLeft) { |
|
163 // convert phonenumber to phone ui language |
|
164 QString converted = HbStringUtil::convertDigits(text); |
|
165 item.setText(converted); |
|
166 } else { |
|
167 item.setText( text ); |
|
168 } |
|
169 item.setElideMode( clip ); |
169 } |
170 } |
170 |
171 |
171 bool BubbleUtils::compareHeaders( |
172 bool BubbleUtils::compareHeaders( |
172 const BubbleHeader* header1, |
173 const BubbleHeader* header1, |
173 const BubbleHeader* header2 ) |
174 const BubbleHeader* header2 ) |
174 { |
175 { |
175 if ( header1->callState() < header2->callState() ) { |
176 // sort according to call states, but keep conference header |
|
177 // last, it shown at foreground only when expanded. |
|
178 if ( (header1->callState() < header2->callState()) || |
|
179 header1->isConference() ) { |
176 return false; |
180 return false; |
177 } else { |
181 } else { |
178 return true; |
182 return true; |
179 } |
183 } |
180 } |
184 } |
181 |
185 |
182 QString BubbleUtils::stylePluginNameWithPath(const QString& pluginName) |
|
183 { |
|
184 QString nameWithPath; |
|
185 |
|
186 #if defined(Q_OS_SYMBIAN) |
|
187 nameWithPath.append("z:/resource/qt/plugins/phone/"); |
|
188 nameWithPath.append(pluginName); |
|
189 #elif defined(Q_OS_WIN) |
|
190 nameWithPath.append("c:/hb/bin/"); |
|
191 nameWithPath.append(pluginName); |
|
192 #else // Q_OS_UNIX |
|
193 nameWithPath.append("/home/lib/"); |
|
194 nameWithPath.append(pluginName); |
|
195 #endif |
|
196 |
|
197 return nameWithPath; |
|
198 } |
|
199 |
|
200 void BubbleUtils::setButtonStyleForAction( |
186 void BubbleUtils::setButtonStyleForAction( |
201 HbPushButton& button, |
187 BubbleButton& button, |
202 const HbAction& action) |
188 const HbAction& action) |
203 { |
189 { |
204 BubbleButtonStyle* style = |
|
205 static_cast<BubbleButtonStyle*>(button.style()); |
|
206 |
|
207 if (action.softKeyRole()==QAction::PositiveSoftKey) { |
190 if (action.softKeyRole()==QAction::PositiveSoftKey) { |
208 style->setButtonColor(BubbleButtonStyle::Green); |
191 button.setButtonType(BubbleButton::GreenButton); |
209 } else if (action.softKeyRole()==QAction::NegativeSoftKey) { |
192 } else if (action.softKeyRole()==QAction::NegativeSoftKey) { |
210 style->setButtonColor(BubbleButtonStyle::Red); |
193 button.setButtonType(BubbleButton::RedButton); |
211 } else { |
194 } else { |
212 style->setButtonColor(BubbleButtonStyle::Default); |
195 button.setButtonType(BubbleButton::DefaultButton); |
213 } |
196 } |
214 |
197 |
215 } |
198 button.updatePrimitives(); |
216 |
199 } |
|
200 |
|
201 void BubbleUtils::setCallStatusIcon( |
|
202 int callState, |
|
203 int callFlags, |
|
204 HbIconItem& icon) |
|
205 { |
|
206 bool showIcon = true; |
|
207 |
|
208 switch(callState) { |
|
209 case BubbleManagerIF::Incoming: |
|
210 case BubbleManagerIF::Alerting: |
|
211 case BubbleManagerIF::Waiting: |
|
212 // from bubble_icon_anim.axml |
|
213 if ( callFlags & BubbleManagerIF::VoIPCall ) { |
|
214 icon.setIconName("voip_call_waiting_anim"); |
|
215 } else if ( callFlags & BubbleManagerIF::Video ) { |
|
216 icon.setIconName("video_call_waiting_anim"); |
|
217 } else { |
|
218 icon.setIconName("voice_call_waiting_anim"); |
|
219 } |
|
220 break; |
|
221 case BubbleManagerIF::Outgoing: |
|
222 case BubbleManagerIF::Active: |
|
223 if ( callFlags & BubbleManagerIF::VoIPCall ) { |
|
224 icon.setIconName("qtg_large_voip_call_active"); |
|
225 } else if ( callFlags & BubbleManagerIF::Video ) { |
|
226 icon.setIconName("qtg_large_video_call_active"); |
|
227 } else { |
|
228 icon.setIconName("qtg_large_active_call"); |
|
229 } |
|
230 break; |
|
231 case BubbleManagerIF::OnHold: |
|
232 if ( callFlags & BubbleManagerIF::VoIPCall ) { |
|
233 icon.setIconName("qtg_large_voip_call_waiting"); |
|
234 } else if ( callFlags & BubbleManagerIF::Video ) { |
|
235 icon.setIconName("qtg_large_video_call_waiting"); |
|
236 } else { |
|
237 icon.setIconName("qtg_large_waiting_call"); |
|
238 } |
|
239 break; |
|
240 case BubbleManagerIF::Disconnected: |
|
241 case BubbleManagerIF::AlertToDisconnected: |
|
242 if ( callFlags & BubbleManagerIF::VoIPCall ) { |
|
243 icon.setIconName("qtg_large_end_call"); |
|
244 } else if ( callFlags & BubbleManagerIF::Video ) { |
|
245 icon.setIconName("qtg_large_end_call"); |
|
246 } else { |
|
247 icon.setIconName("qtg_large_end_call"); |
|
248 } |
|
249 break; |
|
250 default: |
|
251 icon.setIcon(HbIcon()); |
|
252 showIcon = false; |
|
253 break; |
|
254 } |
|
255 |
|
256 if (showIcon) { |
|
257 icon.show(); |
|
258 } |
|
259 } |
|
260 |
|
261 void BubbleUtils::setNumberTypeIcon( |
|
262 int callState, |
|
263 int callFlags, |
|
264 HbIconItem& icon) |
|
265 { |
|
266 if ( (( callState == BubbleManagerIF::Incoming ) || |
|
267 ( callState == BubbleManagerIF::Waiting )) && |
|
268 (callFlags & BubbleManagerIF::Diverted) ) { |
|
269 icon.setIcon( HbIcon(":/qtg_mono_call_diverted.svg") ); |
|
270 |
|
271 // temporary, diverted icon is not yet in theme and |
|
272 // because of that css coloring doesn't work |
|
273 QColor color; |
|
274 color = HbColorScheme::color("qtc_list_item_title_normal"); |
|
275 if (color.isValid()) { |
|
276 icon.setColor(Qt::white); |
|
277 } |
|
278 |
|
279 icon.show(); |
|
280 } else { |
|
281 icon.setIcon( HbIcon() ); |
|
282 icon.hide(); |
|
283 } |
|
284 } |
|
285 |
|
286 void BubbleUtils::setCipheringIcon( |
|
287 int callState, |
|
288 int callFlags, |
|
289 HbIconItem& icon) |
|
290 { |
|
291 Q_UNUSED(callState) |
|
292 |
|
293 if (callFlags & BubbleManagerIF::NoCiphering) { |
|
294 icon.setIcon( HbIcon("qtg_mono_ciphering_off") ); |
|
295 icon.show(); |
|
296 } else { |
|
297 icon.setIcon( HbIcon() ); |
|
298 icon.hide(); |
|
299 } |
|
300 } |
|
301 |