Changeset 769 for trunk/src/gui/widgets/qmenu.cpp
- Timestamp:
- Aug 2, 2010, 9:27:30 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 2 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/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 }
Note:
See TracChangeset
for help on using the changeset viewer.