Changeset 769 for trunk/src/gui/widgets
- Timestamp:
- Aug 2, 2010, 9:27:30 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 32 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/widgets/qabstractbutton.cpp
r651 r769 58 58 #define AUTO_REPEAT_INTERVAL 100 59 59 60 extern bool qt_tab_all_widgets;60 Q_GUI_EXPORT extern bool qt_tab_all_widgets; 61 61 62 62 /*! -
trunk/src/gui/widgets/qabstractscrollarea.cpp
r651 r769 395 395 q->style()->styleHint(QStyle::SH_ScrollView_FrameOnlyAroundContents, &opt, q)) { 396 396 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); 398 398 const QPoint cornerExtra(needv ? extra : 0, needh ? extra : 0); 399 399 QRect frameRect = widgetRect; -
trunk/src/gui/widgets/qabstractslider.cpp
r651 r769 48 48 #include "qaccessible.h" 49 49 #endif 50 #ifdef QT_KEYPAD_NAVIGATION51 #include "qtabwidget.h" // Needed in inTabWidget()52 #endif // QT_KEYPAD_NAVIGATION53 50 #include <limits.h> 54 51 … … 215 212 216 213 QAbstractSliderPrivate::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), 219 216 blocktracking(false), pressed(false), 220 217 invertedAppearance(false), invertedControls(false), … … 689 686 } 690 687 688 bool 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 } 691 734 692 735 /*! … … 698 741 Q_D(QAbstractSlider); 699 742 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)) 736 745 e->accept(); 737 746 } 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 778 750 /*! 779 751 \reimp … … 841 813 && (!hasEditFocus() && QApplication::navigationMode() == Qt::NavigationModeKeypadTabOrder 842 814 || d->orientation == Qt::Vertical 843 || !hasEditFocus() && (canKeypadNavigate(Qt::Horizontal) || inTabWidget(this)))) { 815 || !hasEditFocus() 816 && (QWidgetPrivate::canKeypadNavigate(Qt::Horizontal) || QWidgetPrivate::inTabWidget(this)))) { 844 817 ev->ignore(); 845 818 return; … … 860 833 && (!hasEditFocus() && QApplication::navigationMode() == Qt::NavigationModeKeypadTabOrder 861 834 || d->orientation == Qt::Vertical 862 || !hasEditFocus() && (canKeypadNavigate(Qt::Horizontal) || inTabWidget(this)))) { 835 || !hasEditFocus() 836 && (QWidgetPrivate::canKeypadNavigate(Qt::Horizontal) || QWidgetPrivate::inTabWidget(this)))) { 863 837 ev->ignore(); 864 838 return; … … 880 854 && (QApplication::navigationMode() == Qt::NavigationModeKeypadTabOrder 881 855 || d->orientation == Qt::Horizontal 882 || !hasEditFocus() && canKeypadNavigate(Qt::Vertical))) {856 || !hasEditFocus() && QWidgetPrivate::canKeypadNavigate(Qt::Vertical))) { 883 857 ev->ignore(); 884 858 break; … … 893 867 && (QApplication::navigationMode() == Qt::NavigationModeKeypadTabOrder 894 868 || d->orientation == Qt::Horizontal 895 || !hasEditFocus() && canKeypadNavigate(Qt::Vertical))) {869 || !hasEditFocus() && QWidgetPrivate::canKeypadNavigate(Qt::Vertical))) { 896 870 ev->ignore(); 897 871 break; -
trunk/src/gui/widgets/qabstractslider_p.h
r651 r769 139 139 q->triggerAction(repeatAction); 140 140 } 141 bool scrollByDelta(Qt::Orientation orientation, Qt::KeyboardModifiers modifiers, int delta); 141 142 }; 142 143 -
trunk/src/gui/widgets/qabstractspinbox.h
r651 r769 138 138 void keyPressEvent(QKeyEvent *event); 139 139 void keyReleaseEvent(QKeyEvent *event); 140 #ifndef QT_NO_WHEELEVENT 140 141 void wheelEvent(QWheelEvent *event); 142 #endif 141 143 void focusInEvent(QFocusEvent *event); 142 144 void focusOutEvent(QFocusEvent *event); -
trunk/src/gui/widgets/qcombobox.cpp
r651 r769 77 77 # include <private/qeffects_p.h> 78 78 #endif 79 #if defined(Q_WS_S60) 80 #include "private/qt_s60_p.h" 81 #endif 82 79 83 QT_BEGIN_NAMESPACE 80 84 … … 140 144 break; 141 145 } 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 } 143 150 menuOption.text = index.model()->data(index, Qt::DisplayRole).toString() 144 151 .replace(QLatin1Char('&'), QLatin1String("&&")); … … 533 540 const bool usePopup = combo->style()->styleHint(QStyle::SH_ComboBox_Popup, &opt, combo); 534 541 #ifndef QT_NO_SCROLLBAR 542 #ifndef Q_WS_S60 535 543 if (usePopup) 536 544 view->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); 545 #endif 537 546 #endif 538 547 if (combo->style()->styleHint(QStyle::SH_ComboBox_ListMouseTracking, &opt, combo) || … … 608 617 combo->style()->styleHint(QStyle::SH_ComboBox_Popup, &opt, combo)); 609 618 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 611 626 QWidget::changeEvent(e); 612 627 } … … 2411 2426 listRect.moveLeft(above.x()); 2412 2427 2428 #ifndef Q_WS_S60 2413 2429 // Position vertically so the curently selected item lines up 2414 2430 // with the combo box. … … 2416 2432 const int offset = listRect.top() - currentItemRect.top(); 2417 2433 listRect.moveTop(above.y() + offset - listRect.top()); 2434 #endif 2418 2435 2419 2436 … … 2422 2439 // important to show as much as possible of the popup. 2423 2440 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 2424 2445 listRect.setHeight(height); 2446 #endif 2447 2425 2448 if (boundToScreen) { 2426 2449 if (listRect.top() < screen.top()) … … 2429 2452 listRect.moveBottom(screen.bottom()); 2430 2453 } 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 2431 2471 } else if (!boundToScreen || listRect.height() <= belowHeight) { 2432 2472 listRect.moveTopLeft(below); … … 2637 2677 d->updateLineEditGeometry(); 2638 2678 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 2639 2712 // ### need to update scrollers etc. as well here 2640 2713 break; -
trunk/src/gui/widgets/qcombobox.h
r651 r769 246 246 void keyPressEvent(QKeyEvent *e); 247 247 void keyReleaseEvent(QKeyEvent *e); 248 #ifndef QT_NO_WHEELEVENT 248 249 void wheelEvent(QWheelEvent *e); 250 #endif 249 251 void contextMenuEvent(QContextMenuEvent *e); 250 252 void inputMethodEvent(QInputMethodEvent *); -
trunk/src/gui/widgets/qcombobox_p.h
r651 r769 201 201 if (sliderAction == QAbstractSlider::SliderSingleStepAdd) 202 202 menuOpt.state |= QStyle::State_DownArrow; 203 #ifndef Q_WS_S60 203 204 p.eraseRect(rect()); 205 #endif 204 206 style()->drawControl(QStyle::CE_MenuScroller, &menuOpt, &p); 205 207 } … … 271 273 const QModelIndex &index) const { 272 274 QStyleOptionMenuItem opt = getStyleOption(option, index); 275 #ifndef Q_WS_S60 273 276 painter->fillRect(option.rect, opt.palette.background()); 277 #endif 274 278 mCombo->style()->drawControl(QStyle::CE_MenuItem, &opt, painter, mCombo); 275 279 } -
trunk/src/gui/widgets/qdialogbuttonbox.cpp
r651 r769 1018 1018 new role. 1019 1019 1020 \note The button box takes ownership of the button. 1021 1020 1022 \sa removeButton(), clear() 1021 1023 */ -
trunk/src/gui/widgets/qdockarealayout.cpp
r651 r769 1991 1991 const int tabBarShape = 0; 1992 1992 #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)); 1996 1995 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)) 1998 2004 return false; 1999 2005 2000 if (!testing) {2001 item_list.append(item);2002 }2003 2006 } else { 2004 2007 return false; … … 2636 2639 bottom_hint = bottom_hint.boundedTo(bottom_max).expandedTo(bottom_min); 2637 2640 2638 fallbackToSizeHints = !have_central;2641 fallbackToSizeHints = false; 2639 2642 2640 2643 if (_ver_struct_list != 0) { -
trunk/src/gui/widgets/qlinecontrol.cpp
r651 r769 66 66 If the text has changed will emit displayTextChanged() 67 67 */ 68 void QLineControl::updateDisplayText( )68 void QLineControl::updateDisplayText(bool forceUpdate) 69 69 { 70 70 QString orig = m_textLayout.text(); … … 103 103 m_ascent = qRound(l.ascent()); 104 104 105 if (str != orig )105 if (str != orig || forceUpdate) 106 106 emit displayTextChanged(str); 107 107 } … … 477 477 } 478 478 m_textLayout.setAdditionalFormats(formats); 479 updateDisplayText( );479 updateDisplayText(/*force*/ true); 480 480 if (cursorPositionChanged) 481 481 emitCursorPositionChanged(); … … 1372 1372 #ifndef QT_NO_SHORTCUT 1373 1373 case QEvent::ShortcutOverride:{ 1374 if (isReadOnly()) 1375 return false; 1374 1376 QKeyEvent* ke = static_cast<QKeyEvent*>(ev); 1375 1377 if (ke == QKeySequence::Copy -
trunk/src/gui/widgets/qlinecontrol_p.h
r651 r769 240 240 void removeSelectedText(); 241 241 void internalSetText(const QString &txt, int pos = -1, bool edited = true); 242 void updateDisplayText( );242 void updateDisplayText(bool forceUpdate = false); 243 243 244 244 void internalInsert(const QString &s); -
trunk/src/gui/widgets/qlineedit.cpp
r651 r769 739 739 return false; 740 740 } 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); 743 749 return true; 744 750 } -
trunk/src/gui/widgets/qlineedit_p.cpp
r651 r769 130 130 { 131 131 Q_Q(QLineEdit); 132 if ( control->preeditAreaText().isEmpty()) {132 if (!control->text().isEmpty() && control->preeditAreaText().isEmpty()) { 133 133 QStyleOptionFrameV2 opt; 134 134 q->initStyleOption(&opt); 135 135 bool showCursor = control->hasSelectedText() ? 136 136 q->style()->styleHint(QStyle::SH_BlinkCursorWhenTextSelected, &opt, q): 137 true;137 q->hasFocus(); 138 138 setCursorVisible(showCursor); 139 139 } -
trunk/src/gui/widgets/qmainwindow.cpp
r651 r769 66 66 QT_END_NAMESPACE 67 67 #endif 68 #ifdef QT_SOFTKEYS_ENABLED69 #include <private/qsoftkeymanager_p.h>70 #endif71 68 72 69 QT_BEGIN_NAMESPACE … … 80 77 #ifdef Q_WS_MAC 81 78 , useHIToolBar(false) 82 #endif83 #ifdef QT_SOFTKEYS_ENABLED84 , menuBarAction(0)85 79 #endif 86 80 #if !defined(QT_NO_DOCKWIDGET) && !defined(QT_NO_CURSOR) … … 95 89 bool useHIToolBar; 96 90 #endif 97 #ifdef QT_SOFTKEYS_ENABLED98 QAction *menuBarAction;99 #endif100 91 void init(); 101 92 QList<int> hoverSeparator; … … 118 109 iconSize = QSize(metric, metric); 119 110 q->setAttribute(Qt::WA_Hover); 120 #ifdef QT_SOFTKEYS_ENABLED121 menuBarAction = QSoftKeyManager::createAction(QSoftKeyManager::MenuSoftKey, q);122 #endif123 111 } 124 112 … … 492 480 } 493 481 d->layout->setMenuBar(menuBar); 494 495 #ifdef QT_SOFTKEYS_ENABLED496 if (menuBar)497 addAction(d->menuBarAction);498 else499 removeAction(d->menuBarAction);500 #endif501 482 } 502 483 -
trunk/src/gui/widgets/qmainwindowlayout.cpp
r651 r769 1773 1773 #ifndef QT_NO_DOCKWIDGET 1774 1774 savedState.dockAreaLayout.centralWidgetItem = layoutState.dockAreaLayout.centralWidgetItem; 1775 savedState.dockAreaLayout.fallbackToSizeHints = true; 1775 1776 #else 1776 1777 savedState.centralWidgetItem = layoutState.centralWidgetItem; -
trunk/src/gui/widgets/qmainwindowlayout_mac.mm
r651 r769 464 464 [[qt_mac_window_for(layoutState.mainWindow->window()) toolbar] 465 465 removeItemAtIndex:toolbarItemsCopy.indexOf(item)]; 466 unifiedToolbarHash.remove(item); 467 qtoolbarsInUnifiedToolbarList.removeAll(toolbar); 466 468 #endif 467 469 break; -
trunk/src/gui/widgets/qmenu.cpp
r651 r769 118 118 parentWidget = parentWidget->parentWidget(); 119 119 setParent(parentWidget, Qt::Window | Qt::Tool); 120 120 setAttribute(Qt::WA_DeleteOnClose, true); 121 121 setAttribute(Qt::WA_X11NetWmWindowTypeMenu, true); 122 122 setWindowTitle(p->windowTitle()); … … 169 169 selectAction = QSoftKeyManager::createKeyedAction(QSoftKeyManager::SelectSoftKey, Qt::Key_Select, q); 170 170 cancelAction = QSoftKeyManager::createKeyedAction(QSoftKeyManager::CancelSoftKey, Qt::Key_Back, q); 171 selectAction->set Visible(false); // Don't show these in the menu172 cancelAction->set Visible(false);171 selectAction->setPriority(QAction::HighPriority); 172 cancelAction->setPriority(QAction::HighPriority); 173 173 q->addAction(selectAction); 174 174 q->addAction(cancelAction); … … 262 262 const int fw = style->pixelMetric(QStyle::PM_MenuPanelWidth, &opt, q); 263 263 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));267 264 const int tearoffHeight = tearoff ? style->pixelMetric(QStyle::PM_MenuTearoffHeight, &opt, q) : 0; 268 265 … … 338 335 339 336 if (!sz.isEmpty()) { 340 max_column_width = qMax(m in_column_width, qMax(max_column_width, sz.width()));337 max_column_width = qMax(max_column_width, sz.width()); 341 338 //wrapping 342 339 if (!scroll && … … 352 349 353 350 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 354 355 355 356 //calculate position … … 992 993 } 993 994 994 class ExceptionGuard995 {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 1004 995 void QMenuPrivate::activateCausedStack(const QList<QPointer<QWidget> > &causedStack, QAction *action, QAction::ActionEvent action_e, bool self) 1005 996 { 1006 ExceptionGuard guard(&activationRecursionGuard);997 QBoolBlocker guard(activationRecursionGuard); 1007 998 #ifdef QT3_SUPPORT 1008 999 const int actionId = q_func()->findIdForAction(action); … … 1227 1218 option->menuItemType = QStyleOptionMenuItem::Separator; 1228 1219 else if (d->defaultAction == action) 1229 1220 option->menuItemType = QStyleOptionMenuItem::DefaultItem; 1230 1221 else 1231 1222 option->menuItemType = QStyleOptionMenuItem::Normal; … … 1407 1398 { 1408 1399 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 } 1415 1408 } 1416 1409 } … … 1720 1713 { 1721 1714 QList<QAction*> acts = actions(); 1715 1722 1716 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 1723 1723 removeAction(acts[i]); 1724 1724 if (acts[i]->parent() == this && acts[i]->d_func()->widgets.isEmpty()) … … 2408 2408 } 2409 2409 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; 2410 2417 #endif 2411 2418 default: … … 2798 2805 QAction *action = d->actionAt(e->pos()); 2799 2806 if (!action) { 2800 if (d->hasHadMouse) 2807 if (d->hasHadMouse 2808 && (!d->currentAction 2809 || !(d->currentAction->menu() && d->currentAction->menu()->isVisible()))) 2801 2810 d->setCurrentAction(0); 2802 2811 return; … … 2920 2929 if (isVisible()) { 2921 2930 d->updateActionRects(); 2922 2931 resize(sizeHint()); 2923 2932 update(); 2924 2933 } -
trunk/src/gui/widgets/qmenu.h
r651 r769 143 143 144 144 #ifdef Q_WS_WINCE 145 HMENU wceMenu( bool create = false);145 HMENU wceMenu(); 146 146 #endif 147 147 … … 163 163 void mousePressEvent(QMouseEvent *); 164 164 void mouseMoveEvent(QMouseEvent *); 165 #ifndef QT_NO_WHEELEVENT 165 166 void wheelEvent(QWheelEvent *); 167 #endif 166 168 void enterEvent(QEvent *); 167 169 void leaveEvent(QEvent *); -
trunk/src/gui/widgets/qmenu_mac.mm
r651 r769 176 176 } 177 177 178 static 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 178 194 static bool actualMenuItemVisibility(const QMenuBarPrivate::QMacMenuBarPrivate *mbp, 179 195 const QMacMenuAction *action) … … 1831 1847 1832 1848 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 1833 1855 extern void qt_event_request_menubarupdate(); //qapplication_mac.cpp 1834 1856 qt_event_request_menubarupdate(); … … 1932 1954 // if the menu bar belongs to an ancestor of modalWidget: 1933 1955 return qt_mac_is_ancestor(menuBar->parentWidget(), modalWidget); 1934 }1935 1936 static void cancelAllMenuTracking()1937 {1938 #ifdef QT_MAC_USE_COCOA1939 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 #endif1948 1956 } 1949 1957 -
trunk/src/gui/widgets/qmenu_p.h
r651 r769 348 348 inline void syncAction(QAction *a) { syncAction(findAction(a)); } 349 349 void removeAction(QWceMenuAction *); 350 void rebuild( bool reCreate = false);350 void rebuild(); 351 351 inline void removeAction(QAction *a) { removeAction(findAction(a)); } 352 352 inline QWceMenuAction *findAction(QAction *a) { … … 359 359 } 360 360 } *wce_menu; 361 HMENU wceMenu( bool create = false);361 HMENU wceMenu(); 362 362 QAction* wceCommands(uint command); 363 363 #endif -
trunk/src/gui/widgets/qmenu_symbian.cpp
r651 r769 150 150 151 151 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); 154 158 if (action->action->menu()) { 155 159 SymbianMenuItem* menuItem = new SymbianMenuItem(); … … 257 261 SymbianMenuItem* menu = qt_symbian_find_menu(id, symbianMenus); 258 262 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 259 271 for (int i = 0; i < menu->children.count(); ++i) 260 272 QT_TRAP_THROWING(menuPane->AddMenuItemL(menu->children.at(i)->menuItemData)); … … 317 329 } 318 330 331 void 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 319 339 QMenuBarPrivate::QSymbianMenuBarPrivate::QSymbianMenuBarPrivate(QMenuBarPrivate *menubar) 320 340 { -
trunk/src/gui/widgets/qmenu_wince.cpp
r651 r769 102 102 }; 103 103 104 typedef int (WINAPI *superfunc)(int, int);105 104 typedef BOOL (WINAPI *AygCreateMenuBar)(qt_SHMENUBARINFO*); 106 105 typedef HRESULT (WINAPI *AygEnableSoftKey)(HWND,UINT,BOOL,BOOL); … … 128 127 ptrEnableSoftKey(handle, command, false, true); 129 128 } 129 130 130 static void qt_wce_disable_soft_key(HWND handle, uint command) 131 131 { … … 135 135 } 136 136 137 static void qt_wce_delete_action_list(QList<QWceMenuAction*> *list) { 137 static void qt_wce_delete_action_list(QList<QWceMenuAction*> *list) 138 { 138 139 for(QList<QWceMenuAction*>::Iterator it = list->begin(); it != list->end(); ++it) { 139 140 QWceMenuAction *action = (*it); … … 145 146 146 147 //search for first QuitRole in QMenuBar 147 static QAction* qt_wce_get_quit_action(QList<QAction *> actionItems) { 148 static QAction* qt_wce_get_quit_action(QList<QAction *> actionItems) 149 { 148 150 QAction *returnAction = 0; 149 151 for (int i = 0; i < actionItems.size(); ++i) { … … 160 162 } 161 163 162 static QAction* qt_wce_get_quit_action(QList<QWceMenuAction*> actionItems) { 164 static QAction* qt_wce_get_quit_action(QList<QWceMenuAction*> actionItems) 165 { 163 166 for (int i = 0; i < actionItems.size(); ++i) { 164 167 if (actionItems.at(i)->action->menuRole() == QAction::QuitRole) … … 173 176 } 174 177 175 static HMODULE qt_wce_get_module_handle() { 178 static HMODULE qt_wce_get_module_handle() 179 { 176 180 HMODULE module = 0; //handle to resources 177 181 if (!(module = GetModuleHandle(L"QtGui4"))) //release dynamic … … 182 186 } 183 187 184 static void qt_wce_change_command(HWND menuHandle, int item, int command) { 188 static void qt_wce_change_command(HWND menuHandle, int item, int command) 189 { 185 190 TBBUTTONINFOA tbbi; 186 191 memset(&tbbi,0,sizeof(tbbi)); … … 191 196 } 192 197 193 static void qt_wce_rename_menu_item(HWND menuHandle, int item, const QString &newText) { 198 static void qt_wce_rename_menu_item(HWND menuHandle, int item, const QString &newText) 199 { 194 200 TBBUTTONINFOA tbbi; 195 201 memset(&tbbi,0,sizeof(tbbi)); … … 202 208 } 203 209 204 static HWND qt_wce_create_menubar(HWND parentHandle, HINSTANCE resourceHandle, int toolbarID, int flags = 0) { 210 static HWND qt_wce_create_menubar(HWND parentHandle, HINSTANCE resourceHandle, int toolbarID, int flags = 0) 211 { 205 212 resolveAygLibs(); 206 213 … … 227 234 } 228 235 229 static void qt_wce_insert_action(HMENU menu, QWceMenuAction *action , bool created) {230 236 static void qt_wce_insert_action(HMENU menu, QWceMenuAction *action) 237 { 231 238 Q_ASSERT_X(menu, "AppendMenu", "menu is 0"); 232 239 if (action->action->isVisible()) { … … 242 249 text.remove(QChar::fromLatin1('&')); 243 250 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())); 245 252 } 246 253 else { … … 255 262 } 256 263 264 // Removes all items from the menu without destroying the handles. 265 static void qt_wce_clear_menu(HMENU hMenu) 266 { 267 while (RemoveMenu(hMenu, 0, MF_BYPOSITION)); 268 } 269 257 270 /*! 258 271 \internal … … 261 274 */ 262 275 263 void QMenuBar::wceRefresh() { 276 void QMenuBar::wceRefresh() 277 { 264 278 for (int i = 0; i < nativeMenuBars.size(); ++i) 265 279 nativeMenuBars.at(i)->d_func()->wceRefresh(); 266 280 } 267 281 268 void QMenuBarPrivate::wceRefresh() { 282 void QMenuBarPrivate::wceRefresh() 283 { 269 284 DrawMenuBar(wce_menubar->menubarHandle); 270 285 } … … 276 291 */ 277 292 278 QAction* QMenu::wceCommands(uint command) { 293 QAction* QMenu::wceCommands(uint command) 294 { 279 295 Q_D(QMenu); 280 296 return d->wceCommands(command); … … 288 304 */ 289 305 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) { 306 void 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 316 bool QMenuBarPrivate::wceEmitSignals(QList<QWceMenuAction*> actions, uint command) 317 { 296 318 QAction *foundAction = 0; 297 319 for (int i = 0; i < actions.size(); ++i) { 298 if (foundAction)299 break;300 320 QWceMenuAction *action = actions.at(i); 301 321 if (action->action->menu()) { 302 322 foundAction = action->action->menu()->wceCommands(command); 323 if (foundAction) 324 break; 303 325 } 304 326 else if (action->command == command) { 305 emit q_func()->triggered(action->action);306 327 action->action->activate(QAction::Trigger); 307 328 return true; … … 315 336 } 316 337 317 void QMenuBarPrivate::wceCommands(uint command) { 338 void QMenuBarPrivate::wceCommands(uint command) 339 { 318 340 if (wceClassicMenu) { 319 341 for (int i = 0; i < wce_menubar->actionItemsClassic.size(); ++i) … … 321 343 } else { 322 344 if (wceEmitSignals(wce_menubar->actionItems, command)) { 323 return 345 return; 324 346 } 325 347 else if (wce_menubar->leftButtonIsMenu) {//check if command is on the left quick button … … 333 355 } 334 356 335 QAction *QMenuPrivate::wceCommands(uint command) { 357 QAction *QMenuPrivate::wceCommands(uint command) 358 { 336 359 QAction *foundAction = 0; 337 360 for (int i = 0; i < wce_menu->actionItems.size(); ++i) { … … 343 366 } 344 367 else if (action->command == command) { 345 acti on->action->activate(QAction::Trigger);368 activateAction(action->action, QAction::Trigger); 346 369 return action->action; 347 370 } … … 352 375 } 353 376 354 void QMenuBarPrivate::wceCreateMenuBar(QWidget *parent) {355 377 void QMenuBarPrivate::wceCreateMenuBar(QWidget *parent) 378 { 356 379 Q_Q(QMenuBar); 357 380 wce_menubar = new QWceMenuBarPrivate(this); … … 367 390 } 368 391 369 void QMenuBarPrivate::wceDestroyMenuBar() { 392 void QMenuBarPrivate::wceDestroyMenuBar() 393 { 370 394 Q_Q(QMenuBar); 371 395 int index = nativeMenuBars.indexOf(q); 372 396 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 403 QMenuBarPrivate::QWceMenuBarPrivate::QWceMenuBarPrivate(QMenuBarPrivate *menubar) 404 : menubarHandle(0), menuHandle(0), leftButtonMenuHandle(0), 405 leftButtonAction(0), leftButtonIsMenu(false), d(menubar) 406 { 407 } 408 409 QMenuBarPrivate::QWceMenuBarPrivate::~QWceMenuBarPrivate() 410 { 384 411 if (menubarHandle) 385 412 DestroyWindow(menubarHandle); … … 399 426 } 400 427 401 QMenuPrivate::QWceMenuPrivate::QWceMenuPrivate() { 402 menuHandle = 0; 403 } 404 405 QMenuPrivate::QWceMenuPrivate::~QWceMenuPrivate() { 428 QMenuPrivate::QWceMenuPrivate::QWceMenuPrivate() 429 : menuHandle(0) 430 { 431 } 432 433 QMenuPrivate::QWceMenuPrivate::~QWceMenuPrivate() 434 { 406 435 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 440 void QMenuPrivate::QWceMenuPrivate::addAction(QAction *a, QWceMenuAction *before) 441 { 411 442 QWceMenuAction *action = new QWceMenuAction; 412 443 action->action = a; … … 415 446 } 416 447 417 void QMenuPrivate::QWceMenuPrivate::addAction(QWceMenuAction *action, QWceMenuAction *before) { 448 void QMenuPrivate::QWceMenuPrivate::addAction(QWceMenuAction *action, QWceMenuAction *before) 449 { 418 450 if (!action) 419 451 return; … … 434 466 */ 435 467 436 HMENU QMenu::wceMenu(bool create) { return d_func()->wceMenu(create); } 437 438 HMENU QMenuPrivate::wceMenu(bool create) { 468 HMENU QMenu::wceMenu() 469 { 470 return d_func()->wceMenu(); 471 } 472 473 HMENU QMenuPrivate::wceMenu() 474 { 439 475 if (!wce_menu) 440 476 wce_menu = new QWceMenuPrivate; 441 if (!wce_menu->menuHandle || create)442 wce_menu->rebuild( create);477 if (!wce_menu->menuHandle) 478 wce_menu->rebuild(); 443 479 return wce_menu->menuHandle; 444 480 } 445 481 446 void QMenuPrivate::QWceMenuPrivate::rebuild(bool reCreate) { 447 if (menuHandle && !reCreate) 448 DestroyMenu(menuHandle); 449 menuHandle = CreatePopupMenu(); 482 void QMenuPrivate::QWceMenuPrivate::rebuild() 483 { 484 if (!menuHandle) 485 menuHandle = CreatePopupMenu(); 486 else 487 qt_wce_clear_menu(menuHandle); 488 450 489 for (int i = 0; i < actionItems.size(); ++i) { 451 490 QWceMenuAction *action = actionItems.at(i); 452 491 action->menuHandle = menuHandle; 453 qt_wce_insert_action(menuHandle, action , true);492 qt_wce_insert_action(menuHandle, action); 454 493 } 455 494 QMenuBar::wceRefresh(); 456 495 } 457 496 458 void QMenuPrivate::QWceMenuPrivate::syncAction(QWceMenuAction *) { 497 void QMenuPrivate::QWceMenuPrivate::syncAction(QWceMenuAction *) 498 { 459 499 rebuild(); 460 500 } 461 501 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) { 502 void QMenuPrivate::QWceMenuPrivate::removeAction(QWceMenuAction *action) 503 { 504 actionItems.removeAll(action); 505 delete action; 506 rebuild(); 507 } 508 509 void QMenuBarPrivate::QWceMenuBarPrivate::addAction(QAction *a, QWceMenuAction *before) 510 { 470 511 QWceMenuAction *action = new QWceMenuAction; 471 512 action->action = a; … … 474 515 } 475 516 476 void QMenuBarPrivate::QWceMenuBarPrivate::addAction(QWceMenuAction *action, QWceMenuAction *before) { 517 void QMenuBarPrivate::QWceMenuBarPrivate::addAction(QWceMenuAction *action, QWceMenuAction *before) 518 { 477 519 if (!action) 478 520 return; … … 486 528 } 487 529 488 void QMenuBarPrivate::QWceMenuBarPrivate::syncAction(QWceMenuAction*) { 530 void QMenuBarPrivate::QWceMenuBarPrivate::syncAction(QWceMenuAction*) 531 { 489 532 QMenuBar::wceRefresh(); 490 533 rebuild(); 491 534 } 492 535 493 void QMenuBarPrivate::QWceMenuBarPrivate::removeAction(QWceMenuAction *action) { 536 void QMenuBarPrivate::QWceMenuBarPrivate::removeAction(QWceMenuAction *action) 537 { 494 538 actionItems.removeAll(action); 495 539 delete action; 496 action = 0;497 540 rebuild(); 498 541 } 499 542 500 void QMenuBarPrivate::_q_updateDefaultAction() { 543 void QMenuBarPrivate::_q_updateDefaultAction() 544 { 501 545 if (wce_menubar) 502 546 wce_menubar->rebuild(); 503 547 } 504 548 505 void QMenuBarPrivate::QWceMenuBarPrivate::rebuild() {506 549 void QMenuBarPrivate::QWceMenuBarPrivate::rebuild() 550 { 507 551 d->q_func()->resize(0,0); 508 552 parentWindowHandle = d->q_func()->parentWidget() ? d->q_func()->parentWidget()->winId() : d->q_func()->winId(); … … 523 567 } 524 568 Q_ASSERT_X(menubarHandle, "rebuild !created", "menubar already deleted"); 569 qt_wce_clear_menu(menuHandle); 525 570 DestroyWindow(menubarHandle); 526 571 menubarHandle = qt_wce_create_menubar(parentWindowHandle, qt_wce_get_module_handle(), resourceHandle); … … 550 595 action->menuHandle = subMenuHandle; 551 596 actionItemsClassic.last().append(action); 552 qt_wce_insert_action(subMenuHandle, action , true);597 qt_wce_insert_action(subMenuHandle, action); 553 598 } 554 599 } … … 564 609 leftButtonIsMenu = (leftButtonAction && leftButtonAction->menu()); 565 610 Q_ASSERT_X(menubarHandle, "rebuild !created", "menubar already deleted"); 611 qt_wce_clear_menu(menuHandle); 566 612 DestroyWindow(menubarHandle); 567 613 if (leftButtonIsMenu) { … … 592 638 QWceMenuAction *action = actionItems.at(i); 593 639 action->menuHandle = menuHandle; 594 qt_wce_insert_action(menuHandle, action , true);640 qt_wce_insert_action(menuHandle, action); 595 641 } 596 642 if (!leftButtonIsMenu) { … … 612 658 action->menuHandle = leftButtonMenuHandle; 613 659 actionItemsLeftButton.append(action); 614 qt_wce_insert_action(leftButtonMenuHandle, action , true);660 qt_wce_insert_action(leftButtonMenuHandle, action); 615 661 } 616 662 } -
trunk/src/gui/widgets/qmenubar.cpp
r651 r769 72 72 #endif 73 73 74 #ifdef QT_SOFTKEYS_ENABLED 75 #include <private/qsoftkeymanager_p.h> 76 #endif 77 74 78 QT_BEGIN_NAMESPACE 75 79 … … 741 745 } 742 746 #endif 743 #ifdef Q_WS_S60744 symbianCreateMenuBar(q->parentWidget());745 if(symbian_menubar)746 q->hide();747 #endif748 749 747 q->setBackgroundRole(QPalette::Button); 750 748 oldWindow = oldParent = 0; 751 749 #ifdef QT3_SUPPORT 752 750 doAutoResize = false; 751 #endif 752 #ifdef QT_SOFTKEYS_ENABLED 753 menuBarAction = 0; 753 754 #endif 754 755 handleReparent(); … … 1385 1386 #endif 1386 1387 #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(); 1388 1399 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 1391 1419 } 1392 1420 … … 1441 1469 d->itemsDirty = true; 1442 1470 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 1444 1478 QWidget::changeEvent(e); 1445 1479 } … … 1924 1958 1925 1959 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. 1927 1961 1928 1962 \sa defaultAction() -
trunk/src/gui/widgets/qmenubar.h
r651 r769 116 116 QAction *defaultAction() const; 117 117 118 static void wceCommands(uint command , HWND controlHandle);118 static void wceCommands(uint command); 119 119 static void wceRefresh(); 120 120 #endif -
trunk/src/gui/widgets/qmenubar_p.h
r651 r769 244 244 void symbianCreateMenuBar(QWidget *); 245 245 void symbianDestroyMenuBar(); 246 void reparentMenuBar(QWidget *oldParent, QWidget *newParent); 246 247 struct QSymbianMenuBarPrivate { 247 248 QList<QSymbianMenuAction*> actionItems; … … 268 269 } *symbian_menubar; 269 270 static int symbianCommands(int command); 270 271 #ifdef QT_SOFTKEYS_ENABLED 272 QAction *menuBarAction; 273 #endif 271 274 #endif 272 275 }; -
trunk/src/gui/widgets/qprintpreviewwidget.cpp
r651 r769 152 152 GraphicsView(QWidget* parent = 0) 153 153 : QGraphicsView(parent) 154 {} 154 { 155 #ifdef Q_WS_MAC 156 setFrameStyle(QFrame::NoFrame); 157 #endif 158 } 155 159 signals: 156 160 void resized(); -
trunk/src/gui/widgets/qscrollbar.cpp
r651 r769 522 522 d_func()->updateHoverControl(he->pos()); 523 523 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 524 542 default: 525 543 break; -
trunk/src/gui/widgets/qspinbox.cpp
r651 r769 449 449 450 450 /*! 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.) 456 457 457 458 Note: QSpinBox does not call this function for specialValueText() … … 462 463 valueFromText() and validate() 463 464 464 \sa valueFromText(), validate() 465 \sa valueFromText(), validate(), QLocale::groupSeparator() 465 466 */ 466 467 … … 870 871 valueFromText(). 871 872 872 \sa valueFromText() 873 \sa valueFromText(), QLocale::groupSeparator() 873 874 */ 874 875 -
trunk/src/gui/widgets/qtabbar.cpp
r651 r769 68 68 #endif 69 69 70 #ifndef QT_NO_STYLE_S60 71 #include "qs60style.h" 72 #endif 73 70 74 QT_BEGIN_NAMESPACE 71 75 … … 479 483 if (useScrollButtons && tabList.count() && last > available) { 480 484 int extra = extraWidth(); 485 #ifndef QT_NO_STYLE_S60 486 QS60Style *s60Style = qobject_cast<QS60Style*>(QApplication::style()); 487 #endif 481 488 if (!vertTabs) { 482 489 Qt::LayoutDirection ld = q->layoutDirection(); … … 486 493 487 494 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 488 502 leftB->setGeometry(arrows.left(), arrows.top(), extra/2, arrows.height()); 489 503 rightB->setGeometry(arrows.right() - extra/2 + buttonOverlap, arrows.top(), 490 504 extra/2, arrows.height()); 505 #ifndef QT_NO_STYLE_S60 506 } 507 #endif 491 508 leftB->setArrowType(Qt::LeftArrow); 492 509 rightB->setArrowType(Qt::RightArrow); 493 510 } 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 494 517 rightB->setGeometry(arrows.left(), arrows.top(), extra/2, arrows.height()); 495 518 leftB->setGeometry(arrows.right() - extra/2 + buttonOverlap, arrows.top(), 496 519 extra/2, arrows.height()); 520 #ifndef QT_NO_STYLE_S60 521 } 522 #endif 497 523 rightB->setArrowType(Qt::LeftArrow); 498 524 leftB->setArrowType(Qt::RightArrow); 499 525 } 500 526 } 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 501 537 QRect arrows = QRect(0, available - extra, size.width(), extra ); 502 538 leftB->setGeometry(arrows.left(), arrows.top(), arrows.width(), extra/2); … … 505 541 arrows.width(), extra/2); 506 542 rightB->setArrowType(Qt::DownArrow); 543 #ifndef QT_NO_STYLE_S60 544 } 545 #endif 507 546 } 508 547 leftB->setEnabled(scrollOffset > 0); -
trunk/src/gui/widgets/qtoolbar.cpp
r651 r769 442 442 to populate the extension pop up with widgets added to the toolbar using 443 443 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. 446 445 447 446 \sa QToolButton, QMenu, QAction, {Application Example}
Note:
See TracChangeset
for help on using the changeset viewer.