76 // 2.1. Except if thre is no current CBA at all and WindowSoftkeysRespondHint is set |
76 // 2.1. Except if thre is no current CBA at all and WindowSoftkeysRespondHint is set |
77 |
77 |
78 // Note: Cannot use IsDisplayingMenuOrDialog since CBA update can be triggered before |
78 // Note: Cannot use IsDisplayingMenuOrDialog since CBA update can be triggered before |
79 // 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. |
80 CEikButtonGroupContainer *appUiCba = S60->buttonGroupContainer(); |
80 CEikButtonGroupContainer *appUiCba = S60->buttonGroupContainer(); |
|
81 if (!appUiCba) |
|
82 return true; |
81 // CEikButtonGroupContainer::Current returns 0 if CBA is not visible at all |
83 // CEikButtonGroupContainer::Current returns 0 if CBA is not visible at all |
82 CEikButtonGroupContainer *currentCba = CEikButtonGroupContainer::Current(); |
84 CEikButtonGroupContainer *currentCba = CEikButtonGroupContainer::Current(); |
83 // Check if softkey need to be update even they are not visible |
85 // Check if softkey need to be update even they are not visible |
84 bool cbaRespondsWhenInvisible = false; |
86 bool cbaRespondsWhenInvisible = false; |
85 QWidget *window = QApplication::activeWindow(); |
87 QWidget *window = QApplication::activeWindow(); |
310 } |
312 } |
311 |
313 |
312 bool QSoftKeyManagerPrivateS60::setRightSoftkey(CEikButtonGroupContainer &cba) |
314 bool QSoftKeyManagerPrivateS60::setRightSoftkey(CEikButtonGroupContainer &cba) |
313 { |
315 { |
314 if (!setSoftkey(cba, QAction::NegativeSoftKey, RSK_POSITION)) { |
316 if (!setSoftkey(cba, QAction::NegativeSoftKey, RSK_POSITION)) { |
315 Qt::WindowType windowType = Qt::Window; |
317 const Qt::WindowType windowType = initialSoftKeySource |
316 QAction *action = requestedSoftKeyActions.value(0); |
318 ? initialSoftKeySource->window()->windowType() : Qt::Window; |
317 if (action) { |
|
318 QWidget *actionParent = action->parentWidget(); |
|
319 Q_ASSERT_X(actionParent, Q_FUNC_INFO, "No parent set for softkey action!"); |
|
320 |
|
321 QWidget *actionWindow = actionParent->window(); |
|
322 Q_ASSERT_X(actionWindow, Q_FUNC_INFO, "Softkey action does not have window!"); |
|
323 windowType = actionWindow->windowType(); |
|
324 } |
|
325 |
|
326 if (windowType != Qt::Dialog && windowType != Qt::Popup) { |
319 if (windowType != Qt::Dialog && windowType != Qt::Popup) { |
327 QString text(QSoftKeyManager::tr("Exit")); |
320 QString text(QSoftKeyManager::tr("Exit")); |
328 TPtrC nativeText = qt_QString2TPtrC(text); |
321 TPtrC nativeText = qt_QString2TPtrC(text); |
329 if (cbaHasImage[RSK_POSITION]) { |
322 if (cbaHasImage[RSK_POSITION]) { |
330 EikSoftkeyImage::SetLabel(&cba, false); |
323 EikSoftkeyImage::SetLabel(&cba, false); |
372 setSoftkeys(*nativeContainer); |
365 setSoftkeys(*nativeContainer); |
373 |
366 |
374 nativeContainer->DrawDeferred(); // 3.1 needs an extra invitation |
367 nativeContainer->DrawDeferred(); // 3.1 needs an extra invitation |
375 } |
368 } |
376 |
369 |
|
370 static void resetMenuBeingConstructed(TAny* /*aAny*/) |
|
371 { |
|
372 S60->menuBeingConstructed = false; |
|
373 } |
|
374 |
|
375 void QSoftKeyManagerPrivateS60::tryDisplayMenuBarL() |
|
376 { |
|
377 CleanupStack::PushL(TCleanupItem(resetMenuBeingConstructed, NULL)); |
|
378 S60->menuBeingConstructed = true; |
|
379 S60->menuBar()->TryDisplayMenuBarL(); |
|
380 CleanupStack::PopAndDestroy(); // Reset menuBeingConstructed to false in all cases |
|
381 } |
|
382 |
377 bool QSoftKeyManagerPrivateS60::handleCommand(int command) |
383 bool QSoftKeyManagerPrivateS60::handleCommand(int command) |
378 { |
384 { |
379 QAction *action = realSoftKeyActions.value(command); |
385 QAction *action = realSoftKeyActions.value(command); |
380 if (action) { |
386 if (action) { |
381 QVariant property = action->property(MENU_ACTION_PROPERTY); |
387 QVariant property = action->property(MENU_ACTION_PROPERTY); |
382 if (property.isValid() && property.toBool()) { |
388 if (property.isValid() && property.toBool()) { |
383 QT_TRAP_THROWING(S60->menuBar()->TryDisplayMenuBarL()); |
389 QT_TRAP_THROWING(tryDisplayMenuBarL()); |
384 } else if (action->menu()) { |
390 } else if (action->menu()) { |
385 // TODO: This is hack, in order to use exising QMenuBar implementation for Symbian |
391 // TODO: This is hack, in order to use exising QMenuBar implementation for Symbian |
386 // menubar needs to have widget to which it is associated. Since we want to associate |
392 // menubar needs to have widget to which it is associated. Since we want to associate |
387 // menubar to action (which is inherited from QObejct), we create and associate QWidget |
393 // menubar to action (which is inherited from QObject), we create and associate QWidget |
388 // to action and pass that for QMenuBar. This associates the menubar to action, and we |
394 // to action and pass that for QMenuBar. This associates the menubar to action, and we |
389 // can have own menubar for each action. |
395 // can have own menubar for each action. |
390 QWidget *actionContainer = action->property("_q_action_widget").value<QWidget*>(); |
396 QWidget *actionContainer = action->property("_q_action_widget").value<QWidget*>(); |
391 if(!actionContainer) { |
397 if(!actionContainer) { |
392 actionContainer = new QWidget(action->parentWidget()); |
398 actionContainer = new QWidget(action->parentWidget()); |
401 QVariant v; |
407 QVariant v; |
402 v.setValue(actionContainer); |
408 v.setValue(actionContainer); |
403 action->setProperty("_q_action_widget", v); |
409 action->setProperty("_q_action_widget", v); |
404 } |
410 } |
405 qt_symbian_next_menu_from_action(actionContainer); |
411 qt_symbian_next_menu_from_action(actionContainer); |
406 QT_TRAP_THROWING(S60->menuBar()->TryDisplayMenuBarL()); |
412 QT_TRAP_THROWING(tryDisplayMenuBarL()); |
407 } else { |
413 } |
408 Q_ASSERT(action->softKeyRole() != QAction::NoSoftKey); |
414 |
409 QWidget *actionParent = action->parentWidget(); |
415 Q_ASSERT(action->softKeyRole() != QAction::NoSoftKey); |
410 Q_ASSERT_X(actionParent, Q_FUNC_INFO, "No parent set for softkey action!"); |
416 QWidget *actionParent = action->parentWidget(); |
411 if (actionParent->isEnabled()) { |
417 Q_ASSERT_X(actionParent, Q_FUNC_INFO, "No parent set for softkey action!"); |
412 action->activate(QAction::Trigger); |
418 if (actionParent->isEnabled()) { |
413 return true; |
419 action->activate(QAction::Trigger); |
414 } |
420 return true; |
415 } |
421 } |
416 } |
422 } |
417 return false; |
423 return false; |
418 } |
424 } |
419 |
425 |