58 const int S60_COMMAND_START = 6000; |
58 const int S60_COMMAND_START = 6000; |
59 const int LSK_POSITION = 0; |
59 const int LSK_POSITION = 0; |
60 const int MSK_POSITION = 3; |
60 const int MSK_POSITION = 3; |
61 const int RSK_POSITION = 2; |
61 const int RSK_POSITION = 2; |
62 |
62 |
63 QSoftKeyManagerPrivateS60::QSoftKeyManagerPrivateS60() |
63 QSoftKeyManagerPrivateS60::QSoftKeyManagerPrivateS60() : cbaHasImage(4) // 4 since MSK position index is 3 |
64 { |
64 { |
65 cachedCbaIconSize[0] = QSize(0,0); |
65 cachedCbaIconSize[0] = QSize(0,0); |
66 cachedCbaIconSize[1] = QSize(0,0); |
66 cachedCbaIconSize[1] = QSize(0,0); |
67 cachedCbaIconSize[2] = QSize(0,0); |
67 cachedCbaIconSize[2] = QSize(0,0); |
68 cachedCbaIconSize[3] = QSize(0,0); |
68 cachedCbaIconSize[3] = QSize(0,0); |
71 bool QSoftKeyManagerPrivateS60::skipCbaUpdate() |
71 bool QSoftKeyManagerPrivateS60::skipCbaUpdate() |
72 { |
72 { |
73 // Lets not update softkeys if |
73 // Lets not update softkeys if |
74 // 1. We don't have application panes, i.e. cba |
74 // 1. We don't have application panes, i.e. cba |
75 // 2. Our CBA is not active, i.e. S60 native dialog or menu with custom CBA is shown |
75 // 2. Our CBA is not active, i.e. S60 native dialog or menu with custom CBA is shown |
|
76 // 2.1. Except if thre is no current CBA at all and WindowSoftkeysRespondHint is set |
|
77 |
76 // Note: Cannot use IsDisplayingMenuOrDialog since CBA update can be triggered before |
78 // Note: Cannot use IsDisplayingMenuOrDialog since CBA update can be triggered before |
77 // menu/dialog CBA is actually displayed i.e. it is being costructed. |
79 // menu/dialog CBA is actually displayed i.e. it is being costructed. |
78 CEikButtonGroupContainer *appUiCba = S60->buttonGroupContainer(); |
80 CEikButtonGroupContainer *appUiCba = S60->buttonGroupContainer(); |
|
81 // CEikButtonGroupContainer::Current returns 0 if CBA is not visible at all |
79 CEikButtonGroupContainer *currentCba = CEikButtonGroupContainer::Current(); |
82 CEikButtonGroupContainer *currentCba = CEikButtonGroupContainer::Current(); |
80 if (QApplication::testAttribute(Qt::AA_S60DontConstructApplicationPanes) || appUiCba != currentCba) { |
83 // Check if softkey need to be update even they are not visible |
|
84 bool cbaRespondsWhenInvisible = false; |
|
85 QWidget *window = QApplication::activeWindow(); |
|
86 if (window && (window->windowFlags() & Qt::WindowSoftkeysRespondHint)) |
|
87 cbaRespondsWhenInvisible = true; |
|
88 |
|
89 if (QApplication::testAttribute(Qt::AA_S60DontConstructApplicationPanes) |
|
90 || (appUiCba != currentCba && !cbaRespondsWhenInvisible)) { |
81 return true; |
91 return true; |
82 } |
92 } |
83 return false; |
93 return false; |
84 } |
94 } |
85 |
95 |
253 |
263 |
254 CEikImage* myimage = new (ELeave) CEikImage; |
264 CEikImage* myimage = new (ELeave) CEikImage; |
255 myimage->SetPicture( nBitmap, nMask ); // nBitmap and nMask ownership transfered |
265 myimage->SetPicture( nBitmap, nMask ); // nBitmap and nMask ownership transfered |
256 |
266 |
257 EikSoftkeyImage::SetImage(cba, *myimage, left); // Takes myimage ownership |
267 EikSoftkeyImage::SetImage(cba, *myimage, left); // Takes myimage ownership |
|
268 cbaHasImage[position] = true; |
258 ret = true; |
269 ret = true; |
259 } else { |
270 } else { |
260 // Restore softkey to text based |
271 // Restore softkey to text based |
261 EikSoftkeyImage::SetLabel(cba, left); |
272 if (cbaHasImage[position]) { |
|
273 EikSoftkeyImage::SetLabel(cba, left); |
|
274 cbaHasImage[position] = false; |
|
275 } |
262 } |
276 } |
263 } |
277 } |
264 return ret; |
278 return ret; |
265 } |
279 } |
266 |
280 |
272 setSoftkeyImage(&cba, *action, position); |
286 setSoftkeyImage(&cba, *action, position); |
273 QString text = softkeyText(*action); |
287 QString text = softkeyText(*action); |
274 TPtrC nativeText = qt_QString2TPtrC(text); |
288 TPtrC nativeText = qt_QString2TPtrC(text); |
275 int command = S60_COMMAND_START + position; |
289 int command = S60_COMMAND_START + position; |
276 setNativeSoftkey(cba, position, command, nativeText); |
290 setNativeSoftkey(cba, position, command, nativeText); |
277 cba.DimCommand(command, !action->isEnabled()); |
291 const bool dimmed = !action->isEnabled() && !QSoftKeyManager::isForceEnabledInSofkeys(action); |
|
292 cba.DimCommand(command, dimmed); |
278 realSoftKeyActions.insert(command, action); |
293 realSoftKeyActions.insert(command, action); |
279 return true; |
294 return true; |
280 } |
295 } |
281 return false; |
296 return false; |
282 } |
297 } |
309 } |
324 } |
310 |
325 |
311 if (windowType != Qt::Dialog && windowType != Qt::Popup) { |
326 if (windowType != Qt::Dialog && windowType != Qt::Popup) { |
312 QString text(QSoftKeyManager::tr("Exit")); |
327 QString text(QSoftKeyManager::tr("Exit")); |
313 TPtrC nativeText = qt_QString2TPtrC(text); |
328 TPtrC nativeText = qt_QString2TPtrC(text); |
314 EikSoftkeyImage::SetLabel(&cba, false); |
329 if (cbaHasImage[RSK_POSITION]) { |
|
330 EikSoftkeyImage::SetLabel(&cba, false); |
|
331 cbaHasImage[RSK_POSITION] = false; |
|
332 } |
315 setNativeSoftkey(cba, RSK_POSITION, EAknSoftkeyExit, nativeText); |
333 setNativeSoftkey(cba, RSK_POSITION, EAknSoftkeyExit, nativeText); |
|
334 cba.DimCommand(EAknSoftkeyExit, false); |
316 return true; |
335 return true; |
317 } |
336 } |
318 } |
337 } |
319 return false; |
338 return false; |
320 } |
339 } |