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/widgets/qmenu.cpp

    r651 r769  
    118118            parentWidget = parentWidget->parentWidget();
    119119        setParent(parentWidget, Qt::Window | Qt::Tool);
    120         setAttribute(Qt::WA_DeleteOnClose, true);
     120        setAttribute(Qt::WA_DeleteOnClose, true);
    121121        setAttribute(Qt::WA_X11NetWmWindowTypeMenu, true);
    122122        setWindowTitle(p->windowTitle());
     
    169169    selectAction = QSoftKeyManager::createKeyedAction(QSoftKeyManager::SelectSoftKey, Qt::Key_Select, q);
    170170    cancelAction = QSoftKeyManager::createKeyedAction(QSoftKeyManager::CancelSoftKey, Qt::Key_Back, q);
    171     selectAction->setVisible(false); // Don't show these in the menu
    172     cancelAction->setVisible(false);
     171    selectAction->setPriority(QAction::HighPriority);
     172    cancelAction->setPriority(QAction::HighPriority);
    173173    q->addAction(selectAction);
    174174    q->addAction(cancelAction);
     
    262262    const int fw = style->pixelMetric(QStyle::PM_MenuPanelWidth, &opt, q);
    263263    const int deskFw = style->pixelMetric(QStyle::PM_MenuDesktopFrameWidth, &opt, q);
    264 
    265     const int sfcMargin = style->sizeFromContents(QStyle::CT_Menu, &opt, QApplication::globalStrut(), q).width() - QApplication::globalStrut().width();
    266     const int min_column_width = q->minimumWidth() - (sfcMargin + leftmargin + rightmargin + 2 * (fw + hmargin));
    267264    const int tearoffHeight = tearoff ? style->pixelMetric(QStyle::PM_MenuTearoffHeight, &opt, q) : 0;
    268265
     
    338335
    339336        if (!sz.isEmpty()) {
    340             max_column_width = qMax(min_column_width, qMax(max_column_width, sz.width()));
     337            max_column_width = qMax(max_column_width, sz.width());
    341338            //wrapping
    342339            if (!scroll &&
     
    352349
    353350    max_column_width += tabWidth; //finally add in the tab width
     351    const int sfcMargin = style->sizeFromContents(QStyle::CT_Menu, &opt, QApplication::globalStrut(), q).width() - QApplication::globalStrut().width();
     352    const int min_column_width = q->minimumWidth() - (sfcMargin + leftmargin + rightmargin + 2 * (fw + hmargin));
     353    max_column_width = qMax(min_column_width, max_column_width);
     354
    354355
    355356    //calculate position
     
    992993}
    993994
    994 class ExceptionGuard
    995 {
    996 public:
    997     inline ExceptionGuard(bool *w = 0) : watched(w) { Q_ASSERT(!(*watched)); *watched = true; }
    998     inline ~ExceptionGuard() { *watched = false; }
    999     inline operator bool() { return *watched; }
    1000 private:
    1001     bool *watched;
    1002 };
    1003 
    1004995void QMenuPrivate::activateCausedStack(const QList<QPointer<QWidget> > &causedStack, QAction *action, QAction::ActionEvent action_e, bool self)
    1005996{
    1006     ExceptionGuard guard(&activationRecursionGuard);
     997    QBoolBlocker guard(activationRecursionGuard);
    1007998#ifdef QT3_SUPPORT
    1008999    const int actionId = q_func()->findIdForAction(action);
     
    12271218        option->menuItemType = QStyleOptionMenuItem::Separator;
    12281219    else if (d->defaultAction == action)
    1229             option->menuItemType = QStyleOptionMenuItem::DefaultItem;
     1220        option->menuItemType = QStyleOptionMenuItem::DefaultItem;
    12301221    else
    12311222        option->menuItemType = QStyleOptionMenuItem::Normal;
     
    14071398{
    14081399    Q_D(QMenu);
    1409     QHash<QAction *, QWidget *>::iterator it = d->widgetItems.begin();
    1410     for (; it != d->widgetItems.end(); ++it) {
    1411         if (QWidget *widget = it.value()) {
    1412             QWidgetAction *action = static_cast<QWidgetAction *>(it.key());
    1413             action->releaseWidget(widget);
    1414             *it = 0;
     1400    if (!d->widgetItems.isEmpty()) {  // avoid detach on shared null hash
     1401        QHash<QAction *, QWidget *>::iterator it = d->widgetItems.begin();
     1402        for (; it != d->widgetItems.end(); ++it) {
     1403            if (QWidget *widget = it.value()) {
     1404                QWidgetAction *action = static_cast<QWidgetAction *>(it.key());
     1405                action->releaseWidget(widget);
     1406                *it = 0;
     1407            }
    14151408        }
    14161409    }
     
    17201713{
    17211714    QList<QAction*> acts = actions();
     1715
    17221716    for(int i = 0; i < acts.size(); i++) {
     1717#ifdef QT_SOFTKEYS_ENABLED
     1718        Q_D(QMenu);
     1719        // Lets not touch to our internal softkey actions
     1720        if(acts[i] == d->selectAction || acts[i] == d->cancelAction)
     1721            continue;
     1722#endif
    17231723        removeAction(acts[i]);
    17241724        if (acts[i]->parent() == this && acts[i]->d_func()->widgets.isEmpty())
     
    24082408        }
    24092409        return true;
     2410#endif
     2411#ifdef QT_SOFTKEYS_ENABLED
     2412    case QEvent::LanguageChange: {
     2413        d->selectAction->setText(QSoftKeyManager::standardSoftKeyText(QSoftKeyManager::SelectSoftKey));
     2414        d->cancelAction->setText(QSoftKeyManager::standardSoftKeyText(QSoftKeyManager::CancelSoftKey));
     2415        }
     2416        break;
    24102417#endif
    24112418    default:
     
    27982805    QAction *action = d->actionAt(e->pos());
    27992806    if (!action) {
    2800         if (d->hasHadMouse)
     2807        if (d->hasHadMouse
     2808            && (!d->currentAction
     2809                || !(d->currentAction->menu() && d->currentAction->menu()->isVisible())))
    28012810            d->setCurrentAction(0);
    28022811        return;
     
    29202929    if (isVisible()) {
    29212930        d->updateActionRects();
    2922         resize(sizeHint());
     2931        resize(sizeHint());
    29232932        update();
    29242933    }
Note: See TracChangeset for help on using the changeset viewer.