Changeset 769 for trunk/src/gui/widgets


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:
32 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/src/gui/widgets/qabstractbutton.cpp

    r651 r769  
    5858#define AUTO_REPEAT_INTERVAL 100
    5959
    60 extern bool qt_tab_all_widgets;
     60Q_GUI_EXPORT extern bool qt_tab_all_widgets;
    6161
    6262/*!
  • trunk/src/gui/widgets/qabstractscrollarea.cpp

    r651 r769  
    395395        q->style()->styleHint(QStyle::SH_ScrollView_FrameOnlyAroundContents, &opt, q)) {
    396396        controlsRect = widgetRect;
    397         const int extra = q->style()->pixelMetric(QStyle::PM_ScrollView_ScrollBarSpacing);
     397        const int extra = q->style()->pixelMetric(QStyle::PM_ScrollView_ScrollBarSpacing, &opt, q);
    398398        const QPoint cornerExtra(needv ? extra : 0, needh ? extra : 0);
    399399        QRect frameRect = widgetRect;
  • trunk/src/gui/widgets/qabstractslider.cpp

    r651 r769  
    4848#include "qaccessible.h"
    4949#endif
    50 #ifdef QT_KEYPAD_NAVIGATION
    51 #include "qtabwidget.h" // Needed in inTabWidget()
    52 #endif // QT_KEYPAD_NAVIGATION
    5350#include <limits.h>
    5451
     
    215212
    216213QAbstractSliderPrivate::QAbstractSliderPrivate()
    217     : minimum(0), maximum(99), singleStep(1), pageStep(10),
    218       value(0), position(0), pressValue(-1), offset_accumulated(0), tracking(true),
     214    : minimum(0), maximum(99), pageStep(10), value(0), position(0), pressValue(-1),
     215      singleStep(1), offset_accumulated(0), tracking(true),
    219216      blocktracking(false), pressed(false),
    220217      invertedAppearance(false), invertedControls(false),
     
    689686}
    690687
     688bool QAbstractSliderPrivate::scrollByDelta(Qt::Orientation orientation, Qt::KeyboardModifiers modifiers, int delta)
     689{
     690    Q_Q(QAbstractSlider);
     691    int stepsToScroll = 0;
     692    // in Qt scrolling to the right gives negative values.
     693    if (orientation == Qt::Horizontal)
     694        delta = -delta;
     695    qreal offset = qreal(delta) / 120;
     696
     697    if ((modifiers & Qt::ControlModifier) || (modifiers & Qt::ShiftModifier)) {
     698        // Scroll one page regardless of delta:
     699        stepsToScroll = qBound(-pageStep, int(offset * pageStep), pageStep);
     700        offset_accumulated = 0;
     701    } else {
     702        // Calculate how many lines to scroll. Depending on what delta is (and
     703        // offset), we might end up with a fraction (e.g. scroll 1.3 lines). We can
     704        // only scroll whole lines, so we keep the reminder until next event.
     705        qreal stepsToScrollF =
     706#ifndef QT_NO_WHEELEVENT
     707                QApplication::wheelScrollLines() *
     708#endif
     709                offset * effectiveSingleStep();
     710        // Check if wheel changed direction since last event:
     711        if (offset_accumulated != 0 && (offset / offset_accumulated) < 0)
     712            offset_accumulated = 0;
     713
     714        offset_accumulated += stepsToScrollF;
     715        stepsToScroll = qBound(-pageStep, int(offset_accumulated), pageStep);
     716        offset_accumulated -= int(offset_accumulated);
     717        if (stepsToScroll == 0)
     718            return false;
     719    }
     720
     721    if (invertedControls)
     722        stepsToScroll = -stepsToScroll;
     723
     724    int prevValue = value;
     725    position = overflowSafeAdd(stepsToScroll); // value will be updated by triggerAction()
     726    q->triggerAction(QAbstractSlider::SliderMove);
     727
     728    if (prevValue == value) {
     729        offset_accumulated = 0;
     730        return false;
     731    }
     732    return true;
     733}
    691734
    692735/*!
     
    698741    Q_D(QAbstractSlider);
    699742    e->ignore();
    700     if (e->orientation() != d->orientation && !rect().contains(e->pos()))
    701         return;
    702 
    703     int stepsToScroll = 0;
    704     qreal offset = qreal(e->delta()) / 120;
    705 
    706     if ((e->modifiers() & Qt::ControlModifier) || (e->modifiers() & Qt::ShiftModifier)) {
    707         // Scroll one page regardless of delta:
    708         stepsToScroll = qBound(-d->pageStep, int(offset * d->pageStep), d->pageStep);
    709         d->offset_accumulated = 0;
    710     } else {
    711         // Calculate how many lines to scroll. Depending on what delta is (and
    712         // offset), we might end up with a fraction (e.g. scroll 1.3 lines). We can
    713         // only scroll whole lines, so we keep the reminder until next event.
    714         qreal stepsToScrollF = offset * QApplication::wheelScrollLines() * d->effectiveSingleStep();
    715         // Check if wheel changed direction since last event:
    716         if (d->offset_accumulated != 0 && (offset / d->offset_accumulated) < 0)
    717             d->offset_accumulated = 0;
    718 
    719         d->offset_accumulated += stepsToScrollF;
    720         stepsToScroll = qBound(-d->pageStep, int(d->offset_accumulated), d->pageStep);
    721         d->offset_accumulated -= int(d->offset_accumulated);
    722         if (stepsToScroll == 0)
    723             return;
    724     }
    725 
    726     if (d->invertedControls)
    727         stepsToScroll = -stepsToScroll;
    728 
    729     int prevValue = d->value;
    730     d->position = d->overflowSafeAdd(stepsToScroll); // value will be updated by triggerAction()
    731     triggerAction(SliderMove);
    732 
    733     if (prevValue == d->value)
    734         d->offset_accumulated = 0;
    735     else
     743    int delta = e->delta();
     744    if (d->scrollByDelta(e->orientation(), e->modifiers(), delta))
    736745        e->accept();
    737746}
    738 #endif
    739 #ifdef QT_KEYPAD_NAVIGATION
    740 /*!
    741     \internal
    742 
    743     Tells us if it there is currently a reachable widget by keypad navigation in
    744     a certain \a orientation.
    745     If no navigation is possible, occuring key events in that \a orientation may
    746     be used to interact with the value in the focussed widget, even though it
    747     currently has not the editFocus.
    748 
    749     \sa QWidgetPrivate::widgetInNavigationDirection(), QWidget::hasEditFocus()
    750 */
    751 inline static bool canKeypadNavigate(Qt::Orientation orientation)
    752 {
    753     return orientation == Qt::Horizontal?
    754             (QWidgetPrivate::widgetInNavigationDirection(QWidgetPrivate::DirectionEast)
    755                     || QWidgetPrivate::widgetInNavigationDirection(QWidgetPrivate::DirectionWest))
    756             :(QWidgetPrivate::widgetInNavigationDirection(QWidgetPrivate::DirectionNorth)
    757                     || QWidgetPrivate::widgetInNavigationDirection(QWidgetPrivate::DirectionSouth));
    758 }
    759 /*!
    760     \internal
    761 
    762     Checks, if the \a widget is inside a QTabWidget. If is is inside
    763     one, left/right key events will be used to switch between tabs in keypad
    764     navigation. If there is no QTabWidget, the horizontal key events can be used to
    765     interact with the value in the focussed widget, even though it currently has
    766     not the editFocus.
    767 
    768     \sa QWidget::hasEditFocus()
    769 */
    770 inline static bool inTabWidget(QWidget *widget)
    771 {
    772     for (QWidget *tabWidget = widget; tabWidget; tabWidget = tabWidget->parentWidget())
    773         if (qobject_cast<const QTabWidget*>(tabWidget))
    774             return true;
    775     return false;
    776 }
    777 #endif // QT_KEYPAD_NAVIGATION
     747
     748#endif
     749
    778750/*!
    779751    \reimp
     
    841813                    && (!hasEditFocus() && QApplication::navigationMode() == Qt::NavigationModeKeypadTabOrder
    842814                    || d->orientation == Qt::Vertical
    843                     || !hasEditFocus() && (canKeypadNavigate(Qt::Horizontal) || inTabWidget(this)))) {
     815                    || !hasEditFocus()
     816                    && (QWidgetPrivate::canKeypadNavigate(Qt::Horizontal) || QWidgetPrivate::inTabWidget(this)))) {
    844817                ev->ignore();
    845818                return;
     
    860833                    && (!hasEditFocus() && QApplication::navigationMode() == Qt::NavigationModeKeypadTabOrder
    861834                    || d->orientation == Qt::Vertical
    862                     || !hasEditFocus() && (canKeypadNavigate(Qt::Horizontal) || inTabWidget(this)))) {
     835                    || !hasEditFocus()
     836                    && (QWidgetPrivate::canKeypadNavigate(Qt::Horizontal) || QWidgetPrivate::inTabWidget(this)))) {
    863837                ev->ignore();
    864838                return;
     
    880854                    && (QApplication::navigationMode() == Qt::NavigationModeKeypadTabOrder
    881855                    || d->orientation == Qt::Horizontal
    882                     || !hasEditFocus() && canKeypadNavigate(Qt::Vertical))) {
     856                    || !hasEditFocus() && QWidgetPrivate::canKeypadNavigate(Qt::Vertical))) {
    883857                ev->ignore();
    884858                break;
     
    893867                    && (QApplication::navigationMode() == Qt::NavigationModeKeypadTabOrder
    894868                    || d->orientation == Qt::Horizontal
    895                     || !hasEditFocus() && canKeypadNavigate(Qt::Vertical))) {
     869                    || !hasEditFocus() && QWidgetPrivate::canKeypadNavigate(Qt::Vertical))) {
    896870                ev->ignore();
    897871                break;
  • trunk/src/gui/widgets/qabstractslider_p.h

    r651 r769  
    139139        q->triggerAction(repeatAction);
    140140    }
     141    bool scrollByDelta(Qt::Orientation orientation, Qt::KeyboardModifiers modifiers, int delta);
    141142};
    142143
  • trunk/src/gui/widgets/qabstractspinbox.h

    r651 r769  
    138138    void keyPressEvent(QKeyEvent *event);
    139139    void keyReleaseEvent(QKeyEvent *event);
     140#ifndef QT_NO_WHEELEVENT
    140141    void wheelEvent(QWheelEvent *event);
     142#endif
    141143    void focusInEvent(QFocusEvent *event);
    142144    void focusOutEvent(QFocusEvent *event);
  • trunk/src/gui/widgets/qcombobox.cpp

    r651 r769  
    7777# include <private/qeffects_p.h>
    7878#endif
     79#if defined(Q_WS_S60)
     80#include "private/qt_s60_p.h"
     81#endif
     82
    7983QT_BEGIN_NAMESPACE
    8084
     
    140144        break;
    141145    }
    142 
     146    if (qVariantCanConvert<QBrush>(index.data(Qt::BackgroundRole))) {
     147        menuOption.palette.setBrush(QPalette::All, QPalette::Background,
     148                                    qvariant_cast<QBrush>(index.data(Qt::BackgroundRole)));
     149    }
    143150    menuOption.text = index.model()->data(index, Qt::DisplayRole).toString()
    144151                           .replace(QLatin1Char('&'), QLatin1String("&&"));
     
    533540    const bool usePopup = combo->style()->styleHint(QStyle::SH_ComboBox_Popup, &opt, combo);
    534541#ifndef QT_NO_SCROLLBAR
     542#ifndef Q_WS_S60
    535543    if (usePopup)
    536544        view->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
     545#endif
    537546#endif
    538547    if (combo->style()->styleHint(QStyle::SH_ComboBox_ListMouseTracking, &opt, combo) ||
     
    608617                               combo->style()->styleHint(QStyle::SH_ComboBox_Popup, &opt, combo));
    609618        setFrameStyle(combo->style()->styleHint(QStyle::SH_ComboBox_PopupFrameStyle, &opt, combo));
    610     }
     619#ifdef QT_SOFTKEYS_ENABLED
     620    } else if (e->type() == QEvent::LanguageChange) {
     621        selectAction->setText(QSoftKeyManager::standardSoftKeyText(QSoftKeyManager::SelectSoftKey));
     622        cancelAction->setText(QSoftKeyManager::standardSoftKeyText(QSoftKeyManager::CancelSoftKey));
     623#endif
     624    }
     625
    611626    QWidget::changeEvent(e);
    612627}
     
    24112426        listRect.moveLeft(above.x());
    24122427
     2428#ifndef Q_WS_S60
    24132429        // Position vertically so the curently selected item lines up
    24142430        // with the combo box.
     
    24162432        const int offset = listRect.top() - currentItemRect.top();
    24172433        listRect.moveTop(above.y() + offset - listRect.top());
     2434#endif
    24182435
    24192436
     
    24222439        // important to show as much as possible of the popup.
    24232440        const int height = !boundToScreen ? listRect.height() : qMin(listRect.height(), screen.height());
     2441#ifdef Q_WS_S60
     2442        //popup needs to be stretched with screen minimum dimension
     2443        listRect.setHeight(qMin(screen.height(), screen.width()));
     2444#else
    24242445        listRect.setHeight(height);
     2446#endif
     2447
    24252448        if (boundToScreen) {
    24262449            if (listRect.top() < screen.top())
     
    24292452                listRect.moveBottom(screen.bottom());
    24302453        }
     2454#ifdef Q_WS_S60
     2455        if (screen.width() < screen.height()) {
     2456            // in portait, menu should be positioned above softkeys
     2457            listRect.moveBottom(screen.bottom());
     2458        } else {
     2459            TRect staConTopRect = TRect();
     2460            AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EStaconTop, staConTopRect);
     2461            listRect.setWidth(listRect.height());
     2462            //by default popup is centered on screen in landscape
     2463            listRect.moveCenter(screen.center());
     2464            if (staConTopRect.IsEmpty()) {
     2465                // landscape without stacon, menu should be at the right
     2466                (opt.direction == Qt::LeftToRight) ? listRect.setRight(screen.right()) :
     2467                                                     listRect.setLeft(screen.left());
     2468            }
     2469        }
     2470#endif
    24312471    } else if (!boundToScreen || listRect.height() <= belowHeight) {
    24322472        listRect.moveTopLeft(below);
     
    26372677            d->updateLineEditGeometry();
    26382678        d->setLayoutItemMargins(QStyle::SE_ComboBoxLayoutItem);
     2679
     2680#ifdef Q_WS_S60
     2681        if (d->container) {
     2682            QStyleOptionComboBox opt;
     2683            initStyleOption(&opt);
     2684
     2685            if (style()->styleHint(QStyle::SH_ComboBox_Popup, &opt, this)) {
     2686                const QRect screen = d->popupGeometry(QApplication::desktop()->screenNumber(this));
     2687
     2688                QRect listRect(style()->subControlRect(QStyle::CC_ComboBox, &opt,
     2689                    QStyle::SC_ComboBoxListBoxPopup, this));
     2690                listRect.setHeight(qMin(screen.height(), screen.width()));
     2691
     2692                if (screen.width() < screen.height()) {
     2693                    // in portait, menu should be positioned above softkeys
     2694                    listRect.moveBottom(screen.bottom());
     2695                } else {
     2696                    TRect staConTopRect = TRect();
     2697                    AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EStaconTop, staConTopRect);
     2698                    listRect.setWidth(listRect.height());
     2699                    //by default popup is centered on screen in landscape
     2700                    listRect.moveCenter(screen.center());
     2701                    if (staConTopRect.IsEmpty()) {
     2702                        // landscape without stacon, menu should be at the right
     2703                        (opt.direction == Qt::LeftToRight) ? listRect.setRight(screen.right()) :
     2704                                                             listRect.setLeft(screen.left());
     2705                    }
     2706                    d->container->setGeometry(listRect);
     2707                }
     2708            }
     2709        }
     2710#endif
     2711
    26392712        // ### need to update scrollers etc. as well here
    26402713        break;
  • trunk/src/gui/widgets/qcombobox.h

    r651 r769  
    246246    void keyPressEvent(QKeyEvent *e);
    247247    void keyReleaseEvent(QKeyEvent *e);
     248#ifndef QT_NO_WHEELEVENT
    248249    void wheelEvent(QWheelEvent *e);
     250#endif
    249251    void contextMenuEvent(QContextMenuEvent *e);
    250252    void inputMethodEvent(QInputMethodEvent *);
  • trunk/src/gui/widgets/qcombobox_p.h

    r651 r769  
    201201        if (sliderAction == QAbstractSlider::SliderSingleStepAdd)
    202202            menuOpt.state |= QStyle::State_DownArrow;
     203#ifndef Q_WS_S60
    203204        p.eraseRect(rect());
     205#endif
    204206        style()->drawControl(QStyle::CE_MenuScroller, &menuOpt, &p);
    205207    }
     
    271273               const QModelIndex &index) const {
    272274        QStyleOptionMenuItem opt = getStyleOption(option, index);
     275#ifndef Q_WS_S60
    273276        painter->fillRect(option.rect, opt.palette.background());
     277#endif
    274278        mCombo->style()->drawControl(QStyle::CE_MenuItem, &opt, painter, mCombo);
    275279    }
  • trunk/src/gui/widgets/qdialogbuttonbox.cpp

    r651 r769  
    10181018    new role.
    10191019
     1020    \note The button box takes ownership of the button.
     1021
    10201022    \sa removeButton(), clear()
    10211023*/
  • trunk/src/gui/widgets/qdockarealayout.cpp

    r651 r769  
    19911991            const int tabBarShape = 0;
    19921992#endif
    1993             QDockAreaLayoutInfo *info = new QDockAreaLayoutInfo(sep, dockPos, o,
    1994                                                                 tabBarShape, mainWindow);
    1995             QDockAreaLayoutItem item(info);
     1993            QDockAreaLayoutItem item(new QDockAreaLayoutInfo(sep, dockPos, o,
     1994                                                                tabBarShape, mainWindow));
    19961995            stream >> item.pos >> item.size >> dummy >> dummy;
    1997             if (!info->restoreState(stream, widgets, testing))
     1996            //we need to make sure the element is in the list so the dock widget can eventually be docked correctly
     1997            if (!testing)
     1998                item_list.append(item);
     1999           
     2000            //here we need to make sure we change the item in the item_list
     2001            QDockAreaLayoutItem &lastItem = testing ? item : item_list.last();
     2002
     2003            if (!lastItem.subinfo->restoreState(stream, widgets, testing))
    19982004                return false;
    19992005
    2000             if (!testing) {
    2001                 item_list.append(item);
    2002             }
    20032006        } else {
    20042007            return false;
     
    26362639    bottom_hint = bottom_hint.boundedTo(bottom_max).expandedTo(bottom_min);
    26372640
    2638     fallbackToSizeHints = !have_central;
     2641    fallbackToSizeHints = false;
    26392642
    26402643    if (_ver_struct_list != 0) {
  • trunk/src/gui/widgets/qlinecontrol.cpp

    r651 r769  
    6666    If the text has changed will emit displayTextChanged()
    6767*/
    68 void QLineControl::updateDisplayText()
     68void QLineControl::updateDisplayText(bool forceUpdate)
    6969{
    7070    QString orig = m_textLayout.text();
     
    103103    m_ascent = qRound(l.ascent());
    104104
    105     if (str != orig)
     105    if (str != orig || forceUpdate)
    106106        emit displayTextChanged(str);
    107107}
     
    477477    }
    478478    m_textLayout.setAdditionalFormats(formats);
    479     updateDisplayText();
     479    updateDisplayText(/*force*/ true);
    480480    if (cursorPositionChanged)
    481481        emitCursorPositionChanged();
     
    13721372#ifndef QT_NO_SHORTCUT
    13731373        case QEvent::ShortcutOverride:{
     1374            if (isReadOnly())
     1375                return false;
    13741376            QKeyEvent* ke = static_cast<QKeyEvent*>(ev);
    13751377            if (ke == QKeySequence::Copy
  • trunk/src/gui/widgets/qlinecontrol_p.h

    r651 r769  
    240240    void removeSelectedText();
    241241    void internalSetText(const QString &txt, int pos = -1, bool edited = true);
    242     void updateDisplayText();
     242    void updateDisplayText(bool forceUpdate = false);
    243243
    244244    void internalInsert(const QString &s);
  • trunk/src/gui/widgets/qlineedit.cpp

    r651 r769  
    739739        return false;
    740740    }
    741     setCursorPosition(newPos);
    742     setSelection(qMin(newMarkAnchor, newMarkDrag), qAbs(newMarkAnchor - newMarkDrag));
     741    int selstart = qMin(newMarkAnchor, newMarkDrag);
     742    int sellength = qAbs(newMarkAnchor - newMarkDrag);
     743    if (selstart == newPos) {
     744        selstart = qMax(newMarkAnchor, newMarkDrag);
     745        sellength = -sellength;
     746    }
     747    //setSelection also set the position
     748    setSelection(selstart, sellength);
    743749    return true;
    744750}
  • trunk/src/gui/widgets/qlineedit_p.cpp

    r651 r769  
    130130{
    131131    Q_Q(QLineEdit);
    132     if (control->preeditAreaText().isEmpty()) {
     132    if (!control->text().isEmpty() && control->preeditAreaText().isEmpty()) {
    133133        QStyleOptionFrameV2 opt;
    134134        q->initStyleOption(&opt);
    135135        bool showCursor = control->hasSelectedText() ?
    136136                          q->style()->styleHint(QStyle::SH_BlinkCursorWhenTextSelected, &opt, q):
    137                           true;
     137                          q->hasFocus();
    138138        setCursorVisible(showCursor);
    139139    }
  • trunk/src/gui/widgets/qmainwindow.cpp

    r651 r769  
    6666QT_END_NAMESPACE
    6767#endif
    68 #ifdef QT_SOFTKEYS_ENABLED
    69 #include <private/qsoftkeymanager_p.h>
    70 #endif
    7168
    7269QT_BEGIN_NAMESPACE
     
    8077#ifdef Q_WS_MAC
    8178            , useHIToolBar(false)
    82 #endif
    83 #ifdef QT_SOFTKEYS_ENABLED
    84             , menuBarAction(0)
    8579#endif
    8680#if !defined(QT_NO_DOCKWIDGET) && !defined(QT_NO_CURSOR)
     
    9589    bool useHIToolBar;
    9690#endif
    97 #ifdef QT_SOFTKEYS_ENABLED
    98     QAction *menuBarAction;
    99 #endif
    10091    void init();
    10192    QList<int> hoverSeparator;
     
    118109    iconSize = QSize(metric, metric);
    119110    q->setAttribute(Qt::WA_Hover);
    120 #ifdef QT_SOFTKEYS_ENABLED
    121     menuBarAction = QSoftKeyManager::createAction(QSoftKeyManager::MenuSoftKey, q);
    122 #endif
    123111}
    124112
     
    492480    }
    493481    d->layout->setMenuBar(menuBar);
    494 
    495 #ifdef QT_SOFTKEYS_ENABLED
    496     if (menuBar)
    497         addAction(d->menuBarAction);
    498     else
    499         removeAction(d->menuBarAction);
    500 #endif
    501482}
    502483
  • trunk/src/gui/widgets/qmainwindowlayout.cpp

    r651 r769  
    17731773#ifndef QT_NO_DOCKWIDGET
    17741774        savedState.dockAreaLayout.centralWidgetItem = layoutState.dockAreaLayout.centralWidgetItem;
     1775        savedState.dockAreaLayout.fallbackToSizeHints = true;
    17751776#else
    17761777        savedState.centralWidgetItem = layoutState.centralWidgetItem;
  • trunk/src/gui/widgets/qmainwindowlayout_mac.mm

    r651 r769  
    464464            [[qt_mac_window_for(layoutState.mainWindow->window()) toolbar]
    465465                removeItemAtIndex:toolbarItemsCopy.indexOf(item)];
     466             unifiedToolbarHash.remove(item);
     467             qtoolbarsInUnifiedToolbarList.removeAll(toolbar);
    466468#endif
    467469            break;
  • 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    }
  • trunk/src/gui/widgets/qmenu.h

    r651 r769  
    143143
    144144#ifdef Q_WS_WINCE
    145     HMENU wceMenu(bool create = false);
     145    HMENU wceMenu();
    146146#endif
    147147
     
    163163    void mousePressEvent(QMouseEvent *);
    164164    void mouseMoveEvent(QMouseEvent *);
     165#ifndef QT_NO_WHEELEVENT
    165166    void wheelEvent(QWheelEvent *);
     167#endif
    166168    void enterEvent(QEvent *);
    167169    void leaveEvent(QEvent *);
  • trunk/src/gui/widgets/qmenu_mac.mm

    r651 r769  
    176176}
    177177
     178static void cancelAllMenuTracking()
     179{
     180#ifdef QT_MAC_USE_COCOA
     181    QMacCocoaAutoReleasePool pool;
     182    NSMenu *mainMenu = [NSApp mainMenu];
     183    [mainMenu cancelTracking];
     184    for (NSMenuItem *item in [mainMenu itemArray]) {
     185        if ([item submenu]) {
     186            [[item submenu] cancelTracking];
     187        }
     188    }
     189#else
     190    CancelMenuTracking(AcquireRootMenu(), true, 0);
     191#endif
     192}
     193
    178194static bool actualMenuItemVisibility(const QMenuBarPrivate::QMacMenuBarPrivate *mbp,
    179195                                     const QMacMenuAction *action)
     
    18311847
    18321848    if (qt_mac_current_menubar.qmenubar == q) {
     1849#ifdef QT_MAC_USE_COCOA
     1850        QT_MANGLE_NAMESPACE(QCocoaMenuLoader) *loader = getMenuLoader();
     1851        [loader removeActionsFromAppMenu];
     1852#else
     1853        cancelAllMenuTracking();
     1854#endif
    18331855        extern void qt_event_request_menubarupdate(); //qapplication_mac.cpp
    18341856        qt_event_request_menubarupdate();
     
    19321954    // if the menu bar belongs to an ancestor of modalWidget:
    19331955    return qt_mac_is_ancestor(menuBar->parentWidget(), modalWidget);
    1934 }
    1935 
    1936 static void cancelAllMenuTracking()
    1937 {
    1938 #ifdef QT_MAC_USE_COCOA
    1939     QMacCocoaAutoReleasePool pool;
    1940     NSMenu *mainMenu = [NSApp mainMenu];
    1941     [mainMenu cancelTracking];
    1942     for (NSMenuItem *item in [mainMenu itemArray]) {
    1943         if ([item submenu]) {
    1944             [[item submenu] cancelTracking];
    1945         }
    1946     }
    1947 #endif
    19481956}
    19491957
  • trunk/src/gui/widgets/qmenu_p.h

    r651 r769  
    348348        inline void syncAction(QAction *a) { syncAction(findAction(a)); }
    349349        void removeAction(QWceMenuAction *);
    350         void rebuild(bool reCreate = false);
     350        void rebuild();
    351351        inline void removeAction(QAction *a) { removeAction(findAction(a)); }
    352352        inline QWceMenuAction *findAction(QAction *a) {
     
    359359        }
    360360    } *wce_menu;
    361     HMENU wceMenu(bool create = false);
     361    HMENU wceMenu();
    362362    QAction* wceCommands(uint command);
    363363#endif
  • trunk/src/gui/widgets/qmenu_symbian.cpp

    r651 r769  
    150150
    151151        const int underlineShortCut = QApplication::style()->styleHint(QStyle::SH_UnderlineShortcut);
    152         QString iconText = action->action->iconText();
    153         TPtrC menuItemText = qt_QString2TPtrC( underlineShortCut ? action->action->text() : iconText);
     152        QString actionText;
     153        if (underlineShortCut)
     154            actionText = action->action->text().left(CEikMenuPaneItem::SData::ENominalTextLength);
     155        else
     156            actionText = action->action->iconText().left(CEikMenuPaneItem::SData::ENominalTextLength);
     157        TPtrC menuItemText = qt_QString2TPtrC(actionText);
    154158        if (action->action->menu()) {
    155159            SymbianMenuItem* menuItem = new SymbianMenuItem();
     
    257261    SymbianMenuItem* menu = qt_symbian_find_menu(id, symbianMenus);
    258262    if (menu) {
     263        // Normally first AddMenuItemL call for menuPane will create the item array.
     264        // However if we don't have any items, we still need the item array. Otherwise
     265        // menupane will crash. That's why we create item array here manually, and
     266        // AddMenuItemL will then use the existing array.
     267        CEikMenuPane::CItemArray* itemArray = q_check_ptr(new CEikMenuPane::CItemArray);
     268        menuPane->SetItemArray(itemArray);
     269        menuPane->SetItemArrayOwnedExternally(EFalse);
     270
    259271        for (int i = 0; i < menu->children.count(); ++i)
    260272            QT_TRAP_THROWING(menuPane->AddMenuItemL(menu->children.at(i)->menuItemData));
     
    317329}
    318330
     331void QMenuBarPrivate::reparentMenuBar(QWidget *oldParent, QWidget *newParent)
     332{
     333    if (menubars()->contains(oldParent)) {
     334        QMenuBarPrivate *object = menubars()->take(oldParent);
     335        menubars()->insert(newParent, object);
     336    }
     337}
     338
    319339QMenuBarPrivate::QSymbianMenuBarPrivate::QSymbianMenuBarPrivate(QMenuBarPrivate *menubar)
    320340{
  • trunk/src/gui/widgets/qmenu_wince.cpp

    r651 r769  
    102102};
    103103
    104 typedef int (WINAPI *superfunc)(int, int);
    105104typedef BOOL (WINAPI *AygCreateMenuBar)(qt_SHMENUBARINFO*);
    106105typedef HRESULT (WINAPI *AygEnableSoftKey)(HWND,UINT,BOOL,BOOL);
     
    128127        ptrEnableSoftKey(handle, command, false, true);
    129128}
     129
    130130static void qt_wce_disable_soft_key(HWND handle, uint command)
    131131{
     
    135135}
    136136
    137 static void qt_wce_delete_action_list(QList<QWceMenuAction*> *list) {
     137static void qt_wce_delete_action_list(QList<QWceMenuAction*> *list)
     138{
    138139    for(QList<QWceMenuAction*>::Iterator it = list->begin(); it != list->end(); ++it) {
    139140        QWceMenuAction *action = (*it);
     
    145146
    146147//search for first QuitRole in QMenuBar
    147 static QAction* qt_wce_get_quit_action(QList<QAction *> actionItems) {
     148static QAction* qt_wce_get_quit_action(QList<QAction *> actionItems)
     149{
    148150    QAction *returnAction = 0;
    149151    for (int i = 0; i < actionItems.size(); ++i) {
     
    160162}
    161163
    162 static QAction* qt_wce_get_quit_action(QList<QWceMenuAction*> actionItems) {
     164static QAction* qt_wce_get_quit_action(QList<QWceMenuAction*> actionItems)
     165{
    163166    for (int i = 0; i < actionItems.size(); ++i) {
    164167        if (actionItems.at(i)->action->menuRole() == QAction::QuitRole)
     
    173176}
    174177
    175 static HMODULE qt_wce_get_module_handle() {
     178static HMODULE qt_wce_get_module_handle()
     179{
    176180    HMODULE module =  0; //handle to resources
    177181    if (!(module = GetModuleHandle(L"QtGui4"))) //release dynamic
     
    182186}
    183187
    184 static void qt_wce_change_command(HWND menuHandle, int item, int command) {
     188static void qt_wce_change_command(HWND menuHandle, int item, int command)
     189{
    185190TBBUTTONINFOA tbbi;
    186191    memset(&tbbi,0,sizeof(tbbi));
     
    191196}
    192197
    193 static void qt_wce_rename_menu_item(HWND menuHandle, int item, const QString &newText) {
     198static void qt_wce_rename_menu_item(HWND menuHandle, int item, const QString &newText)
     199{
    194200    TBBUTTONINFOA tbbi;
    195201    memset(&tbbi,0,sizeof(tbbi));
     
    202208}
    203209
    204 static HWND qt_wce_create_menubar(HWND parentHandle, HINSTANCE resourceHandle, int toolbarID, int flags = 0) {
     210static HWND qt_wce_create_menubar(HWND parentHandle, HINSTANCE resourceHandle, int toolbarID, int flags = 0)
     211{
    205212    resolveAygLibs();
    206213
     
    227234}
    228235
    229 static void qt_wce_insert_action(HMENU menu, QWceMenuAction *action, bool created) {
    230 
     236static void qt_wce_insert_action(HMENU menu, QWceMenuAction *action)
     237{
    231238    Q_ASSERT_X(menu, "AppendMenu", "menu is 0");
    232239    if (action->action->isVisible()) {
     
    242249            text.remove(QChar::fromLatin1('&'));
    243250            AppendMenu (menu, MF_STRING | flags | MF_POPUP,
    244             (UINT) action->action->menu()->wceMenu(created), reinterpret_cast<const wchar_t *> (text.utf16()));
     251            (UINT) action->action->menu()->wceMenu(), reinterpret_cast<const wchar_t *> (text.utf16()));
    245252        }
    246253        else {
     
    255262}
    256263
     264// Removes all items from the menu without destroying the handles.
     265static void qt_wce_clear_menu(HMENU hMenu)
     266{
     267    while (RemoveMenu(hMenu, 0, MF_BYPOSITION));
     268}
     269
    257270/*!
    258271    \internal
     
    261274*/
    262275
    263 void QMenuBar::wceRefresh() {
     276void QMenuBar::wceRefresh()
     277{
    264278    for (int i = 0; i < nativeMenuBars.size(); ++i)
    265279        nativeMenuBars.at(i)->d_func()->wceRefresh();
    266280}
    267281
    268 void QMenuBarPrivate::wceRefresh() {
     282void QMenuBarPrivate::wceRefresh()
     283{
    269284    DrawMenuBar(wce_menubar->menubarHandle);
    270285}
     
    276291*/
    277292
    278 QAction* QMenu::wceCommands(uint command) {
     293QAction* QMenu::wceCommands(uint command)
     294{
    279295    Q_D(QMenu);
    280296    return d->wceCommands(command);
     
    288304*/
    289305
    290 void QMenuBar::wceCommands(uint command, HWND) {
    291     for (int i = 0; i < nativeMenuBars.size(); ++i)
    292             nativeMenuBars.at(i)->d_func()->wceCommands(command);
    293 }
    294 
    295 bool QMenuBarPrivate::wceEmitSignals(QList<QWceMenuAction*> actions, uint command) {
     306void QMenuBar::wceCommands(uint command)
     307{
     308    const HWND hwndActiveWindow = GetActiveWindow();
     309    for (int i = 0; i < nativeMenuBars.size(); ++i) {
     310        QMenuBarPrivate* nativeMenuBar = nativeMenuBars.at(i)->d_func();
     311        if (hwndActiveWindow == nativeMenuBar->wce_menubar->parentWindowHandle)
     312            nativeMenuBar->wceCommands(command);
     313    }
     314}
     315
     316bool QMenuBarPrivate::wceEmitSignals(QList<QWceMenuAction*> actions, uint command)
     317{
    296318    QAction *foundAction = 0;
    297319    for (int i = 0; i < actions.size(); ++i) {
    298         if (foundAction)
    299             break;
    300320        QWceMenuAction *action = actions.at(i);
    301321        if (action->action->menu()) {
    302322            foundAction = action->action->menu()->wceCommands(command);
     323            if (foundAction)
     324                break;
    303325        }
    304326        else if (action->command == command) {
    305             emit q_func()->triggered(action->action);
    306327            action->action->activate(QAction::Trigger);
    307328            return true;
     
    315336}
    316337
    317 void QMenuBarPrivate::wceCommands(uint command) {
     338void QMenuBarPrivate::wceCommands(uint command)
     339{
    318340    if (wceClassicMenu) {
    319341        for (int i = 0; i < wce_menubar->actionItemsClassic.size(); ++i)
     
    321343    } else {
    322344        if (wceEmitSignals(wce_menubar->actionItems, command)) {
    323             return ;
     345            return;
    324346        }
    325347        else if (wce_menubar->leftButtonIsMenu) {//check if command is on the left quick button
     
    333355}
    334356
    335 QAction *QMenuPrivate::wceCommands(uint command) {
     357QAction *QMenuPrivate::wceCommands(uint command)
     358{
    336359    QAction *foundAction = 0;
    337360    for (int i  = 0; i < wce_menu->actionItems.size(); ++i) {
     
    343366        }
    344367        else if (action->command == command) {
    345             action->action->activate(QAction::Trigger);
     368            activateAction(action->action, QAction::Trigger);
    346369            return action->action;
    347370        }
     
    352375}
    353376
    354 void QMenuBarPrivate::wceCreateMenuBar(QWidget *parent) {
    355 
     377void QMenuBarPrivate::wceCreateMenuBar(QWidget *parent)
     378{
    356379    Q_Q(QMenuBar);
    357380    wce_menubar = new QWceMenuBarPrivate(this);
     
    367390}
    368391
    369 void QMenuBarPrivate::wceDestroyMenuBar() {
     392void QMenuBarPrivate::wceDestroyMenuBar()
     393{
    370394    Q_Q(QMenuBar);
    371395    int index = nativeMenuBars.indexOf(q);
    372396    nativeMenuBars.removeAt(index);
    373     if (wce_menubar)
    374       delete wce_menubar;
    375     wce_menubar = 0;
    376 }
    377 
    378 QMenuBarPrivate::QWceMenuBarPrivate::QWceMenuBarPrivate(QMenuBarPrivate *menubar) :
    379                                      menubarHandle(0), menuHandle(0),leftButtonMenuHandle(0) ,
    380                                      leftButtonAction(0), leftButtonIsMenu(false), d(menubar) {
    381 }
    382 
    383 QMenuBarPrivate::QWceMenuBarPrivate::~QWceMenuBarPrivate() {
     397    if (wce_menubar) {
     398        delete wce_menubar;
     399        wce_menubar = 0;
     400    }
     401}
     402
     403QMenuBarPrivate::QWceMenuBarPrivate::QWceMenuBarPrivate(QMenuBarPrivate *menubar)
     404:   menubarHandle(0), menuHandle(0), leftButtonMenuHandle(0),
     405    leftButtonAction(0), leftButtonIsMenu(false), d(menubar)
     406{
     407}
     408
     409QMenuBarPrivate::QWceMenuBarPrivate::~QWceMenuBarPrivate()
     410{
    384411    if (menubarHandle)
    385412        DestroyWindow(menubarHandle);
     
    399426}
    400427
    401 QMenuPrivate::QWceMenuPrivate::QWceMenuPrivate() {
    402     menuHandle = 0;
    403 }
    404 
    405 QMenuPrivate::QWceMenuPrivate::~QWceMenuPrivate() {
     428QMenuPrivate::QWceMenuPrivate::QWceMenuPrivate()
     429:   menuHandle(0)
     430{
     431}
     432
     433QMenuPrivate::QWceMenuPrivate::~QWceMenuPrivate()
     434{
    406435    qt_wce_delete_action_list(&actionItems);
    407     menuHandle = 0;
    408 }
    409 
    410 void QMenuPrivate::QWceMenuPrivate::addAction(QAction *a, QWceMenuAction *before) {
     436    if (menuHandle)
     437        DestroyMenu(menuHandle);
     438}
     439
     440void QMenuPrivate::QWceMenuPrivate::addAction(QAction *a, QWceMenuAction *before)
     441{
    411442    QWceMenuAction *action = new QWceMenuAction;
    412443    action->action = a;
     
    415446}
    416447
    417 void QMenuPrivate::QWceMenuPrivate::addAction(QWceMenuAction *action, QWceMenuAction *before) {
     448void QMenuPrivate::QWceMenuPrivate::addAction(QWceMenuAction *action, QWceMenuAction *before)
     449{
    418450    if (!action)
    419451        return;
     
    434466*/
    435467
    436 HMENU QMenu::wceMenu(bool create) { return d_func()->wceMenu(create); }
    437 
    438 HMENU QMenuPrivate::wceMenu(bool create) {
     468HMENU QMenu::wceMenu()
     469{
     470    return d_func()->wceMenu();
     471}
     472
     473HMENU QMenuPrivate::wceMenu()
     474{
    439475    if (!wce_menu)
    440476        wce_menu = new QWceMenuPrivate;
    441     if (!wce_menu->menuHandle || create)
    442         wce_menu->rebuild(create);
     477    if (!wce_menu->menuHandle)
     478        wce_menu->rebuild();
    443479    return wce_menu->menuHandle;
    444480}
    445481
    446 void QMenuPrivate::QWceMenuPrivate::rebuild(bool reCreate) {
    447     if (menuHandle && !reCreate)
    448       DestroyMenu(menuHandle);
    449     menuHandle = CreatePopupMenu();
     482void QMenuPrivate::QWceMenuPrivate::rebuild()
     483{
     484    if (!menuHandle)
     485        menuHandle = CreatePopupMenu();
     486    else
     487        qt_wce_clear_menu(menuHandle);
     488
    450489    for (int i = 0; i < actionItems.size(); ++i) {
    451490        QWceMenuAction *action = actionItems.at(i);
    452491        action->menuHandle = menuHandle;
    453         qt_wce_insert_action(menuHandle, action, true);
     492        qt_wce_insert_action(menuHandle, action);
    454493    }
    455494    QMenuBar::wceRefresh();
    456495}
    457496
    458 void QMenuPrivate::QWceMenuPrivate::syncAction(QWceMenuAction *) {
     497void QMenuPrivate::QWceMenuPrivate::syncAction(QWceMenuAction *)
     498{
    459499    rebuild();
    460500}
    461501
    462 void QMenuPrivate::QWceMenuPrivate::removeAction(QWceMenuAction *action) {
    463         actionItems.removeAll(action);
    464         delete action;
    465         action = 0;
    466         rebuild();
    467 }
    468 
    469 void QMenuBarPrivate::QWceMenuBarPrivate::addAction(QAction *a, QWceMenuAction *before) {
     502void QMenuPrivate::QWceMenuPrivate::removeAction(QWceMenuAction *action)
     503{
     504    actionItems.removeAll(action);
     505    delete action;
     506    rebuild();
     507}
     508
     509void QMenuBarPrivate::QWceMenuBarPrivate::addAction(QAction *a, QWceMenuAction *before)
     510{
    470511    QWceMenuAction *action = new QWceMenuAction;
    471512    action->action = a;
     
    474515}
    475516
    476 void QMenuBarPrivate::QWceMenuBarPrivate::addAction(QWceMenuAction *action, QWceMenuAction *before) {
     517void QMenuBarPrivate::QWceMenuBarPrivate::addAction(QWceMenuAction *action, QWceMenuAction *before)
     518{
    477519    if (!action)
    478520        return;
     
    486528}
    487529
    488 void QMenuBarPrivate::QWceMenuBarPrivate::syncAction(QWceMenuAction*) {
     530void QMenuBarPrivate::QWceMenuBarPrivate::syncAction(QWceMenuAction*)
     531{
    489532    QMenuBar::wceRefresh();
    490533    rebuild();
    491534}
    492535
    493 void QMenuBarPrivate::QWceMenuBarPrivate::removeAction(QWceMenuAction *action) {
     536void QMenuBarPrivate::QWceMenuBarPrivate::removeAction(QWceMenuAction *action)
     537{
    494538    actionItems.removeAll(action);
    495539    delete action;
    496     action = 0;
    497540    rebuild();
    498541}
    499542
    500 void QMenuBarPrivate::_q_updateDefaultAction() {
     543void QMenuBarPrivate::_q_updateDefaultAction()
     544{
    501545    if (wce_menubar)
    502546        wce_menubar->rebuild();
    503547}
    504548
    505 void QMenuBarPrivate::QWceMenuBarPrivate::rebuild() {
    506 
     549void QMenuBarPrivate::QWceMenuBarPrivate::rebuild()
     550{
    507551    d->q_func()->resize(0,0);
    508552    parentWindowHandle = d->q_func()->parentWidget() ? d->q_func()->parentWidget()->winId() : d->q_func()->winId();
     
    523567        }
    524568        Q_ASSERT_X(menubarHandle, "rebuild !created", "menubar already deleted");
     569        qt_wce_clear_menu(menuHandle);
    525570        DestroyWindow(menubarHandle);
    526571        menubarHandle = qt_wce_create_menubar(parentWindowHandle, qt_wce_get_module_handle(), resourceHandle);
     
    550595                action->menuHandle = subMenuHandle;
    551596                actionItemsClassic.last().append(action);
    552                 qt_wce_insert_action(subMenuHandle, action, true);
     597                qt_wce_insert_action(subMenuHandle, action);
    553598            }
    554599        }
     
    564609        leftButtonIsMenu = (leftButtonAction && leftButtonAction->menu());
    565610        Q_ASSERT_X(menubarHandle, "rebuild !created", "menubar already deleted");
     611        qt_wce_clear_menu(menuHandle);
    566612        DestroyWindow(menubarHandle);
    567613        if (leftButtonIsMenu) {
     
    592638            QWceMenuAction *action = actionItems.at(i);
    593639            action->menuHandle = menuHandle;
    594             qt_wce_insert_action(menuHandle, action, true);
     640            qt_wce_insert_action(menuHandle, action);
    595641        }
    596642        if (!leftButtonIsMenu) {
     
    612658                action->menuHandle = leftButtonMenuHandle;
    613659                actionItemsLeftButton.append(action);
    614                 qt_wce_insert_action(leftButtonMenuHandle, action, true);
     660                qt_wce_insert_action(leftButtonMenuHandle, action);
    615661            }
    616662        }
  • trunk/src/gui/widgets/qmenubar.cpp

    r651 r769  
    7272#endif
    7373
     74#ifdef QT_SOFTKEYS_ENABLED
     75#include <private/qsoftkeymanager_p.h>
     76#endif
     77
    7478QT_BEGIN_NAMESPACE
    7579
     
    741745    }
    742746#endif
    743 #ifdef Q_WS_S60
    744     symbianCreateMenuBar(q->parentWidget());
    745     if(symbian_menubar)
    746         q->hide();
    747 #endif
    748 
    749747    q->setBackgroundRole(QPalette::Button);
    750748    oldWindow = oldParent = 0;
    751749#ifdef QT3_SUPPORT
    752750    doAutoResize = false;
     751#endif
     752#ifdef QT_SOFTKEYS_ENABLED
     753    menuBarAction = 0;
    753754#endif
    754755    handleReparent();
     
    13851386#endif
    13861387#ifdef Q_WS_S60
    1387     if (symbian_menubar)
     1388
     1389    // Construct symbian_menubar when this code path is entered first time
     1390    // and when newParent != NULL
     1391    if (!symbian_menubar)
     1392        symbianCreateMenuBar(newParent);
     1393
     1394    // Reparent and rebuild menubar when parent is changed
     1395    if (symbian_menubar) {
     1396        if (oldParent != newParent)
     1397            reparentMenuBar(oldParent, newParent);
     1398        q->hide();
    13881399        symbian_menubar->rebuild();
    1389 #endif
    1390 
     1400    }
     1401
     1402#ifdef QT_SOFTKEYS_ENABLED
     1403    // Constuct menuBarAction when this code path is entered first time
     1404    if (!menuBarAction) {
     1405        if (newParent) {
     1406            menuBarAction = QSoftKeyManager::createAction(QSoftKeyManager::MenuSoftKey, newParent);
     1407            newParent->addAction(menuBarAction);
     1408        }
     1409    } else {
     1410        // If reparenting i.e. we already have menuBarAction, remove it from old parent
     1411        // and add for a new parent
     1412        if (oldParent)
     1413            oldParent->removeAction(menuBarAction);
     1414        if (newParent)
     1415            newParent->addAction(menuBarAction);
     1416    }
     1417#endif // QT_SOFTKEYS_ENABLED
     1418#endif // Q_WS_S60
    13911419}
    13921420
     
    14411469        d->itemsDirty = true;
    14421470        d->updateGeometries();
    1443     }
     1471#ifdef QT_SOFTKEYS_ENABLED
     1472    } else if (e->type() == QEvent::LanguageChange) {
     1473        if (d->menuBarAction)
     1474            d->menuBarAction->setText(QSoftKeyManager::standardSoftKeyText(QSoftKeyManager::MenuSoftKey));
     1475#endif
     1476    }
     1477
    14441478    QWidget::changeEvent(e);
    14451479}
     
    19241958
    19251959  Currently there is only support for the default action on Windows
    1926   Mobile. All other platforms ignore the default action.
     1960  Mobile. On all other platforms this method is not available.
    19271961
    19281962  \sa defaultAction()
  • trunk/src/gui/widgets/qmenubar.h

    r651 r769  
    116116    QAction *defaultAction() const;
    117117
    118     static void wceCommands(uint command, HWND controlHandle);
     118    static void wceCommands(uint command);
    119119    static void wceRefresh();
    120120#endif
  • trunk/src/gui/widgets/qmenubar_p.h

    r651 r769  
    244244    void symbianCreateMenuBar(QWidget *);
    245245    void symbianDestroyMenuBar();
     246    void reparentMenuBar(QWidget *oldParent, QWidget *newParent);
    246247    struct QSymbianMenuBarPrivate {
    247248        QList<QSymbianMenuAction*> actionItems;
     
    268269    } *symbian_menubar;
    269270    static int symbianCommands(int command);
    270 
     271#ifdef QT_SOFTKEYS_ENABLED
     272    QAction *menuBarAction;
     273#endif
    271274#endif
    272275};
  • trunk/src/gui/widgets/qprintpreviewwidget.cpp

    r651 r769  
    152152    GraphicsView(QWidget* parent = 0)
    153153        : QGraphicsView(parent)
    154         {}
     154    {
     155#ifdef Q_WS_MAC
     156        setFrameStyle(QFrame::NoFrame);
     157#endif
     158    }
    155159signals:
    156160    void resized();
  • trunk/src/gui/widgets/qscrollbar.cpp

    r651 r769  
    522522        d_func()->updateHoverControl(he->pos());
    523523        break;
     524#ifndef QT_NO_WHEELEVENT
     525    case QEvent::Wheel: {
     526        // override wheel event without adding virtual function override
     527        QWheelEvent *ev = static_cast<QWheelEvent *>(event);
     528        int delta = ev->delta();
     529        // scrollbar is a special case - in vertical mode it reaches minimum
     530        // value in the upper position, however QSlider's minimum value is on
     531        // the bottom. So we need to invert a value, but since the scrollbar is
     532        // inverted by default, we need to inverse the delta value for the
     533        // horizontal orientation.
     534        if (ev->orientation() == Qt::Horizontal)
     535            delta = -delta;
     536        Q_D(QScrollBar);
     537        if (d->scrollByDelta(ev->orientation(), ev->modifiers(), delta))
     538            event->accept();
     539        return true;
     540    }
     541#endif
    524542    default:
    525543        break;
  • trunk/src/gui/widgets/qspinbox.cpp

    r651 r769  
    449449
    450450/*!
    451     This virtual function is used by the spin box whenever it needs
    452     to display the given \a value. The default implementation returns
    453     a string containing \a value printed in the standard way using
    454     QWidget::locale().toString(). Reimplementations may return anything. (See
    455     the example in the detailed description.)
     451    This virtual function is used by the spin box whenever it needs to
     452    display the given \a value. The default implementation returns a
     453    string containing \a value printed in the standard way using
     454    QWidget::locale().toString(), but with the thousand separator
     455    removed. Reimplementations may return anything. (See the example
     456    in the detailed description.)
    456457
    457458    Note: QSpinBox does not call this function for specialValueText()
     
    462463    valueFromText() and validate()
    463464
    464     \sa valueFromText(), validate()
     465    \sa valueFromText(), validate(), QLocale::groupSeparator()
    465466*/
    466467
     
    870871    valueFromText().
    871872
    872     \sa valueFromText()
     873    \sa valueFromText(), QLocale::groupSeparator()
    873874*/
    874875
  • trunk/src/gui/widgets/qtabbar.cpp

    r651 r769  
    6868#endif
    6969
     70#ifndef QT_NO_STYLE_S60
     71#include "qs60style.h"
     72#endif
     73
    7074QT_BEGIN_NAMESPACE
    7175
     
    479483    if (useScrollButtons && tabList.count() && last > available) {
    480484        int extra = extraWidth();
     485#ifndef QT_NO_STYLE_S60
     486        QS60Style *s60Style = qobject_cast<QS60Style*>(QApplication::style());
     487#endif
    481488        if (!vertTabs) {
    482489            Qt::LayoutDirection ld = q->layoutDirection();
     
    486493
    487494            if (ld == Qt::LeftToRight) {
     495// In S60style, tab scroll buttons are layoutted separately, on the sides of the tabbar.
     496#ifndef QT_NO_STYLE_S60
     497                if (s60Style) {
     498                    rightB->setGeometry(arrows.left() + extra / 2, arrows.top(), extra / 2, arrows.height());
     499                    leftB->setGeometry(0, arrows.top(), extra / 2, arrows.height());
     500                } else {
     501#endif
    488502                leftB->setGeometry(arrows.left(), arrows.top(), extra/2, arrows.height());
    489503                rightB->setGeometry(arrows.right() - extra/2 + buttonOverlap, arrows.top(),
    490504                                    extra/2, arrows.height());
     505#ifndef QT_NO_STYLE_S60
     506                }
     507#endif
    491508                leftB->setArrowType(Qt::LeftArrow);
    492509                rightB->setArrowType(Qt::RightArrow);
    493510            } else {
     511#ifndef QT_NO_STYLE_S60
     512                if (s60Style) {
     513                    rightB->setGeometry(arrows.left() + extra / 2, arrows.top(), extra / 2, arrows.height());
     514                    leftB->setGeometry(0, arrows.top(), extra / 2, arrows.height());
     515                } else {
     516#endif
    494517                rightB->setGeometry(arrows.left(), arrows.top(), extra/2, arrows.height());
    495518                leftB->setGeometry(arrows.right() - extra/2 + buttonOverlap, arrows.top(),
    496519                                    extra/2, arrows.height());
     520#ifndef QT_NO_STYLE_S60
     521                }
     522#endif
    497523                rightB->setArrowType(Qt::LeftArrow);
    498524                leftB->setArrowType(Qt::RightArrow);
    499525            }
    500526        } else {
     527#ifndef QT_NO_STYLE_S60
     528            if (s60Style) {
     529                QRect arrows = QRect(0, 0, size.width(), available );
     530                leftB->setGeometry(arrows.left(), arrows.top(), arrows.width(), extra / 2);
     531                leftB->setArrowType(Qt::UpArrow);
     532                rightB->setGeometry(arrows.left(), arrows.bottom() - extra / 2 + 1,
     533                                    arrows.width(), extra / 2);
     534                rightB->setArrowType(Qt::DownArrow);
     535            } else {
     536#endif
    501537            QRect arrows = QRect(0, available - extra, size.width(), extra );
    502538            leftB->setGeometry(arrows.left(), arrows.top(), arrows.width(), extra/2);
     
    505541                                arrows.width(), extra/2);
    506542            rightB->setArrowType(Qt::DownArrow);
     543#ifndef QT_NO_STYLE_S60
     544            }
     545#endif
    507546        }
    508547        leftB->setEnabled(scrollOffset > 0);
  • trunk/src/gui/widgets/qtoolbar.cpp

    r651 r769  
    442442    to populate the extension pop up with widgets added to the toolbar using
    443443    addWidget(). Please use widget actions created by inheriting QWidgetAction
    444     and implementing QWidgetAction::createWidget() instead. This is a known
    445     issue which will be fixed in a future release.
     444    and implementing QWidgetAction::createWidget() instead.
    446445
    447446    \sa QToolButton, QMenu, QAction, {Application Example}
Note: See TracChangeset for help on using the changeset viewer.