Changeset 769 for trunk/src/gui/kernel/qsoftkeymanager_s60.cpp
- Timestamp:
- Aug 2, 2010, 9:27:30 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
- Property svn:mergeinfo changed
/branches/vendor/nokia/qt/4.6.3 (added) merged: 768 /branches/vendor/nokia/qt/current merged: 767 /branches/vendor/nokia/qt/4.6.2 removed
- Property svn:mergeinfo changed
-
trunk/src/gui/kernel/qsoftkeymanager_s60.cpp
r651 r769 61 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 65 cachedCbaIconSize[0] = QSize(0,0); … … 67 67 cachedCbaIconSize[2] = QSize(0,0); 68 68 cachedCbaIconSize[3] = QSize(0,0); 69 skipNextUpdate = false;70 69 } 71 70 72 71 bool QSoftKeyManagerPrivateS60::skipCbaUpdate() 73 72 { 74 // lets not update softkeys if73 // Lets not update softkeys if 75 74 // 1. We don't have application panes, i.e. cba 76 // 2. S60 native dialog or menu is shown 77 if (QApplication::testAttribute(Qt::AA_S60DontConstructApplicationPanes) || 78 CCoeEnv::Static()->AppUi()->IsDisplayingMenuOrDialog() || skipNextUpdate) { 79 skipNextUpdate = false; 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 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. 80 CEikButtonGroupContainer *appUiCba = S60->buttonGroupContainer(); 81 if (!appUiCba) 82 return true; 83 // CEikButtonGroupContainer::Current returns 0 if CBA is not visible at all 84 CEikButtonGroupContainer *currentCba = CEikButtonGroupContainer::Current(); 85 // Check if softkey need to be update even they are not visible 86 bool cbaRespondsWhenInvisible = false; 87 QWidget *window = QApplication::activeWindow(); 88 if (window && (window->windowFlags() & Qt::WindowSoftkeysRespondHint)) 89 cbaRespondsWhenInvisible = true; 90 91 if (QApplication::testAttribute(Qt::AA_S60DontConstructApplicationPanes) 92 || (appUiCba != currentCba && !cbaRespondsWhenInvisible)) { 80 93 return true; 81 94 } … … 255 268 256 269 EikSoftkeyImage::SetImage(cba, *myimage, left); // Takes myimage ownership 270 cbaHasImage[position] = true; 257 271 ret = true; 258 272 } else { 259 273 // Restore softkey to text based 260 EikSoftkeyImage::SetLabel(cba, left); 274 if (cbaHasImage[position]) { 275 EikSoftkeyImage::SetLabel(cba, left); 276 cbaHasImage[position] = false; 277 } 261 278 } 262 279 } … … 274 291 int command = S60_COMMAND_START + position; 275 292 setNativeSoftkey(cba, position, command, nativeText); 276 cba.DimCommand(command, !action->isEnabled()); 293 const bool dimmed = !action->isEnabled() && !QSoftKeyManager::isForceEnabledInSofkeys(action); 294 cba.DimCommand(command, dimmed); 277 295 realSoftKeyActions.insert(command, action); 278 296 return true; … … 297 315 { 298 316 if (!setSoftkey(cba, QAction::NegativeSoftKey, RSK_POSITION)) { 299 Qt::WindowType windowType = Qt::Window; 300 QAction *action = requestedSoftKeyActions.value(0); 301 if (action) { 302 QWidget *actionParent = action->parentWidget(); 303 Q_ASSERT_X(actionParent, Q_FUNC_INFO, "No parent set for softkey action!"); 304 305 QWidget *actionWindow = actionParent->window(); 306 Q_ASSERT_X(actionWindow, Q_FUNC_INFO, "Softkey action does not have window!"); 307 windowType = actionWindow->windowType(); 308 } 309 317 const Qt::WindowType windowType = initialSoftKeySource 318 ? initialSoftKeySource->window()->windowType() : Qt::Window; 310 319 if (windowType != Qt::Dialog && windowType != Qt::Popup) { 311 320 QString text(QSoftKeyManager::tr("Exit")); 312 321 TPtrC nativeText = qt_QString2TPtrC(text); 313 EikSoftkeyImage::SetLabel(&cba, false); 322 if (cbaHasImage[RSK_POSITION]) { 323 EikSoftkeyImage::SetLabel(&cba, false); 324 cbaHasImage[RSK_POSITION] = false; 325 } 314 326 setNativeSoftkey(cba, RSK_POSITION, EAknSoftkeyExit, nativeText); 327 cba.DimCommand(EAknSoftkeyExit, false); 315 328 return true; 316 329 } … … 355 368 } 356 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 357 383 bool QSoftKeyManagerPrivateS60::handleCommand(int command) 358 384 { … … 361 387 QVariant property = action->property(MENU_ACTION_PROPERTY); 362 388 if (property.isValid() && property.toBool()) { 363 QT_TRAP_THROWING( S60->menuBar()->TryDisplayMenuBarL());389 QT_TRAP_THROWING(tryDisplayMenuBarL()); 364 390 } else if (action->menu()) { 365 391 // TODO: This is hack, in order to use exising QMenuBar implementation for Symbian 366 392 // menubar needs to have widget to which it is associated. Since we want to associate 367 // menubar to action (which is inherited from QOb ejct), we create and associate QWidget393 // menubar to action (which is inherited from QObject), we create and associate QWidget 368 394 // to action and pass that for QMenuBar. This associates the menubar to action, and we 369 395 // can have own menubar for each action. … … 384 410 } 385 411 qt_symbian_next_menu_from_action(actionContainer); 386 QT_TRAP_THROWING(S60->menuBar()->TryDisplayMenuBarL()); 387 // TODO: hack remove, it can happen that IsDisplayingMenuOrDialog return false 388 // in updateSoftKeys_sys, and we will override menu CBA with our own 389 skipNextUpdate = true; 390 } else { 391 Q_ASSERT(action->softKeyRole() != QAction::NoSoftKey); 392 QWidget *actionParent = action->parentWidget(); 393 Q_ASSERT_X(actionParent, Q_FUNC_INFO, "No parent set for softkey action!"); 394 if (actionParent->isEnabled()) { 395 action->activate(QAction::Trigger); 396 return true; 397 } 412 QT_TRAP_THROWING(tryDisplayMenuBarL()); 413 } 414 415 Q_ASSERT(action->softKeyRole() != QAction::NoSoftKey); 416 QWidget *actionParent = action->parentWidget(); 417 Q_ASSERT_X(actionParent, Q_FUNC_INFO, "No parent set for softkey action!"); 418 if (actionParent->isEnabled()) { 419 action->activate(QAction::Trigger); 420 return true; 398 421 } 399 422 }
Note:
See TracChangeset
for help on using the changeset viewer.