Ignore:
Timestamp:
Aug 2, 2010, 9:27:30 PM (15 years ago)
Author:
Dmitry A. Kuminov
Message:

trunk: Merged in qt 4.6.3 sources from branches/vendor/nokia/qt.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/src/gui/kernel/qsoftkeymanager_s60.cpp

    r651 r769  
    6161const int RSK_POSITION = 2;
    6262
    63 QSoftKeyManagerPrivateS60::QSoftKeyManagerPrivateS60()
     63QSoftKeyManagerPrivateS60::QSoftKeyManagerPrivateS60() : cbaHasImage(4) // 4 since MSK position index is 3
    6464{
    6565    cachedCbaIconSize[0] = QSize(0,0);
     
    6767    cachedCbaIconSize[2] = QSize(0,0);
    6868    cachedCbaIconSize[3] = QSize(0,0);
    69     skipNextUpdate = false;
    7069}
    7170
    7271bool QSoftKeyManagerPrivateS60::skipCbaUpdate()
    7372{
    74     // lets not update softkeys if
     73    // Lets not update softkeys if
    7574    // 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)) {
    8093        return true;
    8194    }
     
    255268
    256269            EikSoftkeyImage::SetImage(cba, *myimage, left); // Takes myimage ownership
     270            cbaHasImage[position] = true;
    257271            ret = true;
    258272        } else {
    259273            // Restore softkey to text based
    260             EikSoftkeyImage::SetLabel(cba, left);
     274            if (cbaHasImage[position]) {
     275                EikSoftkeyImage::SetLabel(cba, left);
     276                cbaHasImage[position] = false;
     277            }
    261278        }
    262279    }
     
    274291        int command = S60_COMMAND_START + position;
    275292        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);
    277295        realSoftKeyActions.insert(command, action);
    278296        return true;
     
    297315{
    298316    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;
    310319        if (windowType != Qt::Dialog && windowType != Qt::Popup) {
    311320            QString text(QSoftKeyManager::tr("Exit"));
    312321            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            }
    314326            setNativeSoftkey(cba, RSK_POSITION, EAknSoftkeyExit, nativeText);
     327            cba.DimCommand(EAknSoftkeyExit, false);
    315328            return true;
    316329        }
     
    355368}
    356369
     370static void resetMenuBeingConstructed(TAny* /*aAny*/)
     371{
     372    S60->menuBeingConstructed = false;
     373}
     374
     375void 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
    357383bool QSoftKeyManagerPrivateS60::handleCommand(int command)
    358384{
     
    361387        QVariant property = action->property(MENU_ACTION_PROPERTY);
    362388        if (property.isValid() && property.toBool()) {
    363             QT_TRAP_THROWING(S60->menuBar()->TryDisplayMenuBarL());
     389            QT_TRAP_THROWING(tryDisplayMenuBarL());
    364390        } else if (action->menu()) {
    365391            // TODO: This is hack, in order to use exising QMenuBar implementation for Symbian
    366392            // menubar needs to have widget to which it is associated. Since we want to associate
    367             // 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
    368394            // to action and pass that for QMenuBar. This associates the menubar to action, and we
    369395            // can have own menubar for each action.
     
    384410            }
    385411            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;
    398421        }
    399422    }
Note: See TracChangeset for help on using the changeset viewer.