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.cpp

    r651 r769  
    5656QSoftKeyManager *QSoftKeyManagerPrivate::self = 0;
    5757
    58 const char *QSoftKeyManager::standardSoftKeyText(StandardSoftKey standardKey)
    59 {
    60     const char *softKeyText = 0;
     58QString QSoftKeyManager::standardSoftKeyText(StandardSoftKey standardKey)
     59{
     60    QString softKeyText;
    6161    switch (standardKey) {
    6262    case OkSoftKey:
    63         softKeyText = QT_TRANSLATE_NOOP("QSoftKeyManager", "Ok");
     63        softKeyText = QSoftKeyManager::tr("Ok");
    6464        break;
    6565    case SelectSoftKey:
    66         softKeyText = QT_TRANSLATE_NOOP("QSoftKeyManager", "Select");
     66        softKeyText = QSoftKeyManager::tr("Select");
    6767        break;
    6868    case DoneSoftKey:
    69         softKeyText = QT_TRANSLATE_NOOP("QSoftKeyManager", "Done");
     69        softKeyText = QSoftKeyManager::tr("Done");
    7070        break;
    7171    case MenuSoftKey:
    72         softKeyText = QT_TRANSLATE_NOOP("QSoftKeyManager", "Options");
     72        softKeyText = QSoftKeyManager::tr("Options");
    7373        break;
    7474    case CancelSoftKey:
    75         softKeyText = QT_TRANSLATE_NOOP("QSoftKeyManager", "Cancel");
     75        softKeyText = QSoftKeyManager::tr("Cancel");
    7676        break;
    7777    default:
     
    101101QAction *QSoftKeyManager::createAction(StandardSoftKey standardKey, QWidget *actionWidget)
    102102{
    103     const char* text = standardSoftKeyText(standardKey);
    104     QAction *action = new QAction(QSoftKeyManager::tr(text), actionWidget);
     103    QAction *action = new QAction(standardSoftKeyText(standardKey), actionWidget);
    105104    QAction::SoftKeyRole softKeyRole = QAction::NoSoftKey;
    106105    switch (standardKey) {
     
    117116    }
    118117    action->setSoftKeyRole(softKeyRole);
     118    action->setVisible(false);
     119    setForceEnabledInSoftkeys(action);
    119120    return action;
    120121}
     
    170171    Q_D(QSoftKeyManager);
    171172    bool ret = false;
    172     QList<QAction*> actions = source.actions();
    173     for (int i = 0; i < actions.count(); ++i) {
    174         if (actions.at(i)->softKeyRole() != QAction::NoSoftKey) {
    175             d->requestedSoftKeyActions.insert(level, actions.at(i));
     173    foreach(QAction *action, source.actions()) {
     174        if (action->softKeyRole() != QAction::NoSoftKey
     175            && (action->isVisible() || isForceEnabledInSofkeys(action))) {
     176            d->requestedSoftKeyActions.insert(level, action);
    176177            ret = true;
    177178        }
    178179    }
    179180    return ret;
     181}
     182
     183
     184static bool isChildOf(const QWidget *c, const QWidget *p)
     185{
     186    while (c) {
     187        if (c == p)
     188            return true;
     189        c = c->parentWidget();
     190    }
     191    return false;
    180192}
    181193
     
    186198    if (!previousSource) {
    187199        // Initial source is primarily focuswidget and secondarily activeWindow
    188         source = QApplication::focusWidget();
    189         if (!source)
    190             source = QApplication::activeWindow();
     200        QWidget *focus = QApplication::focusWidget();
     201        QWidget *popup = QApplication::activePopupWidget();
     202        if (popup) {
     203            if (isChildOf(focus, popup))
     204                source = focus;
     205            else
     206                source = popup;
     207        }
     208        if (!source) {
     209            QWidget *modal = QApplication::activeModalWidget();
     210            if (modal) {
     211                if (isChildOf(focus, modal))
     212                    source = focus;
     213                else
     214                    source = modal;
     215            }
     216        }
     217        if (!source) {
     218            source = focus;
     219            if (!source)
     220                source = QApplication::activeWindow();
     221        }
    191222    } else {
    192223        // Softkey merging is based on four criterias
     
    212243    bool recursiveMerging = false;
    213244    QWidget *source = softkeySource(NULL, recursiveMerging);
    214     do {
    215         if (source) {
    216             bool added = appendSoftkeys(*source, level);
    217             source = softkeySource(source, recursiveMerging);
    218             level = added ? ++level : level;
    219         }
    220     } while (source);
     245    d->initialSoftKeySource = source;
     246    while (source) {
     247        if (appendSoftkeys(*source, level))
     248            ++level;
     249        source = softkeySource(source, recursiveMerging);
     250    }
    221251
    222252    d->updateSoftKeys_sys();
    223253    return true;
     254}
     255
     256void QSoftKeyManager::setForceEnabledInSoftkeys(QAction *action)
     257{
     258    action->setProperty(FORCE_ENABLED_PROPERTY, QVariant(true));
     259}
     260
     261bool QSoftKeyManager::isForceEnabledInSofkeys(QAction *action)
     262{
     263    bool ret = false;
     264    QVariant property = action->property(FORCE_ENABLED_PROPERTY);
     265    if (property.isValid() && property.toBool())
     266        ret = true;
     267    return ret;
    224268}
    225269
Note: See TracChangeset for help on using the changeset viewer.